teiid SVN: r2122 - in trunk: build/kits/jboss-container/deploy/teiid/connectors and 50 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-13 09:40:34 -0400 (Thu, 13 May 2010)
New Revision: 2122
Added:
trunk/connectors/salesforce-api/src/main/resources/partner_v17.wsdl
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java
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/postgresql/PostgreSQLExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java
Removed:
trunk/build/kits/jboss-container/deploy/teiid/connectors/text-translator.xml
trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java
trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java
trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java
trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java
trunk/connectors/salesforce-api/src/main/resources/partner_v15.wsdl
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java
trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/SequeLinkOracleCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java
trunk/engine/src/main/java/com/
trunk/engine/src/test/java/com/
Modified:
trunk/
trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml
trunk/build/kits/jboss-container/deploy/teiid/connectors/ldap-translator.xml
trunk/build/kits/jboss-container/deploy/teiid/connectors/loopback-translator.xml
trunk/build/kits/jboss-container/deploy/teiid/connectors/salesforce-translator.xml
trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/connectors/salesforce-api/src/main/java/com/sforce/soap/partner/SforceService.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
trunk/connectors/sandbox/translator-yahoo/src/main/resources/META-INF/jboss-beans.xml
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java
trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbyCapabilities.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
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/TestSubstringFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java
trunk/connectors/translator-ldap/src/main/resources/META-INF/jboss-beans.xml
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
trunk/connectors/translator-loopback/src/main/resources/META-INF/jboss-beans.xml
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/resources/META-INF/jboss-beans.xml
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java
trunk/connectors/translator-text/src/main/resources/META-INF/jboss-beans.xml
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java
trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
Log:
TEIID-1089: Merging the ExecutionFactory and Capabilities concept toghether.
Property changes on: trunk
___________________________________________________________________
Name: svn:ignore
- .classpath
.settings
target
.project
+ .classpath
.settings
target
.project
build.xml
Modified: trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/build/kits/jboss-container/deploy/teiid/connectors/jdbc-translator.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -2,72 +2,67 @@
<translator-factory>
<translator>
<name>access</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.access.AccessSQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.access.AccessExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>db2</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.db2.DB2SQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.db2.DB2ExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>derby</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.derby.DerbySQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.derby.DerbyExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>h2</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.h2.H2Translator" />
+ <execution-factory-class>org.teiid.translator.jdbc.h2.H2ExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>hsql</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.hsql.HsqlTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.hsql.HsqlExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
-
<translator>
<name>mysql</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.mysql.MySQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.mysql.MySQLExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
+
+ <translator>
+ <name>mysql5</name>
+ <execution-factory-class>org.teiid.translator.jdbc.mysql.MySQL5ExecutionFactory</execution-factory-class>
+ <xa-capable>true</xa-capable>
+ </translator>
<translator>
<name>oracle</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.oracle.OracleSQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.oracle.OracleExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>postgresql</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.postgresql.PostgreSQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.postgresql.PostgreSQLExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>sqlserver</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.sqlserver.SQLServerExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
<translator>
<name>sybase</name>
- <execution-factory-class>org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</execution-factory-class>
- <translator-property name="ExtensionTranslationClassName" value="org.teiid.translator.jdbc.sybase.SybaseSQLTranslator" />
+ <execution-factory-class>org.teiid.translator.jdbc.sybase.SybaseExecutionFactory</execution-factory-class>
<xa-capable>true</xa-capable>
</translator>
</translator-factory>
\ No newline at end of file
Modified: trunk/build/kits/jboss-container/deploy/teiid/connectors/ldap-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/connectors/ldap-translator.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/build/kits/jboss-container/deploy/teiid/connectors/ldap-translator.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -2,7 +2,7 @@
<translator-factory>
<translator>
<name>ldap</name>
- <execution-factory-class>org.teiid.resource.adapter.ldap.LDAPExecutionFactory</execution-factory-class>
+ <execution-factory-class>org.teiid.translator.ldap.LDAPExecutionFactory</execution-factory-class>
<translator-property name="SearchDefaultBaseDN" value="" />
<translator-property name="SearchDefaultScope" value="SUBTREE_SCOPE" />
<translator-property name="RestrictToObjectClass" value="false" />
Modified: trunk/build/kits/jboss-container/deploy/teiid/connectors/loopback-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/connectors/loopback-translator.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/build/kits/jboss-container/deploy/teiid/connectors/loopback-translator.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -2,6 +2,6 @@
<translator-factory>
<translator>
<name>loopback</name>
- <execution-factory-class>org.teiid.resource.adapter.loopback.LoopbackExecutionFactory</execution-factory-class>
+ <execution-factory-class>org.teiid.translator.loopback.LoopbackExecutionFactory</execution-factory-class>
</translator>
</translator-factory>
\ No newline at end of file
Modified: trunk/build/kits/jboss-container/deploy/teiid/connectors/salesforce-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/connectors/salesforce-translator.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/build/kits/jboss-container/deploy/teiid/connectors/salesforce-translator.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -2,6 +2,6 @@
<translator-factory>
<translator>
<name>salesforce</name>
- <execution-factory-class>org.teiid.resource.adapter.salesforce.SalesForceExecutionFactory</execution-factory-class>
+ <execution-factory-class>org.teiid.translator.salesforce.SalesForceExecutionFactory</execution-factory-class>
</translator>
</translator-factory>
\ No newline at end of file
Deleted: trunk/build/kits/jboss-container/deploy/teiid/connectors/text-translator.xml
===================================================================
--- trunk/build/kits/jboss-container/deploy/teiid/connectors/text-translator.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/build/kits/jboss-container/deploy/teiid/connectors/text-translator.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-<translator-factory>
- <translator>
- <name>text</name>
- <execution-factory-class>org.teiid.resource.adapter.text.TextExecutionFactory</execution-factory-class>
- </translator>
-</translator-factory>
\ No newline at end of file
Deleted: trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,379 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator;
-
-import java.util.List;
-
-
-
-/**
- * This class is a base implementation of the ConnectorCapabilities interface.
- * It is implemented to return false for all capabilities. Subclass this base
- * class and override any methods necessary to specify capabilities the
- * connector actually supports.
- */
-public class BasicConnectorCapabilities implements ConnectorCapabilities {
-
- /**
- * Construct the basic capabilities class.
- */
- public BasicConnectorCapabilities() {
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelectDistinct()
- */
- public boolean supportsSelectDistinct() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAliasedGroup()
- */
- public boolean supportsAliasedGroup() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelfJoins()
- */
- public boolean supportsSelfJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOuterJoins()
- */
- public boolean supportsOuterJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsBetweenCriteria()
- */
- public boolean supportsBetweenCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCompareCriteriaEquals()
- */
- public boolean supportsCompareCriteriaEquals() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteria()
- */
- public boolean supportsLikeCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
- */
- public boolean supportsLikeCriteriaEscapeCharacter() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteria()
- */
- public boolean supportsInCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteriaSubquery()
- */
- public boolean supportsInCriteriaSubquery() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsIsNullCriteria()
- */
- public boolean supportsIsNullCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrCriteria()
- */
- public boolean supportsOrCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsNotCriteria()
- */
- public boolean supportsNotCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsExistsCriteria()
- */
- public boolean supportsExistsCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
- */
- public boolean supportsQuantifiedCompareCriteriaSome() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
- */
- public boolean supportsQuantifiedCompareCriteriaAll() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesSum()
- */
- public boolean supportsAggregatesSum() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesAvg()
- */
- public boolean supportsAggregatesAvg() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMin()
- */
- public boolean supportsAggregatesMin() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMax()
- */
- public boolean supportsAggregatesMax() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCount()
- */
- public boolean supportsAggregatesCount() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCountStar()
- */
- public boolean supportsAggregatesCountStar() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesDistinct()
- */
- public boolean supportsAggregatesDistinct() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsScalarSubqueries()
- */
- public boolean supportsScalarSubqueries() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCorrelatedSubqueries()
- */
- public boolean supportsCorrelatedSubqueries() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCaseExpressions()
- */
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSearchedCaseExpressions()
- */
- public boolean supportsSearchedCaseExpressions() {
- return false;
- }
-
- /**
- * Return null to indicate no functions are supported.
- * @return null
- * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- return null;
- }
-
- public boolean supportsInlineViews() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
- * @since 4.2
- */
- public boolean supportsUnions() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#getMaxInCriteriaSize()
- * @since 4.2
- */
- public int getMaxInCriteriaSize() {
- return -1;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return false;
- }
-
- public boolean supportsRowLimit() {
- return false;
- }
-
- public boolean supportsRowOffset() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#getMaxFromGroups()
- */
- public int getMaxFromGroups() {
- return -1; //-1 indicates no max
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsExcept()
- */
- public boolean supportsExcept() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsIntersect()
- */
- public boolean supportsIntersect() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsSetQueryOrderBy()
- */
- public boolean supportsSetQueryOrderBy() {
- return false;
- }
-
- @Override
- public boolean useAnsiJoin() {
- return false;
- }
-
- @Override
- public boolean requiresCriteria() {
- return false;
- }
-
- @Override
- public boolean supportsBatchedUpdates() {
- return false;
- }
-
- @Override
- public boolean supportsGroupBy() {
- return false;
- }
-
- @Override
- public boolean supportsHaving() {
- return false;
- }
-
- @Override
- public boolean supportsInnerJoins() {
- return false;
- }
-
- @Override
- public boolean supportsSelectExpression() {
- return false;
- }
-
- @Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.ANY;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return false;
- }
-
- @Override
- public boolean supportsInsertWithQueryExpression() {
- return false;
- }
-
- @Override
- public boolean supportsBulkUpdate() {
- return false;
- }
-
- @Override
- public boolean supportsOrderByUnrelated() {
- return false;
- }
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,28 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator;
-
-
-public abstract class BasicExecution implements Execution {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,209 +0,0 @@
-package org.teiid.translator;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.Properties;
-
-import org.teiid.core.TeiidException;
-import org.teiid.core.util.ReflectionHelper;
-import org.teiid.core.util.StringUtil;
-import org.teiid.language.Call;
-import org.teiid.language.Command;
-import org.teiid.language.LanguageFactory;
-import org.teiid.language.QueryExpression;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.resource.spi.BasicManagedConnectionFactory;
-
-
-public class BasicExecutionFactory implements ExecutionFactory {
-
- protected ConnectorCapabilities capabilities;
- private static final TypeFacility TYPE_FACILITY = new TypeFacility();
-
- private String capabilitiesClass;
- private boolean immutable = false;
- private boolean exceptionOnMaxRows = false;
- private int maxResultRows = -1;
- private boolean xaCapable;
- private String overrideCapabilitiesFile;
- private boolean sourceRequired = true;
-
- @Override
- public void start() throws ConnectorException {
- }
-
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return BasicConnectorCapabilities.class;
- }
-
- @Override
- public ConnectorCapabilities getCapabilities() throws ConnectorException {
- if (capabilities == null) {
- // create Capabilities
- capabilities = BasicManagedConnectionFactory.getInstance(ConnectorCapabilities.class, getCapabilitiesClass(), null, getDefaultCapabilities());
- }
-
- // capabilities overload
- Properties props = getOverrideCapabilities();
- if (this.capabilities != null && props != null) {
- this.capabilities = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(this.capabilities, props));
- }
- return capabilities;
- }
-
- @Override
- public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException {
- if (command instanceof QueryExpression) {
- return createResultSetExecution((QueryExpression)command, executionContext, metadata, connectionFactory);
- }
- if (command instanceof Call) {
- return createProcedureExecution((Call)command, executionContext, metadata, connectionFactory);
- }
- return createUpdateExecution(command, executionContext, metadata, connectionFactory);
- }
-
- public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
- throw new ConnectorException("Unsupported Execution"); //$NON-NLS-1$
- }
-
- public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
- throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
- }
-
- public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
- throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
- }
-
- // derived
- private Properties overrideCapabilities;
-
-
- @Override
- public LanguageFactory getLanguageFactory() {
- return LanguageFactory.INSTANCE;
- }
-
- @Override
- public TypeFacility getTypeFacility() {
- return TYPE_FACILITY;
- }
-
- @Override
- public Properties getOverrideCapabilities() throws ConnectorException {
- if (this.overrideCapabilities == null && getOverrideCapabilitiesFile() != null) {
- try {
- this.overrideCapabilities = new Properties();
- this.overrideCapabilities.loadFromXML(this.getClass().getResourceAsStream(getOverrideCapabilitiesFile()));
- } catch (IOException e) {
- throw new ConnectorException(e);
- }
- }
- return this.overrideCapabilities;
- }
-
- public static <T> T getInstance(Class<T> expectedType, String className, Collection ctorObjs, Class defaultClass) throws ConnectorException {
- try {
- if (className == null) {
- if (defaultClass == null) {
- throw new ConnectorException("Neither class name or default class specified to create an instance"); //$NON-NLS-1$
- }
- return expectedType.cast(defaultClass.newInstance());
- }
- return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
- } catch (TeiidException e) {
- throw new ConnectorException(e);
- } catch (IllegalAccessException e) {
- throw new ConnectorException(e);
- } catch(InstantiationException e) {
- throw new ConnectorException(e);
- }
- }
- /**
- * Overloads the connector capabilities with one defined in the connector binding properties
- */
- static final class CapabilitesOverloader implements InvocationHandler {
- ConnectorCapabilities caps;
- Properties properties;
-
- CapabilitesOverloader(ConnectorCapabilities caps, Properties properties){
- this.caps = caps;
- this.properties = properties;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String value = this.properties.getProperty(method.getName());
- if (value == null || value.trim().length() == 0 || (args != null && args.length != 0)) {
- return method.invoke(this.caps, args);
- }
- return StringUtil.valueOf(value, method.getReturnType());
- }
- }
-
- @Override
- public String getCapabilitiesClass() {
- return capabilitiesClass;
- }
-
- public void setCapabilitiesClass(String arg0) {
- this.capabilitiesClass = arg0;
- }
-
- @Override
- public boolean isImmutable() {
- return immutable;
- }
-
- public void setImmutable(boolean arg0) {
- this.immutable = arg0;
- }
-
- @Override
- public boolean isExceptionOnMaxRows() {
- return exceptionOnMaxRows;
- }
-
- public void setExceptionOnMaxRows(boolean arg0) {
- this.exceptionOnMaxRows = arg0;
- }
-
- @Override
- public int getMaxResultRows() {
- return maxResultRows;
- }
-
- public void setMaxResultRows(int arg0) {
- this.maxResultRows = arg0;
- }
-
- @Override
- public boolean isXaCapable() {
- return xaCapable;
- }
-
- public void setXaCapable(boolean arg0) {
- this.xaCapable = arg0;
- }
-
- @Override
- public String getOverrideCapabilitiesFile() throws ConnectorException {
- return this.overrideCapabilitiesFile;
- }
-
-
- public void setOverrideCapabilitiesFile(String overrideCapabilitiesFile) {
- this.overrideCapabilitiesFile = overrideCapabilitiesFile;
- }
-
- @Override
- public boolean isSourceRequired() {
- return sourceRequired;
- }
-
- public void setSourceRequired(boolean value) {
- this.sourceRequired = value;
- }
-}
Modified: trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -22,105 +22,122 @@
package org.teiid.translator;
-import java.util.Properties;
+import java.util.List;
+import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.language.LanguageFactory;
+import org.teiid.language.QueryExpression;
import org.teiid.metadata.RuntimeMetadata;
/**
- * <p>The primary entry point for a Connector. This interface should be implemented
- * by the connector writer.</p>
+ * <p>The primary entry point for a Translator. This class should be extended by the custom translator writer.</p>
*
- * <p>The JCA Container will instantiate the implementation of this class. Once the class has been
- * instantiated, the {@link #start()} method will be called
- * with all necessary connector properties. </p>
+ * The deployer instantiates this class through reflection. So it is important to have no-arg constructor. Once constructed
+ * the "start" method is called. This class represents the basic capabilities of the translator.
*/
-public interface ExecutionFactory {
+public class ExecutionFactory implements ConnectorCapabilities{
+ public static final int DEFAULT_MAX_FROM_GROUPS = -1;
+
+ private static final TypeFacility TYPE_FACILITY = new TypeFacility();
+
+ private boolean immutable = false;
+ private boolean exceptionOnMaxRows = false;
+ private int maxResultRows = DEFAULT_MAX_FROM_GROUPS;
+ private boolean xaCapable;
+ private boolean sourceRequired = true;
+
/**
* Initialize the connector with supplied configuration
*/
- void start() throws ConnectorException;
+ public void start() throws ConnectorException {
+ }
/**
- * Capabilities Class Name
- * @return
- */
- @TranslatorProperty(name="capabilities-class", display="Connector Capabilities",description="The class to use to provide the Connector Capabilities")
- public String getCapabilitiesClass();
-
- /**
* Defines if the Connector is read-only connector
* @return
*/
@TranslatorProperty(name="immutable", display="Is Immutable",description="Is Immutable, True if the source never changes.",advanced=true, defaultValue="false")
- public boolean isImmutable();
+ public boolean isImmutable() {
+ return immutable;
+ }
+ public void setImmutable(boolean arg0) {
+ this.immutable = arg0;
+ }
+
/**
* Throw exception if there are more rows in the result set than specified in the MaxResultRows setting.
* @return
*/
@TranslatorProperty(name="exception-on-max-rows", display="Exception on Exceeding Max Rows",description="Indicates if an Exception should be thrown if the specified value for Maximum Result Rows is exceeded; else no exception and no more than the maximum will be returned",advanced=true, defaultValue="true")
- public boolean isExceptionOnMaxRows();
+ public boolean isExceptionOnMaxRows() {
+ return exceptionOnMaxRows;
+ }
+
+ public void setExceptionOnMaxRows(boolean arg0) {
+ this.exceptionOnMaxRows = arg0;
+ }
/**
* Maximum result set rows to fetch
* @return
*/
@TranslatorProperty(name="max-result-rows", display="Maximum Result Rows", description="Maximum Result Rows allowed", advanced=true, defaultValue="-1")
- public int getMaxResultRows();
+ public int getMaxResultRows() {
+ return maxResultRows;
+ }
+
+ public void setMaxResultRows(int arg0) {
+ this.maxResultRows = arg0;
+ }
/**
* Shows the XA transaction capability of the Connector.
* @return
*/
@TranslatorProperty(name="xa-capable", display="Is XA Capable", description="True, if this connector supports XA Transactions", defaultValue="false")
- public boolean isXaCapable();
+ public boolean isXaCapable() {
+ return xaCapable;
+ }
+
+ public void setXaCapable(boolean arg0) {
+ this.xaCapable = arg0;
+ }
/**
- * Get the Override capabilities for the connector
- * @return
- */
- @TranslatorProperty(name="override-capabilities-file", display="Override capabilities file", description="Property file that defines the override capability properties")
- String getOverrideCapabilitiesFile() throws ConnectorException;
-
- /**
* Flag that indicates if a underlying source connection required for this execution factory to work
* @return
*/
- @TranslatorProperty(name="source-required", display="Source Connection Required", description="Flag that indicates, a source required for the translator to work", readOnly= true)
- boolean isSourceRequired();
+ public boolean isSourceRequired() {
+ return sourceRequired;
+ }
+
+ public void setSourceRequired(boolean value) {
+ this.sourceRequired = value;
+ }
/**
* Obtain a reference to the default LanguageFactory that can be used to construct
* new language interface objects. This is typically needed when modifying the language
* objects passed to the connector or for testing when objects need to be created.
*/
- LanguageFactory getLanguageFactory();
+ public LanguageFactory getLanguageFactory() {
+ return LanguageFactory.INSTANCE;
+ }
/**
* Obtain a reference to the type facility, which can be used to perform many type
* conversions supplied by the Connector API.
*/
- TypeFacility getTypeFacility();
+ public TypeFacility getTypeFacility() {
+ return TYPE_FACILITY;
+ }
/**
- * Get the Override capabilities for the connector
- * @return
- */
- Properties getOverrideCapabilities() throws ConnectorException;
-
- /**
- * Get the capabilities of this connector. The capabilities affect what kinds of
- * queries (and other commands) will be sent to the connector.
- * @return ConnectorCapabilities
- */
- ConnectorCapabilities getCapabilities() throws ConnectorException;
-
- /**
* Create an execution object for the specified command
* @param command the command
* @param executionContext Provides information about the context that this command is
@@ -129,5 +146,285 @@
* @param connection connection factory object to the data source
* @return An execution object that can use to execute the command
*/
- Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException;
+ public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException {
+ if (command instanceof QueryExpression) {
+ return createResultSetExecution((QueryExpression)command, executionContext, metadata, connectionFactory);
+ }
+ if (command instanceof Call) {
+ return createProcedureExecution((Call)command, executionContext, metadata, connectionFactory);
+ }
+ return createUpdateExecution(command, executionContext, metadata, connectionFactory);
+ }
+
+ public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
+ throw new ConnectorException("Unsupported Execution"); //$NON-NLS-1$
+ }
+
+ public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
+ throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
+ }
+
+ public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
+ throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
+ }
+
+ @Override
+ public boolean supportsSelectDistinct() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAliasedGroup() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelfJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBetweenCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaEquals() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsLikeCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInCriteriaSubquery() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsIsNullCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExistsCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesSum() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesAvg() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesMin() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesMax() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCount() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesDistinct() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCaseExpressions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSearchedCaseExpressions() {
+ return false;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ return null;
+ }
+
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return false;
+ }
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return DEFAULT_MAX_FROM_GROUPS;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsRowOffset() {
+ return false;
+ }
+
+ @Override
+ public int getMaxFromGroups() {
+ return DEFAULT_MAX_FROM_GROUPS; //-1 indicates no max
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean useAnsiJoin() {
+ return false;
+ }
+
+ @Override
+ public boolean requiresCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBatchedUpdates() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsHaving() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInnerJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelectExpression() {
+ return false;
+ }
+
+ @Override
+ public SupportedJoinCriteria getSupportedJoinCriteria() {
+ return SupportedJoinCriteria.ANY;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBulkUpdate() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderByUnrelated() {
+ return false;
+ }
+
}
Deleted: trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java
===================================================================
--- trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.connector;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-import java.util.Properties;
-
-import org.junit.Test;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ExecutionFactory;
-
-
-public class TestBasicExecutionFactory {
-
- @Test public void testConnectorCapabilitiesOverride() throws Exception {
-
- ExecutionFactory c = new BasicExecutionFactory();
- //Mockito.stub(c.getCapabilities()).toReturn(new BasicConnectorCapabilities());
-
- ConnectorCapabilities caps = c.getCapabilities();
- assertFalse(caps.supportsExistsCriteria());
- assertFalse(caps.supportsExcept());
-
-
- c = new BasicExecutionFactory() {
- @Override
- public Properties getOverrideCapabilities() {
- Properties props = new Properties();
- props.setProperty("supportsExistsCriteria", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("supportsExcept", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- return props;
- }
- };
-
- caps = c.getCapabilities();
- assertTrue(caps.supportsExistsCriteria());
- assertTrue(caps.supportsExcept());
- }
-}
Modified: trunk/connectors/salesforce-api/src/main/java/com/sforce/soap/partner/SforceService.java
===================================================================
--- trunk/connectors/salesforce-api/src/main/java/com/sforce/soap/partner/SforceService.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/salesforce-api/src/main/java/com/sforce/soap/partner/SforceService.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -5,13 +5,13 @@
package com.sforce.soap.partner;
-import java.net.MalformedURLException;
import java.net.URL;
+
import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
-import javax.xml.ws.Service;
/**
* This class was generated by Apache CXF 2.2.5
@@ -21,22 +21,18 @@
*/
-@WebServiceClient(name = "SforceService",
- wsdlLocation = "file:/NotBackedUp/jdoyle/tools/JBoss-WS.3.3.2/jbossws-cxf-bin-dist/deploy/bin/partner_17.wsdl",
- targetNamespace = "urn:partner.soap.sforce.com")
+@WebServiceClient(name = "SforceService", wsdlLocation = SforceService.PARTNER_WSDL,targetNamespace = "urn:partner.soap.sforce.com")
public class SforceService extends Service {
- public final static URL WSDL_LOCATION;
- public final static QName SERVICE = new QName("urn:partner.soap.sforce.com", "SforceService");
- public final static QName Soap = new QName("urn:partner.soap.sforce.com", "Soap");
+ private static final String PARTNER_WSDL = "partner_17.wsdl"; //$NON-NLS-1$
+ public final static URL WSDL_LOCATION;
+ public final static QName SERVICE = new QName("urn:partner.soap.sforce.com", "SforceService"); //$NON-NLS-1$ //$NON-NLS-2$
+ public final static QName Soap = new QName("urn:partner.soap.sforce.com", "Soap");//$NON-NLS-1$ //$NON-NLS-2$
static {
- URL url = null;
- try {
- url = new URL("file:/NotBackedUp/jdoyle/tools/JBoss-WS.3.3.2/jbossws-cxf-bin-dist/deploy/bin/partner_17.wsdl");
- } catch (MalformedURLException e) {
- System.err.println("Can not initialize the default wsdl from file:/NotBackedUp/jdoyle/tools/JBoss-WS.3.3.2/jbossws-cxf-bin-dist/deploy/bin/partner_17.wsdl");
- // e.printStackTrace();
- }
+ URL url = SforceService.class.getClassLoader().getResource(PARTNER_WSDL);
+ if (url == null) {
+ System.err.println("Can not find the default wsdl for salesforce"); //$NON-NLS-1$
+ }
WSDL_LOCATION = url;
}
Deleted: trunk/connectors/salesforce-api/src/main/resources/partner_v15.wsdl
===================================================================
--- trunk/connectors/salesforce-api/src/main/resources/partner_v15.wsdl 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/salesforce-api/src/main/resources/partner_v15.wsdl 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,2852 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-
-
-<!--
-Salesforce.com Partner Web Services API Version 15.0
-Generated on 2009-04-15 20:55:33 +0000.
-
-Copyright 1999-2009 salesforce.com, inc.
-All Rights Reserved
--->
-
-<definitions targetNamespace="urn:partner.soap.sforce.com"
- xmlns="http://schemas.xmlsoap.org/wsdl/"
- xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
- xmlns:xsd="http://www.w3.org/2001/XMLSchema"
- xmlns:fns="urn:fault.partner.soap.sforce.com"
- xmlns:tns="urn:partner.soap.sforce.com"
- xmlns:ens="urn:sobject.partner.soap.sforce.com">
- <types>
-
- <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:sobject.partner.soap.sforce.com">
-
- <import namespace="urn:partner.soap.sforce.com"/>
-
-
- <!-- Dynamic sObject -->
- <complexType name="sObject">
- <sequence>
- <element name="type" type="xsd:string"/>
- <element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="Id" type="tns:ID" nillable="true" />
- <any namespace="##targetNamespace" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
- </sequence>
- </complexType>
-
- </schema>
-
- <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:partner.soap.sforce.com">
-
- <import namespace="urn:sobject.partner.soap.sforce.com"/>
-
- <!-- Our simple ID Type -->
- <simpleType name="ID">
- <restriction base="xsd:string">
- <length value="18"/>
- <pattern value='[a-zA-Z0-9]{18}'/>
- </restriction>
- </simpleType>
-
- <simpleType name="QueryLocator">
- <restriction base="xsd:string"/>
- </simpleType>
-
- <!-- Shared Result Types -->
- <complexType name="QueryResult">
- <sequence>
- <element name="done" type="xsd:boolean"/>
- <element name="queryLocator" type="tns:QueryLocator" nillable="true"/>
- <element name="records" type="ens:sObject" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="size" type="xsd:int"/>
- </sequence>
- </complexType>
-
-
-
- <!-- Search Result -->
- <complexType name="SearchResult">
- <sequence>
- <element name="searchRecords" minOccurs="0" maxOccurs="unbounded" type="tns:SearchRecord"/>
- <element name="sforceReserved" minOccurs="0" maxOccurs="1" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="SearchRecord">
- <sequence>
- <element name="record" type="ens:sObject"/>
- </sequence>
- </complexType>
-
- <!-- GetUpdated Result -->
- <complexType name="GetUpdatedResult">
- <sequence>
- <element name="ids" minOccurs="0" maxOccurs="unbounded" type="tns:ID"/>
- <element name="latestDateCovered" type="xsd:dateTime"/>
- <element name="sforceReserved" minOccurs="0" maxOccurs="1" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <!-- GetDeleted Result -->
- <complexType name="GetDeletedResult">
- <sequence>
- <element name="deletedRecords" minOccurs="0" maxOccurs="unbounded" type="tns:DeletedRecord"/>
- <element name="earliestDateAvailable" type="xsd:dateTime"/>
- <element name="latestDateCovered" type="xsd:dateTime"/>
- <element name="sforceReserved" minOccurs="0" maxOccurs="1" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="DeletedRecord">
- <sequence>
- <element name="deletedDate" type="xsd:dateTime"/>
- <element name="id" type="tns:ID"/>
- </sequence>
- </complexType>
-
-
- <complexType name="GetServerTimestampResult">
- <sequence>
- <element name="timestamp" type="xsd:dateTime"/>
- </sequence>
- </complexType>
-
-
- <!-- InvalidateSessions Result -->
- <complexType name="InvalidateSessionsResult">
- <sequence>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="SetPasswordResult">
- </complexType>
-
- <complexType name="ResetPasswordResult">
- <sequence>
- <element name="password" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="GetUserInfoResult">
- <sequence>
- <element name="accessibilityMode" type="xsd:boolean"/>
- <element name="currencySymbol" type="xsd:string" nillable="true"/>
- <element name="orgDefaultCurrencyIsoCode" type="xsd:string" nillable="true"/>
- <element name="orgHasPersonAccounts" type="xsd:boolean"/>
- <element name="organizationId" type="tns:ID"/>
- <element name="organizationMultiCurrency" type="xsd:boolean"/>
- <element name="organizationName" type="xsd:string"/>
- <element name="profileId" type="tns:ID"/>
- <element name="roleId" type="tns:ID" nillable="true"/>
- <element name="userDefaultCurrencyIsoCode" type="xsd:string" nillable="true"/>
- <element name="userEmail" type="xsd:string"/>
- <element name="userFullName" type="xsd:string"/>
- <element name="userId" type="tns:ID"/>
- <element name="userLanguage" type="xsd:string"/>
- <element name="userLocale" type="xsd:string"/>
- <element name="userName" type="xsd:string"/>
- <element name="userTimeZone" type="xsd:string"/>
- <element name="userType" type="xsd:string"/>
- <element name="userUiSkin" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="LoginResult">
- <sequence>
- <element name="metadataServerUrl" type="xsd:string" nillable="true"/>
- <element name="passwordExpired" type="xsd:boolean" />
- <element name="sandbox" type="xsd:boolean"/>
- <element name="serverUrl" type="xsd:string" nillable="true"/>
- <element name="sessionId" type="xsd:string" nillable="true"/>
-
- <element name="userId" type="tns:ID" nillable="true"/>
- <element name="userInfo" type="tns:GetUserInfoResult" minOccurs="0"/>
- </sequence>
- </complexType>
-
- <simpleType name="StatusCode">
- <restriction base="xsd:string">
- <enumeration value="ALREADY_IN_PROCESS"/>
- <enumeration value="ASSIGNEE_TYPE_REQUIRED"/>
- <enumeration value="BAD_CUSTOM_ENTITY_PARENT_DOMAIN"/>
- <enumeration value="BCC_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED"/>
- <enumeration value="CANNOT_CASCADE_PRODUCT_ACTIVE"/>
- <enumeration value="CANNOT_CHANGE_FIELD_TYPE_OF_APEX_REFERENCED_FIELD"/>
- <enumeration value="CANNOT_CREATE_ANOTHER_MANAGED_PACKAGE"/>
- <enumeration value="CANNOT_DEACTIVATE_DIVISION"/>
- <enumeration value="CANNOT_DELETE_LAST_DATED_CONVERSION_RATE"/>
- <enumeration value="CANNOT_DELETE_MANAGED_OBJECT"/>
- <enumeration value="CANNOT_DISABLE_LAST_ADMIN"/>
- <enumeration value="CANNOT_ENABLE_IP_RESTRICT_REQUESTS"/>
- <enumeration value="CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY"/>
- <enumeration value="CANNOT_MODIFY_MANAGED_OBJECT"/>
- <enumeration value="CANNOT_RENAME_APEX_REFERENCED_FIELD"/>
- <enumeration value="CANNOT_RENAME_APEX_REFERENCED_OBJECT"/>
- <enumeration value="CANNOT_REPARENT_RECORD"/>
- <enumeration value="CANNOT_UPDATE_CONVERTED_LEAD"/>
- <enumeration value="CANT_DISABLE_CORP_CURRENCY"/>
- <enumeration value="CANT_UNSET_CORP_CURRENCY"/>
- <enumeration value="CHILD_SHARE_FAILS_PARENT"/>
- <enumeration value="CIRCULAR_DEPENDENCY"/>
- <enumeration value="CUSTOM_CLOB_FIELD_LIMIT_EXCEEDED"/>
- <enumeration value="CUSTOM_ENTITY_OR_FIELD_LIMIT"/>
- <enumeration value="CUSTOM_FIELD_INDEX_LIMIT_EXCEEDED"/>
- <enumeration value="CUSTOM_INDEX_EXISTS"/>
- <enumeration value="CUSTOM_LINK_LIMIT_EXCEEDED"/>
- <enumeration value="CUSTOM_TAB_LIMIT_EXCEEDED"/>
- <enumeration value="DELETE_FAILED"/>
- <enumeration value="DELETE_REQUIRED_ON_CASCADE"/>
- <enumeration value="DEPENDENCY_EXISTS"/>
- <enumeration value="DUPLICATE_CASE_SOLUTION"/>
- <enumeration value="DUPLICATE_COMM_NICKNAME"/>
- <enumeration value="DUPLICATE_CUSTOM_ENTITY_DEFINITION"/>
- <enumeration value="DUPLICATE_CUSTOM_TAB_MOTIF"/>
- <enumeration value="DUPLICATE_DEVELOPER_NAME"/>
- <enumeration value="DUPLICATE_EXTERNAL_ID"/>
- <enumeration value="DUPLICATE_MASTER_LABEL"/>
- <enumeration value="DUPLICATE_USERNAME"/>
- <enumeration value="DUPLICATE_VALUE"/>
- <enumeration value="EMAIL_NOT_PROCESSED_DUE_TO_PRIOR_ERROR"/>
- <enumeration value="EMPTY_SCONTROL_FILE_NAME"/>
- <enumeration value="ENTITY_FAILED_IFLASTMODIFIED_ON_UPDATE"/>
- <enumeration value="ENTITY_IS_ARCHIVED"/>
- <enumeration value="ENTITY_IS_DELETED"/>
- <enumeration value="ENTITY_IS_LOCKED"/>
- <enumeration value="ERROR_IN_MAILER"/>
- <enumeration value="FAILED_ACTIVATION"/>
- <enumeration value="FIELD_CUSTOM_VALIDATION_EXCEPTION"/>
- <enumeration value="FIELD_INTEGRITY_EXCEPTION"/>
- <enumeration value="HTML_FILE_UPLOAD_NOT_ALLOWED"/>
- <enumeration value="IMAGE_TOO_LARGE"/>
- <enumeration value="INACTIVE_OWNER_OR_USER"/>
- <enumeration value="INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY"/>
- <enumeration value="INSUFFICIENT_ACCESS_OR_READONLY"/>
- <enumeration value="INVALID_ACCESS_LEVEL"/>
- <enumeration value="INVALID_ARGUMENT_TYPE"/>
- <enumeration value="INVALID_ASSIGNEE_TYPE"/>
- <enumeration value="INVALID_ASSIGNMENT_RULE"/>
- <enumeration value="INVALID_BATCH_OPERATION"/>
- <enumeration value="INVALID_CREDIT_CARD_INFO"/>
- <enumeration value="INVALID_CROSS_REFERENCE_KEY"/>
- <enumeration value="INVALID_CROSS_REFERENCE_TYPE_FOR_FIELD"/>
- <enumeration value="INVALID_CURRENCY_CONV_RATE"/>
- <enumeration value="INVALID_CURRENCY_CORP_RATE"/>
- <enumeration value="INVALID_CURRENCY_ISO"/>
- <enumeration value="INVALID_EMAIL_ADDRESS"/>
- <enumeration value="INVALID_EMPTY_KEY_OWNER"/>
- <enumeration value="INVALID_FIELD"/>
- <enumeration value="INVALID_FIELD_FOR_INSERT_UPDATE"/>
- <enumeration value="INVALID_FIELD_WHEN_USING_TEMPLATE"/>
- <enumeration value="INVALID_FILTER_ACTION"/>
- <enumeration value="INVALID_GOOGLE_DOCS_URL"/>
- <enumeration value="INVALID_ID_FIELD"/>
- <enumeration value="INVALID_INET_ADDRESS"/>
- <enumeration value="INVALID_LINEITEM_CLONE_STATE"/>
- <enumeration value="INVALID_MASTER_OR_TRANSLATED_SOLUTION"/>
- <enumeration value="INVALID_OPERATION"/>
- <enumeration value="INVALID_OPERATOR"/>
- <enumeration value="INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST"/>
- <enumeration value="INVALID_PARTNER_NETWORK_STATUS"/>
- <enumeration value="INVALID_PERSON_ACCOUNT_OPERATION"/>
- <enumeration value="INVALID_SAVE_AS_ACTIVITY_FLAG"/>
- <enumeration value="INVALID_SESSION_ID"/>
- <enumeration value="INVALID_SETUP_OWNER"/>
- <enumeration value="INVALID_STATUS"/>
- <enumeration value="INVALID_TYPE"/>
- <enumeration value="INVALID_TYPE_FOR_OPERATION"/>
- <enumeration value="INVALID_TYPE_ON_FIELD_IN_RECORD"/>
- <enumeration value="IP_RANGE_LIMIT_EXCEEDED"/>
- <enumeration value="LICENSE_LIMIT_EXCEEDED"/>
- <enumeration value="LIMIT_EXCEEDED"/>
- <enumeration value="MALFORMED_ID"/>
- <enumeration value="MANAGER_NOT_DEFINED"/>
- <enumeration value="MASSMAIL_RETRY_LIMIT_EXCEEDED"/>
- <enumeration value="MASS_MAIL_LIMIT_EXCEEDED"/>
- <enumeration value="MAXIMUM_CCEMAILS_EXCEEDED"/>
- <enumeration value="MAXIMUM_DASHBOARD_COMPONENTS_EXCEEDED"/>
- <enumeration value="MAXIMUM_HIERARCHY_LEVELS_REACHED"/>
- <enumeration value="MAXIMUM_SIZE_OF_ATTACHMENT"/>
- <enumeration value="MAXIMUM_SIZE_OF_DOCUMENT"/>
- <enumeration value="MAX_ACTIONS_PER_RULE_EXCEEDED"/>
- <enumeration value="MAX_ACTIVE_RULES_EXCEEDED"/>
- <enumeration value="MAX_APPROVAL_STEPS_EXCEEDED"/>
- <enumeration value="MAX_FORMULAS_PER_RULE_EXCEEDED"/>
- <enumeration value="MAX_RULES_EXCEEDED"/>
- <enumeration value="MAX_RULE_ENTRIES_EXCEEDED"/>
- <enumeration value="MAX_TASK_DESCRIPTION_EXCEEEDED"/>
- <enumeration value="MAX_TM_RULES_EXCEEDED"/>
- <enumeration value="MAX_TM_RULE_ITEMS_EXCEEDED"/>
- <enumeration value="MERGE_FAILED"/>
- <enumeration value="MISSING_ARGUMENT"/>
- <enumeration value="MIXED_DML_OPERATION"/>
- <enumeration value="NONUNIQUE_SHIPPING_ADDRESS"/>
- <enumeration value="NO_APPLICABLE_PROCESS"/>
- <enumeration value="NO_ATTACHMENT_PERMISSION"/>
- <enumeration value="NO_MASS_MAIL_PERMISSION"/>
- <enumeration value="NUMBER_OUTSIDE_VALID_RANGE"/>
- <enumeration value="NUM_HISTORY_FIELDS_BY_SOBJECT_EXCEEDED"/>
- <enumeration value="OPTED_OUT_OF_MASS_MAIL"/>
- <enumeration value="PACKAGE_LICENSE_REQUIRED"/>
- <enumeration value="PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT"/>
- <enumeration value="PRIVATE_CONTACT_ON_ASSET"/>
- <enumeration value="RECORD_IN_USE_BY_WORKFLOW"/>
- <enumeration value="REQUEST_RUNNING_TOO_LONG"/>
- <enumeration value="REQUIRED_FIELD_MISSING"/>
- <enumeration value="SELF_REFERENCE_FROM_TRIGGER"/>
- <enumeration value="SHARE_NEEDED_FOR_CHILD_OWNER"/>
- <enumeration value="STANDARD_PRICE_NOT_DEFINED"/>
- <enumeration value="STORAGE_LIMIT_EXCEEDED"/>
- <enumeration value="STRING_TOO_LONG"/>
- <enumeration value="TABSET_LIMIT_EXCEEDED"/>
- <enumeration value="TEMPLATE_NOT_ACTIVE"/>
- <enumeration value="TERRITORY_REALIGN_IN_PROGRESS"/>
- <enumeration value="TEXT_DATA_OUTSIDE_SUPPORTED_CHARSET"/>
- <enumeration value="TOO_MANY_APEX_REQUESTS"/>
- <enumeration value="TOO_MANY_ENUM_VALUE"/>
- <enumeration value="TRANSFER_REQUIRES_READ"/>
- <enumeration value="UNABLE_TO_LOCK_ROW"/>
- <enumeration value="UNAVAILABLE_RECORDTYPE_EXCEPTION"/>
- <enumeration value="UNDELETE_FAILED"/>
- <enumeration value="UNKNOWN_EXCEPTION"/>
- <enumeration value="UNSPECIFIED_EMAIL_ADDRESS"/>
- <enumeration value="UNSUPPORTED_APEX_TRIGGER_OPERATON"/>
- <enumeration value="WEBLINK_SIZE_LIMIT_EXCEEDED"/>
- <enumeration value="WRONG_CONTROLLER_TYPE"/>
- </restriction>
- </simpleType>
-
-
- <complexType name="Error">
- <sequence>
- <element name="fields" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="message" type="xsd:string"/>
- <element name="statusCode" type="tns:StatusCode"/>
- </sequence>
- </complexType>
-
- <complexType name="SendEmailError">
- <sequence>
- <element name="fields" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="message" type="xsd:string"/>
- <element name="statusCode" type="tns:StatusCode"/>
- <element name="targetObjectId" type="tns:ID" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="SaveResult">
- <sequence>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID" nillable="true"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="UpsertResult">
- <sequence>
- <element name="created" type="xsd:boolean"/>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID" nillable="true"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="MergeRequest">
- <sequence>
- <element name="masterRecord" type="ens:sObject"/>
- <element name="recordToMergeIds" type="tns:ID" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="MergeResult">
- <sequence>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID" nillable="true"/>
- <element name="mergedRecordIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
- <element name="success" type="xsd:boolean"/>
- <element name="updatedRelatedIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="ProcessRequest">
- <sequence>
- <element name="comments" type="xsd:string" nillable="true"/>
- <element name="nextApproverIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="ProcessSubmitRequest">
- <complexContent>
- <extension base="tns:ProcessRequest">
- <sequence>
- <element name="objectId" type="tns:ID"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="ProcessWorkitemRequest">
- <complexContent>
- <extension base="tns:ProcessRequest">
- <sequence>
- <element name="action" type="xsd:string"/>
- <element name="workitemId" type="tns:ID"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="ProcessResult">
- <sequence>
- <element name="actorIds" type="tns:ID" nillable="false" minOccurs="0" maxOccurs="unbounded"/>
- <element name="entityId" type="tns:ID" nillable="true"/>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="instanceId" type="tns:ID" nillable="true"/>
- <element name="instanceStatus" type="xsd:string" nillable="true"/>
- <element name="newWorkitemIds" type="tns:ID" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="DeleteResult">
- <sequence>
- <element name="errors" type="tns:Error" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID" nillable="true"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="UndeleteResult">
- <sequence>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID" nillable="true"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="EmptyRecycleBinResult">
- <sequence>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID" nillable="true"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="LeadConvert">
- <sequence>
- <element name="accountId" type="tns:ID" nillable="true"/>
- <element name="contactId" type="tns:ID" nillable="true"/>
- <element name="convertedStatus" type="xsd:string"/>
- <element name="doNotCreateOpportunity" type="xsd:boolean"/>
- <element name="leadId" type="tns:ID"/>
- <element name="opportunityName" type="xsd:string" nillable="true"/>
- <element name="overwriteLeadSource" type="xsd:boolean"/>
- <element name="ownerId" type="tns:ID" nillable="true"/>
- <element name="sendNotificationEmail" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="LeadConvertResult">
- <sequence>
- <element name="accountId" type="tns:ID" nillable="true"/>
- <element name="contactId" type="tns:ID" nillable="true"/>
- <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
- <element name="leadId" type="tns:ID" nillable="true"/>
- <element name="opportunityId" type="tns:ID" nillable="true"/>
- <element name="success" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeSObjectResult">
- <sequence>
- <element name="activateable" type="xsd:boolean"/>
- <element name="childRelationships" type="tns:ChildRelationship" minOccurs="0" maxOccurs="unbounded"/>
- <element name="createable" type="xsd:boolean"/>
- <element name="custom" type="xsd:boolean"/>
- <element name="deletable" type="xsd:boolean"/>
- <element name="fields" type="tns:Field" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="keyPrefix" type="xsd:string" nillable="true"/>
- <element name="label" type="xsd:string"/>
- <element name="labelPlural" type="xsd:string"/>
- <element name="layoutable" type="xsd:boolean"/>
- <element name="mergeable" type="xsd:boolean"/>
- <element name="name" type="xsd:string"/>
- <element name="queryable" type="xsd:boolean"/>
- <element name="recordTypeInfos" type="tns:RecordTypeInfo" minOccurs="0" maxOccurs="unbounded"/>
- <element name="replicateable" type="xsd:boolean"/>
- <element name="retrieveable" type="xsd:boolean"/>
- <element name="searchable" type="xsd:boolean" />
- <element name="triggerable" type="xsd:boolean" minOccurs="0"/>
- <element name="undeletable" type="xsd:boolean"/>
- <element name="updateable" type="xsd:boolean"/>
- <element name="urlDetail" type="xsd:string" nillable="true"/>
- <element name="urlEdit" type="xsd:string" nillable="true"/>
- <element name="urlNew" type="xsd:string" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="ChildRelationship">
- <sequence>
- <element name="cascadeDelete" type="xsd:boolean"/>
- <element name="childSObject" type="xsd:string"/>
- <element name="field" type="xsd:string"/>
- <element name="relationshipName" type="xsd:string" minOccurs="0"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeGlobalResult">
- <sequence>
- <element name="encoding" type="xsd:string" nillable="true"/>
- <element name="maxBatchSize" type="xsd:int"/>
- <element name="types" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <simpleType name="fieldType">
- <restriction base="xsd:string">
- <enumeration value="string"/>
- <enumeration value="picklist"/>
- <enumeration value="multipicklist"/>
- <enumeration value="combobox"/>
- <enumeration value="reference"/>
- <enumeration value="base64"/>
- <enumeration value="boolean"/>
- <enumeration value="currency"/>
- <enumeration value="textarea"/>
- <enumeration value="int"/>
- <enumeration value="double"/>
- <enumeration value="percent"/>
- <enumeration value="phone"/>
- <enumeration value="id"/>
- <enumeration value="date"/>
- <enumeration value="datetime"/>
- <enumeration value="time"/>
- <enumeration value="url"/>
- <enumeration value="email"/>
- <enumeration value="encryptedstring"/>
- <enumeration value="anyType"/> <!-- can be string, picklist, reference, boolean, currency, int, double, percent, id, date, datetime, url, email -->
- </restriction>
- </simpleType>
-
- <simpleType name="soapType">
- <restriction base="xsd:string">
- <enumeration value="tns:ID"/>
- <enumeration value="xsd:base64Binary"/>
- <enumeration value="xsd:boolean"/>
- <enumeration value="xsd:double"/>
- <enumeration value="xsd:int"/>
- <enumeration value="xsd:string"/>
- <enumeration value="xsd:date"/>
- <enumeration value="xsd:dateTime"/>
- <enumeration value="xsd:time"/>
- <enumeration value="xsd:anyType"/> <!-- can be id, booolean, double, int, string, date, dateTime -->
- </restriction>
- </simpleType>
-
- <complexType name="Field">
- <sequence>
- <element name="autoNumber" type="xsd:boolean"/>
- <element name="byteLength" type="xsd:int"/>
- <element name="calculated" type="xsd:boolean"/>
- <element name="calculatedFormula" type="xsd:string" minOccurs="0"/>
- <element name="caseSensitive" type="xsd:boolean"/>
- <element name="controllerName" type="xsd:string" minOccurs="0"/>
- <element name="createable" type="xsd:boolean"/>
- <element name="custom" type="xsd:boolean"/>
- <element name="defaultValueFormula" type="xsd:string" minOccurs="0"/>
- <element name="defaultedOnCreate" type="xsd:boolean"/>
- <element name="dependentPicklist" type="xsd:boolean" minOccurs="0"/>
- <element name="digits" type="xsd:int"/>
- <element name="externalId" type="xsd:boolean" minOccurs="0"/>
- <element name="filterable" type="xsd:boolean"/>
- <element name="htmlFormatted" type="xsd:boolean" minOccurs="0"/>
- <element name="idLookup" type="xsd:boolean"/>
- <element name="inlineHelpText" type="xsd:string" minOccurs="0"/>
- <element name="label" type="xsd:string"/>
- <element name="length" type="xsd:int"/>
- <element name="name" type="xsd:string"/>
- <element name="nameField" type="xsd:boolean"/>
- <element name="namePointing" type="xsd:boolean" minOccurs="0"/>
- <element name="nillable" type="xsd:boolean"/>
- <element name="picklistValues" type="tns:PicklistEntry" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="precision" type="xsd:int"/>
- <element name="referenceTo" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="relationshipName" type="xsd:string" minOccurs="0"/>
- <element name="relationshipOrder" type="xsd:int" minOccurs="0"/>
- <element name="restrictedPicklist" type="xsd:boolean"/>
- <element name="scale" type="xsd:int"/>
- <element name="soapType" type="tns:soapType"/>
- <element name="sortable" type="xsd:boolean" minOccurs="0"/>
- <element name="type" type="tns:fieldType"/>
- <element name="unique" type="xsd:boolean"/>
- <element name="updateable" type="xsd:boolean"/>
- <element name="writeRequiresMasterRead" type="xsd:boolean" minOccurs="0"/>
- </sequence>
- </complexType>
-
- <complexType name="PicklistEntry">
- <sequence>
- <element name="active" type="xsd:boolean"/>
- <element name="defaultValue" type="xsd:boolean"/>
- <element name="label" type="xsd:string" nillable="true"/>
- <element name="validFor" type="xsd:base64Binary" minOccurs="0"/>
- <element name="value" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeSoftphoneLayoutResult">
- <sequence>
- <element name="callTypes" type="tns:DescribeSoftphoneLayoutCallType" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID"/>
- <element name="name" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeSoftphoneLayoutCallType">
- <sequence>
- <element name="infoFields" type="tns:DescribeSoftphoneLayoutInfoField" maxOccurs="unbounded"/>
- <element name="name" type="xsd:string"/>
- <element name="sections" type="tns:DescribeSoftphoneLayoutSection" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeSoftphoneLayoutInfoField">
- <sequence>
- <element name="name" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeSoftphoneLayoutSection">
- <sequence>
- <element name="entityApiName" type="xsd:string"/>
- <element name="items" type="tns:DescribeSoftphoneLayoutItem" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeSoftphoneLayoutItem">
- <sequence>
- <element name="itemApiName" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutResult">
- <sequence>
- <element name="layouts" type="tns:DescribeLayout" maxOccurs="unbounded"/>
- <element name="recordTypeMappings" type="tns:RecordTypeMapping" minOccurs="0" maxOccurs="unbounded"/>
- <element name="recordTypeSelectorRequired" type="xsd:boolean" />
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayout">
- <sequence>
- <element name="buttonLayoutSection" type="tns:DescribeLayoutButtonSection" minOccurs="0"/>
- <element name="detailLayoutSections" type="tns:DescribeLayoutSection" minOccurs="0" maxOccurs="unbounded"/>
- <element name="editLayoutSections" type="tns:DescribeLayoutSection" minOccurs="0" maxOccurs="unbounded"/>
- <element name="id" type="tns:ID"/>
-
-
- <element name="relatedLists" type="tns:RelatedList" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutSection">
- <sequence>
- <element name="columns" type="xsd:int"/>
- <element name="heading" type="xsd:string"/>
- <element name="layoutRows" type="tns:DescribeLayoutRow" maxOccurs="unbounded"/>
- <element name="rows" type="xsd:int"/>
- <element name="useCollapsibleSection" type="xsd:boolean"/>
- <element name="useHeading" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutButtonSection">
- <sequence>
- <element name="detailButtons" type="tns:DescribeLayoutButton" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutRow">
- <sequence>
- <element name="layoutItems" type="tns:DescribeLayoutItem" maxOccurs="unbounded"/>
- <element name="numItems" type="xsd:int"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutItem">
- <sequence>
- <element name="editable" type="xsd:boolean"/>
- <element name="label" type="xsd:string" nillable="true"/>
- <element name="layoutComponents" type="tns:DescribeLayoutComponent" minOccurs="0" maxOccurs="unbounded"/>
- <element name="placeholder" type="xsd:boolean"/>
- <element name="required" type="xsd:boolean"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutButton">
- <sequence>
- <element name="custom" type="xsd:boolean"/>
- <element name="label" type="xsd:string" nillable="true"/>
- <element name="name" type="xsd:string" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeLayoutComponent">
- <sequence>
- <element name="displayLines" type="xsd:int"/>
- <element name="tabOrder" type="xsd:int"/>
- <element name="type" type="tns:layoutComponentType"/>
- <element name="value" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <simpleType name="layoutComponentType">
- <restriction base="xsd:string">
- <enumeration value="Field"/>
- <enumeration value="Separator"/>
- <enumeration value="SControl"/>
- <enumeration value="EmptySpace"/>
- </restriction>
- </simpleType>
-
- <complexType name="RecordTypeInfo">
- <sequence>
- <element name="available" type="xsd:boolean"/>
- <element name="defaultRecordTypeMapping" type="xsd:boolean"/>
- <element name="name" type="xsd:string"/>
- <element name="recordTypeId" type="tns:ID" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="RecordTypeMapping">
- <sequence>
- <element name="available" type="xsd:boolean"/>
- <element name="defaultRecordTypeMapping" type="xsd:boolean"/>
- <element name="layoutId" type="tns:ID"/>
- <element name="name" type="xsd:string"/>
- <element name="picklistsForRecordType" type="tns:PicklistForRecordType" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- <element name="recordTypeId" type="tns:ID" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="PicklistForRecordType">
- <sequence>
- <element name="picklistName" type="xsd:string"/>
- <element name="picklistValues" type="tns:PicklistEntry" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="RelatedList">
- <sequence>
- <element name="columns" type="tns:RelatedListColumn" maxOccurs="unbounded"/>
- <element name="custom" type="xsd:boolean"/>
- <element name="field" type="xsd:string" nillable="true"/>
- <element name="label" type="xsd:string"/>
- <element name="limitRows" type="xsd:int"/>
- <element name="name" type="xsd:string"/>
- <element name="sobject" type="xsd:string" nillable="true"/>
- <element name="sort" type="tns:RelatedListSort" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="RelatedListColumn">
- <sequence>
- <element name="field" type="xsd:string" nillable="true"/>
- <element name="format" type="xsd:string" nillable="true"/>
- <element name="label" type="xsd:string"/>
- <element name="name" type="xsd:string"/>
- </sequence>
- </complexType>
-
- <complexType name="RelatedListSort">
- <sequence>
- <element name="ascending" type="xsd:boolean"/>
- <element name="column" type="xsd:string"/>
- </sequence>
- </complexType>
-
-
-
- <complexType name="EmailFileAttachment">
- <sequence>
- <element name="body" nillable="true" minOccurs="0" type="xsd:base64Binary"/>
- <element name="fileName" type="xsd:string" />
- </sequence>
- </complexType>
- <simpleType name="EmailPriority">
- <restriction base="xsd:string">
- <enumeration value="Highest"/>
- <enumeration value="High"/>
- <enumeration value="Normal"/>
- <enumeration value="Low"/>
- <enumeration value="Lowest"/>
- </restriction>
- </simpleType>
-
- <complexType name="Email">
- <sequence>
- <element name="bccSender" type="xsd:boolean" nillable="true"/>
- <element name="emailPriority" type="tns:EmailPriority" nillable="true"/>
- <element name="replyTo" type="xsd:string" nillable="true"/>
- <element name="saveAsActivity" type="xsd:boolean" nillable="true"/>
- <element name="senderDisplayName" type="xsd:string" nillable="true"/>
- <element name="subject" type="xsd:string" nillable="true"/>
- <element name="useSignature" type="xsd:boolean" nillable="true"/>
- </sequence>
- </complexType>
-
- <complexType name="MassEmailMessage">
- <complexContent>
- <extension base="tns:Email">
- <sequence>
- <element name="description" type="xsd:string" nillable="true"/>
- <element name="targetObjectIds" minOccurs="0" maxOccurs="250" type="tns:ID" />
- <element name="templateId" type="tns:ID"/>
- <element name="whatIds" minOccurs="0" maxOccurs="250" type="tns:ID" />
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="SingleEmailMessage">
- <complexContent>
- <extension base="tns:Email">
- <sequence>
- <element name="bccAddresses" minOccurs="0" maxOccurs="5" type="xsd:string" nillable="true"/>
- <element name="ccAddresses" minOccurs="0" maxOccurs="5" type="xsd:string" nillable="true"/>
- <element name="charset" type="xsd:string" nillable="true"/>
- <element name="documentAttachments" minOccurs="0" maxOccurs="unbounded" type="tns:ID" />
- <element name="htmlBody" type="xsd:string" nillable="true"/>
- <element name="fileAttachments" minOccurs="0" maxOccurs="unbounded" type="tns:EmailFileAttachment"/>
- <element name="plainTextBody" type="xsd:string" nillable="true"/>
- <element name="targetObjectId" type="tns:ID" nillable="true"/>
- <element name="templateId" type="tns:ID" nillable="true"/>
- <element name="toAddresses" minOccurs="0" maxOccurs="10" type="xsd:string" nillable="true"/>
- <element name="whatId" type="tns:ID" nillable="true"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="SendEmailResult">
- <sequence>
- <element name="errors" minOccurs="0" maxOccurs="unbounded" type="tns:SendEmailError" />
- <element name="success" type="xsd:boolean" />
- </sequence>
- </complexType>
-
-
-
- <complexType name="DescribeTabSetResult">
- <sequence>
- <element name="label" type="xsd:string" />
- <element name="logoUrl" type="xsd:string" />
- <element name="namespace" type="xsd:string" minOccurs="0"/>
- <element name="selected" type="xsd:boolean" />
- <element name="tabs" type="tns:DescribeTab" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
-
- <complexType name="DescribeTab">
- <sequence>
- <element name="custom" type="xsd:boolean" />
- <element name="iconUrl" type="xsd:string" />
- <element name="label" type="xsd:string" />
- <element name="miniIconUrl" type="xsd:string" />
- <element name="sobjectName" type="xsd:string" nillable="true" />
- <element name="url" type="xsd:string" />
- </sequence>
- </complexType>
-
-
-
-
-
- <!-- Login Message Types -->
- <element name="login">
- <complexType>
- <sequence>
- <element name="username" type="xsd:string"/>
- <element name="password" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="loginResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:LoginResult"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Describe Message Types -->
- <element name="describeSObject">
- <complexType>
- <sequence>
- <element name="sObjectType" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="describeSObjectResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DescribeSObjectResult" nillable="true"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- DescibeSObjects Message Types -->
- <element name="describeSObjects">
- <complexType>
- <sequence>
- <element name="sObjectType" type="xsd:string" minOccurs='0' maxOccurs='100' />
- </sequence>
- </complexType>
- </element>
- <element name="describeSObjectsResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DescribeSObjectResult" nillable="true" minOccurs='0' maxOccurs='100'/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Describe Global Message Types -->
- <element name="describeGlobal">
- <complexType>
- <sequence/>
- </complexType>
- </element>
- <element name="describeGlobalResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DescribeGlobalResult"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="describeLayout">
- <complexType>
- <sequence>
- <element name="sObjectType" type="xsd:string"/>
- <element name="recordTypeIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="describeLayoutResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DescribeLayoutResult" nillable="true"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="describeSoftphoneLayout">
- <complexType>
- <sequence/>
- </complexType>
- </element>
- <element name="describeSoftphoneLayoutResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DescribeSoftphoneLayoutResult" nillable="true"/>
- </sequence>
- </complexType>
- </element>
-
-
- <element name="describeTabs">
- <complexType>
- <sequence/>
- </complexType>
- </element>
- <element name="describeTabsResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DescribeTabSetResult" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Create Message Types -->
- <element name="create">
- <complexType>
- <sequence>
- <element name="sObjects" type="ens:sObject" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="createResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:SaveResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
-
-
- <!-- Send Email Types -->
- <element name="sendEmail">
- <complexType>
- <sequence>
- <element name="messages" type="tns:Email" minOccurs="0" maxOccurs="10"/>
- </sequence>
- </complexType>
- </element>
- <element name="sendEmailResponse">
- <complexType>
- <sequence>
- <element name="result" minOccurs="0" maxOccurs="10" type="tns:SendEmailResult"/>
- </sequence>
- </complexType>
- </element>
-
-
- <!-- Update Message Types -->
- <element name="update">
- <complexType>
- <sequence>
- <element name="sObjects" type="ens:sObject" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="updateResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:SaveResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Upsert Message Types -->
- <element name="upsert">
- <complexType>
- <sequence>
- <element name="externalIDFieldName" type="xsd:string"/>
- <element name="sObjects" type="ens:sObject" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="upsertResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:UpsertResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Merge Message Types -->
- <element name="merge">
- <complexType>
- <sequence>
- <element name="request" type="tns:MergeRequest" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="mergeResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:MergeResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Delete Message Types -->
- <element name="delete">
- <complexType>
- <sequence>
- <element name="ids" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="deleteResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:DeleteResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Undelete Message Types -->
- <element name="undelete">
- <complexType>
- <sequence>
- <element name="ids" type="tns:ID" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="undeleteResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:UndeleteResult" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- EmptyRecycleBin Message Types -->
- <element name="emptyRecycleBin">
- <complexType>
- <sequence>
- <element name="ids" type="tns:ID" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="emptyRecycleBinResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:EmptyRecycleBinResult" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Process Message Types -->
- <element name="process">
- <complexType>
- <sequence>
- <element name="actions" type="tns:ProcessRequest" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="processResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:ProcessResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Retrieve (ID List) Message Types -->
- <element name="retrieve">
- <complexType>
- <sequence>
- <element name="fieldList" type="xsd:string"/>
- <element name="sObjectType" type="xsd:string"/>
- <element name="ids" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="retrieveResponse">
- <complexType>
- <sequence>
- <element name="result" type="ens:sObject" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Convert Lead Message Types -->
- <element name="convertLead">
- <complexType>
- <sequence>
- <element name="leadConverts" type="tns:LeadConvert" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="convertLeadResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:LeadConvertResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Get Updated Message Types -->
- <element name="getUpdated">
- <complexType>
- <sequence>
- <element name="sObjectType" type="xsd:string"/>
- <element name="startDate" type="xsd:dateTime"/>
- <element name="endDate" type="xsd:dateTime"/>
- </sequence>
- </complexType>
- </element>
- <element name="getUpdatedResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:GetUpdatedResult"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Get Deleted Message Types -->
- <element name="getDeleted">
- <complexType>
- <sequence>
- <element name="sObjectType" type="xsd:string"/>
- <element name="startDate" type="xsd:dateTime"/>
- <element name="endDate" type="xsd:dateTime"/>
- </sequence>
- </complexType>
- </element>
- <element name="getDeletedResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:GetDeletedResult"/>
- </sequence>
- </complexType>
- </element>
-
-
- <!-- Logout current session -->
- <element name="logout">
- <complexType>
- </complexType>
- </element>
-
- <element name="logoutResponse">
- <complexType>
- </complexType>
- </element>
-
- <!-- Invalidate a list of session ids -->
- <element name="invalidateSessions">
- <complexType>
- <sequence>
- <element name="sessionIds" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="invalidateSessionsResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:InvalidateSessionsResult" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Create Query -->
- <element name="query">
- <complexType>
- <sequence>
- <element name="queryString" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="queryResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:QueryResult"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Create Query All -->
- <element name="queryAll">
- <complexType>
- <sequence>
- <element name="queryString" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="queryAllResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:QueryResult"/>
- </sequence>
- </complexType>
- </element>
-
- <!-- Next Batch of sObjects from a query -->
- <element name="queryMore">
- <complexType>
- <sequence>
- <element name="queryLocator" type="tns:QueryLocator"/>
- </sequence>
- </complexType>
- </element>
- <element name="queryMoreResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:QueryResult"/>
- </sequence>
- </complexType>
- </element>
-
-
-
- <!-- Create Search -->
- <element name="search">
- <complexType>
- <sequence>
- <element name="searchString" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="searchResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:SearchResult"/>
- </sequence>
- </complexType>
- </element>
-
-
-
- <element name="getServerTimestamp">
- <complexType>
- <sequence/>
- </complexType>
- </element>
- <element name="getServerTimestampResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:GetServerTimestampResult"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="setPassword">
- <complexType>
- <sequence>
- <element name="userId" type="tns:ID"/>
- <element name="password" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
- <element name="setPasswordResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:SetPasswordResult"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="resetPassword">
- <complexType>
- <sequence>
- <element name="userId" type="tns:ID"/>
- </sequence>
- </complexType>
- </element>
- <element name="resetPasswordResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:ResetPasswordResult"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="getUserInfo">
- <complexType>
- <sequence/>
- </complexType>
- </element>
- <element name="getUserInfoResponse">
- <complexType>
- <sequence>
- <element name="result" type="tns:GetUserInfoResult"/>
- </sequence>
- </complexType>
- </element>
-
-
-
- <!-- Header Elements -->
- <element name="SessionHeader">
- <complexType>
- <sequence>
- <element name="sessionId" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="LoginScopeHeader">
- <complexType>
- <sequence>
- <element name="organizationId" type="tns:ID"/>
- <element name="portalId" type="tns:ID" minOccurs="0"/>
- </sequence>
- </complexType>
- </element>
-
-
- <element name="CallOptions">
- <complexType>
- <sequence>
- <element name="client" type="xsd:string" nillable="true"/>
- <element name="defaultNamespace" type="xsd:string" nillable="true"/>
-
- </sequence>
- </complexType>
- </element>
-
-
- <element name="QueryOptions">
- <complexType>
- <sequence>
- <element name="batchSize" type="xsd:int" minOccurs="0"/>
-
- </sequence>
- </complexType>
- </element>
-
-
- <simpleType name="DebugLevel">
- <restriction base="xsd:string">
- <enumeration value="None"/>
- <enumeration value="DebugOnly"/>
- <enumeration value="Db"/>
- </restriction>
- </simpleType>
- <element name="DebuggingHeader">
- <complexType>
- <sequence>
- <element name="debugLevel" type="tns:DebugLevel"/>
- </sequence>
- </complexType>
- </element>
- <element name="DebuggingInfo">
- <complexType>
- <sequence>
- <element name="debugLog" type="xsd:string"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="AllowFieldTruncationHeader">
- <complexType>
- <sequence>
- <element name="allowFieldTruncation" type="xsd:boolean" />
- </sequence>
- </complexType>
- </element>
-
- <!-- ideally this could of just been elem name="..." type="xsd:boolean"
- but is required to be nested within a complexType for .NET 1.1 compatibility -->
- <element name="MruHeader">
- <complexType>
- <sequence>
- <element name="updateMru" type="xsd:boolean" />
- </sequence>
- </complexType>
- </element>
-
- <element name="EmailHeader">
- <complexType>
- <sequence>
- <element name="triggerAutoResponseEmail" type="xsd:boolean"/>
- <element name="triggerOtherEmail" type="xsd:boolean"/>
- <element name="triggerUserEmail" type="xsd:boolean"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="AssignmentRuleHeader">
- <complexType>
- <sequence>
- <element name="assignmentRuleId" type="tns:ID" nillable="true" />
- <element name="useDefaultRule" type="xsd:boolean" nillable="true" />
- </sequence>
- </complexType>
- </element>
-
- <element name="UserTerritoryDeleteHeader">
- <complexType>
- <sequence>
- <element name="transferToUserId" type="tns:ID" nillable="true"/>
- </sequence>
- </complexType>
- </element>
-
-
-
- <element name="LocaleOptions">
- <complexType>
- <sequence>
- <element name="language" type="xsd:string" minOccurs="0"/>
- </sequence>
- </complexType>
- </element>
- </schema>
-
- <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:fault.partner.soap.sforce.com" xmlns:fns="urn:fault.partner.soap.sforce.com">
-
- <simpleType name="ExceptionCode">
- <restriction base="xsd:string">
- <enumeration value="API_CURRENTLY_DISABLED"/>
- <enumeration value="API_DISABLED_FOR_ORG"/>
- <enumeration value="CANT_ADD_STANDADRD_PORTAL_USER_TO_TERRITORY"/>
- <enumeration value="CANT_ADD_STANDARD_PORTAL_USER_TO_TERRITORY"/>
- <enumeration value="CIRCULAR_OBJECT_GRAPH"/>
- <enumeration value="CLIENT_NOT_ACCESSIBLE_FOR_USER"/>
- <enumeration value="CLIENT_REQUIRE_UPDATE_FOR_USER"/>
- <enumeration value="CUSTOM_METADATA_LIMIT_EXCEEDED"/>
- <enumeration value="DUPLICATE_VALUE"/>
- <enumeration value="EMAIL_BATCH_SIZE_LIMIT_EXCEEDED"/>
- <enumeration value="EMAIL_TO_CASE_INVALID_ROUTING"/>
- <enumeration value="EMAIL_TO_CASE_LIMIT_EXCEEDED"/>
- <enumeration value="EMAIL_TO_CASE_NOT_ENABLED"/>
- <enumeration value="EXCEEDED_ID_LIMIT"/>
- <enumeration value="EXCEEDED_LEAD_CONVERT_LIMIT"/>
- <enumeration value="EXCEEDED_MAX_SIZE_REQUEST"/>
- <enumeration value="EXCEEDED_MAX_TYPES_LIMIT"/>
- <enumeration value="EXCEEDED_QUOTA"/>
- <enumeration value="FUNCTIONALITY_NOT_ENABLED"/>
- <enumeration value="INACTIVE_OWNER_OR_USER"/>
- <enumeration value="INACTIVE_PORTAL"/>
- <enumeration value="INSUFFICIENT_ACCESS"/>
- <enumeration value="INVALID_ASSIGNMENT_RULE"/>
- <enumeration value="INVALID_BATCH_SIZE"/>
- <enumeration value="INVALID_CLIENT"/>
- <enumeration value="INVALID_CROSS_REFERENCE_KEY"/>
- <enumeration value="INVALID_FIELD"/>
- <enumeration value="INVALID_FILTER_LANGUAGE"/>
- <enumeration value="INVALID_FILTER_VALUE"/>
- <enumeration value="INVALID_ID_FIELD"/>
- <enumeration value="INVALID_LOCALE_LANGUAGE"/>
- <enumeration value="INVALID_LOCATOR"/>
- <enumeration value="INVALID_LOGIN"/>
- <enumeration value="INVALID_NEW_PASSWORD"/>
- <enumeration value="INVALID_OPERATION"/>
- <enumeration value="INVALID_OPERATION_WITH_EXPIRED_PASSWORD"/>
- <enumeration value="INVALID_QUERY_FILTER_OPERATOR"/>
- <enumeration value="INVALID_QUERY_LOCATOR"/>
- <enumeration value="INVALID_QUERY_SCOPE"/>
- <enumeration value="INVALID_REPLICATION_DATE"/>
- <enumeration value="INVALID_SEARCH"/>
- <enumeration value="INVALID_SEARCH_SCOPE"/>
- <enumeration value="INVALID_SESSION_ID"/>
- <enumeration value="INVALID_SOAP_HEADER"/>
- <enumeration value="INVALID_SSO_GATEWAY_URL"/>
- <enumeration value="INVALID_TYPE"/>
- <enumeration value="INVALID_TYPE_FOR_OPERATION"/>
- <enumeration value="LIMIT_EXCEEDED"/>
- <enumeration value="LOGIN_CHALLENGE_ISSUED"/>
- <enumeration value="LOGIN_CHALLENGE_PENDING"/>
- <enumeration value="LOGIN_DURING_RESTRICTED_DOMAIN"/>
- <enumeration value="LOGIN_DURING_RESTRICTED_TIME"/>
- <enumeration value="LOGIN_MUST_USE_SECURITY_TOKEN"/>
- <enumeration value="MALFORMED_ID"/>
- <enumeration value="MALFORMED_QUERY"/>
- <enumeration value="MALFORMED_SEARCH"/>
- <enumeration value="MISSING_ARGUMENT"/>
- <enumeration value="NOT_MODIFIED"/>
- <enumeration value="NO_SOFTPHONE_LAYOUT"/>
- <enumeration value="NUMBER_OUTSIDE_VALID_RANGE"/>
- <enumeration value="OPERATION_TOO_LARGE"/>
- <enumeration value="ORG_LOCKED"/>
- <enumeration value="ORG_NOT_OWNED_BY_INSTANCE"/>
- <enumeration value="PASSWORD_LOCKOUT"/>
- <enumeration value="PORTAL_NO_ACCESS"/>
- <enumeration value="QUERY_TIMEOUT"/>
- <enumeration value="QUERY_TOO_COMPLICATED"/>
- <enumeration value="REQUEST_LIMIT_EXCEEDED"/>
- <enumeration value="REQUEST_RUNNING_TOO_LONG"/>
- <enumeration value="SERVER_UNAVAILABLE"/>
- <enumeration value="SSO_SERVICE_DOWN"/>
- <enumeration value="TOO_MANY_APEX_REQUESTS"/>
- <enumeration value="TRIAL_EXPIRED"/>
- <enumeration value="UNKNOWN_EXCEPTION"/>
- <enumeration value="UNSUPPORTED_API_VERSION"/>
- <enumeration value="UNSUPPORTED_CLIENT"/>
- </restriction>
- </simpleType>
- <!-- For convenience these QNames are returned in the standard soap faultcode element -->
- <simpleType name="FaultCode">
- <restriction base="xsd:QName">
- <enumeration value="fns:API_CURRENTLY_DISABLED"/>
- <enumeration value="fns:API_DISABLED_FOR_ORG"/>
- <enumeration value="fns:CANT_ADD_STANDADRD_PORTAL_USER_TO_TERRITORY"/>
- <enumeration value="fns:CANT_ADD_STANDARD_PORTAL_USER_TO_TERRITORY"/>
- <enumeration value="fns:CIRCULAR_OBJECT_GRAPH"/>
- <enumeration value="fns:CLIENT_NOT_ACCESSIBLE_FOR_USER"/>
- <enumeration value="fns:CLIENT_REQUIRE_UPDATE_FOR_USER"/>
- <enumeration value="fns:CUSTOM_METADATA_LIMIT_EXCEEDED"/>
- <enumeration value="fns:DUPLICATE_VALUE"/>
- <enumeration value="fns:EMAIL_BATCH_SIZE_LIMIT_EXCEEDED"/>
- <enumeration value="fns:EMAIL_TO_CASE_INVALID_ROUTING"/>
- <enumeration value="fns:EMAIL_TO_CASE_LIMIT_EXCEEDED"/>
- <enumeration value="fns:EMAIL_TO_CASE_NOT_ENABLED"/>
- <enumeration value="fns:EXCEEDED_ID_LIMIT"/>
- <enumeration value="fns:EXCEEDED_LEAD_CONVERT_LIMIT"/>
- <enumeration value="fns:EXCEEDED_MAX_SIZE_REQUEST"/>
- <enumeration value="fns:EXCEEDED_MAX_TYPES_LIMIT"/>
- <enumeration value="fns:EXCEEDED_QUOTA"/>
- <enumeration value="fns:FUNCTIONALITY_NOT_ENABLED"/>
- <enumeration value="fns:INACTIVE_OWNER_OR_USER"/>
- <enumeration value="fns:INACTIVE_PORTAL"/>
- <enumeration value="fns:INSUFFICIENT_ACCESS"/>
- <enumeration value="fns:INVALID_ASSIGNMENT_RULE"/>
- <enumeration value="fns:INVALID_BATCH_SIZE"/>
- <enumeration value="fns:INVALID_CLIENT"/>
- <enumeration value="fns:INVALID_CROSS_REFERENCE_KEY"/>
- <enumeration value="fns:INVALID_FIELD"/>
- <enumeration value="fns:INVALID_FILTER_LANGUAGE"/>
- <enumeration value="fns:INVALID_FILTER_VALUE"/>
- <enumeration value="fns:INVALID_ID_FIELD"/>
- <enumeration value="fns:INVALID_LOCALE_LANGUAGE"/>
- <enumeration value="fns:INVALID_LOCATOR"/>
- <enumeration value="fns:INVALID_LOGIN"/>
- <enumeration value="fns:INVALID_NEW_PASSWORD"/>
- <enumeration value="fns:INVALID_OPERATION"/>
- <enumeration value="fns:INVALID_OPERATION_WITH_EXPIRED_PASSWORD"/>
- <enumeration value="fns:INVALID_QUERY_FILTER_OPERATOR"/>
- <enumeration value="fns:INVALID_QUERY_LOCATOR"/>
- <enumeration value="fns:INVALID_QUERY_SCOPE"/>
- <enumeration value="fns:INVALID_REPLICATION_DATE"/>
- <enumeration value="fns:INVALID_SEARCH"/>
- <enumeration value="fns:INVALID_SEARCH_SCOPE"/>
- <enumeration value="fns:INVALID_SESSION_ID"/>
- <enumeration value="fns:INVALID_SOAP_HEADER"/>
- <enumeration value="fns:INVALID_SSO_GATEWAY_URL"/>
- <enumeration value="fns:INVALID_TYPE"/>
- <enumeration value="fns:INVALID_TYPE_FOR_OPERATION"/>
- <enumeration value="fns:LIMIT_EXCEEDED"/>
- <enumeration value="fns:LOGIN_CHALLENGE_ISSUED"/>
- <enumeration value="fns:LOGIN_CHALLENGE_PENDING"/>
- <enumeration value="fns:LOGIN_DURING_RESTRICTED_DOMAIN"/>
- <enumeration value="fns:LOGIN_DURING_RESTRICTED_TIME"/>
- <enumeration value="fns:LOGIN_MUST_USE_SECURITY_TOKEN"/>
- <enumeration value="fns:MALFORMED_ID"/>
- <enumeration value="fns:MALFORMED_QUERY"/>
- <enumeration value="fns:MALFORMED_SEARCH"/>
- <enumeration value="fns:MISSING_ARGUMENT"/>
- <enumeration value="fns:NOT_MODIFIED"/>
- <enumeration value="fns:NO_SOFTPHONE_LAYOUT"/>
- <enumeration value="fns:NUMBER_OUTSIDE_VALID_RANGE"/>
- <enumeration value="fns:OPERATION_TOO_LARGE"/>
- <enumeration value="fns:ORG_LOCKED"/>
- <enumeration value="fns:ORG_NOT_OWNED_BY_INSTANCE"/>
- <enumeration value="fns:PASSWORD_LOCKOUT"/>
- <enumeration value="fns:PORTAL_NO_ACCESS"/>
- <enumeration value="fns:QUERY_TIMEOUT"/>
- <enumeration value="fns:QUERY_TOO_COMPLICATED"/>
- <enumeration value="fns:REQUEST_LIMIT_EXCEEDED"/>
- <enumeration value="fns:REQUEST_RUNNING_TOO_LONG"/>
- <enumeration value="fns:SERVER_UNAVAILABLE"/>
- <enumeration value="fns:SSO_SERVICE_DOWN"/>
- <enumeration value="fns:TOO_MANY_APEX_REQUESTS"/>
- <enumeration value="fns:TRIAL_EXPIRED"/>
- <enumeration value="fns:UNKNOWN_EXCEPTION"/>
- <enumeration value="fns:UNSUPPORTED_API_VERSION"/>
- <enumeration value="fns:UNSUPPORTED_CLIENT"/>
- </restriction>
- </simpleType>
-
-
- <!-- Fault -->
- <complexType name="ApiFault">
- <sequence>
- <element name="exceptionCode" type="fns:ExceptionCode"/>
- <element name="exceptionMessage" type="xsd:string"/>
-
- </sequence>
- </complexType>
-
- <element name="fault" type="fns:ApiFault" />
-
- <complexType name="ApiQueryFault">
- <complexContent>
- <extension base="fns:ApiFault">
- <sequence>
- <element name="row" type="xsd:int"/>
- <element name="column" type="xsd:int"/>
- </sequence>
- </extension>
- </complexContent>
- </complexType>
-
- <complexType name="LoginFault">
- <complexContent>
- <extension base="fns:ApiFault"/>
- </complexContent>
- </complexType>
- <element name="LoginFault" type="fns:LoginFault"/>
-
- <complexType name="InvalidQueryLocatorFault">
- <complexContent>
- <extension base="fns:ApiFault"/>
- </complexContent>
- </complexType>
- <element name="InvalidQueryLocatorFault" type="fns:InvalidQueryLocatorFault"/>
-
- <complexType name="InvalidNewPasswordFault">
- <complexContent>
- <extension base="fns:ApiFault"/>
- </complexContent>
- </complexType>
- <element name="InvalidNewPasswordFault" type="fns:InvalidNewPasswordFault"/>
-
- <complexType name="InvalidIdFault">
- <complexContent>
- <extension base="fns:ApiFault"/>
- </complexContent>
- </complexType>
- <element name="InvalidIdFault" type="fns:InvalidIdFault"/>
-
- <complexType name="UnexpectedErrorFault">
- <complexContent>
- <extension base="fns:ApiFault"/>
- </complexContent>
- </complexType>
- <element name="UnexpectedErrorFault" type="fns:UnexpectedErrorFault"/>
-
- <complexType name="InvalidFieldFault">
- <complexContent>
- <extension base="fns:ApiQueryFault"/>
- </complexContent>
- </complexType>
- <element name="InvalidFieldFault" type="fns:InvalidFieldFault"/>
-
- <complexType name="InvalidSObjectFault">
- <complexContent>
- <extension base="fns:ApiQueryFault"/>
- </complexContent>
- </complexType>
- <element name="InvalidSObjectFault" type="fns:InvalidSObjectFault"/>
-
- <complexType name="MalformedQueryFault">
- <complexContent>
- <extension base="fns:ApiQueryFault"/>
- </complexContent>
- </complexType>
- <element name="MalformedQueryFault" type="fns:MalformedQueryFault"/>
-
- <complexType name="MalformedSearchFault">
- <complexContent>
- <extension base="fns:ApiQueryFault"/>
- </complexContent>
- </complexType>
- <element name="MalformedSearchFault" type="fns:MalformedSearchFault"/>
-
-
- </schema>
- </types>
-
- <!-- Header Message -->
- <message name="Header">
- <part element="tns:LoginScopeHeader" name="LoginScopeHeader"/>
- <part element="tns:SessionHeader" name="SessionHeader"/>
-
- <part element="tns:CallOptions" name="CallOptions"/>
-
- <part element="tns:QueryOptions" name="QueryOptions"/>
- <part element="tns:AssignmentRuleHeader" name="AssignmentRuleHeader"/>
- <part element="tns:AllowFieldTruncationHeader" name="AllowFieldTruncationHeader"/>
- <part element="tns:MruHeader" name="MruHeader"/>
- <part element="tns:EmailHeader" name="EmailHeader"/>
-
- <part element="tns:UserTerritoryDeleteHeader" name="UserTerritoryDeleteHeader"/>
-
- <part element="tns:DebuggingHeader" name="DebuggingHeader"/>
- <part element="tns:DebuggingInfo" name="DebuggingInfo"/>
- <part element="tns:LocaleOptions" name="LocaleOptions"/>
- </message>
-
- <!-- Fault Messages -->
-
- <message name="ApiFault">
- <part name="fault" element="fns:fault"/>
- </message>
-
- <message name="LoginFault">
- <part name="fault" element="fns:LoginFault"/>
- </message>
- <message name="InvalidQueryLocatorFault">
- <part name="fault" element="fns:InvalidQueryLocatorFault"/>
- </message>
- <message name="InvalidNewPasswordFault">
- <part name="fault" element="fns:InvalidNewPasswordFault"/>
- </message>
- <message name="InvalidIdFault">
- <part name="fault" element="fns:InvalidIdFault"/>
- </message>
- <message name="UnexpectedErrorFault">
- <part name="fault" element="fns:UnexpectedErrorFault"/>
- </message>
- <message name="InvalidFieldFault">
- <part name="fault" element="fns:InvalidFieldFault"/>
- </message>
- <message name="InvalidSObjectFault">
- <part name="fault" element="fns:InvalidSObjectFault"/>
- </message>
- <message name="MalformedQueryFault">
- <part name="fault" element="fns:MalformedQueryFault"/>
- </message>
- <message name="MalformedSearchFault">
- <part name="fault" element="fns:MalformedSearchFault"/>
- </message>
-
-
- <!-- Method Messages -->
- <message name="loginRequest">
- <part element="tns:login" name="parameters"/>
- </message>
- <message name="loginResponse">
- <part element="tns:loginResponse" name="parameters"/>
- </message>
-
- <message name="describeSObjectRequest">
- <part element="tns:describeSObject" name="parameters"/>
- </message>
- <message name="describeSObjectResponse">
- <part element="tns:describeSObjectResponse" name="parameters"/>
- </message>
-
- <message name="describeSObjectsRequest">
- <part element="tns:describeSObjects" name="parameters"/>
- </message>
- <message name="describeSObjectsResponse">
- <part element="tns:describeSObjectsResponse" name="parameters"/>
- </message>
-
- <message name="describeGlobalRequest">
- <part element="tns:describeGlobal" name="parameters"/>
- </message>
- <message name="describeGlobalResponse">
- <part element="tns:describeGlobalResponse" name="parameters"/>
- </message>
-
- <message name="describeLayoutRequest">
- <part element="tns:describeLayout" name="parameters"/>
- </message>
- <message name="describeLayoutResponse">
- <part element="tns:describeLayoutResponse" name="parameters"/>
- </message>
-
- <message name="describeSoftphoneLayoutRequest">
- <part element="tns:describeSoftphoneLayout" name="parameters"/>
- </message>
- <message name="describeSoftphoneLayoutResponse">
- <part element="tns:describeSoftphoneLayoutResponse" name="parameters"/>
- </message>
-
- <message name="describeTabsRequest">
- <part element="tns:describeTabs" name="parameters"/>
- </message>
- <message name="describeTabsResponse">
- <part element="tns:describeTabsResponse" name="parameters"/>
- </message>
-
- <message name="createRequest">
- <part element="tns:create" name="parameters"/>
- </message>
- <message name="createResponse">
- <part element="tns:createResponse" name="parameters"/>
- </message>
-
- <message name="updateRequest">
- <part element="tns:update" name="parameters"/>
- </message>
- <message name="updateResponse">
- <part element="tns:updateResponse" name="parameters"/>
- </message>
-
- <message name="upsertRequest">
- <part element="tns:upsert" name="parameters"/>
- </message>
- <message name="upsertResponse">
- <part element="tns:upsertResponse" name="parameters"/>
- </message>
-
- <message name="mergeRequest">
- <part element="tns:merge" name="parameters"/>
- </message>
- <message name="mergeResponse">
- <part element="tns:mergeResponse" name="parameters"/>
- </message>
-
- <message name="deleteRequest">
- <part element="tns:delete" name="parameters"/>
- </message>
- <message name="deleteResponse">
- <part element="tns:deleteResponse" name="parameters"/>
- </message>
-
- <message name="undeleteRequest">
- <part element="tns:undelete" name="parameters"/>
- </message>
- <message name="undeleteResponse">
- <part element="tns:undeleteResponse" name="parameters"/>
- </message>
-
- <message name="emptyRecycleBinRequest">
- <part element="tns:emptyRecycleBin" name="parameters"/>
- </message>
- <message name="emptyRecycleBinResponse">
- <part element="tns:emptyRecycleBinResponse" name="parameters"/>
- </message>
-
- <message name="retrieveRequest">
- <part element="tns:retrieve" name="parameters"/>
- </message>
- <message name="retrieveResponse">
- <part element="tns:retrieveResponse" name="parameters"/>
- </message>
-
- <message name="processRequest">
- <part element="tns:process" name="parameters"/>
- </message>
- <message name="processResponse">
- <part element="tns:processResponse" name="parameters"/>
- </message>
-
- <message name="convertLeadRequest">
- <part element="tns:convertLead" name="parameters"/>
- </message>
- <message name="convertLeadResponse">
- <part element="tns:convertLeadResponse" name="parameters"/>
- </message>
-
- <message name="logoutRequest">
- <part element="tns:logout" name="parameters"/>
- </message>
- <message name="logoutResponse">
- <part element="tns:logoutResponse" name="parameters"/>
- </message>
-
- <message name="invalidateSessionsRequest">
- <part element="tns:invalidateSessions" name="parameters"/>
- </message>
- <message name="invalidateSessionsResponse">
- <part element="tns:invalidateSessionsResponse" name="parameters"/>
- </message>
-
- <message name="getDeletedRequest">
- <part element="tns:getDeleted" name="parameters"/>
- </message>
- <message name="getDeletedResponse">
- <part element="tns:getDeletedResponse" name="parameters"/>
- </message>
-
- <message name="getUpdatedRequest">
- <part element="tns:getUpdated" name="parameters"/>
- </message>
- <message name="getUpdatedResponse">
- <part element="tns:getUpdatedResponse" name="parameters"/>
- </message>
-
- <message name="queryRequest">
- <part element="tns:query" name="parameters"/>
- </message>
- <message name="queryResponse">
- <part element="tns:queryResponse" name="parameters"/>
- </message>
-
- <message name="queryAllRequest">
- <part element="tns:queryAll" name="parameters"/>
- </message>
- <message name="queryAllResponse">
- <part element="tns:queryAllResponse" name="parameters"/>
- </message>
-
- <message name="queryMoreRequest">
- <part element="tns:queryMore" name="parameters"/>
- </message>
- <message name="queryMoreResponse">
- <part element="tns:queryMoreResponse" name="parameters"/>
- </message>
-
- <message name="searchRequest">
- <part element="tns:search" name="parameters"/>
- </message>
- <message name="searchResponse">
- <part element="tns:searchResponse" name="parameters"/>
- </message>
-
- <message name="getServerTimestampRequest">
- <part element="tns:getServerTimestamp" name="parameters"/>
- </message>
- <message name="getServerTimestampResponse">
- <part element="tns:getServerTimestampResponse" name="parameters"/>
- </message>
-
- <message name="setPasswordRequest">
- <part element="tns:setPassword" name="parameters"/>
- </message>
- <message name="setPasswordResponse">
- <part element="tns:setPasswordResponse" name="parameters"/>
- </message>
-
- <message name="resetPasswordRequest">
- <part element="tns:resetPassword" name="parameters"/>
- </message>
- <message name="resetPasswordResponse">
- <part element="tns:resetPasswordResponse" name="parameters"/>
- </message>
-
- <message name="getUserInfoRequest">
- <part element="tns:getUserInfo" name="parameters"/>
- </message>
- <message name="getUserInfoResponse">
- <part element="tns:getUserInfoResponse" name="parameters"/>
- </message>
-
- <message name="sendEmailRequest">
- <part element="tns:sendEmail" name="parameters"/>
- </message>
- <message name="sendEmailResponse">
- <part element="tns:sendEmailResponse" name="parameters"/>
- </message>
-
-
-
- <!-- Soap PortType -->
- <portType name="Soap">
- <operation name="login">
- <documentation>Login to the Salesforce.com SOAP Api</documentation>
- <input message="tns:loginRequest"/>
- <output message="tns:loginResponse"/>
- <fault message="tns:LoginFault" name="LoginFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- </operation>
-
- <operation name="describeSObject">
- <documentation>Describe an sObject</documentation>
- <input message="tns:describeSObjectRequest"/>
- <output message="tns:describeSObjectResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="describeSObjects">
- <documentation>Describe a number sObjects</documentation>
- <input message="tns:describeSObjectsRequest"/>
- <output message="tns:describeSObjectsResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="describeGlobal">
- <documentation>Describe the Global state</documentation>
- <input message="tns:describeGlobalRequest"/>
- <output message="tns:describeGlobalResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="describeLayout">
- <documentation>Describe the layout of an sObject</documentation>
- <input message="tns:describeLayoutRequest"/>
- <output message="tns:describeLayoutResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- </operation>
-
- <operation name="describeSoftphoneLayout">
- <documentation>Describe the layout of the SoftPhone</documentation>
- <input message="tns:describeSoftphoneLayoutRequest"/>
- <output message="tns:describeSoftphoneLayoutResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="describeTabs">
- <documentation>Describe the tabs that appear on a users page</documentation>
- <input message="tns:describeTabsRequest"/>
- <output message="tns:describeTabsResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="create">
- <documentation>Create a set of new sObjects</documentation>
- <input message="tns:createRequest"/>
- <output message="tns:createResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- </operation>
-
- <operation name="update">
- <documentation>Update a set of sObjects</documentation>
- <input message="tns:updateRequest"/>
- <output message="tns:updateResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- </operation>
-
- <operation name="upsert">
- <documentation>Update or insert a set of sObjects based on object id</documentation>
- <input message="tns:upsertRequest"/>
- <output message="tns:upsertResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- </operation>
-
- <operation name="merge">
- <documentation>Merge and update a set of sObjects based on object id</documentation>
- <input message="tns:mergeRequest"/>
- <output message="tns:mergeResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- </operation>
-
- <operation name="delete">
- <documentation>Delete a set of sObjects</documentation>
- <input message="tns:deleteRequest"/>
- <output message="tns:deleteResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="undelete">
- <documentation>Undelete a set of sObjects</documentation>
- <input message="tns:undeleteRequest"/>
- <output message="tns:undeleteResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="emptyRecycleBin">
- <documentation>Empty a set of sObjects from the recycle bin</documentation>
- <input message="tns:emptyRecycleBinRequest"/>
- <output message="tns:emptyRecycleBinResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="retrieve">
- <documentation>Get a set of sObjects</documentation>
- <input message="tns:retrieveRequest"/>
- <output message="tns:retrieveResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- <fault message="tns:MalformedQueryFault" name="MalformedQueryFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- </operation>
-
- <operation name="process">
- <documentation>Submit an entity to a workflow process or process a workitem</documentation>
- <input message="tns:processRequest"/>
- <output message="tns:processResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- </operation>
-
- <operation name="convertLead">
- <documentation>convert a set of leads</documentation>
- <input message="tns:convertLeadRequest"/>
- <output message="tns:convertLeadResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="logout">
- <documentation>Logout the current user, invalidating the current session.</documentation>
- <input message="tns:logoutRequest"/>
- <output message="tns:logoutResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="invalidateSessions">
- <documentation>Logs out and invalidates session ids</documentation>
- <input message="tns:invalidateSessionsRequest"/>
- <output message="tns:invalidateSessionsResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="getDeleted">
- <documentation>Get the IDs for deleted sObjects</documentation>
- <input message="tns:getDeletedRequest"/>
- <output message="tns:getDeletedResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="getUpdated">
- <documentation>Get the IDs for updated sObjects</documentation>
- <input message="tns:getUpdatedRequest"/>
- <output message="tns:getUpdatedResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="query">
- <documentation>Create a Query Cursor</documentation>
- <input message="tns:queryRequest"/>
- <output message="tns:queryResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- <fault message="tns:MalformedQueryFault" name="MalformedQueryFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidQueryLocatorFault" name="InvalidQueryLocatorFault"/>
- </operation>
-
- <operation name="queryAll">
- <documentation>Create a Query Cursor, including deleted sObjects</documentation>
- <input message="tns:queryAllRequest"/>
- <output message="tns:queryAllResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- <fault message="tns:MalformedQueryFault" name="MalformedQueryFault"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidQueryLocatorFault" name="InvalidQueryLocatorFault"/>
- </operation>
-
- <operation name="queryMore">
- <documentation>Gets the next batch of sObjects from a query</documentation>
- <input message="tns:queryMoreRequest"/>
- <output message="tns:queryMoreResponse"/>
- <fault message="tns:InvalidQueryLocatorFault" name="InvalidQueryLocatorFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- </operation>
-
- <operation name="search">
- <documentation>Search for sObjects</documentation>
- <input message="tns:searchRequest"/>
- <output message="tns:searchResponse"/>
- <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
- <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
- <fault message="tns:MalformedSearchFault" name="MalformedSearchFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="getServerTimestamp">
- <documentation>Gets server timestamp</documentation>
- <input message="tns:getServerTimestampRequest"/>
- <output message="tns:getServerTimestampResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="setPassword">
- <documentation>Set a user's password</documentation>
- <input message="tns:setPasswordRequest"/>
- <output message="tns:setPasswordResponse"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:InvalidNewPasswordFault" name="InvalidNewPasswordFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="resetPassword">
- <documentation>Reset a user's password</documentation>
- <input message="tns:resetPasswordRequest"/>
- <output message="tns:resetPasswordResponse"/>
- <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="getUserInfo">
- <documentation>Returns standard information relevant to the current user</documentation>
- <input message="tns:getUserInfoRequest"/>
- <output message="tns:getUserInfoResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- <operation name="sendEmail">
- <documentation>Send outbound email</documentation>
- <input message="tns:sendEmailRequest"/>
- <output message="tns:sendEmailResponse"/>
- <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
- </operation>
-
- </portType>
-
- <!-- Soap Binding -->
- <binding name="SoapBinding" type="tns:Soap">
- <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
- <operation name="login">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="LoginScopeHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="LoginFault">
- <soap:fault name="LoginFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- </operation>
- <operation name="describeSObject">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="LocaleOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="describeSObjects">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="LocaleOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="describeGlobal">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="describeLayout">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- </operation>
- <operation name="describeSoftphoneLayout">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="describeTabs">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="create">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
- <soap:header use="literal" message="tns:Header" part="MruHeader"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- </operation>
- <operation name="update">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
- <soap:header use="literal" message="tns:Header" part="MruHeader"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- </operation>
- <operation name="upsert">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
- <soap:header use="literal" message="tns:Header" part="MruHeader"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- </operation>
- <operation name="merge">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
- <soap:header use="literal" message="tns:Header" part="MruHeader"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- </operation>
- <operation name="delete">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="UserTerritoryDeleteHeader"/>
- <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="undelete">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="emptyRecycleBin">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="retrieve">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
- <soap:header use="literal" message="tns:Header" part="MruHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- <fault name="MalformedQueryFault">
- <soap:fault name="MalformedQueryFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- </operation>
- <operation name="process">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- </operation>
- <operation name="convertLead">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
- <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="logout">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="invalidateSessions">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="getDeleted">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="getUpdated">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="query">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
- <soap:header use="literal" message="tns:Header" part="MruHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- <fault name="MalformedQueryFault">
- <soap:fault name="MalformedQueryFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidQueryLocatorFault">
- <soap:fault name="InvalidQueryLocatorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="queryAll">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- <fault name="MalformedQueryFault">
- <soap:fault name="MalformedQueryFault" use="literal"/>
- </fault>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidQueryLocatorFault">
- <soap:fault name="InvalidQueryLocatorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="queryMore">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidQueryLocatorFault">
- <soap:fault name="InvalidQueryLocatorFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- </operation>
- <operation name="search">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidSObjectFault">
- <soap:fault name="InvalidSObjectFault" use="literal"/>
- </fault>
- <fault name="InvalidFieldFault">
- <soap:fault name="InvalidFieldFault" use="literal"/>
- </fault>
- <fault name="MalformedSearchFault">
- <soap:fault name="MalformedSearchFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="getServerTimestamp">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="setPassword">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="InvalidNewPasswordFault">
- <soap:fault name="InvalidNewPasswordFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="resetPassword">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="InvalidIdFault">
- <soap:fault name="InvalidIdFault" use="literal"/>
- </fault>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="getUserInfo">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
- <operation name="sendEmail">
- <soap:operation soapAction=""/>
- <input>
- <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
- <soap:header use="literal" message="tns:Header" part="CallOptions"/>
- <soap:body parts="parameters" use="literal"/>
- </input>
- <output>
- <soap:body use="literal"/>
- </output>
- <fault name="UnexpectedErrorFault">
- <soap:fault name="UnexpectedErrorFault" use="literal"/>
- </fault>
- </operation>
-
- </binding>
-
- <!-- Soap Service Endpoint -->
- <service name="SforceService">
- <documentation>Sforce SOAP API</documentation>
- <port binding="tns:SoapBinding" name="Soap">
- <soap:address location="https://www.salesforce.com/services/Soap/u/15.0"/>
- </port>
- </service>
-</definitions>
-
Added: trunk/connectors/salesforce-api/src/main/resources/partner_v17.wsdl
===================================================================
--- trunk/connectors/salesforce-api/src/main/resources/partner_v17.wsdl (rev 0)
+++ trunk/connectors/salesforce-api/src/main/resources/partner_v17.wsdl 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,2930 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Salesforce.com Partner Web Services API Version 17.0
+Generated on 2010-02-11 17:24:10 +0000.
+
+Copyright 1999-2010 salesforce.com, inc.
+All Rights Reserved
+-->
+<definitions targetNamespace="urn:partner.soap.sforce.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:fns="urn:fault.partner.soap.sforce.com" xmlns:tns="urn:partner.soap.sforce.com" xmlns:ens="urn:sobject.partner.soap.sforce.com">
+ <types>
+
+ <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:sobject.partner.soap.sforce.com">
+
+ <import namespace="urn:partner.soap.sforce.com"/>
+
+
+ <!-- Dynamic sObject -->
+ <complexType name="sObject">
+ <sequence>
+ <element name="type" type="xsd:string"/>
+ <element name="fieldsToNull" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="Id" type="tns:ID" nillable="true"/>
+ <any namespace="##targetNamespace" minOccurs="0" maxOccurs="unbounded" processContents="lax"/>
+ </sequence>
+ </complexType>
+
+ </schema>
+
+ <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:partner.soap.sforce.com">
+
+ <import namespace="urn:sobject.partner.soap.sforce.com"/>
+
+ <!-- Our simple ID Type -->
+ <simpleType name="ID">
+ <restriction base="xsd:string">
+ <length value="18"/>
+ <pattern value="[a-zA-Z0-9]{18}"/>
+ </restriction>
+ </simpleType>
+
+ <simpleType name="QueryLocator">
+ <restriction base="xsd:string"/>
+ </simpleType>
+
+ <!-- Shared Result Types -->
+ <complexType name="QueryResult">
+ <sequence>
+ <element name="done" type="xsd:boolean"/>
+ <element name="queryLocator" type="tns:QueryLocator" nillable="true"/>
+ <element name="records" type="ens:sObject" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="size" type="xsd:int"/>
+ </sequence>
+ </complexType>
+
+
+
+ <!-- Search Result -->
+ <complexType name="SearchResult">
+ <sequence>
+ <element name="searchRecords" minOccurs="0" maxOccurs="unbounded" type="tns:SearchRecord"/>
+ <element name="sforceReserved" minOccurs="0" maxOccurs="1" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="SearchRecord">
+ <sequence>
+ <element name="record" type="ens:sObject"/>
+ </sequence>
+ </complexType>
+
+ <!-- GetUpdated Result -->
+ <complexType name="GetUpdatedResult">
+ <sequence>
+ <element name="ids" minOccurs="0" maxOccurs="unbounded" type="tns:ID"/>
+ <element name="latestDateCovered" type="xsd:dateTime"/>
+ <element name="sforceReserved" minOccurs="0" maxOccurs="1" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <!-- GetDeleted Result -->
+ <complexType name="GetDeletedResult">
+ <sequence>
+ <element name="deletedRecords" minOccurs="0" maxOccurs="unbounded" type="tns:DeletedRecord"/>
+ <element name="earliestDateAvailable" type="xsd:dateTime"/>
+ <element name="latestDateCovered" type="xsd:dateTime"/>
+ <element name="sforceReserved" minOccurs="0" maxOccurs="1" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DeletedRecord">
+ <sequence>
+ <element name="deletedDate" type="xsd:dateTime"/>
+ <element name="id" type="tns:ID"/>
+ </sequence>
+ </complexType>
+
+
+ <complexType name="GetServerTimestampResult">
+ <sequence>
+ <element name="timestamp" type="xsd:dateTime"/>
+ </sequence>
+ </complexType>
+
+
+ <!-- InvalidateSessions Result -->
+ <complexType name="InvalidateSessionsResult">
+ <sequence>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="SetPasswordResult">
+ </complexType>
+
+ <complexType name="ResetPasswordResult">
+ <sequence>
+ <element name="password" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="GetUserInfoResult">
+ <sequence>
+ <element name="accessibilityMode" type="xsd:boolean"/>
+ <element name="currencySymbol" type="xsd:string" nillable="true"/>
+ <element name="orgDefaultCurrencyIsoCode" type="xsd:string" nillable="true"/>
+ <element name="orgDisallowHtmlAttachments" type="xsd:boolean"/>
+ <element name="orgHasPersonAccounts" type="xsd:boolean"/>
+ <element name="organizationId" type="tns:ID"/>
+ <element name="organizationMultiCurrency" type="xsd:boolean"/>
+ <element name="organizationName" type="xsd:string"/>
+ <element name="profileId" type="tns:ID"/>
+ <element name="roleId" type="tns:ID" nillable="true"/>
+ <element name="userDefaultCurrencyIsoCode" type="xsd:string" nillable="true"/>
+ <element name="userEmail" type="xsd:string"/>
+ <element name="userFullName" type="xsd:string"/>
+ <element name="userId" type="tns:ID"/>
+ <element name="userLanguage" type="xsd:string"/>
+ <element name="userLocale" type="xsd:string"/>
+ <element name="userName" type="xsd:string"/>
+ <element name="userTimeZone" type="xsd:string"/>
+ <element name="userType" type="xsd:string"/>
+ <element name="userUiSkin" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="LoginResult">
+ <sequence>
+ <element name="metadataServerUrl" type="xsd:string" nillable="true"/>
+ <element name="passwordExpired" type="xsd:boolean"/>
+ <element name="sandbox" type="xsd:boolean"/>
+ <element name="serverUrl" type="xsd:string" nillable="true"/>
+ <element name="sessionId" type="xsd:string" nillable="true"/>
+
+ <element name="userId" type="tns:ID" nillable="true"/>
+ <element name="userInfo" type="tns:GetUserInfoResult" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+ <simpleType name="StatusCode">
+ <restriction base="xsd:string">
+ <enumeration value="ALREADY_IN_PROCESS"/>
+ <enumeration value="ASSIGNEE_TYPE_REQUIRED"/>
+ <enumeration value="BAD_CUSTOM_ENTITY_PARENT_DOMAIN"/>
+ <enumeration value="BCC_NOT_ALLOWED_IF_BCC_COMPLIANCE_ENABLED"/>
+ <enumeration value="CANNOT_CASCADE_PRODUCT_ACTIVE"/>
+ <enumeration value="CANNOT_CHANGE_FIELD_TYPE_OF_APEX_REFERENCED_FIELD"/>
+ <enumeration value="CANNOT_CREATE_ANOTHER_MANAGED_PACKAGE"/>
+ <enumeration value="CANNOT_DEACTIVATE_DIVISION"/>
+ <enumeration value="CANNOT_DELETE_LAST_DATED_CONVERSION_RATE"/>
+ <enumeration value="CANNOT_DELETE_MANAGED_OBJECT"/>
+ <enumeration value="CANNOT_DISABLE_LAST_ADMIN"/>
+ <enumeration value="CANNOT_ENABLE_IP_RESTRICT_REQUESTS"/>
+ <enumeration value="CANNOT_INSERT_UPDATE_ACTIVATE_ENTITY"/>
+ <enumeration value="CANNOT_MODIFY_MANAGED_OBJECT"/>
+ <enumeration value="CANNOT_RENAME_APEX_REFERENCED_FIELD"/>
+ <enumeration value="CANNOT_RENAME_APEX_REFERENCED_OBJECT"/>
+ <enumeration value="CANNOT_REPARENT_RECORD"/>
+ <enumeration value="CANNOT_UPDATE_CONVERTED_LEAD"/>
+ <enumeration value="CANT_DISABLE_CORP_CURRENCY"/>
+ <enumeration value="CANT_UNSET_CORP_CURRENCY"/>
+ <enumeration value="CHILD_SHARE_FAILS_PARENT"/>
+ <enumeration value="CIRCULAR_DEPENDENCY"/>
+ <enumeration value="COMMUNITY_NOT_ACCESSIBLE"/>
+ <enumeration value="CUSTOM_CLOB_FIELD_LIMIT_EXCEEDED"/>
+ <enumeration value="CUSTOM_ENTITY_OR_FIELD_LIMIT"/>
+ <enumeration value="CUSTOM_FIELD_INDEX_LIMIT_EXCEEDED"/>
+ <enumeration value="CUSTOM_INDEX_EXISTS"/>
+ <enumeration value="CUSTOM_LINK_LIMIT_EXCEEDED"/>
+ <enumeration value="CUSTOM_TAB_LIMIT_EXCEEDED"/>
+ <enumeration value="DELETE_FAILED"/>
+ <enumeration value="DELETE_REQUIRED_ON_CASCADE"/>
+ <enumeration value="DEPENDENCY_EXISTS"/>
+ <enumeration value="DUPLICATE_CASE_SOLUTION"/>
+ <enumeration value="DUPLICATE_COMM_NICKNAME"/>
+ <enumeration value="DUPLICATE_CUSTOM_ENTITY_DEFINITION"/>
+ <enumeration value="DUPLICATE_CUSTOM_TAB_MOTIF"/>
+ <enumeration value="DUPLICATE_DEVELOPER_NAME"/>
+ <enumeration value="DUPLICATE_EXTERNAL_ID"/>
+ <enumeration value="DUPLICATE_MASTER_LABEL"/>
+ <enumeration value="DUPLICATE_SENDER_DISPLAY_NAME"/>
+ <enumeration value="DUPLICATE_USERNAME"/>
+ <enumeration value="DUPLICATE_VALUE"/>
+ <enumeration value="EMAIL_NOT_PROCESSED_DUE_TO_PRIOR_ERROR"/>
+ <enumeration value="EMPTY_SCONTROL_FILE_NAME"/>
+ <enumeration value="ENTITY_FAILED_IFLASTMODIFIED_ON_UPDATE"/>
+ <enumeration value="ENTITY_IS_ARCHIVED"/>
+ <enumeration value="ENTITY_IS_DELETED"/>
+ <enumeration value="ENTITY_IS_LOCKED"/>
+ <enumeration value="ERROR_IN_MAILER"/>
+ <enumeration value="FAILED_ACTIVATION"/>
+ <enumeration value="FIELD_CUSTOM_VALIDATION_EXCEPTION"/>
+ <enumeration value="FIELD_INTEGRITY_EXCEPTION"/>
+ <enumeration value="FILTERED_LOOKUP_LIMIT_EXCEEDED"/>
+ <enumeration value="HTML_FILE_UPLOAD_NOT_ALLOWED"/>
+ <enumeration value="IMAGE_TOO_LARGE"/>
+ <enumeration value="INACTIVE_OWNER_OR_USER"/>
+ <enumeration value="INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY"/>
+ <enumeration value="INSUFFICIENT_ACCESS_OR_READONLY"/>
+ <enumeration value="INVALID_ACCESS_LEVEL"/>
+ <enumeration value="INVALID_ARGUMENT_TYPE"/>
+ <enumeration value="INVALID_ASSIGNEE_TYPE"/>
+ <enumeration value="INVALID_ASSIGNMENT_RULE"/>
+ <enumeration value="INVALID_BATCH_OPERATION"/>
+ <enumeration value="INVALID_CONTENT_TYPE"/>
+ <enumeration value="INVALID_CREDIT_CARD_INFO"/>
+ <enumeration value="INVALID_CROSS_REFERENCE_KEY"/>
+ <enumeration value="INVALID_CROSS_REFERENCE_TYPE_FOR_FIELD"/>
+ <enumeration value="INVALID_CURRENCY_CONV_RATE"/>
+ <enumeration value="INVALID_CURRENCY_CORP_RATE"/>
+ <enumeration value="INVALID_CURRENCY_ISO"/>
+ <enumeration value="INVALID_EMAIL_ADDRESS"/>
+ <enumeration value="INVALID_EMPTY_KEY_OWNER"/>
+ <enumeration value="INVALID_FIELD"/>
+ <enumeration value="INVALID_FIELD_FOR_INSERT_UPDATE"/>
+ <enumeration value="INVALID_FIELD_WHEN_USING_TEMPLATE"/>
+ <enumeration value="INVALID_FILTER_ACTION"/>
+ <enumeration value="INVALID_GOOGLE_DOCS_URL"/>
+ <enumeration value="INVALID_ID_FIELD"/>
+ <enumeration value="INVALID_INET_ADDRESS"/>
+ <enumeration value="INVALID_LINEITEM_CLONE_STATE"/>
+ <enumeration value="INVALID_MASTER_OR_TRANSLATED_SOLUTION"/>
+ <enumeration value="INVALID_MESSAGE_ID_REFERENCE"/>
+ <enumeration value="INVALID_OPERATION"/>
+ <enumeration value="INVALID_OPERATOR"/>
+ <enumeration value="INVALID_OR_NULL_FOR_RESTRICTED_PICKLIST"/>
+ <enumeration value="INVALID_PARTNER_NETWORK_STATUS"/>
+ <enumeration value="INVALID_PERSON_ACCOUNT_OPERATION"/>
+ <enumeration value="INVALID_SAVE_AS_ACTIVITY_FLAG"/>
+ <enumeration value="INVALID_SESSION_ID"/>
+ <enumeration value="INVALID_SETUP_OWNER"/>
+ <enumeration value="INVALID_STATUS"/>
+ <enumeration value="INVALID_TYPE"/>
+ <enumeration value="INVALID_TYPE_FOR_OPERATION"/>
+ <enumeration value="INVALID_TYPE_ON_FIELD_IN_RECORD"/>
+ <enumeration value="IP_RANGE_LIMIT_EXCEEDED"/>
+ <enumeration value="LICENSE_LIMIT_EXCEEDED"/>
+ <enumeration value="LIGHT_PORTAL_USER_EXCEPTION"/>
+ <enumeration value="LIMIT_EXCEEDED"/>
+ <enumeration value="MALFORMED_ID"/>
+ <enumeration value="MANAGER_NOT_DEFINED"/>
+ <enumeration value="MASSMAIL_RETRY_LIMIT_EXCEEDED"/>
+ <enumeration value="MASS_MAIL_LIMIT_EXCEEDED"/>
+ <enumeration value="MAXIMUM_CCEMAILS_EXCEEDED"/>
+ <enumeration value="MAXIMUM_DASHBOARD_COMPONENTS_EXCEEDED"/>
+ <enumeration value="MAXIMUM_HIERARCHY_LEVELS_REACHED"/>
+ <enumeration value="MAXIMUM_SIZE_OF_ATTACHMENT"/>
+ <enumeration value="MAXIMUM_SIZE_OF_DOCUMENT"/>
+ <enumeration value="MAX_ACTIONS_PER_RULE_EXCEEDED"/>
+ <enumeration value="MAX_ACTIVE_RULES_EXCEEDED"/>
+ <enumeration value="MAX_APPROVAL_STEPS_EXCEEDED"/>
+ <enumeration value="MAX_FORMULAS_PER_RULE_EXCEEDED"/>
+ <enumeration value="MAX_RULES_EXCEEDED"/>
+ <enumeration value="MAX_RULE_ENTRIES_EXCEEDED"/>
+ <enumeration value="MAX_TASK_DESCRIPTION_EXCEEEDED"/>
+ <enumeration value="MAX_TM_RULES_EXCEEDED"/>
+ <enumeration value="MAX_TM_RULE_ITEMS_EXCEEDED"/>
+ <enumeration value="MERGE_FAILED"/>
+ <enumeration value="MISSING_ARGUMENT"/>
+ <enumeration value="MIXED_DML_OPERATION"/>
+ <enumeration value="NONUNIQUE_SHIPPING_ADDRESS"/>
+ <enumeration value="NO_APPLICABLE_PROCESS"/>
+ <enumeration value="NO_ATTACHMENT_PERMISSION"/>
+ <enumeration value="NO_INACTIVE_DIVISION_MEMBERS"/>
+ <enumeration value="NO_MASS_MAIL_PERMISSION"/>
+ <enumeration value="NUMBER_OUTSIDE_VALID_RANGE"/>
+ <enumeration value="NUM_HISTORY_FIELDS_BY_SOBJECT_EXCEEDED"/>
+ <enumeration value="OPTED_OUT_OF_MASS_MAIL"/>
+ <enumeration value="PACKAGE_LICENSE_REQUIRED"/>
+ <enumeration value="PORTAL_USER_ALREADY_EXISTS_FOR_CONTACT"/>
+ <enumeration value="PRIVATE_CONTACT_ON_ASSET"/>
+ <enumeration value="RECORD_IN_USE_BY_WORKFLOW"/>
+ <enumeration value="REQUEST_RUNNING_TOO_LONG"/>
+ <enumeration value="REQUIRED_FIELD_MISSING"/>
+ <enumeration value="SELF_REFERENCE_FROM_TRIGGER"/>
+ <enumeration value="SHARE_NEEDED_FOR_CHILD_OWNER"/>
+ <enumeration value="STANDARD_PRICE_NOT_DEFINED"/>
+ <enumeration value="STORAGE_LIMIT_EXCEEDED"/>
+ <enumeration value="STRING_TOO_LONG"/>
+ <enumeration value="TABSET_LIMIT_EXCEEDED"/>
+ <enumeration value="TEMPLATE_NOT_ACTIVE"/>
+ <enumeration value="TERRITORY_REALIGN_IN_PROGRESS"/>
+ <enumeration value="TEXT_DATA_OUTSIDE_SUPPORTED_CHARSET"/>
+ <enumeration value="TOO_MANY_APEX_REQUESTS"/>
+ <enumeration value="TOO_MANY_ENUM_VALUE"/>
+ <enumeration value="TRANSFER_REQUIRES_READ"/>
+ <enumeration value="UNABLE_TO_LOCK_ROW"/>
+ <enumeration value="UNAVAILABLE_RECORDTYPE_EXCEPTION"/>
+ <enumeration value="UNDELETE_FAILED"/>
+ <enumeration value="UNKNOWN_EXCEPTION"/>
+ <enumeration value="UNSPECIFIED_EMAIL_ADDRESS"/>
+ <enumeration value="UNSUPPORTED_APEX_TRIGGER_OPERATON"/>
+ <enumeration value="UNVERIFIED_SENDER_ADDRESS"/>
+ <enumeration value="WEBLINK_SIZE_LIMIT_EXCEEDED"/>
+ <enumeration value="WRONG_CONTROLLER_TYPE"/>
+ </restriction>
+ </simpleType>
+
+
+ <complexType name="Error">
+ <sequence>
+ <element name="fields" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="message" type="xsd:string"/>
+ <element name="statusCode" type="tns:StatusCode"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="SendEmailError">
+ <sequence>
+ <element name="fields" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="message" type="xsd:string"/>
+ <element name="statusCode" type="tns:StatusCode"/>
+ <element name="targetObjectId" type="tns:ID" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="SaveResult">
+ <sequence>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID" nillable="true"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="UpsertResult">
+ <sequence>
+ <element name="created" type="xsd:boolean"/>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID" nillable="true"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="MergeRequest">
+ <sequence>
+ <element name="masterRecord" type="ens:sObject"/>
+ <element name="recordToMergeIds" type="tns:ID" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="MergeResult">
+ <sequence>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID" nillable="true"/>
+ <element name="mergedRecordIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="success" type="xsd:boolean"/>
+ <element name="updatedRelatedIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="ProcessRequest">
+ <sequence>
+ <element name="comments" type="xsd:string" nillable="true"/>
+ <element name="nextApproverIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="ProcessSubmitRequest">
+ <complexContent>
+ <extension base="tns:ProcessRequest">
+ <sequence>
+ <element name="objectId" type="tns:ID"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="ProcessWorkitemRequest">
+ <complexContent>
+ <extension base="tns:ProcessRequest">
+ <sequence>
+ <element name="action" type="xsd:string"/>
+ <element name="workitemId" type="tns:ID"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+
+
+ <complexType name="ProcessResult">
+ <sequence>
+ <element name="actorIds" type="tns:ID" nillable="false" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="entityId" type="tns:ID" nillable="true"/>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="instanceId" type="tns:ID" nillable="true"/>
+ <element name="instanceStatus" type="xsd:string" nillable="true"/>
+ <element name="newWorkitemIds" type="tns:ID" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+
+
+
+
+ <complexType name="DeleteResult">
+ <sequence>
+ <element name="errors" type="tns:Error" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID" nillable="true"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="UndeleteResult">
+ <sequence>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID" nillable="true"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="EmptyRecycleBinResult">
+ <sequence>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID" nillable="true"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="LeadConvert">
+ <sequence>
+ <element name="accountId" type="tns:ID" nillable="true"/>
+ <element name="contactId" type="tns:ID" nillable="true"/>
+ <element name="convertedStatus" type="xsd:string"/>
+ <element name="doNotCreateOpportunity" type="xsd:boolean"/>
+ <element name="leadId" type="tns:ID"/>
+ <element name="opportunityName" type="xsd:string" nillable="true"/>
+ <element name="overwriteLeadSource" type="xsd:boolean"/>
+ <element name="ownerId" type="tns:ID" nillable="true"/>
+ <element name="sendNotificationEmail" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="LeadConvertResult">
+ <sequence>
+ <element name="accountId" type="tns:ID" nillable="true"/>
+ <element name="contactId" type="tns:ID" nillable="true"/>
+ <element name="errors" type="tns:Error" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="leadId" type="tns:ID" nillable="true"/>
+ <element name="opportunityId" type="tns:ID" nillable="true"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeSObjectResult">
+ <sequence>
+ <element name="activateable" type="xsd:boolean"/>
+ <element name="childRelationships" type="tns:ChildRelationship" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="createable" type="xsd:boolean"/>
+ <element name="custom" type="xsd:boolean"/>
+ <element name="customSetting" type="xsd:boolean"/>
+ <element name="deletable" type="xsd:boolean"/>
+ <element name="deprecatedAndHidden" type="xsd:boolean"/>
+ <element name="fields" type="tns:Field" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="keyPrefix" type="xsd:string" nillable="true"/>
+ <element name="label" type="xsd:string"/>
+ <element name="labelPlural" type="xsd:string"/>
+ <element name="layoutable" type="xsd:boolean"/>
+ <element name="mergeable" type="xsd:boolean"/>
+ <element name="name" type="xsd:string"/>
+ <element name="queryable" type="xsd:boolean"/>
+ <element name="recordTypeInfos" type="tns:RecordTypeInfo" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="replicateable" type="xsd:boolean"/>
+ <element name="retrieveable" type="xsd:boolean"/>
+ <element name="searchable" type="xsd:boolean"/>
+ <element name="triggerable" type="xsd:boolean" minOccurs="0"/>
+ <element name="undeletable" type="xsd:boolean"/>
+ <element name="updateable" type="xsd:boolean"/>
+ <element name="urlDetail" type="xsd:string" nillable="true"/>
+ <element name="urlEdit" type="xsd:string" nillable="true"/>
+ <element name="urlNew" type="xsd:string" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <!-- this is a subset of properties for each SObject that is returned by the describeGlobal call -->
+ <complexType name="DescribeGlobalSObjectResult">
+ <sequence>
+ <element name="activateable" type="xsd:boolean"/>
+ <element name="createable" type="xsd:boolean"/>
+ <element name="custom" type="xsd:boolean"/>
+ <element name="customSetting" type="xsd:boolean"/>
+ <element name="deletable" type="xsd:boolean"/>
+ <element name="deprecatedAndHidden" type="xsd:boolean"/>
+ <element name="keyPrefix" type="xsd:string" nillable="true"/>
+ <element name="label" type="xsd:string"/>
+ <element name="labelPlural" type="xsd:string"/>
+ <element name="layoutable" type="xsd:boolean"/>
+ <element name="mergeable" type="xsd:boolean"/>
+ <element name="name" type="xsd:string"/>
+ <element name="queryable" type="xsd:boolean"/>
+ <element name="replicateable" type="xsd:boolean"/>
+ <element name="retrieveable" type="xsd:boolean"/>
+ <element name="searchable" type="xsd:boolean"/>
+ <element name="triggerable" type="xsd:boolean"/>
+ <element name="undeletable" type="xsd:boolean"/>
+ <element name="updateable" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="ChildRelationship">
+ <sequence>
+ <element name="cascadeDelete" type="xsd:boolean"/>
+ <element name="childSObject" type="xsd:string"/>
+ <element name="deprecatedAndHidden" type="xsd:boolean"/>
+ <element name="field" type="xsd:string"/>
+ <element name="relationshipName" type="xsd:string" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeGlobalResult">
+ <sequence>
+ <element name="encoding" type="xsd:string" nillable="true"/>
+ <element name="maxBatchSize" type="xsd:int"/>
+ <element name="sobjects" type="tns:DescribeGlobalSObjectResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <simpleType name="fieldType">
+ <restriction base="xsd:string">
+ <enumeration value="string"/>
+ <enumeration value="picklist"/>
+ <enumeration value="multipicklist"/>
+ <enumeration value="combobox"/>
+ <enumeration value="reference"/>
+ <enumeration value="base64"/>
+ <enumeration value="boolean"/>
+ <enumeration value="currency"/>
+ <enumeration value="textarea"/>
+ <enumeration value="int"/>
+ <enumeration value="double"/>
+ <enumeration value="percent"/>
+ <enumeration value="phone"/>
+ <enumeration value="id"/>
+ <enumeration value="date"/>
+ <enumeration value="datetime"/>
+ <enumeration value="time"/>
+ <enumeration value="url"/>
+ <enumeration value="email"/>
+ <enumeration value="encryptedstring"/>
+ <enumeration value="anyType"/> <!-- can be string, picklist, reference, boolean, currency, int, double, percent, id, date, datetime, url, email -->
+ </restriction>
+ </simpleType>
+
+ <simpleType name="soapType">
+ <restriction base="xsd:string">
+ <enumeration value="tns:ID"/>
+ <enumeration value="xsd:base64Binary"/>
+ <enumeration value="xsd:boolean"/>
+ <enumeration value="xsd:double"/>
+ <enumeration value="xsd:int"/>
+ <enumeration value="xsd:string"/>
+ <enumeration value="xsd:date"/>
+ <enumeration value="xsd:dateTime"/>
+ <enumeration value="xsd:time"/>
+ <enumeration value="xsd:anyType"/> <!-- can be id, booolean, double, int, string, date, dateTime -->
+ </restriction>
+ </simpleType>
+
+ <complexType name="Field">
+ <sequence>
+ <element name="autoNumber" type="xsd:boolean"/>
+ <element name="byteLength" type="xsd:int"/>
+ <element name="calculated" type="xsd:boolean"/>
+ <element name="calculatedFormula" type="xsd:string" minOccurs="0"/>
+ <element name="caseSensitive" type="xsd:boolean"/>
+ <element name="controllerName" type="xsd:string" minOccurs="0"/>
+ <element name="createable" type="xsd:boolean"/>
+ <element name="custom" type="xsd:boolean"/>
+ <element name="defaultValueFormula" type="xsd:string" minOccurs="0"/>
+ <element name="defaultedOnCreate" type="xsd:boolean"/>
+ <element name="dependentPicklist" type="xsd:boolean" minOccurs="0"/>
+ <element name="deprecatedAndHidden" type="xsd:boolean"/>
+ <element name="digits" type="xsd:int"/>
+ <element name="externalId" type="xsd:boolean" minOccurs="0"/>
+ <element name="filterable" type="xsd:boolean"/>
+ <element name="htmlFormatted" type="xsd:boolean" minOccurs="0"/>
+ <element name="idLookup" type="xsd:boolean"/>
+ <element name="inlineHelpText" type="xsd:string" minOccurs="0"/>
+ <element name="label" type="xsd:string"/>
+ <element name="length" type="xsd:int"/>
+ <element name="name" type="xsd:string"/>
+ <element name="nameField" type="xsd:boolean"/>
+ <element name="namePointing" type="xsd:boolean" minOccurs="0"/>
+ <element name="nillable" type="xsd:boolean"/>
+ <element name="picklistValues" type="tns:PicklistEntry" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="precision" type="xsd:int"/>
+ <element name="referenceTo" type="xsd:string" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="relationshipName" type="xsd:string" minOccurs="0"/>
+ <element name="relationshipOrder" type="xsd:int" minOccurs="0"/>
+ <element name="restrictedPicklist" type="xsd:boolean"/>
+ <element name="scale" type="xsd:int"/>
+ <element name="soapType" type="tns:soapType"/>
+ <element name="sortable" type="xsd:boolean" minOccurs="0"/>
+ <element name="type" type="tns:fieldType"/>
+ <element name="unique" type="xsd:boolean"/>
+ <element name="updateable" type="xsd:boolean"/>
+ <element name="writeRequiresMasterRead" type="xsd:boolean" minOccurs="0"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="PicklistEntry">
+ <sequence>
+ <element name="active" type="xsd:boolean"/>
+ <element name="defaultValue" type="xsd:boolean"/>
+ <element name="label" type="xsd:string" nillable="true"/>
+ <element name="validFor" type="xsd:base64Binary" minOccurs="0"/>
+ <element name="value" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeSoftphoneLayoutResult">
+ <sequence>
+ <element name="callTypes" type="tns:DescribeSoftphoneLayoutCallType" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID"/>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeSoftphoneLayoutCallType">
+ <sequence>
+ <element name="infoFields" type="tns:DescribeSoftphoneLayoutInfoField" maxOccurs="unbounded"/>
+ <element name="name" type="xsd:string"/>
+ <element name="sections" type="tns:DescribeSoftphoneLayoutSection" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeSoftphoneLayoutInfoField">
+ <sequence>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeSoftphoneLayoutSection">
+ <sequence>
+ <element name="entityApiName" type="xsd:string"/>
+ <element name="items" type="tns:DescribeSoftphoneLayoutItem" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeSoftphoneLayoutItem">
+ <sequence>
+ <element name="itemApiName" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutResult">
+ <sequence>
+ <element name="layouts" type="tns:DescribeLayout" maxOccurs="unbounded"/>
+ <element name="recordTypeMappings" type="tns:RecordTypeMapping" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="recordTypeSelectorRequired" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayout">
+ <sequence>
+ <element name="buttonLayoutSection" type="tns:DescribeLayoutButtonSection" minOccurs="0"/>
+ <element name="detailLayoutSections" type="tns:DescribeLayoutSection" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="editLayoutSections" type="tns:DescribeLayoutSection" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="id" type="tns:ID"/>
+
+
+ <element name="relatedLists" type="tns:RelatedList" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutSection">
+ <sequence>
+ <element name="columns" type="xsd:int"/>
+ <element name="heading" type="xsd:string"/>
+ <element name="layoutRows" type="tns:DescribeLayoutRow" maxOccurs="unbounded"/>
+ <element name="rows" type="xsd:int"/>
+ <element name="useCollapsibleSection" type="xsd:boolean"/>
+ <element name="useHeading" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutButtonSection">
+ <sequence>
+ <element name="detailButtons" type="tns:DescribeLayoutButton" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutRow">
+ <sequence>
+ <element name="layoutItems" type="tns:DescribeLayoutItem" maxOccurs="unbounded"/>
+ <element name="numItems" type="xsd:int"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutItem">
+ <sequence>
+ <element name="editable" type="xsd:boolean"/>
+ <element name="label" type="xsd:string" nillable="true"/>
+ <element name="layoutComponents" type="tns:DescribeLayoutComponent" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="placeholder" type="xsd:boolean"/>
+ <element name="required" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutButton">
+ <sequence>
+ <element name="custom" type="xsd:boolean"/>
+ <element name="label" type="xsd:string" nillable="true"/>
+ <element name="name" type="xsd:string" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeLayoutComponent">
+ <sequence>
+ <element name="displayLines" type="xsd:int"/>
+ <element name="tabOrder" type="xsd:int"/>
+ <element name="type" type="tns:layoutComponentType"/>
+ <element name="value" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <simpleType name="layoutComponentType">
+ <restriction base="xsd:string">
+ <enumeration value="Field"/>
+ <enumeration value="Separator"/>
+ <enumeration value="SControl"/>
+ <enumeration value="EmptySpace"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="RecordTypeInfo">
+ <sequence>
+ <element name="available" type="xsd:boolean"/>
+ <element name="defaultRecordTypeMapping" type="xsd:boolean"/>
+ <element name="name" type="xsd:string"/>
+ <element name="recordTypeId" type="tns:ID" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="RecordTypeMapping">
+ <sequence>
+ <element name="available" type="xsd:boolean"/>
+ <element name="defaultRecordTypeMapping" type="xsd:boolean"/>
+ <element name="layoutId" type="tns:ID"/>
+ <element name="name" type="xsd:string"/>
+ <element name="picklistsForRecordType" type="tns:PicklistForRecordType" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ <element name="recordTypeId" type="tns:ID" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="PicklistForRecordType">
+ <sequence>
+ <element name="picklistName" type="xsd:string"/>
+ <element name="picklistValues" type="tns:PicklistEntry" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="RelatedList">
+ <sequence>
+ <element name="columns" type="tns:RelatedListColumn" maxOccurs="unbounded"/>
+ <element name="custom" type="xsd:boolean"/>
+ <element name="field" type="xsd:string" nillable="true"/>
+ <element name="label" type="xsd:string"/>
+ <element name="limitRows" type="xsd:int"/>
+ <element name="name" type="xsd:string"/>
+ <element name="sobject" type="xsd:string" nillable="true"/>
+ <element name="sort" type="tns:RelatedListSort" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="RelatedListColumn">
+ <sequence>
+ <element name="field" type="xsd:string" nillable="true"/>
+ <element name="format" type="xsd:string" nillable="true"/>
+ <element name="label" type="xsd:string"/>
+ <element name="name" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="RelatedListSort">
+ <sequence>
+ <element name="ascending" type="xsd:boolean"/>
+ <element name="column" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+
+
+ <complexType name="EmailFileAttachment">
+ <sequence>
+ <element name="body" nillable="true" minOccurs="0" type="xsd:base64Binary"/>
+ <element name="contentType" nillable="true" minOccurs="0" type="xsd:string"/>
+ <element name="fileName" type="xsd:string"/>
+ <element name="inline" type="xsd:boolean" minOccurs="0"/>
+ </sequence>
+ </complexType>
+ <simpleType name="EmailPriority">
+ <restriction base="xsd:string">
+ <enumeration value="Highest"/>
+ <enumeration value="High"/>
+ <enumeration value="Normal"/>
+ <enumeration value="Low"/>
+ <enumeration value="Lowest"/>
+ </restriction>
+ </simpleType>
+
+ <complexType name="Email">
+ <sequence>
+ <element name="bccSender" type="xsd:boolean" nillable="true"/>
+ <element name="emailPriority" type="tns:EmailPriority" nillable="true"/>
+ <element name="replyTo" type="xsd:string" nillable="true"/>
+ <element name="saveAsActivity" type="xsd:boolean" nillable="true"/>
+ <element name="senderDisplayName" type="xsd:string" nillable="true"/>
+ <element name="subject" type="xsd:string" nillable="true"/>
+ <element name="useSignature" type="xsd:boolean" nillable="true"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="MassEmailMessage">
+ <complexContent>
+ <extension base="tns:Email">
+ <sequence>
+ <element name="description" type="xsd:string" nillable="true"/>
+ <element name="targetObjectIds" minOccurs="0" maxOccurs="250" type="tns:ID"/>
+ <element name="templateId" type="tns:ID"/>
+ <element name="whatIds" minOccurs="0" maxOccurs="250" type="tns:ID"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="SingleEmailMessage">
+ <complexContent>
+ <extension base="tns:Email">
+ <sequence>
+ <element name="bccAddresses" minOccurs="0" maxOccurs="25" type="xsd:string" nillable="true"/>
+ <element name="ccAddresses" minOccurs="0" maxOccurs="25" type="xsd:string" nillable="true"/>
+ <element name="charset" type="xsd:string" nillable="true"/>
+ <element name="documentAttachments" minOccurs="0" maxOccurs="unbounded" type="tns:ID"/>
+ <element name="htmlBody" type="xsd:string" nillable="true"/>
+ <element name="inReplyTo" minOccurs="0" type="xsd:string" nillable="true"/>
+ <element name="fileAttachments" minOccurs="0" maxOccurs="unbounded" type="tns:EmailFileAttachment"/>
+ <element name="orgWideEmailAddressId" minOccurs="0" maxOccurs="1" type="tns:ID" nillable="true"/>
+ <element name="plainTextBody" type="xsd:string" nillable="true"/>
+ <element name="references" minOccurs="0" type="xsd:string" nillable="true"/>
+ <element name="targetObjectId" type="tns:ID" nillable="true"/>
+ <element name="templateId" type="tns:ID" nillable="true"/>
+ <element name="toAddresses" minOccurs="0" maxOccurs="100" type="xsd:string" nillable="true"/>
+ <element name="whatId" type="tns:ID" nillable="true"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="SendEmailResult">
+ <sequence>
+ <element name="errors" minOccurs="0" maxOccurs="unbounded" type="tns:SendEmailError"/>
+ <element name="success" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+
+
+
+ <complexType name="DescribeTabSetResult">
+ <sequence>
+ <element name="label" type="xsd:string"/>
+ <element name="logoUrl" type="xsd:string"/>
+ <element name="namespace" type="xsd:string" minOccurs="0"/>
+ <element name="selected" type="xsd:boolean"/>
+ <element name="tabs" type="tns:DescribeTab" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+
+ <complexType name="DescribeTab">
+ <sequence>
+ <element name="custom" type="xsd:boolean"/>
+ <element name="iconUrl" type="xsd:string"/>
+ <element name="label" type="xsd:string"/>
+ <element name="miniIconUrl" type="xsd:string"/>
+ <element name="sobjectName" type="xsd:string" nillable="true"/>
+ <element name="url" type="xsd:string"/>
+ </sequence>
+ </complexType>
+
+
+
+
+
+ <!-- Login Message Types -->
+ <element name="login">
+ <complexType>
+ <sequence>
+ <element name="username" type="xsd:string"/>
+ <element name="password" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="loginResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:LoginResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Describe Message Types -->
+ <element name="describeSObject">
+ <complexType>
+ <sequence>
+ <element name="sObjectType" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="describeSObjectResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DescribeSObjectResult" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- DescibeSObjects Message Types -->
+ <element name="describeSObjects">
+ <complexType>
+ <sequence>
+ <element name="sObjectType" type="xsd:string" minOccurs="0" maxOccurs="100"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="describeSObjectsResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DescribeSObjectResult" nillable="true" minOccurs="0" maxOccurs="100"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Describe Global Message Types -->
+ <element name="describeGlobal">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <element name="describeGlobalResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DescribeGlobalResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="describeLayout">
+ <complexType>
+ <sequence>
+ <element name="sObjectType" type="xsd:string"/>
+ <element name="recordTypeIds" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="describeLayoutResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DescribeLayoutResult" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="describeSoftphoneLayout">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <element name="describeSoftphoneLayoutResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DescribeSoftphoneLayoutResult" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <element name="describeTabs">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <element name="describeTabsResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DescribeTabSetResult" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Create Message Types -->
+ <element name="create">
+ <complexType>
+ <sequence>
+ <element name="sObjects" type="ens:sObject" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="createResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:SaveResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <!-- Send Email Types -->
+ <element name="sendEmail">
+ <complexType>
+ <sequence>
+ <element name="messages" type="tns:Email" minOccurs="0" maxOccurs="10"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="sendEmailResponse">
+ <complexType>
+ <sequence>
+ <element name="result" minOccurs="0" maxOccurs="10" type="tns:SendEmailResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <!-- Update Message Types -->
+ <element name="update">
+ <complexType>
+ <sequence>
+ <element name="sObjects" type="ens:sObject" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="updateResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:SaveResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Upsert Message Types -->
+ <element name="upsert">
+ <complexType>
+ <sequence>
+ <element name="externalIDFieldName" type="xsd:string"/>
+ <element name="sObjects" type="ens:sObject" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="upsertResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:UpsertResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Merge Message Types -->
+ <element name="merge">
+ <complexType>
+ <sequence>
+ <element name="request" type="tns:MergeRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="mergeResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:MergeResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Delete Message Types -->
+ <element name="delete">
+ <complexType>
+ <sequence>
+ <element name="ids" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="deleteResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:DeleteResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Undelete Message Types -->
+ <element name="undelete">
+ <complexType>
+ <sequence>
+ <element name="ids" type="tns:ID" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="undeleteResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:UndeleteResult" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- EmptyRecycleBin Message Types -->
+ <element name="emptyRecycleBin">
+ <complexType>
+ <sequence>
+ <element name="ids" type="tns:ID" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="emptyRecycleBinResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:EmptyRecycleBinResult" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Process Message Types -->
+ <element name="process">
+ <complexType>
+ <sequence>
+ <element name="actions" type="tns:ProcessRequest" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="processResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:ProcessResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+
+ <!-- Retrieve (ID List) Message Types -->
+ <element name="retrieve">
+ <complexType>
+ <sequence>
+ <element name="fieldList" type="xsd:string"/>
+ <element name="sObjectType" type="xsd:string"/>
+ <element name="ids" type="tns:ID" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="retrieveResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="ens:sObject" nillable="true" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Convert Lead Message Types -->
+ <element name="convertLead">
+ <complexType>
+ <sequence>
+ <element name="leadConverts" type="tns:LeadConvert" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="convertLeadResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:LeadConvertResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Get Updated Message Types -->
+ <element name="getUpdated">
+ <complexType>
+ <sequence>
+ <element name="sObjectType" type="xsd:string"/>
+ <element name="startDate" type="xsd:dateTime"/>
+ <element name="endDate" type="xsd:dateTime"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getUpdatedResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:GetUpdatedResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Get Deleted Message Types -->
+ <element name="getDeleted">
+ <complexType>
+ <sequence>
+ <element name="sObjectType" type="xsd:string"/>
+ <element name="startDate" type="xsd:dateTime"/>
+ <element name="endDate" type="xsd:dateTime"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="getDeletedResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:GetDeletedResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <!-- Logout current session -->
+ <element name="logout">
+ <complexType>
+ </complexType>
+ </element>
+
+ <element name="logoutResponse">
+ <complexType>
+ </complexType>
+ </element>
+
+ <!-- Invalidate a list of session ids -->
+ <element name="invalidateSessions">
+ <complexType>
+ <sequence>
+ <element name="sessionIds" type="xsd:string" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="invalidateSessionsResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:InvalidateSessionsResult" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Create Query -->
+ <element name="query">
+ <complexType>
+ <sequence>
+ <element name="queryString" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="queryResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:QueryResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Create Query All -->
+ <element name="queryAll">
+ <complexType>
+ <sequence>
+ <element name="queryString" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="queryAllResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:QueryResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <!-- Next Batch of sObjects from a query -->
+ <element name="queryMore">
+ <complexType>
+ <sequence>
+ <element name="queryLocator" type="tns:QueryLocator"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="queryMoreResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:QueryResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <!-- Create Search -->
+ <element name="search">
+ <complexType>
+ <sequence>
+ <element name="searchString" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="searchResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:SearchResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <element name="getServerTimestamp">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <element name="getServerTimestampResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:GetServerTimestampResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="setPassword">
+ <complexType>
+ <sequence>
+ <element name="userId" type="tns:ID"/>
+ <element name="password" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="setPasswordResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:SetPasswordResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="resetPassword">
+ <complexType>
+ <sequence>
+ <element name="userId" type="tns:ID"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="resetPasswordResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:ResetPasswordResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="getUserInfo">
+ <complexType>
+ <sequence/>
+ </complexType>
+ </element>
+ <element name="getUserInfoResponse">
+ <complexType>
+ <sequence>
+ <element name="result" type="tns:GetUserInfoResult"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <!-- Header Elements -->
+ <element name="SessionHeader">
+ <complexType>
+ <sequence>
+ <element name="sessionId" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="LoginScopeHeader">
+ <complexType>
+ <sequence>
+ <element name="organizationId" type="tns:ID"/>
+ <element name="portalId" type="tns:ID" minOccurs="0"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <element name="CallOptions">
+ <complexType>
+ <sequence>
+ <element name="client" type="xsd:string" nillable="true"/>
+ <element name="defaultNamespace" type="xsd:string" nillable="true"/>
+
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <element name="QueryOptions">
+ <complexType>
+ <sequence>
+ <element name="batchSize" type="xsd:int" minOccurs="0"/>
+
+ </sequence>
+ </complexType>
+ </element>
+
+
+ <simpleType name="DebugLevel">
+ <restriction base="xsd:string">
+ <enumeration value="None"/>
+ <enumeration value="DebugOnly"/>
+ <enumeration value="Db"/>
+ </restriction>
+ </simpleType>
+ <element name="DebuggingHeader">
+ <complexType>
+ <sequence>
+ <element name="debugLevel" type="tns:DebugLevel"/>
+ </sequence>
+ </complexType>
+ </element>
+ <element name="DebuggingInfo">
+ <complexType>
+ <sequence>
+ <element name="debugLog" type="xsd:string"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <xsd:complexType name="PackageVersion">
+ <xsd:sequence>
+ <xsd:element name="majorNumber" type="xsd:int"/>
+ <xsd:element name="minorNumber" type="xsd:int"/>
+ <xsd:element name="namespace" type="xsd:string"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ <xsd:element name="PackageVersionHeader">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="packageVersions" minOccurs="0" maxOccurs="unbounded" type="tns:PackageVersion"/>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+
+ <element name="AllowFieldTruncationHeader">
+ <complexType>
+ <sequence>
+ <element name="allowFieldTruncation" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <!-- ideally this could of just been elem name="..." type="xsd:boolean"
+ but is required to be nested within a complexType for .NET 1.1 compatibility -->
+ <element name="MruHeader">
+ <complexType>
+ <sequence>
+ <element name="updateMru" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="EmailHeader">
+ <complexType>
+ <sequence>
+ <element name="triggerAutoResponseEmail" type="xsd:boolean"/>
+ <element name="triggerOtherEmail" type="xsd:boolean"/>
+ <element name="triggerUserEmail" type="xsd:boolean"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="AssignmentRuleHeader">
+ <complexType>
+ <sequence>
+ <element name="assignmentRuleId" type="tns:ID" nillable="true"/>
+ <element name="useDefaultRule" type="xsd:boolean" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="UserTerritoryDeleteHeader">
+ <complexType>
+ <sequence>
+ <element name="transferToUserId" type="tns:ID" nillable="true"/>
+ </sequence>
+ </complexType>
+ </element>
+
+
+
+ <element name="LocaleOptions">
+ <complexType>
+ <sequence>
+ <element name="language" type="xsd:string" minOccurs="0"/>
+ </sequence>
+ </complexType>
+ </element>
+ </schema>
+
+ <schema elementFormDefault="qualified" xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:fault.partner.soap.sforce.com" xmlns:fns="urn:fault.partner.soap.sforce.com">
+
+ <simpleType name="ExceptionCode">
+ <restriction base="xsd:string">
+ <enumeration value="API_CURRENTLY_DISABLED"/>
+ <enumeration value="API_DISABLED_FOR_ORG"/>
+ <enumeration value="CANT_ADD_STANDADRD_PORTAL_USER_TO_TERRITORY"/>
+ <enumeration value="CANT_ADD_STANDARD_PORTAL_USER_TO_TERRITORY"/>
+ <enumeration value="CIRCULAR_OBJECT_GRAPH"/>
+ <enumeration value="CLIENT_NOT_ACCESSIBLE_FOR_USER"/>
+ <enumeration value="CLIENT_REQUIRE_UPDATE_FOR_USER"/>
+ <enumeration value="CUSTOM_METADATA_LIMIT_EXCEEDED"/>
+ <enumeration value="DUPLICATE_VALUE"/>
+ <enumeration value="EMAIL_BATCH_SIZE_LIMIT_EXCEEDED"/>
+ <enumeration value="EMAIL_TO_CASE_INVALID_ROUTING"/>
+ <enumeration value="EMAIL_TO_CASE_LIMIT_EXCEEDED"/>
+ <enumeration value="EMAIL_TO_CASE_NOT_ENABLED"/>
+ <enumeration value="EXCEEDED_ID_LIMIT"/>
+ <enumeration value="EXCEEDED_LEAD_CONVERT_LIMIT"/>
+ <enumeration value="EXCEEDED_MAX_SIZE_REQUEST"/>
+ <enumeration value="EXCEEDED_MAX_TYPES_LIMIT"/>
+ <enumeration value="EXCEEDED_QUOTA"/>
+ <enumeration value="FUNCTIONALITY_NOT_ENABLED"/>
+ <enumeration value="INACTIVE_OWNER_OR_USER"/>
+ <enumeration value="INACTIVE_PORTAL"/>
+ <enumeration value="INSUFFICIENT_ACCESS"/>
+ <enumeration value="INVALID_ASSIGNMENT_RULE"/>
+ <enumeration value="INVALID_BATCH_SIZE"/>
+ <enumeration value="INVALID_CLIENT"/>
+ <enumeration value="INVALID_CROSS_REFERENCE_KEY"/>
+ <enumeration value="INVALID_FIELD"/>
+ <enumeration value="INVALID_FILTER_LANGUAGE"/>
+ <enumeration value="INVALID_FILTER_VALUE"/>
+ <enumeration value="INVALID_ID_FIELD"/>
+ <enumeration value="INVALID_LOCALE_LANGUAGE"/>
+ <enumeration value="INVALID_LOCATOR"/>
+ <enumeration value="INVALID_LOGIN"/>
+ <enumeration value="INVALID_NEW_PASSWORD"/>
+ <enumeration value="INVALID_OPERATION"/>
+ <enumeration value="INVALID_OPERATION_WITH_EXPIRED_PASSWORD"/>
+ <enumeration value="INVALID_QUERY_FILTER_OPERATOR"/>
+ <enumeration value="INVALID_QUERY_LOCATOR"/>
+ <enumeration value="INVALID_QUERY_SCOPE"/>
+ <enumeration value="INVALID_REPLICATION_DATE"/>
+ <enumeration value="INVALID_SEARCH"/>
+ <enumeration value="INVALID_SEARCH_SCOPE"/>
+ <enumeration value="INVALID_SESSION_ID"/>
+ <enumeration value="INVALID_SOAP_HEADER"/>
+ <enumeration value="INVALID_SSO_GATEWAY_URL"/>
+ <enumeration value="INVALID_TYPE"/>
+ <enumeration value="INVALID_TYPE_FOR_OPERATION"/>
+ <enumeration value="LIMIT_EXCEEDED"/>
+ <enumeration value="LOGIN_CHALLENGE_ISSUED"/>
+ <enumeration value="LOGIN_CHALLENGE_PENDING"/>
+ <enumeration value="LOGIN_DURING_RESTRICTED_DOMAIN"/>
+ <enumeration value="LOGIN_DURING_RESTRICTED_TIME"/>
+ <enumeration value="LOGIN_MUST_USE_SECURITY_TOKEN"/>
+ <enumeration value="MALFORMED_ID"/>
+ <enumeration value="MALFORMED_QUERY"/>
+ <enumeration value="MALFORMED_SEARCH"/>
+ <enumeration value="MISSING_ARGUMENT"/>
+ <enumeration value="NOT_MODIFIED"/>
+ <enumeration value="NO_SOFTPHONE_LAYOUT"/>
+ <enumeration value="NUMBER_OUTSIDE_VALID_RANGE"/>
+ <enumeration value="OPERATION_TOO_LARGE"/>
+ <enumeration value="ORG_LOCKED"/>
+ <enumeration value="ORG_NOT_OWNED_BY_INSTANCE"/>
+ <enumeration value="PASSWORD_LOCKOUT"/>
+ <enumeration value="PORTAL_NO_ACCESS"/>
+ <enumeration value="QUERY_TIMEOUT"/>
+ <enumeration value="QUERY_TOO_COMPLICATED"/>
+ <enumeration value="REQUEST_LIMIT_EXCEEDED"/>
+ <enumeration value="REQUEST_RUNNING_TOO_LONG"/>
+ <enumeration value="SERVER_UNAVAILABLE"/>
+ <enumeration value="SSO_SERVICE_DOWN"/>
+ <enumeration value="TOO_MANY_APEX_REQUESTS"/>
+ <enumeration value="TRIAL_EXPIRED"/>
+ <enumeration value="UNKNOWN_EXCEPTION"/>
+ <enumeration value="UNSUPPORTED_API_VERSION"/>
+ <enumeration value="UNSUPPORTED_CLIENT"/>
+ </restriction>
+ </simpleType>
+ <!-- For convenience these QNames are returned in the standard soap faultcode element -->
+ <simpleType name="FaultCode">
+ <restriction base="xsd:QName">
+ <enumeration value="fns:API_CURRENTLY_DISABLED"/>
+ <enumeration value="fns:API_DISABLED_FOR_ORG"/>
+ <enumeration value="fns:CANT_ADD_STANDADRD_PORTAL_USER_TO_TERRITORY"/>
+ <enumeration value="fns:CANT_ADD_STANDARD_PORTAL_USER_TO_TERRITORY"/>
+ <enumeration value="fns:CIRCULAR_OBJECT_GRAPH"/>
+ <enumeration value="fns:CLIENT_NOT_ACCESSIBLE_FOR_USER"/>
+ <enumeration value="fns:CLIENT_REQUIRE_UPDATE_FOR_USER"/>
+ <enumeration value="fns:CUSTOM_METADATA_LIMIT_EXCEEDED"/>
+ <enumeration value="fns:DUPLICATE_VALUE"/>
+ <enumeration value="fns:EMAIL_BATCH_SIZE_LIMIT_EXCEEDED"/>
+ <enumeration value="fns:EMAIL_TO_CASE_INVALID_ROUTING"/>
+ <enumeration value="fns:EMAIL_TO_CASE_LIMIT_EXCEEDED"/>
+ <enumeration value="fns:EMAIL_TO_CASE_NOT_ENABLED"/>
+ <enumeration value="fns:EXCEEDED_ID_LIMIT"/>
+ <enumeration value="fns:EXCEEDED_LEAD_CONVERT_LIMIT"/>
+ <enumeration value="fns:EXCEEDED_MAX_SIZE_REQUEST"/>
+ <enumeration value="fns:EXCEEDED_MAX_TYPES_LIMIT"/>
+ <enumeration value="fns:EXCEEDED_QUOTA"/>
+ <enumeration value="fns:FUNCTIONALITY_NOT_ENABLED"/>
+ <enumeration value="fns:INACTIVE_OWNER_OR_USER"/>
+ <enumeration value="fns:INACTIVE_PORTAL"/>
+ <enumeration value="fns:INSUFFICIENT_ACCESS"/>
+ <enumeration value="fns:INVALID_ASSIGNMENT_RULE"/>
+ <enumeration value="fns:INVALID_BATCH_SIZE"/>
+ <enumeration value="fns:INVALID_CLIENT"/>
+ <enumeration value="fns:INVALID_CROSS_REFERENCE_KEY"/>
+ <enumeration value="fns:INVALID_FIELD"/>
+ <enumeration value="fns:INVALID_FILTER_LANGUAGE"/>
+ <enumeration value="fns:INVALID_FILTER_VALUE"/>
+ <enumeration value="fns:INVALID_ID_FIELD"/>
+ <enumeration value="fns:INVALID_LOCALE_LANGUAGE"/>
+ <enumeration value="fns:INVALID_LOCATOR"/>
+ <enumeration value="fns:INVALID_LOGIN"/>
+ <enumeration value="fns:INVALID_NEW_PASSWORD"/>
+ <enumeration value="fns:INVALID_OPERATION"/>
+ <enumeration value="fns:INVALID_OPERATION_WITH_EXPIRED_PASSWORD"/>
+ <enumeration value="fns:INVALID_QUERY_FILTER_OPERATOR"/>
+ <enumeration value="fns:INVALID_QUERY_LOCATOR"/>
+ <enumeration value="fns:INVALID_QUERY_SCOPE"/>
+ <enumeration value="fns:INVALID_REPLICATION_DATE"/>
+ <enumeration value="fns:INVALID_SEARCH"/>
+ <enumeration value="fns:INVALID_SEARCH_SCOPE"/>
+ <enumeration value="fns:INVALID_SESSION_ID"/>
+ <enumeration value="fns:INVALID_SOAP_HEADER"/>
+ <enumeration value="fns:INVALID_SSO_GATEWAY_URL"/>
+ <enumeration value="fns:INVALID_TYPE"/>
+ <enumeration value="fns:INVALID_TYPE_FOR_OPERATION"/>
+ <enumeration value="fns:LIMIT_EXCEEDED"/>
+ <enumeration value="fns:LOGIN_CHALLENGE_ISSUED"/>
+ <enumeration value="fns:LOGIN_CHALLENGE_PENDING"/>
+ <enumeration value="fns:LOGIN_DURING_RESTRICTED_DOMAIN"/>
+ <enumeration value="fns:LOGIN_DURING_RESTRICTED_TIME"/>
+ <enumeration value="fns:LOGIN_MUST_USE_SECURITY_TOKEN"/>
+ <enumeration value="fns:MALFORMED_ID"/>
+ <enumeration value="fns:MALFORMED_QUERY"/>
+ <enumeration value="fns:MALFORMED_SEARCH"/>
+ <enumeration value="fns:MISSING_ARGUMENT"/>
+ <enumeration value="fns:NOT_MODIFIED"/>
+ <enumeration value="fns:NO_SOFTPHONE_LAYOUT"/>
+ <enumeration value="fns:NUMBER_OUTSIDE_VALID_RANGE"/>
+ <enumeration value="fns:OPERATION_TOO_LARGE"/>
+ <enumeration value="fns:ORG_LOCKED"/>
+ <enumeration value="fns:ORG_NOT_OWNED_BY_INSTANCE"/>
+ <enumeration value="fns:PASSWORD_LOCKOUT"/>
+ <enumeration value="fns:PORTAL_NO_ACCESS"/>
+ <enumeration value="fns:QUERY_TIMEOUT"/>
+ <enumeration value="fns:QUERY_TOO_COMPLICATED"/>
+ <enumeration value="fns:REQUEST_LIMIT_EXCEEDED"/>
+ <enumeration value="fns:REQUEST_RUNNING_TOO_LONG"/>
+ <enumeration value="fns:SERVER_UNAVAILABLE"/>
+ <enumeration value="fns:SSO_SERVICE_DOWN"/>
+ <enumeration value="fns:TOO_MANY_APEX_REQUESTS"/>
+ <enumeration value="fns:TRIAL_EXPIRED"/>
+ <enumeration value="fns:UNKNOWN_EXCEPTION"/>
+ <enumeration value="fns:UNSUPPORTED_API_VERSION"/>
+ <enumeration value="fns:UNSUPPORTED_CLIENT"/>
+ </restriction>
+ </simpleType>
+
+
+ <!-- Fault -->
+ <complexType name="ApiFault">
+ <sequence>
+ <element name="exceptionCode" type="fns:ExceptionCode"/>
+ <element name="exceptionMessage" type="xsd:string"/>
+
+ </sequence>
+ </complexType>
+
+ <element name="fault" type="fns:ApiFault"/>
+
+ <complexType name="ApiQueryFault">
+ <complexContent>
+ <extension base="fns:ApiFault">
+ <sequence>
+ <element name="row" type="xsd:int"/>
+ <element name="column" type="xsd:int"/>
+ </sequence>
+ </extension>
+ </complexContent>
+ </complexType>
+
+ <complexType name="LoginFault">
+ <complexContent>
+ <extension base="fns:ApiFault"/>
+ </complexContent>
+ </complexType>
+ <element name="LoginFault" type="fns:LoginFault"/>
+
+ <complexType name="InvalidQueryLocatorFault">
+ <complexContent>
+ <extension base="fns:ApiFault"/>
+ </complexContent>
+ </complexType>
+ <element name="InvalidQueryLocatorFault" type="fns:InvalidQueryLocatorFault"/>
+
+ <complexType name="InvalidNewPasswordFault">
+ <complexContent>
+ <extension base="fns:ApiFault"/>
+ </complexContent>
+ </complexType>
+ <element name="InvalidNewPasswordFault" type="fns:InvalidNewPasswordFault"/>
+
+ <complexType name="InvalidIdFault">
+ <complexContent>
+ <extension base="fns:ApiFault"/>
+ </complexContent>
+ </complexType>
+ <element name="InvalidIdFault" type="fns:InvalidIdFault"/>
+
+ <complexType name="UnexpectedErrorFault">
+ <complexContent>
+ <extension base="fns:ApiFault"/>
+ </complexContent>
+ </complexType>
+ <element name="UnexpectedErrorFault" type="fns:UnexpectedErrorFault"/>
+
+ <complexType name="InvalidFieldFault">
+ <complexContent>
+ <extension base="fns:ApiQueryFault"/>
+ </complexContent>
+ </complexType>
+ <element name="InvalidFieldFault" type="fns:InvalidFieldFault"/>
+
+ <complexType name="InvalidSObjectFault">
+ <complexContent>
+ <extension base="fns:ApiQueryFault"/>
+ </complexContent>
+ </complexType>
+ <element name="InvalidSObjectFault" type="fns:InvalidSObjectFault"/>
+
+ <complexType name="MalformedQueryFault">
+ <complexContent>
+ <extension base="fns:ApiQueryFault"/>
+ </complexContent>
+ </complexType>
+ <element name="MalformedQueryFault" type="fns:MalformedQueryFault"/>
+
+ <complexType name="MalformedSearchFault">
+ <complexContent>
+ <extension base="fns:ApiQueryFault"/>
+ </complexContent>
+ </complexType>
+ <element name="MalformedSearchFault" type="fns:MalformedSearchFault"/>
+
+
+ </schema>
+ </types>
+
+ <!-- Header Message -->
+ <message name="Header">
+ <part element="tns:LoginScopeHeader" name="LoginScopeHeader"/>
+ <part element="tns:SessionHeader" name="SessionHeader"/>
+
+ <part element="tns:CallOptions" name="CallOptions"/>
+
+ <part element="tns:QueryOptions" name="QueryOptions"/>
+ <part element="tns:AssignmentRuleHeader" name="AssignmentRuleHeader"/>
+ <part element="tns:AllowFieldTruncationHeader" name="AllowFieldTruncationHeader"/>
+
+ <part element="tns:MruHeader" name="MruHeader"/>
+ <part element="tns:EmailHeader" name="EmailHeader"/>
+
+ <part element="tns:UserTerritoryDeleteHeader" name="UserTerritoryDeleteHeader"/>
+
+ <part element="tns:DebuggingHeader" name="DebuggingHeader"/>
+ <part element="tns:PackageVersionHeader" name="PackageVersionHeader"/>
+ <part element="tns:DebuggingInfo" name="DebuggingInfo"/>
+ <part element="tns:LocaleOptions" name="LocaleOptions"/>
+ </message>
+
+ <!-- Fault Messages -->
+
+ <message name="ApiFault">
+ <part name="fault" element="fns:fault"/>
+ </message>
+
+ <message name="LoginFault">
+ <part name="fault" element="fns:LoginFault"/>
+ </message>
+ <message name="InvalidQueryLocatorFault">
+ <part name="fault" element="fns:InvalidQueryLocatorFault"/>
+ </message>
+ <message name="InvalidNewPasswordFault">
+ <part name="fault" element="fns:InvalidNewPasswordFault"/>
+ </message>
+ <message name="InvalidIdFault">
+ <part name="fault" element="fns:InvalidIdFault"/>
+ </message>
+ <message name="UnexpectedErrorFault">
+ <part name="fault" element="fns:UnexpectedErrorFault"/>
+ </message>
+ <message name="InvalidFieldFault">
+ <part name="fault" element="fns:InvalidFieldFault"/>
+ </message>
+ <message name="InvalidSObjectFault">
+ <part name="fault" element="fns:InvalidSObjectFault"/>
+ </message>
+ <message name="MalformedQueryFault">
+ <part name="fault" element="fns:MalformedQueryFault"/>
+ </message>
+ <message name="MalformedSearchFault">
+ <part name="fault" element="fns:MalformedSearchFault"/>
+ </message>
+
+
+ <!-- Method Messages -->
+ <message name="loginRequest">
+ <part element="tns:login" name="parameters"/>
+ </message>
+ <message name="loginResponse">
+ <part element="tns:loginResponse" name="parameters"/>
+ </message>
+
+ <message name="describeSObjectRequest">
+ <part element="tns:describeSObject" name="parameters"/>
+ </message>
+ <message name="describeSObjectResponse">
+ <part element="tns:describeSObjectResponse" name="parameters"/>
+ </message>
+
+ <message name="describeSObjectsRequest">
+ <part element="tns:describeSObjects" name="parameters"/>
+ </message>
+ <message name="describeSObjectsResponse">
+ <part element="tns:describeSObjectsResponse" name="parameters"/>
+ </message>
+
+ <message name="describeGlobalRequest">
+ <part element="tns:describeGlobal" name="parameters"/>
+ </message>
+ <message name="describeGlobalResponse">
+ <part element="tns:describeGlobalResponse" name="parameters"/>
+ </message>
+
+ <message name="describeLayoutRequest">
+ <part element="tns:describeLayout" name="parameters"/>
+ </message>
+ <message name="describeLayoutResponse">
+ <part element="tns:describeLayoutResponse" name="parameters"/>
+ </message>
+
+ <message name="describeSoftphoneLayoutRequest">
+ <part element="tns:describeSoftphoneLayout" name="parameters"/>
+ </message>
+ <message name="describeSoftphoneLayoutResponse">
+ <part element="tns:describeSoftphoneLayoutResponse" name="parameters"/>
+ </message>
+
+ <message name="describeTabsRequest">
+ <part element="tns:describeTabs" name="parameters"/>
+ </message>
+ <message name="describeTabsResponse">
+ <part element="tns:describeTabsResponse" name="parameters"/>
+ </message>
+
+ <message name="createRequest">
+ <part element="tns:create" name="parameters"/>
+ </message>
+ <message name="createResponse">
+ <part element="tns:createResponse" name="parameters"/>
+ </message>
+
+ <message name="updateRequest">
+ <part element="tns:update" name="parameters"/>
+ </message>
+ <message name="updateResponse">
+ <part element="tns:updateResponse" name="parameters"/>
+ </message>
+
+ <message name="upsertRequest">
+ <part element="tns:upsert" name="parameters"/>
+ </message>
+ <message name="upsertResponse">
+ <part element="tns:upsertResponse" name="parameters"/>
+ </message>
+
+ <message name="mergeRequest">
+ <part element="tns:merge" name="parameters"/>
+ </message>
+ <message name="mergeResponse">
+ <part element="tns:mergeResponse" name="parameters"/>
+ </message>
+
+ <message name="deleteRequest">
+ <part element="tns:delete" name="parameters"/>
+ </message>
+ <message name="deleteResponse">
+ <part element="tns:deleteResponse" name="parameters"/>
+ </message>
+
+ <message name="undeleteRequest">
+ <part element="tns:undelete" name="parameters"/>
+ </message>
+ <message name="undeleteResponse">
+ <part element="tns:undeleteResponse" name="parameters"/>
+ </message>
+
+ <message name="emptyRecycleBinRequest">
+ <part element="tns:emptyRecycleBin" name="parameters"/>
+ </message>
+ <message name="emptyRecycleBinResponse">
+ <part element="tns:emptyRecycleBinResponse" name="parameters"/>
+ </message>
+
+ <message name="retrieveRequest">
+ <part element="tns:retrieve" name="parameters"/>
+ </message>
+ <message name="retrieveResponse">
+ <part element="tns:retrieveResponse" name="parameters"/>
+ </message>
+
+ <message name="processRequest">
+ <part element="tns:process" name="parameters"/>
+ </message>
+ <message name="processResponse">
+ <part element="tns:processResponse" name="parameters"/>
+ </message>
+
+ <message name="convertLeadRequest">
+ <part element="tns:convertLead" name="parameters"/>
+ </message>
+ <message name="convertLeadResponse">
+ <part element="tns:convertLeadResponse" name="parameters"/>
+ </message>
+
+ <message name="logoutRequest">
+ <part element="tns:logout" name="parameters"/>
+ </message>
+ <message name="logoutResponse">
+ <part element="tns:logoutResponse" name="parameters"/>
+ </message>
+
+ <message name="invalidateSessionsRequest">
+ <part element="tns:invalidateSessions" name="parameters"/>
+ </message>
+ <message name="invalidateSessionsResponse">
+ <part element="tns:invalidateSessionsResponse" name="parameters"/>
+ </message>
+
+ <message name="getDeletedRequest">
+ <part element="tns:getDeleted" name="parameters"/>
+ </message>
+ <message name="getDeletedResponse">
+ <part element="tns:getDeletedResponse" name="parameters"/>
+ </message>
+
+ <message name="getUpdatedRequest">
+ <part element="tns:getUpdated" name="parameters"/>
+ </message>
+ <message name="getUpdatedResponse">
+ <part element="tns:getUpdatedResponse" name="parameters"/>
+ </message>
+
+ <message name="queryRequest">
+ <part element="tns:query" name="parameters"/>
+ </message>
+ <message name="queryResponse">
+ <part element="tns:queryResponse" name="parameters"/>
+ </message>
+
+ <message name="queryAllRequest">
+ <part element="tns:queryAll" name="parameters"/>
+ </message>
+ <message name="queryAllResponse">
+ <part element="tns:queryAllResponse" name="parameters"/>
+ </message>
+
+ <message name="queryMoreRequest">
+ <part element="tns:queryMore" name="parameters"/>
+ </message>
+ <message name="queryMoreResponse">
+ <part element="tns:queryMoreResponse" name="parameters"/>
+ </message>
+
+ <message name="searchRequest">
+ <part element="tns:search" name="parameters"/>
+ </message>
+ <message name="searchResponse">
+ <part element="tns:searchResponse" name="parameters"/>
+ </message>
+
+ <message name="getServerTimestampRequest">
+ <part element="tns:getServerTimestamp" name="parameters"/>
+ </message>
+ <message name="getServerTimestampResponse">
+ <part element="tns:getServerTimestampResponse" name="parameters"/>
+ </message>
+
+ <message name="setPasswordRequest">
+ <part element="tns:setPassword" name="parameters"/>
+ </message>
+ <message name="setPasswordResponse">
+ <part element="tns:setPasswordResponse" name="parameters"/>
+ </message>
+
+ <message name="resetPasswordRequest">
+ <part element="tns:resetPassword" name="parameters"/>
+ </message>
+ <message name="resetPasswordResponse">
+ <part element="tns:resetPasswordResponse" name="parameters"/>
+ </message>
+
+ <message name="getUserInfoRequest">
+ <part element="tns:getUserInfo" name="parameters"/>
+ </message>
+ <message name="getUserInfoResponse">
+ <part element="tns:getUserInfoResponse" name="parameters"/>
+ </message>
+
+ <message name="sendEmailRequest">
+ <part element="tns:sendEmail" name="parameters"/>
+ </message>
+ <message name="sendEmailResponse">
+ <part element="tns:sendEmailResponse" name="parameters"/>
+ </message>
+
+
+
+ <!-- Soap PortType -->
+ <portType name="Soap">
+ <operation name="login">
+ <documentation>Login to the Salesforce.com SOAP Api</documentation>
+ <input message="tns:loginRequest"/>
+ <output message="tns:loginResponse"/>
+ <fault message="tns:LoginFault" name="LoginFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ </operation>
+
+ <operation name="describeSObject">
+ <documentation>Describe an sObject</documentation>
+ <input message="tns:describeSObjectRequest"/>
+ <output message="tns:describeSObjectResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="describeSObjects">
+ <documentation>Describe a number sObjects</documentation>
+ <input message="tns:describeSObjectsRequest"/>
+ <output message="tns:describeSObjectsResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="describeGlobal">
+ <documentation>Describe the Global state</documentation>
+ <input message="tns:describeGlobalRequest"/>
+ <output message="tns:describeGlobalResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="describeLayout">
+ <documentation>Describe the layout of an sObject</documentation>
+ <input message="tns:describeLayoutRequest"/>
+ <output message="tns:describeLayoutResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ </operation>
+
+ <operation name="describeSoftphoneLayout">
+ <documentation>Describe the layout of the SoftPhone</documentation>
+ <input message="tns:describeSoftphoneLayoutRequest"/>
+ <output message="tns:describeSoftphoneLayoutResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="describeTabs">
+ <documentation>Describe the tabs that appear on a users page</documentation>
+ <input message="tns:describeTabsRequest"/>
+ <output message="tns:describeTabsResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="create">
+ <documentation>Create a set of new sObjects</documentation>
+ <input message="tns:createRequest"/>
+ <output message="tns:createResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ </operation>
+
+ <operation name="update">
+ <documentation>Update a set of sObjects</documentation>
+ <input message="tns:updateRequest"/>
+ <output message="tns:updateResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ </operation>
+
+ <operation name="upsert">
+ <documentation>Update or insert a set of sObjects based on object id</documentation>
+ <input message="tns:upsertRequest"/>
+ <output message="tns:upsertResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ </operation>
+
+ <operation name="merge">
+ <documentation>Merge and update a set of sObjects based on object id</documentation>
+ <input message="tns:mergeRequest"/>
+ <output message="tns:mergeResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ </operation>
+
+ <operation name="delete">
+ <documentation>Delete a set of sObjects</documentation>
+ <input message="tns:deleteRequest"/>
+ <output message="tns:deleteResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="undelete">
+ <documentation>Undelete a set of sObjects</documentation>
+ <input message="tns:undeleteRequest"/>
+ <output message="tns:undeleteResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="emptyRecycleBin">
+ <documentation>Empty a set of sObjects from the recycle bin</documentation>
+ <input message="tns:emptyRecycleBinRequest"/>
+ <output message="tns:emptyRecycleBinResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="retrieve">
+ <documentation>Get a set of sObjects</documentation>
+ <input message="tns:retrieveRequest"/>
+ <output message="tns:retrieveResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ <fault message="tns:MalformedQueryFault" name="MalformedQueryFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ </operation>
+
+ <operation name="process">
+ <documentation>Submit an entity to a workflow process or process a workitem</documentation>
+ <input message="tns:processRequest"/>
+ <output message="tns:processResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ </operation>
+
+ <operation name="convertLead">
+ <documentation>convert a set of leads</documentation>
+ <input message="tns:convertLeadRequest"/>
+ <output message="tns:convertLeadResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="logout">
+ <documentation>Logout the current user, invalidating the current session.</documentation>
+ <input message="tns:logoutRequest"/>
+ <output message="tns:logoutResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="invalidateSessions">
+ <documentation>Logs out and invalidates session ids</documentation>
+ <input message="tns:invalidateSessionsRequest"/>
+ <output message="tns:invalidateSessionsResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="getDeleted">
+ <documentation>Get the IDs for deleted sObjects</documentation>
+ <input message="tns:getDeletedRequest"/>
+ <output message="tns:getDeletedResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="getUpdated">
+ <documentation>Get the IDs for updated sObjects</documentation>
+ <input message="tns:getUpdatedRequest"/>
+ <output message="tns:getUpdatedResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="query">
+ <documentation>Create a Query Cursor</documentation>
+ <input message="tns:queryRequest"/>
+ <output message="tns:queryResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ <fault message="tns:MalformedQueryFault" name="MalformedQueryFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidQueryLocatorFault" name="InvalidQueryLocatorFault"/>
+ </operation>
+
+ <operation name="queryAll">
+ <documentation>Create a Query Cursor, including deleted sObjects</documentation>
+ <input message="tns:queryAllRequest"/>
+ <output message="tns:queryAllResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ <fault message="tns:MalformedQueryFault" name="MalformedQueryFault"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidQueryLocatorFault" name="InvalidQueryLocatorFault"/>
+ </operation>
+
+ <operation name="queryMore">
+ <documentation>Gets the next batch of sObjects from a query</documentation>
+ <input message="tns:queryMoreRequest"/>
+ <output message="tns:queryMoreResponse"/>
+ <fault message="tns:InvalidQueryLocatorFault" name="InvalidQueryLocatorFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ </operation>
+
+ <operation name="search">
+ <documentation>Search for sObjects</documentation>
+ <input message="tns:searchRequest"/>
+ <output message="tns:searchResponse"/>
+ <fault message="tns:InvalidSObjectFault" name="InvalidSObjectFault"/>
+ <fault message="tns:InvalidFieldFault" name="InvalidFieldFault"/>
+ <fault message="tns:MalformedSearchFault" name="MalformedSearchFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="getServerTimestamp">
+ <documentation>Gets server timestamp</documentation>
+ <input message="tns:getServerTimestampRequest"/>
+ <output message="tns:getServerTimestampResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="setPassword">
+ <documentation>Set a user's password</documentation>
+ <input message="tns:setPasswordRequest"/>
+ <output message="tns:setPasswordResponse"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:InvalidNewPasswordFault" name="InvalidNewPasswordFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="resetPassword">
+ <documentation>Reset a user's password</documentation>
+ <input message="tns:resetPasswordRequest"/>
+ <output message="tns:resetPasswordResponse"/>
+ <fault message="tns:InvalidIdFault" name="InvalidIdFault"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="getUserInfo">
+ <documentation>Returns standard information relevant to the current user</documentation>
+ <input message="tns:getUserInfoRequest"/>
+ <output message="tns:getUserInfoResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ <operation name="sendEmail">
+ <documentation>Send outbound email</documentation>
+ <input message="tns:sendEmailRequest"/>
+ <output message="tns:sendEmailResponse"/>
+ <fault message="tns:UnexpectedErrorFault" name="UnexpectedErrorFault"/>
+ </operation>
+
+ </portType>
+
+ <!-- Soap Binding -->
+ <binding name="SoapBinding" type="tns:Soap">
+ <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="login">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="LoginScopeHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="LoginFault">
+ <soap:fault name="LoginFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="describeSObject">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="LocaleOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="describeSObjects">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="LocaleOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="describeGlobal">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="describeLayout">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="describeSoftphoneLayout">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="describeTabs">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="create">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
+ <soap:header use="literal" message="tns:Header" part="MruHeader"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="update">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
+ <soap:header use="literal" message="tns:Header" part="MruHeader"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="upsert">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
+ <soap:header use="literal" message="tns:Header" part="MruHeader"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="merge">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AssignmentRuleHeader"/>
+ <soap:header use="literal" message="tns:Header" part="MruHeader"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="delete">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="UserTerritoryDeleteHeader"/>
+ <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="undelete">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="emptyRecycleBin">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="retrieve">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
+ <soap:header use="literal" message="tns:Header" part="MruHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ <fault name="MalformedQueryFault">
+ <soap:fault name="MalformedQueryFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="process">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="convertLead">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="AllowFieldTruncationHeader"/>
+ <soap:header use="literal" message="tns:Header" part="DebuggingHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:header use="literal" message="tns:Header" part="DebuggingInfo"/>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="logout">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="invalidateSessions">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getDeleted">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getUpdated">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="query">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
+ <soap:header use="literal" message="tns:Header" part="MruHeader"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ <fault name="MalformedQueryFault">
+ <soap:fault name="MalformedQueryFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidQueryLocatorFault">
+ <soap:fault name="InvalidQueryLocatorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="queryAll">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ <fault name="MalformedQueryFault">
+ <soap:fault name="MalformedQueryFault" use="literal"/>
+ </fault>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidQueryLocatorFault">
+ <soap:fault name="InvalidQueryLocatorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="queryMore">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="QueryOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidQueryLocatorFault">
+ <soap:fault name="InvalidQueryLocatorFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="search">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="PackageVersionHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidSObjectFault">
+ <soap:fault name="InvalidSObjectFault" use="literal"/>
+ </fault>
+ <fault name="InvalidFieldFault">
+ <soap:fault name="InvalidFieldFault" use="literal"/>
+ </fault>
+ <fault name="MalformedSearchFault">
+ <soap:fault name="MalformedSearchFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getServerTimestamp">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="setPassword">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="InvalidNewPasswordFault">
+ <soap:fault name="InvalidNewPasswordFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="resetPassword">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:header use="literal" message="tns:Header" part="EmailHeader"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="InvalidIdFault">
+ <soap:fault name="InvalidIdFault" use="literal"/>
+ </fault>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="getUserInfo">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+ <operation name="sendEmail">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:header use="literal" message="tns:Header" part="SessionHeader"/>
+ <soap:header use="literal" message="tns:Header" part="CallOptions"/>
+ <soap:body parts="parameters" use="literal"/>
+ </input>
+ <output>
+ <soap:body use="literal"/>
+ </output>
+ <fault name="UnexpectedErrorFault">
+ <soap:fault name="UnexpectedErrorFault" use="literal"/>
+ </fault>
+ </operation>
+
+ </binding>
+
+ <!-- Soap Service Endpoint -->
+ <service name="SforceService">
+ <documentation>Sforce SOAP API</documentation>
+ <port binding="tns:SoapBinding" name="Soap">
+ <soap:address location="https://www.salesforce.com/services/Soap/u/17.0"/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: trunk/connectors/salesforce-api/src/main/resources/partner_v17.wsdl
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Deleted: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,61 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.yahoo;
-
-import java.util.Collections;
-import java.util.List;
-
-import org.teiid.translator.BasicConnectorCapabilities;
-
-
-/**
- * Specifies the capabilities of this connector. The Yahoo connector
- * supports only some basic criteria capability
- */
-public class YahooCapabilities extends BasicConnectorCapabilities {
-
- public static final int YAHOO_MAX_SET_SIZE = 100;
-
- /**
- * Construct the capabilities class
- */
- public YahooCapabilities() {
- }
-
- public List getSupportedFunctions() {
- return Collections.EMPTY_LIST;
- }
-
- public boolean supportsCompareCriteriaEquals() {
- return true;
- }
-
- public boolean supportsInCriteria() {
- return true;
- }
-
- public int getMaxInCriteriaSize() {
- return YAHOO_MAX_SET_SIZE;
- }
-
-}
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -47,7 +47,6 @@
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ResultSetExecution;
@@ -56,7 +55,7 @@
/**
* Represents the execution of a command.
*/
-public class YahooExecution extends BasicExecution implements ResultSetExecution {
+public class YahooExecution implements ResultSetExecution {
public static final String JAVA_PROP_HTTP_PROXY_HOST = "http.proxyHost"; //$NON-NLS-1$
public static final String JAVA_PROP_HTTP_PROXY_PORT = "http.proxyPort"; //$NON-NLS-1$
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -22,29 +22,44 @@
package org.teiid.translator.yahoo;
+import java.util.Collections;
+import java.util.List;
+
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ResultSetExecution;
-public class YahooExecutionFactory extends BasicExecutionFactory {
+public class YahooExecutionFactory extends ExecutionFactory {
+ public static final int YAHOO_MAX_SET_SIZE = 100;
+
@Override
public void start() throws ConnectorException {
}
@Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return YahooCapabilities.class;
- }
-
- @Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
throws ConnectorException {
return new YahooExecution((Select)command, metadata);
}
+
+ public List getSupportedFunctions() {
+ return Collections.EMPTY_LIST;
+ }
+
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ public int getMaxInCriteriaSize() {
+ return YAHOO_MAX_SET_SIZE;
+ }
}
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/resources/META-INF/jboss-beans.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/resources/META-INF/jboss-beans.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -10,7 +10,7 @@
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.resource.adapter.yahoo.YahooExecutionFactory</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.yahoo.YahooExecutionFactory</parameter>
<parameter class="java.lang.String">${project.artifactId}-${project.version}</parameter>
<parameter class="java.lang.String">${project.description}</parameter>
</constructor>
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -35,14 +35,14 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionContext;
/**
*/
-public abstract class JDBCBaseExecution extends BasicExecution {
+public abstract class JDBCBaseExecution implements Execution {
// ===========================================================================================================================
// Fields
@@ -50,8 +50,8 @@
// Passed to constructor
protected Connection connection;
- protected Translator sqlTranslator;
protected ExecutionContext context;
+ protected JDBCExecutionFactory executionFactory;
// Derived from properties
protected boolean trimString;
@@ -65,17 +65,18 @@
// Constructors
// ===========================================================================================================================
- protected JDBCBaseExecution(Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
+ protected JDBCBaseExecution(Connection connection, ExecutionContext context, JDBCExecutionFactory jef) {
this.connection = connection;
- this.sqlTranslator = translator;
this.context = context;
- trimString = env.isTrimStrings();
- fetchSize = (env.getFetchSize() != -1)?env.getFetchSize():context.getBatchSize();
- maxResultRows = env.getMaxResultRows();
+ this.executionFactory = jef;
+
+ trimString = jef.isTrimStrings();
+ fetchSize = (jef.getFetchSize() != -1)?jef.getFetchSize():context.getBatchSize();
+ maxResultRows = jef.getMaxResultRows();
//if the connector work needs to throw an excpetion, set the size plus 1
- if (maxResultRows > 0 && env.isExceptionOnMaxRows()) {
+ if (maxResultRows > 0 && jef.isExceptionOnMaxRows()) {
maxResultRows++;
}
if (maxResultRows > 0) {
@@ -97,7 +98,7 @@
value = ((List<?>)value).get(row);
}
Class<?> paramType = paramValue.getType();
- sqlTranslator.bindValue(stmt, value, paramType, i+1);
+ this.executionFactory.bindValue(stmt, value, paramType, i+1);
}
if (rowCount > 1) {
stmt.addBatch();
@@ -110,7 +111,7 @@
// ===========================================================================================================================
protected TranslatedCommand translateCommand(Command command) throws ConnectorException {
- TranslatedCommand translatedCommand = new TranslatedCommand(context, sqlTranslator);
+ TranslatedCommand translatedCommand = new TranslatedCommand(context, this.executionFactory);
translatedCommand.translateCommand(command);
if (translatedCommand.getSql() != null && LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) {
@@ -199,10 +200,6 @@
return this.connection;
}
- public Translator getSqlTranslator() {
- return sqlTranslator;
- }
-
public void addStatementWarnings() throws SQLException {
SQLWarning warning = this.statement.getWarnings();
while (warning != null) {
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,331 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.translator.BasicConnectorCapabilities;
-
-
-/**
- */
-public class JDBCCapabilities extends BasicConnectorCapabilities {
-
- /**
- *
- */
- public JDBCCapabilities() {
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- return Arrays.asList(new String[] { "+", "-", "*", "/" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#getMaxInCriteriaSize()
- * @since 4.2
- */
- public int getMaxInCriteriaSize() {
- return 1000;
- }
-
- @Override
- public boolean supportsGroupBy() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesAvg()
- */
- public boolean supportsAggregatesAvg() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesCount()
- */
- public boolean supportsAggregatesCount() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesCountStar()
- */
- public boolean supportsAggregatesCountStar() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesDistinct()
- */
- public boolean supportsAggregatesDistinct() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesMax()
- */
- public boolean supportsAggregatesMax() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesMin()
- */
- public boolean supportsAggregatesMin() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesSum()
- */
- public boolean supportsAggregatesSum() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAliasedGroup()
- */
- public boolean supportsAliasedGroup() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsBetweenCriteria()
- */
- public boolean supportsBetweenCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsCaseExpressions()
- */
- public boolean supportsCaseExpressions() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsCompareCriteriaEquals()
- */
- public boolean supportsCompareCriteriaEquals() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsCorrelatedSubqueries()
- */
- public boolean supportsCorrelatedSubqueries() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsExistsCriteria()
- */
- public boolean supportsExistsCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsInCriteria()
- */
- public boolean supportsInCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsInCriteriaSubquery()
- */
- public boolean supportsInCriteriaSubquery() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsIsNullCriteria()
- */
- public boolean supportsIsNullCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsLikeCriteria()
- */
- public boolean supportsLikeCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
- */
- public boolean supportsLikeCriteriaEscapeCharacter() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsNotCriteria()
- */
- public boolean supportsNotCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOrCriteria()
- */
- public boolean supportsOrCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return true;
- }
-
- @Override
- public boolean supportsOrderByUnrelated() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOuterJoins()
- */
- public boolean supportsOuterJoins() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
- */
- public boolean supportsQuantifiedCompareCriteriaAll() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsScalarSubqueries()
- */
- public boolean supportsScalarSubqueries() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsSearchedCaseExpressions()
- */
- public boolean supportsSearchedCaseExpressions() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsSelectDistinct()
- */
- public boolean supportsSelectDistinct() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsSelfJoins()
- */
- public boolean supportsSelfJoins() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsInlineViews()
- */
- public boolean supportsInlineViews() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
- */
- public boolean supportsQuantifiedCompareCriteriaSome() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsSetQueryOrderBy()
- */
- @Override
- public boolean supportsSetQueryOrderBy() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
- */
- public boolean supportsUnions() {
- return true;
- }
-
- @Override
- public boolean supportsBulkUpdate() {
- return true;
- }
-
- @Override
- public boolean supportsBatchedUpdates() {
- return true;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return true;
- }
-
- @Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.ANY;
- }
-
- @Override
- public boolean supportsHaving() {
- return true;
- }
-
- @Override
- public boolean supportsInnerJoins() {
- return true;
- }
-
- @Override
- public boolean supportsSelectExpression() {
- return true;
- }
-
- @Override
- public boolean supportsInsertWithQueryExpression() {
- return true;
- }
-
-}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -22,73 +22,143 @@
package org.teiid.translator.jdbc;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.CallableStatement;
import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.TimeZone;
import javax.sql.DataSource;
-import org.teiid.core.TeiidException;
import org.teiid.core.util.PropertiesUtils;
-import org.teiid.core.util.ReflectionHelper;
-import org.teiid.core.util.StringUtil;
+import org.teiid.language.Argument;
import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
import org.teiid.language.Command;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
import org.teiid.language.QueryExpression;
+import org.teiid.language.SetQuery;
+import org.teiid.language.Argument.Direction;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.MetadataProvider;
import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.UpdateExecution;
/**
* JDBC implementation of Connector interface.
*/
-public class JDBCExecutionFactory extends BasicExecutionFactory implements MetadataProvider {
+public class JDBCExecutionFactory extends ExecutionFactory implements MetadataProvider {
+
+ public static final int DEFAULT_MAX_IN_CRITERIA = 1000;
+
+ public enum NullOrder {
+ HIGH,
+ LOW,
+ FIRST,
+ LAST
+ }
- private ConnectorCapabilities capabilities;
- private Translator sqlTranslator;
+ // Because the retrieveValue() method will be hit for every value of
+ // every JDBC result set returned, we do lots of weird special stuff here
+ // to improve the performance (most importantly to remove big if/else checks
+ // of every possible type.
+
+ private static final Map<Class<?>, Integer> TYPE_CODE_MAP = new HashMap<Class<?>, Integer>();
+
+ private static final int INTEGER_CODE = 0;
+ private static final int LONG_CODE = 1;
+ private static final int DOUBLE_CODE = 2;
+ private static final int BIGDECIMAL_CODE = 3;
+ private static final int SHORT_CODE = 4;
+ private static final int FLOAT_CODE = 5;
+ private static final int TIME_CODE = 6;
+ private static final int DATE_CODE = 7;
+ private static final int TIMESTAMP_CODE = 8;
+ private static final int BLOB_CODE = 9;
+ private static final int CLOB_CODE = 10;
+ private static final int BOOLEAN_CODE = 11;
+
+ static {
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.INTEGER, new Integer(INTEGER_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.LONG, new Integer(LONG_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.DOUBLE, new Integer(DOUBLE_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL, new Integer(BIGDECIMAL_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.SHORT, new Integer(SHORT_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.FLOAT, new Integer(FLOAT_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.TIME, new Integer(TIME_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.DATE, new Integer(DATE_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, new Integer(TIMESTAMP_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BLOB, new Integer(BLOB_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.CLOB, new Integer(CLOB_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, new Integer(BOOLEAN_CODE));
+ TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BYTE, new Integer(SHORT_CODE));
+ }
+
+ private static final ThreadLocal<MessageFormat> COMMENT = new ThreadLocal<MessageFormat>() {
+ protected MessageFormat initialValue() {
+ return new MessageFormat("/*teiid sessionid:{0}, requestid:{1}.{2}*/ "); //$NON-NLS-1$
+ }
+ };
+ public final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
+
+ private static final ThreadLocal<Calendar> CALENDAR = new ThreadLocal<Calendar>() {
+ @Override
+ protected Calendar initialValue() {
+ return Calendar.getInstance();
+ }
+ };
+
+ private Map<String, FunctionModifier> functionModifiers = new HashMap<String, FunctionModifier>();
+
private boolean useBindVariables;
private String databaseTimeZone;
- private String extensionTranslationClassName;
private boolean trimStrings;
private boolean useCommentsInSourceQuery;
private int fetchSize;
+
+ boolean initialConnection = true;
@Override
public void start() throws ConnectorException {
super.start();
- capabilities = getTranslator().getConnectorCapabilities();
+
+ String timeZone = getDatabaseTimeZone();
+ if(timeZone != null && timeZone.trim().length() > 0) {
+ TimeZone tz = TimeZone.getTimeZone(timeZone);
+ if(!DEFAULT_TIME_ZONE.hasSameRules(tz)) {
+ CALENDAR.set(Calendar.getInstance(tz));
+ }
+ }
}
-
- public Translator getTranslator() throws ConnectorException {
- if (this.sqlTranslator == null) {
- try {
- String className = getExtensionTranslationClassName();
- if (!StringUtil.isValid(className)) {
- this.sqlTranslator = new Translator();
- } else {
- this.sqlTranslator = (Translator)ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
- }
- sqlTranslator.initialize(this);
- } catch (TeiidException e) {
- throw new ConnectorException(e);
- }
- }
- return this.sqlTranslator;
- }
- @Override
- public ConnectorCapabilities getCapabilities() {
- return capabilities;
- }
-
@TranslatorProperty(name="UseBindVariables", display="Use Bind Variables", description="Use prepared statements and bind variables",advanced=true, defaultValue="false")
public boolean isUseBindVariables() {
return this.useBindVariables;
@@ -107,29 +177,6 @@
this.databaseTimeZone = databaseTimeZone;
}
- @TranslatorProperty(name="ExtensionTranslationClassName", display="Extension SQL Translation Class", required=true,
- defaultValue="org.teiid.translator.jdbc.translator.Translator",
- allowed= {"org.teiid.translator.jdbc.translator.Translator",
- "org.teiid.translator.jdbc.access.AccessSQLTranslator",
- "org.teiid.translator.jdbc.db2.DB2SQLTranslator",
- "org.teiid.translator.jdbc.derby.DerbySQLTranslator",
- "org.teiid.translator.jdbc.h2.H2Translator",
- "org.teiid.translator.jdbc.hsql.HsqlTranslator",
- "org.teiid.translator.jdbc.mysql.MySQLTranslator",
- "org.teiid.translator.jdbc.mysql.MySQL5Translator",
- "org.teiid.translator.jdbc.oracle.OracleSQLTranslator",
- "org.teiid.translator.jdbc.postgresql.PostgreSQLTranslator",
- "org.teiid.translator.jdbc.sqlserver.SqlServerSQLTranslator",
- "org.teiid.translator.jdbc.sybase.SybaseSQLTranslator"
- })
- public String getExtensionTranslationClassName() {
- return this.extensionTranslationClassName;
- }
-
- public void setExtensionTranslationClassName(String extensionTranslationClassName) {
- this.extensionTranslationClassName = extensionTranslationClassName;
- }
-
@TranslatorProperty(name="TrimStrings",display="Trim string flag", description="Right Trim fixed character types returned as Strings - note that the native type must be char or nchar and the source must support the rtrim function.",advanced=true, defaultValue="false")
public boolean isTrimStrings() {
return this.trimStrings;
@@ -170,8 +217,8 @@
DataSource ds = (DataSource)connectionFactory;
Connection conn = ds.getConnection();
//TODO: This is not correct; this should be only called once for connection creation
- getTranslator().afterConnectionCreation(conn);
- return new JDBCQueryExecution(command, conn, executionContext, this, getTranslator());
+ afterConnectionCreation(conn);
+ return new JDBCQueryExecution(command, conn, executionContext, this);
} catch(SQLException e) {
throw new ConnectorException(e);
}
@@ -184,8 +231,8 @@
DataSource ds = (DataSource)connectionFactory;
Connection conn = ds.getConnection();
//TODO: This is not correct; this should be only called once for connection creation
- getTranslator().afterConnectionCreation(conn);
- return new JDBCProcedureExecution(command, conn, executionContext, this, getTranslator());
+ afterConnectionCreation(conn);
+ return new JDBCProcedureExecution(command, conn, executionContext, this);
} catch (SQLException e) {
throw new ConnectorException(e);
}
@@ -199,8 +246,8 @@
Connection conn = ds.getConnection();
//TODO: This is not correct; this should be only called once for connection creation
- getTranslator().afterConnectionCreation(conn);
- return new JDBCUpdateExecution(command, conn, executionContext, this, getTranslator());
+ afterConnectionCreation(conn);
+ return new JDBCUpdateExecution(command, conn, executionContext, this);
} catch (SQLException e) {
throw new ConnectorException(e);
}
@@ -226,4 +273,841 @@
throw new ConnectorException(e);
}
}
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ return getDefaultSupportedFunctions();
+ }
+
+ public List<String> getDefaultSupportedFunctions(){
+ return Arrays.asList(new String[] { "+", "-", "*", "/" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return DEFAULT_MAX_IN_CRITERIA;
+ }
+
+ @Override
+ public boolean supportsGroupBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesAvg() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesCount() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesDistinct() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesMax() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesMin() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesSum() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAliasedGroup() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsBetweenCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCaseExpressions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExistsCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFullOuterJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteriaSubquery() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIsNullCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrderBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrderByUnrelated() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSearchedCaseExpressions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelectDistinct() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelfJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsBulkUpdate() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsBatchedUpdates() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return true;
+ }
+
+ @Override
+ public SupportedJoinCriteria getSupportedJoinCriteria() {
+ return SupportedJoinCriteria.ANY;
+ }
+
+ @Override
+ public boolean supportsHaving() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInnerJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelectExpression() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return true;
+ }
+
+ /**
+ * Gets the database calendar. This will be set to the time zone
+ * specified by the property {@link JDBCPropertyNames#DATABASE_TIME_ZONE}, or
+ * the local time zone if none is specified.
+ * @return
+ */
+ public Calendar getDatabaseCalendar() {
+ return CALENDAR.get();
+ }
+
+ /**
+ * Return a List of translated parts ({@link LanguageObject}s and Objects), or null
+ * if to rely on the default translation. Override with care.
+ * @param command
+ * @param context
+ * @return
+ */
+ public List<?> translate(LanguageObject obj, ExecutionContext context) {
+ List<?> parts = null;
+ if (obj instanceof Function) {
+ Function function = (Function)obj;
+ if (functionModifiers != null) {
+ FunctionModifier modifier = functionModifiers.get(function.getName().toLowerCase());
+ if (modifier != null) {
+ parts = modifier.translate(function);
+ }
+ }
+ } else if (obj instanceof Command) {
+ parts = translateCommand((Command)obj, context);
+ } else if (obj instanceof Limit) {
+ parts = translateLimit((Limit)obj, context);
+ } else if (obj instanceof ColumnReference) {
+ ColumnReference elem = (ColumnReference)obj;
+ if (isTrimStrings() && elem.getType() == TypeFacility.RUNTIME_TYPES.STRING && elem.getMetadataObject() != null
+ && ("char".equalsIgnoreCase(elem.getMetadataObject().getNativeType()) || "nchar".equalsIgnoreCase(elem.getMetadataObject().getNativeType()))) { //$NON-NLS-1$ //$NON-NLS-2$
+ return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.RTRIM, new Expression[] {elem}, TypeFacility.RUNTIME_TYPES.STRING));
+ }
+ }
+ return parts;
+ }
+
+ /**
+ * Return a List of translated parts ({@link LanguageObject}s and Objects), or null
+ * if to rely on the default translation.
+ * @param command
+ * @param context
+ * @return
+ */
+ public List<?> translateCommand(Command command, ExecutionContext context) {
+ return null;
+ }
+
+ /**
+ * Return a List of translated parts ({@link LanguageObject}s and Objects), or null
+ * if to rely on the default translation.
+ * @param limit
+ * @param context
+ * @return
+ */
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ return null;
+ }
+
+ /**
+ * Return a map of function name in lower case to FunctionModifier.
+ * @return Map of function name to FunctionModifier.
+ */
+ public Map<String, FunctionModifier> getFunctionModifiers() {
+ return functionModifiers;
+ }
+
+ /**
+ * Add the {@link FunctionModifier} to the set of known modifiers.
+ * @param name
+ * @param modifier
+ */
+ public void registerFunctionModifier(String name, FunctionModifier modifier) {
+ this.functionModifiers.put(name, modifier);
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal boolean value. By default, a boolean literal is represented as:
+ * <code>'0'</code> or <code>'1'</code>.
+ * @param booleanValue Boolean value, never null
+ * @return Translated string
+ */
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ if(booleanValue.booleanValue()) {
+ return "1"; //$NON-NLS-1$
+ }
+ return "0"; //$NON-NLS-1$
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal date value. By default, a date literal is represented as:
+ * <code>{d '2002-12-31'}</code>
+ * @param dateValue Date value, never null
+ * @return Translated string
+ */
+ public String translateLiteralDate(java.sql.Date dateValue) {
+ return "{d '" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal time value. By default, a time literal is represented as:
+ * <code>{t '23:59:59'}</code>
+ *
+ * See {@link JDBCExecutionFactory#hasTimeType()} to represent literal times as timestamps.
+ *
+ * @param timeValue Time value, never null
+ * @return Translated string
+ */
+ public String translateLiteralTime(Time timeValue) {
+ if (!hasTimeType()) {
+ return "{ts '1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return "{t '" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Subclasses should override this method to provide a different sql translation
+ * of the literal timestamp value. By default, a timestamp literal is
+ * represented as: <code>{ts '2002-12-31 23:59:59'}</code>.
+ *
+ * See {@link JDBCExecutionFactory#getTimestampNanoPrecision()} to control the literal
+ * precision.
+ *
+ * @param timestampValue Timestamp value, never null
+ * @return Translated string
+ */
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Format the dateObject (of type date, time, or timestamp) into a string
+ * using the DatabaseTimeZone format.
+ * @param dateObject
+ * @return Formatted string
+ */
+ public String formatDateValue(java.util.Date dateObject) {
+ if (dateObject instanceof Timestamp && getTimestampNanoPrecision() < 9) {
+ Timestamp ts = (Timestamp)dateObject;
+ Timestamp newTs = new Timestamp(ts.getTime());
+ if (getTimestampNanoPrecision() > 0) {
+ int mask = (int)Math.pow(10, 9-getTimestampNanoPrecision());
+ newTs.setNanos(ts.getNanos()/mask*mask);
+ } else {
+ newTs.setNanos(0);
+ }
+ dateObject = newTs;
+ }
+ return getTypeFacility().convertDate(dateObject, DEFAULT_TIME_ZONE, getDatabaseCalendar(), dateObject.getClass()).toString();
+ }
+
+ /**
+ * Returns true to indicate that SQL should include a comment
+ * indicating the session and request ids.
+ */
+ public boolean addSourceComment() {
+ return isUseCommentsInSourceQuery();
+ }
+
+ /**
+ * Indicates whether group alias should be of the form
+ * "...FROM groupA AS X" or "...FROM groupA X". Certain
+ * data sources (such as Oracle) may not support the first
+ * form.
+ * @return boolean
+ */
+ public boolean useAsInGroupAlias(){
+ return true;
+ }
+
+ /**
+ * Use PreparedStatements (or CallableStatements) as
+ * appropriate for all commands. Bind values will be
+ * determined by the {@link BindValueVisitor}. {@link Literal#setBindValue(boolean)}
+ * can be used to force a literal to be a bind value.
+ */
+ public boolean usePreparedStatements() {
+ return isUseBindVariables();
+ }
+
+ /**
+ * Set to true to indicate that every branch of a set query
+ * should have parenthesis, i.e. (query) union (query)
+ * @return
+ */
+ public boolean useParensForSetQueries() {
+ return false;
+ }
+
+ /**
+ * Return false to indicate that time support should be emulated
+ * with timestamps.
+ * @return
+ */
+ public boolean hasTimeType() {
+ return true;
+ }
+
+ /**
+ * Returns the name for a given {@link SetQuery.Operation}
+ * @param operation
+ * @return
+ */
+ public String getSetOperationString(SetQuery.Operation operation) {
+ return operation.toString();
+ }
+
+ /**
+ * Returns the source comment for
+ * @param context
+ * @param command
+ * @return
+ */
+ public String getSourceComment(ExecutionContext context, Command command) {
+ if (addSourceComment() && context != null) {
+ return COMMENT.get().format(new Object[] {context.getConnectionIdentifier(), context.getRequestIdentifier(), context.getPartIdentifier()});
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /**
+ * Override to return a name other than the default [group.]element
+ * @param group
+ * @param element
+ * @return
+ */
+ public String replaceElementName(String group, String element) {
+ return null;
+ }
+
+ /**
+ * Return the precision of timestamp literals. Defaults to 9
+ * @return
+ */
+ public int getTimestampNanoPrecision() {
+ return 9;
+ }
+
+ /**
+ * This is a generic implementation. Because different databases handle
+ * stored procedures differently, subclasses should override this method
+ * if necessary.
+ */
+ public ResultSet executeStoredProcedure(CallableStatement statement, TranslatedCommand command, Class<?> returnType) throws SQLException {
+ List params = command.getPreparedValues();
+ int index = 1;
+
+ if(returnType != null){
+ registerSpecificTypeOfOutParameter(statement, returnType, index++);
+ }
+
+ Iterator iter = params.iterator();
+ while(iter.hasNext()){
+ Argument param = (Argument)iter.next();
+
+ if(param.getDirection() == Direction.INOUT){
+ registerSpecificTypeOfOutParameter(statement,param.getType(), index);
+ }else if(param.getDirection() == Direction.OUT){
+ registerSpecificTypeOfOutParameter(statement,param.getType(), index++);
+ }
+
+ if(param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT){
+ bindValue(statement, param.getArgumentValue().getValue(), param.getType(), index++);
+ }
+ }
+ boolean resultSetNext = statement.execute();
+
+ while (!resultSetNext) {
+ int update_count = statement.getUpdateCount();
+ if (update_count == -1) {
+ break;
+ }
+ resultSetNext = statement.getMoreResults();
+ }
+ return statement.getResultSet();
+ }
+
+ /**
+ * For registering specific output parameter types we need to translate these into the appropriate
+ * java.sql.Types output parameters
+ * We will need to match these up with the appropriate standard sql types
+ * @param cstmt
+ * @param parameter
+ * @throws SQLException
+ */
+ protected void registerSpecificTypeOfOutParameter(CallableStatement statement, Class<?> runtimeType, int index) throws SQLException {
+ int typeToSet = TypeFacility.getSQLTypeFromRuntimeType(runtimeType);
+
+ statement.registerOutParameter(index,typeToSet);
+ }
+
+ /**
+ * Sets prepared statement parameter i with param.
+ *
+ * Performs special handling to translate dates using the database time zone and to
+ * translate biginteger, float, and char to JDBC safe objects.
+ *
+ * @param stmt
+ * @param param
+ * @param paramType
+ * @param i
+ * @param cal
+ * @throws SQLException
+ */
+ public void bindValue(PreparedStatement stmt, Object param, Class<?> paramType, int i) throws SQLException {
+ int type = TypeFacility.getSQLTypeFromRuntimeType(paramType);
+
+ if (param == null) {
+ stmt.setNull(i, type);
+ return;
+ }
+ //if this is a Date object, then use the database calendar
+ if (paramType.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
+ stmt.setDate(i,(java.sql.Date)param, getDatabaseCalendar());
+ return;
+ }
+ if (paramType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
+ stmt.setTime(i,(java.sql.Time)param, getDatabaseCalendar());
+ return;
+ }
+ if (paramType.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
+ stmt.setTimestamp(i,(java.sql.Timestamp)param, getDatabaseCalendar());
+ return;
+ }
+ //convert these the following to jdbc safe values
+ if (TypeFacility.RUNTIME_TYPES.BIG_INTEGER.equals(paramType)) {
+ param = new BigDecimal((BigInteger)param);
+ } else if (TypeFacility.RUNTIME_TYPES.FLOAT.equals(paramType)) {
+ param = new Double(((Float)param).doubleValue());
+ } else if (TypeFacility.RUNTIME_TYPES.CHAR.equals(paramType)) {
+ param = ((Character)param).toString();
+ }
+ stmt.setObject(i, param, type);
+ }
+
+ /**
+ * Retrieve the value on the current resultset row for the given column index.
+ * @param results
+ * @param columnIndex
+ * @param expectedType
+ * @return
+ * @throws SQLException
+ */
+ public Object retrieveValue(ResultSet results, int columnIndex, Class<?> expectedType) throws SQLException {
+ Integer code = TYPE_CODE_MAP.get(expectedType);
+ if(code != null) {
+ // Calling the specific methods here is more likely to get uniform (and fast) results from different
+ // data sources as the driver likely knows the best and fastest way to convert from the underlying
+ // raw form of the data to the expected type. We use a switch with codes in order without gaps
+ // as there is a special bytecode instruction that treats this case as a map such that not every value
+ // needs to be tested, which means it is very fast.
+ switch(code.intValue()) {
+ case INTEGER_CODE: {
+ int value = results.getInt(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Integer.valueOf(value);
+ }
+ case LONG_CODE: {
+ long value = results.getLong(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Long.valueOf(value);
+ }
+ case DOUBLE_CODE: {
+ double value = results.getDouble(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Double.valueOf(value);
+ }
+ case BIGDECIMAL_CODE: {
+ return results.getBigDecimal(columnIndex);
+ }
+ case SHORT_CODE: {
+ short value = results.getShort(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Short.valueOf(value);
+ }
+ case FLOAT_CODE: {
+ float value = results.getFloat(columnIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Float.valueOf(value);
+ }
+ case TIME_CODE: {
+ return results.getTime(columnIndex, getDatabaseCalendar());
+ }
+ case DATE_CODE: {
+ return results.getDate(columnIndex, getDatabaseCalendar());
+ }
+ case TIMESTAMP_CODE: {
+ return results.getTimestamp(columnIndex, getDatabaseCalendar());
+ }
+ case BLOB_CODE: {
+ try {
+ return results.getBlob(columnIndex);
+ } catch (SQLException e) {
+ // ignore
+ }
+ try {
+ return results.getBytes(columnIndex);
+ } catch (SQLException e) {
+ // ignore
+ }
+ break;
+ }
+ case CLOB_CODE: {
+ try {
+ return results.getClob(columnIndex);
+ } catch (SQLException e) {
+ // ignore
+ }
+ break;
+ }
+ case BOOLEAN_CODE: {
+ return results.getBoolean(columnIndex);
+ }
+ }
+ }
+
+ return results.getObject(columnIndex);
+ }
+
+ /**
+ * Retrieve the value for the given parameter index
+ * @param results
+ * @param parameterIndex
+ * @param expectedType
+ * @return
+ * @throws SQLException
+ */
+ public Object retrieveValue(CallableStatement results, int parameterIndex, Class expectedType) throws SQLException{
+ Integer code = TYPE_CODE_MAP.get(expectedType);
+ if(code != null) {
+ switch(code.intValue()) {
+ case INTEGER_CODE: {
+ int value = results.getInt(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Integer.valueOf(value);
+ }
+ case LONG_CODE: {
+ long value = results.getLong(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Long.valueOf(value);
+ }
+ case DOUBLE_CODE: {
+ double value = results.getDouble(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return new Double(value);
+ }
+ case BIGDECIMAL_CODE: {
+ return results.getBigDecimal(parameterIndex);
+ }
+ case SHORT_CODE: {
+ short value = results.getShort(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return Short.valueOf(value);
+ }
+ case FLOAT_CODE: {
+ float value = results.getFloat(parameterIndex);
+ if(results.wasNull()) {
+ return null;
+ }
+ return new Float(value);
+ }
+ case TIME_CODE: {
+ return results.getTime(parameterIndex, getDatabaseCalendar());
+ }
+ case DATE_CODE: {
+ return results.getDate(parameterIndex, getDatabaseCalendar());
+ }
+ case TIMESTAMP_CODE: {
+ return results.getTimestamp(parameterIndex, getDatabaseCalendar());
+ }
+ case BLOB_CODE: {
+ try {
+ return results.getBlob(parameterIndex);
+ } catch (SQLException e) {
+ // ignore
+ }
+ try {
+ return results.getBytes(parameterIndex);
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ case CLOB_CODE: {
+ try {
+ return results.getClob(parameterIndex);
+ } catch (SQLException e) {
+ // ignore
+ }
+ }
+ case BOOLEAN_CODE: {
+ return results.getBoolean(parameterIndex);
+ }
+ }
+ }
+
+ // otherwise fall through and call getObject() and rely on the normal
+ // translation routines
+ return results.getObject(parameterIndex);
+ }
+
+ /**
+ * Called exactly once for this source.
+ * @param connection
+ */
+ protected void afterInitialConnectionCreation(Connection connection) {
+ // now dig some details about this driver/database for log.
+ try {
+ StringBuffer sb = new StringBuffer();
+ DatabaseMetaData dbmd = connection.getMetaData();
+ sb.append("Commit=").append(connection.getAutoCommit()); //$NON-NLS-1$
+ sb.append(";DatabaseProductName=").append(dbmd.getDatabaseProductName()); //$NON-NLS-1$
+ sb.append(";DatabaseProductVersion=").append(dbmd.getDatabaseProductVersion()); //$NON-NLS-1$
+ sb.append(";DriverMajorVersion=").append(dbmd.getDriverMajorVersion()); //$NON-NLS-1$
+ sb.append(";DriverMajorVersion=").append(dbmd.getDriverMinorVersion()); //$NON-NLS-1$
+ sb.append(";DriverName=").append(dbmd.getDriverName()); //$NON-NLS-1$
+ sb.append(";DriverVersion=").append(dbmd.getDriverVersion()); //$NON-NLS-1$
+ sb.append(";IsolationLevel=").append(dbmd.getDefaultTransactionIsolation()); //$NON-NLS-1$
+
+ LogManager.logInfo(LogConstants.CTX_CONNECTOR, sb.toString());
+ } catch (SQLException e) {
+ String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_jdbc_connection_details"); //$NON-NLS-1$
+ LogManager.logInfo(LogConstants.CTX_CONNECTOR, errorStr);
+ }
+ }
+
+ /**
+ * Provides a hook to call source specific logic when
+ * a connection is created.
+ *
+ * defect request 13979 & 13978
+ */
+ public void afterConnectionCreation(Connection connection) {
+ if (initialConnection) {
+ synchronized (this) {
+ if (!initialConnection) {
+ return;
+ }
+ initialConnection = false;
+ afterInitialConnectionCreation(connection);
+ }
+ }
+ }
+
+
+
+ /**
+ * Create the {@link SQLConversionVisitor} that will perform translation. Typical custom
+ * JDBC connectors will not need to create custom conversion visitors, rather implementors
+ * should override existing {@link JDBCExecutionFactory} methods.
+ * @return
+ */
+ public SQLConversionVisitor getSQLConversionVisitor() {
+ return new SQLConversionVisitor(this);
+ }
+
+ /**
+ * Set to true to indicate that every branch of a join
+ * should have parenthesis.
+ * @return
+ */
+ public boolean useParensForJoins() {
+ return false;
+ }
+
+ /**
+ * get the default null ordering
+ * @return
+ */
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.LOW;
+ }
+
+ /**
+ *
+ * @return true if nulls high|low can be specified
+ */
+ public boolean supportsExplicitNullOrdering() {
+ return false;
+ }
+
+ /**
+ *
+ * @return true if the limit clause is part of the select
+ */
+ public boolean useSelectLimit() {
+ return false;
+ }
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -47,8 +47,8 @@
* @param props
* @param id
*/
- public JDBCProcedureExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
- super(command, connection, context, env, translator);
+ public JDBCProcedureExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env) {
+ super(command, connection, context, env);
}
@Override
@@ -64,7 +64,7 @@
try{
//create parameter index map
CallableStatement cstmt = getCallableStatement(sql);
- this.results = sqlTranslator.executeStoredProcedure(cstmt, translatedComm, procedure.getReturnType());
+ this.results = this.executionFactory.executeStoredProcedure(cstmt, translatedComm, procedure.getReturnType());
addStatementWarnings();
}catch(SQLException e){
throw new ConnectorException(e, JDBCPlugin.Util.getString("JDBCQueryExecution.Error_executing_query__1", sql)); //$NON-NLS-1$
@@ -108,7 +108,7 @@
private void addParameterValue(List<Object> result, int paramIndex,
Class<?> type) throws SQLException {
- Object value = sqlTranslator.retrieveValue((CallableStatement)this.statement, paramIndex, type);
+ Object value = this.executionFactory.retrieveValue((CallableStatement)this.statement, paramIndex, type);
result.add(value);
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -57,8 +57,8 @@
// Constructors
// ===========================================================================================================================
- public JDBCQueryExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
- super(connection, context, env, translator);
+ public JDBCQueryExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env) {
+ super(connection, context, env);
this.command = command;
}
@@ -96,7 +96,7 @@
for (int i = 0; i < columnDataTypes.length; i++) {
// Convert from 0-based to 1-based
- Object value = sqlTranslator.retrieveValue(results, i+1, columnDataTypes[i]);
+ Object value = this.executionFactory.retrieveValue(results, i+1, columnDataTypes[i]);
vals.add(value);
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -51,8 +51,8 @@
* @param props
* @param id
*/
- public JDBCUpdateExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
- super(connection, context, env, translator);
+ public JDBCUpdateExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env) {
+ super(connection, context, env);
this.command = command;
}
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -56,7 +56,7 @@
import org.teiid.language.visitor.SQLStringVisitor;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.Translator.NullOrder;
+import org.teiid.translator.jdbc.JDBCExecutionFactory.NullOrder;
/**
@@ -71,7 +71,7 @@
private static double SCIENTIC_HIGH = Math.pow(10, 7);
private ExecutionContext context;
- private Translator translator;
+ private JDBCExecutionFactory executionFactory;
private boolean prepared;
@@ -82,9 +82,9 @@
private boolean replaceWithBinding = false;
- public SQLConversionVisitor(Translator translator) {
- this.translator = translator;
- this.prepared = translator.usePreparedStatements();
+ public SQLConversionVisitor(JDBCExecutionFactory ef) {
+ this.executionFactory = ef;
+ this.prepared = executionFactory.usePreparedStatements();
}
@Override
@@ -107,7 +107,7 @@
} else if (trans instanceof LanguageObject) {
obj = (LanguageObject)trans;
} else {
- parts = translator.translate(obj, context);
+ parts = executionFactory.translate(obj, context);
if (parts != null) {
this.translations.put(obj, parts);
} else {
@@ -134,8 +134,8 @@
@Override
public void visit(SortSpecification obj) {
super.visit(obj);
- NullOrder nullOrder = this.translator.getDefaultNullOrder();
- if (!this.translator.supportsExplicitNullOrdering() || nullOrder == NullOrder.LOW) {
+ NullOrder nullOrder = this.executionFactory.getDefaultNullOrder();
+ if (!this.executionFactory.supportsExplicitNullOrdering() || nullOrder == NullOrder.LOW) {
return;
}
if (obj.getOrdering() == Ordering.ASC) {
@@ -179,13 +179,13 @@
valuesbuffer.append(obj);
}
} else if(type.equals(TypeFacility.RUNTIME_TYPES.BOOLEAN)) {
- valuesbuffer.append(translator.translateLiteralBoolean((Boolean)obj));
+ valuesbuffer.append(executionFactory.translateLiteralBoolean((Boolean)obj));
} else if(type.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
- valuesbuffer.append(translator.translateLiteralTimestamp((Timestamp)obj));
+ valuesbuffer.append(executionFactory.translateLiteralTimestamp((Timestamp)obj));
} else if(type.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
- valuesbuffer.append(translator.translateLiteralTime((Time)obj));
+ valuesbuffer.append(executionFactory.translateLiteralTime((Time)obj));
} else if(type.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
- valuesbuffer.append(translator.translateLiteralDate((java.sql.Date)obj));
+ valuesbuffer.append(executionFactory.translateLiteralDate((java.sql.Date)obj));
} else {
// If obj is string, toSting() will not create a new String
// object, it returns it self, so new object creation.
@@ -282,7 +282,7 @@
}
protected String getSourceComment(Command command) {
- return this.translator.getSourceComment(this.context, command);
+ return this.executionFactory.getSourceComment(this.context, command);
}
/**
@@ -342,31 +342,31 @@
@Override
protected boolean useAsInGroupAlias() {
- return this.translator.useAsInGroupAlias();
+ return this.executionFactory.useAsInGroupAlias();
}
@Override
protected boolean useParensForSetQueries() {
- return translator.useParensForSetQueries();
+ return executionFactory.useParensForSetQueries();
}
@Override
protected String replaceElementName(String group, String element) {
- return translator.replaceElementName(group, element);
+ return executionFactory.replaceElementName(group, element);
}
@Override
protected void appendSetOperation(Operation operation) {
- buffer.append(translator.getSetOperationString(operation));
+ buffer.append(executionFactory.getSetOperationString(operation));
}
@Override
protected boolean useParensForJoins() {
- return translator.useParensForJoins();
+ return executionFactory.useParensForJoins();
}
protected boolean useSelectLimit() {
- return translator.useSelectLimit();
+ return executionFactory.useSelectLimit();
}
}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,274 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc;
-
-import java.util.List;
-
-
-/**
- * This is a "simple" capabilities class that allows criteria but no
- * complicated joins, subqueries, etc to be passed to the connector.
- * This capabilities class may come in handy for testing and for
- * sources that support JDBC but don't support extended JDBC capabilities.
- */
-public class SimpleCapabilities extends JDBCCapabilities {
-
- public SimpleCapabilities() {
- }
-
- @Override
- public int getMaxInCriteriaSize() {
- return 250;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCompareCriteriaEquals()
- */
- public boolean supportsCompareCriteriaEquals() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteria()
- */
- public boolean supportsInCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsIsNullCriteria()
- */
- public boolean supportsIsNullCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteria()
- */
- public boolean supportsLikeCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsNotCriteria()
- */
- public boolean supportsNotCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrCriteria()
- */
- public boolean supportsOrCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelectDistinct()
- */
- public boolean supportsSelectDistinct() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAliasedGroup()
- */
- public boolean supportsAliasedGroup() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelfJoins()
- */
- public boolean supportsSelfJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOuterJoins()
- */
- public boolean supportsOuterJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsBetweenCriteria()
- */
- public boolean supportsBetweenCriteria() {
- return false;
- }
-
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
- */
- public boolean supportsLikeCriteriaEscapeCharacter() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteriaSubquery()
- */
- public boolean supportsInCriteriaSubquery() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsExistsCriteria()
- */
- public boolean supportsExistsCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
- */
- public boolean supportsQuantifiedCompareCriteriaSome() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
- */
- public boolean supportsQuantifiedCompareCriteriaAll() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesSum()
- */
- public boolean supportsAggregatesSum() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesAvg()
- */
- public boolean supportsAggregatesAvg() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMin()
- */
- public boolean supportsAggregatesMin() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMax()
- */
- public boolean supportsAggregatesMax() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCount()
- */
- public boolean supportsAggregatesCount() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCountStar()
- */
- public boolean supportsAggregatesCountStar() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesDistinct()
- */
- public boolean supportsAggregatesDistinct() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsScalarSubqueries()
- */
- public boolean supportsScalarSubqueries() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCorrelatedSubqueries()
- */
- public boolean supportsCorrelatedSubqueries() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCaseExpressions()
- */
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSearchedCaseExpressions()
- */
- public boolean supportsSearchedCaseExpressions() {
- return false;
- }
-
- /**
- * Return null to indicate no functions are supported.
- * @return null
- * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
- */
- public List getSupportedFunctions() {
- return null;
- }
-
- public boolean supportsInlineViews() {
- return false;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
- * @since 4.2
- */
- public boolean supportsUnions() {
- return false;
- }
-
- @Override
- public boolean supportsInsertWithQueryExpression() {
- return false;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,205 @@
+/*
+ * 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;
+
+import java.util.List;
+
+
+/**
+ * This is a "simple" capabilities class that allows criteria but no
+ * complicated joins, subqueries, etc to be passed to the connector.
+ * This capabilities class may come in handy for testing and for
+ * sources that support JDBC but don't support extended JDBC capabilities.
+ */
+public class SimpleJDBCExecutionFactory extends JDBCExecutionFactory {
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return 250;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIsNullCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelectDistinct() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAliasedGroup() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelfJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBetweenCriteria() {
+ return false;
+ }
+
+
+ @Override
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInCriteriaSubquery() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExistsCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesSum() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesAvg() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesMin() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesMax() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCount() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesDistinct() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsCaseExpressions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSearchedCaseExpressions() {
+ return false;
+ }
+
+ @Override
+ public List getSupportedFunctions() {
+ return null;
+ }
+
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return false;
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleJDBCExecutionFactory.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -45,15 +45,15 @@
private boolean prepared;
private List preparedValues;
- private Translator sqlTranslator;
+ private JDBCExecutionFactory executionFactory;
private ExecutionContext context;
/**
* Constructor, takes a SQLConversionVisitor subclass
* @param visitor a SQLConversionVisitor subclass
*/
- public TranslatedCommand(ExecutionContext context, Translator sqlTranslator){
- this.sqlTranslator = sqlTranslator;
+ public TranslatedCommand(ExecutionContext context, JDBCExecutionFactory executionFactory){
+ this.executionFactory = executionFactory;
this.context = context;
}
@@ -65,9 +65,9 @@
* @throws ConnectorException
*/
public void translateCommand(Command command) throws ConnectorException {
- SQLConversionVisitor sqlConversionVisitor = sqlTranslator.getSQLConversionVisitor();
+ SQLConversionVisitor sqlConversionVisitor = executionFactory.getSQLConversionVisitor();
sqlConversionVisitor.setExecutionContext(context);
- if (sqlTranslator.usePreparedStatements() || hasBindValue(command)) {
+ if (executionFactory.usePreparedStatements() || hasBindValue(command)) {
sqlConversionVisitor.setPrepared(true);
}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,818 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.DatabaseMetaData;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.text.MessageFormat;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.teiid.core.util.ReflectionHelper;
-import org.teiid.language.Argument;
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Command;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.LanguageFactory;
-import org.teiid.language.LanguageObject;
-import org.teiid.language.Limit;
-import org.teiid.language.Literal;
-import org.teiid.language.SetQuery;
-import org.teiid.language.Argument.Direction;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.TypeFacility;
-
-
-/**
- * Base class for creating source SQL queries and retrieving results.
- * Specific databases should override as necessary.
- */
-public class Translator {
-
- public enum NullOrder {
- HIGH,
- LOW,
- FIRST,
- LAST
- }
-
- // Because the retrieveValue() method will be hit for every value of
- // every JDBC result set returned, we do lots of weird special stuff here
- // to improve the performance (most importantly to remove big if/else checks
- // of every possible type.
-
- private static final Map<Class<?>, Integer> TYPE_CODE_MAP = new HashMap<Class<?>, Integer>();
-
- private static final int INTEGER_CODE = 0;
- private static final int LONG_CODE = 1;
- private static final int DOUBLE_CODE = 2;
- private static final int BIGDECIMAL_CODE = 3;
- private static final int SHORT_CODE = 4;
- private static final int FLOAT_CODE = 5;
- private static final int TIME_CODE = 6;
- private static final int DATE_CODE = 7;
- private static final int TIMESTAMP_CODE = 8;
- private static final int BLOB_CODE = 9;
- private static final int CLOB_CODE = 10;
- private static final int BOOLEAN_CODE = 11;
-
- static {
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.INTEGER, new Integer(INTEGER_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.LONG, new Integer(LONG_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.DOUBLE, new Integer(DOUBLE_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BIG_DECIMAL, new Integer(BIGDECIMAL_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.SHORT, new Integer(SHORT_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.FLOAT, new Integer(FLOAT_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.TIME, new Integer(TIME_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.DATE, new Integer(DATE_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.TIMESTAMP, new Integer(TIMESTAMP_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BLOB, new Integer(BLOB_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.CLOB, new Integer(CLOB_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BOOLEAN, new Integer(BOOLEAN_CODE));
- TYPE_CODE_MAP.put(TypeFacility.RUNTIME_TYPES.BYTE, new Integer(SHORT_CODE));
- }
-
- private static final ThreadLocal<MessageFormat> COMMENT = new ThreadLocal<MessageFormat>() {
- protected MessageFormat initialValue() {
- return new MessageFormat("/*teiid sessionid:{0}, requestid:{1}.{2}*/ "); //$NON-NLS-1$
- }
- };
- public final static TimeZone DEFAULT_TIME_ZONE = TimeZone.getDefault();
-
- private static final ThreadLocal<Calendar> CALENDAR = new ThreadLocal<Calendar>() {
- @Override
- protected Calendar initialValue() {
- return Calendar.getInstance();
- }
- };
-
- private Map<String, FunctionModifier> functionModifiers = new HashMap<String, FunctionModifier>();
- private JDBCExecutionFactory environment;
-
- private boolean useComments;
- private boolean usePreparedStatements;
-
- private TypeFacility typeFacility;
-
- private volatile boolean initialConnection;
- private boolean trimChar;
-
- /**
- * Initialize the SQLTranslator.
- * @param env
- * @param metadata
- * @throws ConnectorException
- */
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- this.environment = env;
- this.typeFacility = env.getTypeFacility();
-
- String timeZone = this.environment.getDatabaseTimeZone();
- if(timeZone != null && timeZone.trim().length() > 0) {
- TimeZone tz = TimeZone.getTimeZone(timeZone);
- if(!DEFAULT_TIME_ZONE.hasSameRules(tz)) {
- CALENDAR.set(Calendar.getInstance(tz));
- }
- }
-
- this.useComments = this.environment.isUseCommentsInSourceQuery();
- this.usePreparedStatements = this.environment.isUseBindVariables();
- trimChar = this.environment.isTrimStrings();
- }
-
- /**
- * Gets the database calendar. This will be set to the time zone
- * specified by the property {@link JDBCPropertyNames#DATABASE_TIME_ZONE}, or
- * the local time zone if none is specified.
- * @return
- */
- public Calendar getDatabaseCalendar() {
- return CALENDAR.get();
- }
-
- /**
- * Gets the {@link LanguageFactory}
- */
- public final LanguageFactory getLanguageFactory() {
- return environment.getLanguageFactory();
- }
-
- /**
- * Return a List of translated parts ({@link LanguageObject}s and Objects), or null
- * if to rely on the default translation. Override with care.
- * @param command
- * @param context
- * @return
- */
- public List<?> translate(LanguageObject obj, ExecutionContext context) {
- List<?> parts = null;
- if (obj instanceof Function) {
- Function function = (Function)obj;
- if (functionModifiers != null) {
- FunctionModifier modifier = functionModifiers.get(function.getName().toLowerCase());
- if (modifier != null) {
- parts = modifier.translate(function);
- }
- }
- } else if (obj instanceof Command) {
- parts = translateCommand((Command)obj, context);
- } else if (obj instanceof Limit) {
- parts = translateLimit((Limit)obj, context);
- } else if (obj instanceof ColumnReference) {
- ColumnReference elem = (ColumnReference)obj;
- if (trimChar && elem.getType() == TypeFacility.RUNTIME_TYPES.STRING && elem.getMetadataObject() != null
- && ("char".equalsIgnoreCase(elem.getMetadataObject().getNativeType()) || "nchar".equalsIgnoreCase(elem.getMetadataObject().getNativeType()))) { //$NON-NLS-1$ //$NON-NLS-2$
- return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.RTRIM, new Expression[] {elem}, TypeFacility.RUNTIME_TYPES.STRING));
- }
- }
- return parts;
- }
-
- /**
- * Return a List of translated parts ({@link LanguageObject}s and Objects), or null
- * if to rely on the default translation.
- * @param command
- * @param context
- * @return
- */
- public List<?> translateCommand(Command command, ExecutionContext context) {
- return null;
- }
-
- /**
- * Return a List of translated parts ({@link LanguageObject}s and Objects), or null
- * if to rely on the default translation.
- * @param limit
- * @param context
- * @return
- */
- public List<?> translateLimit(Limit limit, ExecutionContext context) {
- return null;
- }
-
- /**
- * Return a map of function name in lower case to FunctionModifier.
- * @return Map of function name to FunctionModifier.
- */
- public Map<String, FunctionModifier> getFunctionModifiers() {
- return functionModifiers;
- }
-
- /**
- * Add the {@link FunctionModifier} to the set of known modifiers.
- * @param name
- * @param modifier
- */
- public void registerFunctionModifier(String name, FunctionModifier modifier) {
- this.functionModifiers.put(name, modifier);
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal boolean value. By default, a boolean literal is represented as:
- * <code>'0'</code> or <code>'1'</code>.
- * @param booleanValue Boolean value, never null
- * @return Translated string
- */
- public String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "1"; //$NON-NLS-1$
- }
- return "0"; //$NON-NLS-1$
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal date value. By default, a date literal is represented as:
- * <code>{d '2002-12-31'}</code>
- * @param dateValue Date value, never null
- * @return Translated string
- */
- public String translateLiteralDate(java.sql.Date dateValue) {
- return "{d '" + formatDateValue(dateValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal time value. By default, a time literal is represented as:
- * <code>{t '23:59:59'}</code>
- *
- * See {@link Translator#hasTimeType()} to represent literal times as timestamps.
- *
- * @param timeValue Time value, never null
- * @return Translated string
- */
- public String translateLiteralTime(Time timeValue) {
- if (!hasTimeType()) {
- return "{ts '1970-01-01 " + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- return "{t '" + formatDateValue(timeValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Subclasses should override this method to provide a different sql translation
- * of the literal timestamp value. By default, a timestamp literal is
- * represented as: <code>{ts '2002-12-31 23:59:59'}</code>.
- *
- * See {@link Translator#getTimestampNanoPrecision()} to control the literal
- * precision.
- *
- * @param timestampValue Timestamp value, never null
- * @return Translated string
- */
- public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Format the dateObject (of type date, time, or timestamp) into a string
- * using the DatabaseTimeZone format.
- * @param dateObject
- * @return Formatted string
- */
- public String formatDateValue(java.util.Date dateObject) {
- if (dateObject instanceof Timestamp && getTimestampNanoPrecision() < 9) {
- Timestamp ts = (Timestamp)dateObject;
- Timestamp newTs = new Timestamp(ts.getTime());
- if (getTimestampNanoPrecision() > 0) {
- int mask = (int)Math.pow(10, 9-getTimestampNanoPrecision());
- newTs.setNanos(ts.getNanos()/mask*mask);
- } else {
- newTs.setNanos(0);
- }
- dateObject = newTs;
- }
- return this.environment.getTypeFacility().convertDate(dateObject,
- DEFAULT_TIME_ZONE, getDatabaseCalendar(), dateObject.getClass()).toString();
- }
-
- /**
- * Returns true to indicate that SQL should include a comment
- * indicating the session and request ids.
- */
- public boolean addSourceComment() {
- return useComments;
- }
-
- /**
- * Indicates whether group alias should be of the form
- * "...FROM groupA AS X" or "...FROM groupA X". Certain
- * data sources (such as Oracle) may not support the first
- * form.
- * @return boolean
- */
- public boolean useAsInGroupAlias(){
- return true;
- }
-
- /**
- * Use PreparedStatements (or CallableStatements) as
- * appropriate for all commands. Bind values will be
- * determined by the {@link BindValueVisitor}. {@link Literal#setBindValue(boolean)}
- * can be used to force a literal to be a bind value.
- */
- public boolean usePreparedStatements() {
- return this.usePreparedStatements;
- }
-
- /**
- * Set to true to indicate that every branch of a set query
- * should have parenthesis, i.e. (query) union (query)
- * @return
- */
- public boolean useParensForSetQueries() {
- return false;
- }
-
- /**
- * Return false to indicate that time support should be emulated
- * with timestamps.
- * @return
- */
- public boolean hasTimeType() {
- return true;
- }
-
- /**
- * Returns the name for a given {@link SetQuery.Operation}
- * @param operation
- * @return
- */
- public String getSetOperationString(SetQuery.Operation operation) {
- return operation.toString();
- }
-
- /**
- * Returns the source comment for
- * @param context
- * @param command
- * @return
- */
- public String getSourceComment(ExecutionContext context, Command command) {
- if (addSourceComment() && context != null) {
- return COMMENT.get().format(new Object[] {context.getConnectionIdentifier(), context.getRequestIdentifier(), context.getPartIdentifier()});
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Override to return a name other than the default [group.]element
- * @param group
- * @param element
- * @return
- */
- public String replaceElementName(String group, String element) {
- return null;
- }
-
- /**
- * Return the precision of timestamp literals. Defaults to 9
- * @return
- */
- public int getTimestampNanoPrecision() {
- return 9;
- }
-
- public TypeFacility getTypeFacility() {
- return typeFacility;
- }
-
- /**
- * This is a generic implementation. Because different databases handle
- * stored procedures differently, subclasses should override this method
- * if necessary.
- */
- public ResultSet executeStoredProcedure(CallableStatement statement, TranslatedCommand command, Class<?> returnType) throws SQLException {
- List params = command.getPreparedValues();
- int index = 1;
-
- if(returnType != null){
- registerSpecificTypeOfOutParameter(statement, returnType, index++);
- }
-
- Iterator iter = params.iterator();
- while(iter.hasNext()){
- Argument param = (Argument)iter.next();
-
- if(param.getDirection() == Direction.INOUT){
- registerSpecificTypeOfOutParameter(statement,param.getType(), index);
- }else if(param.getDirection() == Direction.OUT){
- registerSpecificTypeOfOutParameter(statement,param.getType(), index++);
- }
-
- if(param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT){
- bindValue(statement, param.getArgumentValue().getValue(), param.getType(), index++);
- }
- }
- boolean resultSetNext = statement.execute();
-
- while (!resultSetNext) {
- int update_count = statement.getUpdateCount();
- if (update_count == -1) {
- break;
- }
- resultSetNext = statement.getMoreResults();
- }
- return statement.getResultSet();
- }
-
- /**
- * For registering specific output parameter types we need to translate these into the appropriate
- * java.sql.Types output parameters
- * We will need to match these up with the appropriate standard sql types
- * @param cstmt
- * @param parameter
- * @throws SQLException
- */
- protected void registerSpecificTypeOfOutParameter(CallableStatement statement, Class<?> runtimeType, int index) throws SQLException {
- int typeToSet = TypeFacility.getSQLTypeFromRuntimeType(runtimeType);
-
- statement.registerOutParameter(index,typeToSet);
- }
-
- /**
- * Sets prepared statement parameter i with param.
- *
- * Performs special handling to translate dates using the database time zone and to
- * translate biginteger, float, and char to JDBC safe objects.
- *
- * @param stmt
- * @param param
- * @param paramType
- * @param i
- * @param cal
- * @throws SQLException
- */
- public void bindValue(PreparedStatement stmt, Object param, Class<?> paramType, int i) throws SQLException {
- int type = TypeFacility.getSQLTypeFromRuntimeType(paramType);
-
- if (param == null) {
- stmt.setNull(i, type);
- return;
- }
- //if this is a Date object, then use the database calendar
- if (paramType.equals(TypeFacility.RUNTIME_TYPES.DATE)) {
- stmt.setDate(i,(java.sql.Date)param, getDatabaseCalendar());
- return;
- }
- if (paramType.equals(TypeFacility.RUNTIME_TYPES.TIME)) {
- stmt.setTime(i,(java.sql.Time)param, getDatabaseCalendar());
- return;
- }
- if (paramType.equals(TypeFacility.RUNTIME_TYPES.TIMESTAMP)) {
- stmt.setTimestamp(i,(java.sql.Timestamp)param, getDatabaseCalendar());
- return;
- }
- //convert these the following to jdbc safe values
- if (TypeFacility.RUNTIME_TYPES.BIG_INTEGER.equals(paramType)) {
- param = new BigDecimal((BigInteger)param);
- } else if (TypeFacility.RUNTIME_TYPES.FLOAT.equals(paramType)) {
- param = new Double(((Float)param).doubleValue());
- } else if (TypeFacility.RUNTIME_TYPES.CHAR.equals(paramType)) {
- param = ((Character)param).toString();
- }
- stmt.setObject(i, param, type);
- }
-
- /**
- * Retrieve the value on the current resultset row for the given column index.
- * @param results
- * @param columnIndex
- * @param expectedType
- * @return
- * @throws SQLException
- */
- public Object retrieveValue(ResultSet results, int columnIndex, Class<?> expectedType) throws SQLException {
- Integer code = TYPE_CODE_MAP.get(expectedType);
- if(code != null) {
- // Calling the specific methods here is more likely to get uniform (and fast) results from different
- // data sources as the driver likely knows the best and fastest way to convert from the underlying
- // raw form of the data to the expected type. We use a switch with codes in order without gaps
- // as there is a special bytecode instruction that treats this case as a map such that not every value
- // needs to be tested, which means it is very fast.
- switch(code.intValue()) {
- case INTEGER_CODE: {
- int value = results.getInt(columnIndex);
- if(results.wasNull()) {
- return null;
- }
- return Integer.valueOf(value);
- }
- case LONG_CODE: {
- long value = results.getLong(columnIndex);
- if(results.wasNull()) {
- return null;
- }
- return Long.valueOf(value);
- }
- case DOUBLE_CODE: {
- double value = results.getDouble(columnIndex);
- if(results.wasNull()) {
- return null;
- }
- return Double.valueOf(value);
- }
- case BIGDECIMAL_CODE: {
- return results.getBigDecimal(columnIndex);
- }
- case SHORT_CODE: {
- short value = results.getShort(columnIndex);
- if(results.wasNull()) {
- return null;
- }
- return Short.valueOf(value);
- }
- case FLOAT_CODE: {
- float value = results.getFloat(columnIndex);
- if(results.wasNull()) {
- return null;
- }
- return Float.valueOf(value);
- }
- case TIME_CODE: {
- return results.getTime(columnIndex, getDatabaseCalendar());
- }
- case DATE_CODE: {
- return results.getDate(columnIndex, getDatabaseCalendar());
- }
- case TIMESTAMP_CODE: {
- return results.getTimestamp(columnIndex, getDatabaseCalendar());
- }
- case BLOB_CODE: {
- try {
- return results.getBlob(columnIndex);
- } catch (SQLException e) {
- // ignore
- }
- try {
- return results.getBytes(columnIndex);
- } catch (SQLException e) {
- // ignore
- }
- break;
- }
- case CLOB_CODE: {
- try {
- return results.getClob(columnIndex);
- } catch (SQLException e) {
- // ignore
- }
- break;
- }
- case BOOLEAN_CODE: {
- return results.getBoolean(columnIndex);
- }
- }
- }
-
- return results.getObject(columnIndex);
- }
-
- /**
- * Retrieve the value for the given parameter index
- * @param results
- * @param parameterIndex
- * @param expectedType
- * @return
- * @throws SQLException
- */
- public Object retrieveValue(CallableStatement results, int parameterIndex, Class expectedType) throws SQLException{
- Integer code = TYPE_CODE_MAP.get(expectedType);
- if(code != null) {
- switch(code.intValue()) {
- case INTEGER_CODE: {
- int value = results.getInt(parameterIndex);
- if(results.wasNull()) {
- return null;
- }
- return Integer.valueOf(value);
- }
- case LONG_CODE: {
- long value = results.getLong(parameterIndex);
- if(results.wasNull()) {
- return null;
- }
- return Long.valueOf(value);
- }
- case DOUBLE_CODE: {
- double value = results.getDouble(parameterIndex);
- if(results.wasNull()) {
- return null;
- }
- return new Double(value);
- }
- case BIGDECIMAL_CODE: {
- return results.getBigDecimal(parameterIndex);
- }
- case SHORT_CODE: {
- short value = results.getShort(parameterIndex);
- if(results.wasNull()) {
- return null;
- }
- return Short.valueOf(value);
- }
- case FLOAT_CODE: {
- float value = results.getFloat(parameterIndex);
- if(results.wasNull()) {
- return null;
- }
- return new Float(value);
- }
- case TIME_CODE: {
- return results.getTime(parameterIndex, getDatabaseCalendar());
- }
- case DATE_CODE: {
- return results.getDate(parameterIndex, getDatabaseCalendar());
- }
- case TIMESTAMP_CODE: {
- return results.getTimestamp(parameterIndex, getDatabaseCalendar());
- }
- case BLOB_CODE: {
- try {
- return results.getBlob(parameterIndex);
- } catch (SQLException e) {
- // ignore
- }
- try {
- return results.getBytes(parameterIndex);
- } catch (SQLException e) {
- // ignore
- }
- }
- case CLOB_CODE: {
- try {
- return results.getClob(parameterIndex);
- } catch (SQLException e) {
- // ignore
- }
- }
- case BOOLEAN_CODE: {
- return results.getBoolean(parameterIndex);
- }
- }
- }
-
- // otherwise fall through and call getObject() and rely on the normal
- // translation routines
- return results.getObject(parameterIndex);
- }
-
- /**
- * Called exactly once for this source.
- * @param connection
- */
- protected void afterInitialConnectionCreation(Connection connection) {
- // now dig some details about this driver/database for log.
- try {
- StringBuffer sb = new StringBuffer();
- DatabaseMetaData dbmd = connection.getMetaData();
- sb.append("Commit=").append(connection.getAutoCommit()); //$NON-NLS-1$
- sb.append(";DatabaseProductName=").append(dbmd.getDatabaseProductName()); //$NON-NLS-1$
- sb.append(";DatabaseProductVersion=").append(dbmd.getDatabaseProductVersion()); //$NON-NLS-1$
- sb.append(";DriverMajorVersion=").append(dbmd.getDriverMajorVersion()); //$NON-NLS-1$
- sb.append(";DriverMajorVersion=").append(dbmd.getDriverMinorVersion()); //$NON-NLS-1$
- sb.append(";DriverName=").append(dbmd.getDriverName()); //$NON-NLS-1$
- sb.append(";DriverVersion=").append(dbmd.getDriverVersion()); //$NON-NLS-1$
- sb.append(";IsolationLevel=").append(dbmd.getDefaultTransactionIsolation()); //$NON-NLS-1$
-
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, sb.toString());
- } catch (SQLException e) {
- String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_jdbc_connection_details"); //$NON-NLS-1$
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, errorStr);
- }
- }
-
- /**
- * Provides a hook to call source specific logic when
- * a connection is created.
- *
- * defect request 13979 & 13978
- */
- public void afterConnectionCreation(Connection connection) {
- if (initialConnection) {
- synchronized (this) {
- if (!initialConnection) {
- return;
- }
- initialConnection = false;
- afterInitialConnectionCreation(connection);
- }
- }
- }
-
-
-
- /**
- * Create the {@link SQLConversionVisitor} that will perform translation. Typical custom
- * JDBC connectors will not need to create custom conversion visitors, rather implementors
- * should override existing {@link Translator} methods.
- * @return
- */
- public SQLConversionVisitor getSQLConversionVisitor() {
- return new SQLConversionVisitor(this);
- }
-
- /**
- * Get the default capabilities class. Will be used by {@link #getConnectorCapabilities()} to
- * return a capabilities instance.
- * @return
- */
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return JDBCCapabilities.class;
- }
-
- /**
- * Get the capabilties for the source.
- * @return
- * @throws ConnectorException
- */
- public ConnectorCapabilities getConnectorCapabilities() throws ConnectorException {
- // create Capabilities
- String className = this.environment.getCapabilitiesClass();
- try {
- ConnectorCapabilities result = null;
- if (className != null && className.length() > 0) {
- result = (ConnectorCapabilities) ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
- } else {
- result = getDefaultCapabilities().newInstance();
- }
-
- return result;
- } catch (Exception e) {
- throw new ConnectorException(e);
- }
- }
-
- /**
- * Set to true to indicate that every branch of a join
- * should have parenthesis.
- * @return
- */
- public boolean useParensForJoins() {
- return false;
- }
-
- /**
- * get the default null ordering
- * @return
- */
- public NullOrder getDefaultNullOrder() {
- return NullOrder.LOW;
- }
-
- /**
- *
- * @return true if nulls high|low can be specified
- */
- public boolean supportsExplicitNullOrdering() {
- return false;
- }
-
- /**
- *
- * @return true if the limit clause is part of the select
- */
- public boolean useSelectLimit() {
- return false;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,46 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.access;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-public class AccessCapabilities extends JDBCCapabilities{
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return false;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- @Override
- public boolean supportsInsertWithQueryExpression() {
- return false;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,87 @@
+/*
+ * 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.access;
+
+import java.util.List;
+
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.sybase.SybaseExecutionFactory;
+
+
+public class AccessExecutionFactory extends SybaseExecutionFactory {
+
+ @Override
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ if(booleanValue.booleanValue()) {
+ return "-1"; //$NON-NLS-1$
+ }
+ return "0"; //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean addSourceComment() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return false;
+ }
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return JDBCExecutionFactory.DEFAULT_MAX_IN_CRITERIA;
+ }
+
+ @Override
+ public int getMaxFromGroups() {
+ return DEFAULT_MAX_FROM_GROUPS;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ return getDefaultSupportedFunctions();
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,51 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.access;
-
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
-
-
-public class AccessSQLTranslator extends SybaseSQLTranslator {
-
- @Override
- public String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "-1"; //$NON-NLS-1$
- }
- return "0"; //$NON-NLS-1$
- }
-
- @Override
- public boolean addSourceComment() {
- return false;
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return AccessCapabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.db2;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-/**
- */
-public class DB2Capabilities extends JDBCCapabilities {
-
- public DB2Capabilities() {
- }
-
- /**
- * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("CEILING"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- //supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- //supportedFunctions.add("INITCAP"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LOCATE"); //$NON-NLS-1$
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- //supportedFunctions.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("RAND"); //$NON-NLS-1$
- supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- //supportedFunctions.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- //supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("DAY"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
- supportedFunctions.add("COALESCE"); //$NON-NLS-1$
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
- */
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
- */
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -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.db2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.Join;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.Join.JoinType;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.LocateFunctionModifier;
+import org.teiid.translator.jdbc.ModFunctionModifier;
+
+public class DB2ExecutionFactory extends JDBCExecutionFactory {
+
+ private final class NullHandlingFormatModifier extends
+ ConvertModifier.FormatModifier {
+ private NullHandlingFormatModifier(String alias) {
+ super(alias);
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ Expression arg = function.getParameters().get(0);
+ if (arg instanceof Literal && ((Literal)arg).getValue() == null) {
+ ((Literal)function.getParameters().get(1)).setValue(this.alias);
+ return null;
+ }
+ return super.translate(function);
+ }
+ }
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("MOD", getLanguageFactory())); //$NON-NLS-1$
+
+ //add in type conversion
+ ConvertModifier convertModifier = new ConvertModifier();
+ convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(31,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(31,12)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convertModifier.addTypeMapping("blob", FunctionModifier.BLOB, FunctionModifier.OBJECT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("clob", FunctionModifier.CLOB, FunctionModifier.XML); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("timestamp('1970-01-01', ", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("timestamp(",function.getParameters().get(0), ", '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ //the next convert is not strictly necessary for db2, but it also works for derby
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(double(", function.getParameters().get(0), ") as real)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("char"), FunctionModifier.STRING); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("smallint"), FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("integer"), FunctionModifier.INTEGER); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("bigint"), FunctionModifier.LONG); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("double"), FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("date"), FunctionModifier.DATE); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("time"), FunctionModifier.TIME); //$NON-NLS-1$
+ convertModifier.addTypeConversion(new NullHandlingFormatModifier("timestamp"), FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convertModifier.addNumericBooleanConversions();
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ return Arrays.asList("FETCH FIRST ", limit.getRowLimit(), " ROWS ONLY"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public List<?> translate(LanguageObject obj, ExecutionContext context) {
+ //DB2 doesn't support cross join
+ if (obj instanceof Join) {
+ Join join = (Join)obj;
+ if (join.getJoinType() == JoinType.CROSS_JOIN) {
+ Literal one = getLanguageFactory().createLiteral(1, TypeFacility.RUNTIME_TYPES.INTEGER);
+ join.setCondition(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one));
+ join.setJoinType(JoinType.INNER_JOIN);
+ }
+ }
+ //DB2 needs projected nulls wrapped in casts
+ if (obj instanceof DerivedColumn) {
+ DerivedColumn selectSymbol = (DerivedColumn)obj;
+ if (selectSymbol.getExpression() instanceof Literal) {
+ Literal literal = (Literal)selectSymbol.getExpression();
+ if (literal.getValue() == null) {
+ selectSymbol.setExpression(ConvertModifier.createConvertFunction(getLanguageFactory(), literal, TypeFacility.getDataTypeName(literal.getType())));
+ }
+ }
+ }
+ return super.translate(obj, context);
+ }
+
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.HIGH;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("CEILING"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ //supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ //supportedFunctions.add("INITCAP"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LOWER"); //$NON-NLS-1$
+ //supportedFunctions.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("RAND"); //$NON-NLS-1$
+ supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ //supportedFunctions.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ //supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("UPPER"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("DAY"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,159 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.db2;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.Join;
-import org.teiid.language.LanguageObject;
-import org.teiid.language.Limit;
-import org.teiid.language.Literal;
-import org.teiid.language.Comparison.Operator;
-import org.teiid.language.Join.JoinType;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.AliasModifier;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.LocateFunctionModifier;
-import org.teiid.translator.jdbc.ModFunctionModifier;
-import org.teiid.translator.jdbc.Translator;
-
-public class DB2SQLTranslator extends Translator {
-
- private final class NullHandlingFormatModifier extends
- ConvertModifier.FormatModifier {
- private NullHandlingFormatModifier(String alias) {
- super(alias);
- }
-
- @Override
- public List<?> translate(Function function) {
- Expression arg = function.getParameters().get(0);
- if (arg instanceof Literal && ((Literal)arg).getValue() == null) {
- ((Literal)function.getParameters().get(1)).setValue(this.alias);
- return null;
- }
- return super.translate(function);
- }
- }
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$
-
- registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("MOD", getLanguageFactory())); //$NON-NLS-1$
-
- //add in type conversion
- ConvertModifier convertModifier = new ConvertModifier();
- convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(31,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(31,12)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convertModifier.addTypeMapping("blob", FunctionModifier.BLOB, FunctionModifier.OBJECT); //$NON-NLS-1$
- convertModifier.addTypeMapping("clob", FunctionModifier.CLOB, FunctionModifier.XML); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("timestamp('1970-01-01', ", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.TIMESTAMP, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("timestamp(",function.getParameters().get(0), ", '00:00:00')"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- //the next convert is not strictly necessary for db2, but it also works for derby
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.FLOAT, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(double(", function.getParameters().get(0), ") as real)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("char"), FunctionModifier.STRING); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("smallint"), FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("integer"), FunctionModifier.INTEGER); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("bigint"), FunctionModifier.LONG); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("double"), FunctionModifier.DOUBLE); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("date"), FunctionModifier.DATE); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("time"), FunctionModifier.TIME); //$NON-NLS-1$
- convertModifier.addTypeConversion(new NullHandlingFormatModifier("timestamp"), FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convertModifier.addNumericBooleanConversions();
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List<?> translateLimit(Limit limit, ExecutionContext context) {
- return Arrays.asList("FETCH FIRST ", limit.getRowLimit(), " ROWS ONLY"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- public List<?> translate(LanguageObject obj, ExecutionContext context) {
- //DB2 doesn't support cross join
- if (obj instanceof Join) {
- Join join = (Join)obj;
- if (join.getJoinType() == JoinType.CROSS_JOIN) {
- Literal one = getLanguageFactory().createLiteral(1, TypeFacility.RUNTIME_TYPES.INTEGER);
- join.setCondition(getLanguageFactory().createCompareCriteria(Operator.EQ, one, one));
- join.setJoinType(JoinType.INNER_JOIN);
- }
- }
- //DB2 needs projected nulls wrapped in casts
- if (obj instanceof DerivedColumn) {
- DerivedColumn selectSymbol = (DerivedColumn)obj;
- if (selectSymbol.getExpression() instanceof Literal) {
- Literal literal = (Literal)selectSymbol.getExpression();
- if (literal.getValue() == null) {
- selectSymbol.setExpression(ConvertModifier.createConvertFunction(getLanguageFactory(), literal, TypeFacility.getDataTypeName(literal.getType())));
- }
- }
- }
- return super.translate(obj, context);
- }
-
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return DB2Capabilities.class;
- }
-
- @Override
- public NullOrder getDefaultNullOrder() {
- return NullOrder.HIGH;
- }
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,192 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.derby;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-
-/**
- * @since 5.0
- */
-public class DerbyCapabilities extends JDBCCapabilities {
-
- public static final String TEN_1 = "10.1"; //$NON-NLS-1$
- public static final String TEN_2 = "10.2"; //$NON-NLS-1$
- public static final String TEN_4 = "10.4"; //$NON-NLS-1$
- public static final String TEN_5 = "10.5"; //$NON-NLS-1$
-
- private String version = TEN_1;
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- if (version.compareTo(TEN_2) >= 0) {
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- }
- if (version.compareTo(TEN_4) >= 0) {
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- }
- // These are executed within the server and never pushed down
- //supportedFunctions.add("BITAND"); //$NON-NLS-1$
- //supportedFunctions.add("BITNOT"); //$NON-NLS-1$
- //supportedFunctions.add("BITOR"); //$NON-NLS-1$
- //supportedFunctions.add("BITXOR"); //$NON-NLS-1$
- if (version.compareTo(TEN_2) >= 0) {
- supportedFunctions.add("CEILING"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- }
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- if (version.compareTo(TEN_2) >= 0) {
- supportedFunctions.add("PI"); //$NON-NLS-1$
- //supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- //supportedFunctions.add("ROUND"); //$NON-NLS-1$
- if (version.compareTo(TEN_4) >= 0) {
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- }
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- }
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- //supportedFunctions.add("TAN"); //$NON-NLS-1$
-
- //supportedFunctions.add("ASCII"); //$NON-NLS-1$
- //supportedFunctions.add("CHR"); //$NON-NLS-1$
- //supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- //supportedFunctions.add("INSERT"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LOCATE"); //$NON-NLS-1$
- //supportedFunctions.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- //supportedFunctions.add("REPEAT"); //$NON-NLS-1$
- //supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- //supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- //supportedFunctions.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
-
- // These are executed within the server and never pushed down
- //supportedFunctions.add("CURDATE"); //$NON-NLS-1$
- //supportedFunctions.add("CURTIME"); //$NON-NLS-1$
- //supportedFunctions.add("NOW"); //$NON-NLS-1$
- //supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- //supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- //supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
-
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- //supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
-
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
-// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
-// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
- //supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
- //supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
-
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("COALESCE"); //$NON-NLS-1$
- return supportedFunctions;
- }
-
- public void setDatabaseVersion(String version) {
- this.version = version;
- }
-
- /**
- * Derby supports only SearchedCaseExpression, not CaseExpression.
- * @see org.teiid.translator.ConnectorCapabilities#supportsCaseExpressions()
- * @since 5.0
- */
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- /**
- * Derby supports only left and right outer joins.
- * @see org.teiid.translator.ConnectorCapabilities#supportsFullOuterJoins()
- * @since 5.0
- */
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- /**
- * Inline views (subqueries in the FROM clause) are supported.
- * @see org.teiid.translator.ConnectorCapabilities#supportsInlineViews()
- * @since 4.3
- */
- public boolean supportsInlineViews() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
- */
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
- */
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
- @Override
- public boolean supportsRowLimit() {
- return this.version.compareTo(TEN_5) >= 0;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,206 @@
+/*
+ * 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.derby;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.jdbc.EscapeSyntaxModifier;
+import org.teiid.translator.jdbc.db2.DB2ExecutionFactory;
+import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
+
+
+
+/**
+ * @since 4.3
+ */
+public class DerbyExecutionFactory extends DB2ExecutionFactory {
+
+ public static final String TEN_1 = "10.1"; //$NON-NLS-1$
+ public static final String TEN_2 = "10.2"; //$NON-NLS-1$
+ public static final String TEN_4 = "10.4"; //$NON-NLS-1$
+ public static final String TEN_5 = "10.5"; //$NON-NLS-1$
+
+ private String version = TEN_1;
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ //additional derby functions
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+
+ //overrides of db2 functions
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier());
+ }
+
+ @Override
+ public boolean addSourceComment() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsExplicitNullOrdering() {
+ return version.compareTo(TEN_4) >= 0;
+ }
+
+ @TranslatorProperty(name="DatabaseVersion", description= "Version of the postgres", defaultValue=TEN_1)
+ public String getDatabaseVersion() {
+ return this.version;
+ }
+
+ public void setDatabaseVersion(String version) {
+ this.version = version;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getDefaultSupportedFunctions());
+
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ if (version.compareTo(TEN_2) >= 0) {
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ }
+ if (version.compareTo(TEN_4) >= 0) {
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ }
+ // These are executed within the server and never pushed down
+ //supportedFunctions.add("BITAND"); //$NON-NLS-1$
+ //supportedFunctions.add("BITNOT"); //$NON-NLS-1$
+ //supportedFunctions.add("BITOR"); //$NON-NLS-1$
+ //supportedFunctions.add("BITXOR"); //$NON-NLS-1$
+ if (version.compareTo(TEN_2) >= 0) {
+ supportedFunctions.add("CEILING"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ }
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ if (version.compareTo(TEN_2) >= 0) {
+ supportedFunctions.add("PI"); //$NON-NLS-1$
+ //supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ //supportedFunctions.add("ROUND"); //$NON-NLS-1$
+ if (version.compareTo(TEN_4) >= 0) {
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ }
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ }
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ //supportedFunctions.add("TAN"); //$NON-NLS-1$
+
+ //supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ //supportedFunctions.add("CHR"); //$NON-NLS-1$
+ //supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ //supportedFunctions.add("INSERT"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ //supportedFunctions.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ //supportedFunctions.add("REPEAT"); //$NON-NLS-1$
+ //supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ //supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ //supportedFunctions.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+
+ // These are executed within the server and never pushed down
+ //supportedFunctions.add("CURDATE"); //$NON-NLS-1$
+ //supportedFunctions.add("CURTIME"); //$NON-NLS-1$
+ //supportedFunctions.add("NOW"); //$NON-NLS-1$
+ //supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ //supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ //supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ //supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
+// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
+// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
+ //supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ //supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+ return supportedFunctions;
+ }
+
+ /**
+ * Derby supports only SearchedCaseExpression, not CaseExpression.
+ * @see org.teiid.translator.ConnectorCapabilities#supportsCaseExpressions()
+ * @since 5.0
+ */
+ @Override
+ public boolean supportsCaseExpressions() {
+ return false;
+ }
+
+ /**
+ * Derby supports only left and right outer joins.
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFullOuterJoins()
+ * @since 5.0
+ */
+ @Override
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return this.version.compareTo(TEN_5) >= 0;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return false;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,73 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.derby;
-
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.EscapeSyntaxModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
-import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
-
-
-
-/**
- * @since 4.3
- */
-public class DerbySQLTranslator extends DB2SQLTranslator {
-
- private String version = DerbyCapabilities.TEN_1;
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- //additional derby functions
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
-
- //overrides of db2 functions
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new EscapeSyntaxModifier());
- }
-
- @Override
- public boolean addSourceComment() {
- return false;
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return DerbyCapabilities.class;
- }
-
- @Override
- public boolean supportsExplicitNullOrdering() {
- return version.compareTo(DerbyCapabilities.TEN_4) >= 0;
- }
-
- public void setDatabaseVersion(String version) {
- this.version = version;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.h2;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-public class H2Capabilities extends JDBCCapabilities {
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
- supportedFunctions.add(SourceSystemFunctions.ABS);
- supportedFunctions.add(SourceSystemFunctions.ACOS);
- supportedFunctions.add(SourceSystemFunctions.ASIN);
- supportedFunctions.add(SourceSystemFunctions.ATAN);
- supportedFunctions.add(SourceSystemFunctions.ATAN2);
- supportedFunctions.add(SourceSystemFunctions.BITAND);
- //supportedFunctions.add(SourceSystemFunctions.BITNOT);
- supportedFunctions.add(SourceSystemFunctions.BITOR);
- supportedFunctions.add(SourceSystemFunctions.BITXOR);
- supportedFunctions.add(SourceSystemFunctions.CEILING);
- 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.LOG10);
- supportedFunctions.add(SourceSystemFunctions.MOD);
- supportedFunctions.add(SourceSystemFunctions.PI);
- supportedFunctions.add(SourceSystemFunctions.POWER);
- supportedFunctions.add(SourceSystemFunctions.RADIANS);
- supportedFunctions.add(SourceSystemFunctions.ROUND);
- supportedFunctions.add(SourceSystemFunctions.SIGN);
- supportedFunctions.add(SourceSystemFunctions.SIN);
- supportedFunctions.add(SourceSystemFunctions.SQRT);
- supportedFunctions.add(SourceSystemFunctions.TAN);
-
- supportedFunctions.add(SourceSystemFunctions.ASCII);
- supportedFunctions.add(SourceSystemFunctions.CHAR);
- supportedFunctions.add(SourceSystemFunctions.CONCAT);
- supportedFunctions.add(SourceSystemFunctions.INSERT);
- supportedFunctions.add(SourceSystemFunctions.LCASE);
- supportedFunctions.add(SourceSystemFunctions.LEFT);
- supportedFunctions.add(SourceSystemFunctions.LENGTH);
- supportedFunctions.add(SourceSystemFunctions.LOCATE);
- supportedFunctions.add(SourceSystemFunctions.LPAD);
- supportedFunctions.add(SourceSystemFunctions.LTRIM);
- supportedFunctions.add(SourceSystemFunctions.REPEAT);
- supportedFunctions.add(SourceSystemFunctions.REPLACE);
- supportedFunctions.add(SourceSystemFunctions.RIGHT);
- supportedFunctions.add(SourceSystemFunctions.RPAD);
- supportedFunctions.add(SourceSystemFunctions.RTRIM);
- supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
- supportedFunctions.add(SourceSystemFunctions.UCASE);
-
- supportedFunctions.add(SourceSystemFunctions.DAYNAME);
- supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
- supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
- supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
-
- supportedFunctions.add(SourceSystemFunctions.FORMATTIMESTAMP);
- supportedFunctions.add(SourceSystemFunctions.HOUR);
- supportedFunctions.add(SourceSystemFunctions.MINUTE);
- supportedFunctions.add(SourceSystemFunctions.MONTH);
- supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
-
- supportedFunctions.add(SourceSystemFunctions.PARSETIMESTAMP);
- supportedFunctions.add(SourceSystemFunctions.QUARTER);
- supportedFunctions.add(SourceSystemFunctions.SECOND);
- supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
- supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
- //supportedFunctions.add(SourceSystemFunctions.TIMESTAMPCREATE);
- supportedFunctions.add(SourceSystemFunctions.WEEK);
- supportedFunctions.add(SourceSystemFunctions.YEAR);
-
- supportedFunctions.add(SourceSystemFunctions.CONVERT);
- supportedFunctions.add(SourceSystemFunctions.IFNULL);
- supportedFunctions.add(SourceSystemFunctions.COALESCE);
- return supportedFunctions;
- }
-
- @Override
- public boolean supportsInlineViews() {
- return true;
- }
-
- @Override
- public boolean supportsRowLimit() {
- return true;
- }
-
- @Override
- public boolean supportsRowOffset() {
- return true;
- }
-
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2ExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,191 @@
+/*
+ * 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.h2;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.ModFunctionModifier;
+import org.teiid.translator.jdbc.hsql.AddDiffModifier;
+import org.teiid.translator.jdbc.oracle.ConcatFunctionModifier;
+
+public class H2ExecutionFactory extends JDBCExecutionFactory {
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ registerFunctionModifier(SourceSystemFunctions.PARSETIMESTAMP, new AliasModifier("parsedatetime")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.FORMATTIMESTAMP, new AliasModifier("formatdatetime")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day_of_month")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new AliasModifier("day_of_week")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new AliasModifier("day_of_year")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(SourceSystemFunctions.MOD, getLanguageFactory()));
+ //TODO: this behavior is configurable in h2 starting with 1.1.119
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
+
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new AddDiffModifier(true, getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new AddDiffModifier(false, getLanguageFactory()));
+
+ ConvertModifier convert = new ConvertModifier();
+ convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
+ convert.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+ convert.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+ convert.addTypeMapping("double", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convert.addTypeMapping("decimal(38,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+ convert.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+ convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convert.addTypeMapping("varchar", FunctionModifier.STRING); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.BITAND);
+ //supportedFunctions.add(SourceSystemFunctions.BITNOT);
+ supportedFunctions.add(SourceSystemFunctions.BITOR);
+ supportedFunctions.add(SourceSystemFunctions.BITXOR);
+ supportedFunctions.add(SourceSystemFunctions.CEILING);
+ 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.LOG10);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.PI);
+ supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.RADIANS);
+ supportedFunctions.add(SourceSystemFunctions.ROUND);
+ supportedFunctions.add(SourceSystemFunctions.SIGN);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+
+ supportedFunctions.add(SourceSystemFunctions.ASCII);
+ supportedFunctions.add(SourceSystemFunctions.CHAR);
+ supportedFunctions.add(SourceSystemFunctions.CONCAT);
+ supportedFunctions.add(SourceSystemFunctions.INSERT);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LPAD);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.REPEAT);
+ supportedFunctions.add(SourceSystemFunctions.REPLACE);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RPAD);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+
+ supportedFunctions.add(SourceSystemFunctions.DAYNAME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
+
+ supportedFunctions.add(SourceSystemFunctions.FORMATTIMESTAMP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
+
+ supportedFunctions.add(SourceSystemFunctions.PARSETIMESTAMP);
+ supportedFunctions.add(SourceSystemFunctions.QUARTER);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
+ //supportedFunctions.add(SourceSystemFunctions.TIMESTAMPCREATE);
+ supportedFunctions.add(SourceSystemFunctions.WEEK);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.IFNULL);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.h2;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.AliasModifier;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.ModFunctionModifier;
-import org.teiid.translator.jdbc.Translator;
-import org.teiid.translator.jdbc.hsql.AddDiffModifier;
-import org.teiid.translator.jdbc.oracle.ConcatFunctionModifier;
-
-public class H2Translator extends Translator {
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.PARSETIMESTAMP, new AliasModifier("parsedatetime")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.FORMATTIMESTAMP, new AliasModifier("formatdatetime")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day_of_month")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new AliasModifier("day_of_week")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new AliasModifier("day_of_year")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(SourceSystemFunctions.MOD, getLanguageFactory()));
- //TODO: this behavior is configurable in h2 starting with 1.1.119
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
-
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new AddDiffModifier(true, getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new AddDiffModifier(false, getLanguageFactory()));
-
- ConvertModifier convert = new ConvertModifier();
- convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
- convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
- convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
- convert.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
- convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
- convert.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
- convert.addTypeMapping("double", FunctionModifier.DOUBLE); //$NON-NLS-1$
- convert.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
- convert.addTypeMapping("decimal(38,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convert.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
- convert.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
- convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convert.addTypeMapping("varchar", FunctionModifier.STRING); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
- }
-
- @Override
- public String translateLiteralDate(Date dateValue) {
- return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTime(Time timeValue) {
- return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return H2Capabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,133 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.hsql;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-public class HsqlCapabilities extends JDBCCapabilities {
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
- supportedFunctions.add(SourceSystemFunctions.ABS);
- supportedFunctions.add(SourceSystemFunctions.ACOS);
- supportedFunctions.add(SourceSystemFunctions.ASIN);
- supportedFunctions.add(SourceSystemFunctions.ATAN);
- supportedFunctions.add(SourceSystemFunctions.ATAN2);
- supportedFunctions.add(SourceSystemFunctions.BITAND);
- //supportedFunctions.add(SourceSystemFunctions.BITNOT);
- supportedFunctions.add(SourceSystemFunctions.BITOR);
- //supportedFunctions.add(SourceSystemFunctions.BITXOR);
- supportedFunctions.add(SourceSystemFunctions.CEILING);
- 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.LOG10);
- supportedFunctions.add(SourceSystemFunctions.MOD);
- supportedFunctions.add(SourceSystemFunctions.PI);
- supportedFunctions.add(SourceSystemFunctions.POWER);
- supportedFunctions.add(SourceSystemFunctions.RADIANS);
- supportedFunctions.add(SourceSystemFunctions.ROUND);
- supportedFunctions.add(SourceSystemFunctions.SIGN);
- supportedFunctions.add(SourceSystemFunctions.SIN);
- supportedFunctions.add(SourceSystemFunctions.SQRT);
- supportedFunctions.add(SourceSystemFunctions.TAN);
-
- supportedFunctions.add(SourceSystemFunctions.ASCII);
- supportedFunctions.add(SourceSystemFunctions.CHAR);
- supportedFunctions.add(SourceSystemFunctions.CONCAT);
- supportedFunctions.add(SourceSystemFunctions.INSERT);
- supportedFunctions.add(SourceSystemFunctions.LCASE);
- supportedFunctions.add(SourceSystemFunctions.LEFT);
- supportedFunctions.add(SourceSystemFunctions.LENGTH);
- supportedFunctions.add(SourceSystemFunctions.LOCATE);
- supportedFunctions.add(SourceSystemFunctions.LPAD);
- supportedFunctions.add(SourceSystemFunctions.LTRIM);
- supportedFunctions.add(SourceSystemFunctions.REPEAT);
- supportedFunctions.add(SourceSystemFunctions.REPLACE);
- supportedFunctions.add(SourceSystemFunctions.RIGHT);
- supportedFunctions.add(SourceSystemFunctions.RPAD);
- supportedFunctions.add(SourceSystemFunctions.RTRIM);
- supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
- supportedFunctions.add(SourceSystemFunctions.UCASE);
-
- supportedFunctions.add(SourceSystemFunctions.DAYNAME);
- supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
- supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
- supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
-
- //supportedFunctions.add(SourceSystemFunctions.FORMATDATE);
- //supportedFunctions.add(SourceSystemFunctions.FORMATTIME);
- //supportedFunctions.add(SourceSystemFunctions.FORMATTIMESTAMP);
- supportedFunctions.add(SourceSystemFunctions.HOUR);
- supportedFunctions.add(SourceSystemFunctions.MINUTE);
- supportedFunctions.add(SourceSystemFunctions.MONTH);
- supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
-
- //supportedFunctions.add(SourceSystemFunctions.PARSEDATE);
- //supportedFunctions.add(SourceSystemFunctions.PARSETIME);
- //supportedFunctions.add(SourceSystemFunctions.PARSETIMESTAMP);
- supportedFunctions.add(SourceSystemFunctions.QUARTER);
- supportedFunctions.add(SourceSystemFunctions.SECOND);
- supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
- supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
- supportedFunctions.add(SourceSystemFunctions.WEEK);
- supportedFunctions.add(SourceSystemFunctions.YEAR);
-
- supportedFunctions.add(SourceSystemFunctions.CONVERT);
- supportedFunctions.add(SourceSystemFunctions.IFNULL);
- supportedFunctions.add(SourceSystemFunctions.COALESCE);
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- public boolean supportsRowOffset() {
- return true;
- }
-
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,181 @@
+/*
+ * 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.hsql;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+public class HsqlExecutionFactory extends JDBCExecutionFactory {
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new AddDiffModifier(true, getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new AddDiffModifier(false, getLanguageFactory()));
+
+ ConvertModifier convert = new ConvertModifier();
+ convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
+ convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
+ convert.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+ convert.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+ convert.addTypeMapping("double", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convert.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convert.addTypeMapping("decimal(38,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convert.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+ convert.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+ convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convert.addTypeMapping("varchar", FunctionModifier.STRING); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.BITAND);
+ //supportedFunctions.add(SourceSystemFunctions.BITNOT);
+ supportedFunctions.add(SourceSystemFunctions.BITOR);
+ //supportedFunctions.add(SourceSystemFunctions.BITXOR);
+ supportedFunctions.add(SourceSystemFunctions.CEILING);
+ 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.LOG10);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.PI);
+ supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.RADIANS);
+ supportedFunctions.add(SourceSystemFunctions.ROUND);
+ supportedFunctions.add(SourceSystemFunctions.SIGN);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+
+ supportedFunctions.add(SourceSystemFunctions.ASCII);
+ supportedFunctions.add(SourceSystemFunctions.CHAR);
+ supportedFunctions.add(SourceSystemFunctions.CONCAT);
+ supportedFunctions.add(SourceSystemFunctions.INSERT);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LPAD);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.REPEAT);
+ supportedFunctions.add(SourceSystemFunctions.REPLACE);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RPAD);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+
+ supportedFunctions.add(SourceSystemFunctions.DAYNAME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
+
+ //supportedFunctions.add(SourceSystemFunctions.FORMATDATE);
+ //supportedFunctions.add(SourceSystemFunctions.FORMATTIME);
+ //supportedFunctions.add(SourceSystemFunctions.FORMATTIMESTAMP);
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
+
+ //supportedFunctions.add(SourceSystemFunctions.PARSEDATE);
+ //supportedFunctions.add(SourceSystemFunctions.PARSETIME);
+ //supportedFunctions.add(SourceSystemFunctions.PARSETIMESTAMP);
+ supportedFunctions.add(SourceSystemFunctions.QUARTER);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
+ supportedFunctions.add(SourceSystemFunctions.WEEK);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.IFNULL);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.hsql;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.Translator;
-
-public class HsqlTranslator extends Translator {
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new AddDiffModifier(true, getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new AddDiffModifier(false, getLanguageFactory()));
-
- ConvertModifier convert = new ConvertModifier();
- convert.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
- convert.addTypeMapping("tinyint", FunctionModifier.BYTE); //$NON-NLS-1$
- convert.addTypeMapping("smallint", FunctionModifier.SHORT); //$NON-NLS-1$
- convert.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
- convert.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
- convert.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
- convert.addTypeMapping("double", FunctionModifier.DOUBLE); //$NON-NLS-1$
- convert.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
- convert.addTypeMapping("decimal(38,0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convert.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
- convert.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
- convert.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convert.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convert.addTypeMapping("varchar", FunctionModifier.STRING); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convert);
- }
-
- @Override
- public String translateLiteralDate(Date dateValue) {
- return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTime(Time timeValue) {
- return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return HsqlCapabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.informix;
-
-import java.util.*;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-/**
- */
-public class InformixCapabilities extends JDBCCapabilities {
- /**
- * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List getSupportedFunctions() {
- List supportedFunctons = new ArrayList();
- supportedFunctons.addAll(super.getSupportedFunctions());
- supportedFunctons.add("CAST"); //$NON-NLS-1$
- supportedFunctons.add("CONVERT"); //$NON-NLS-1$
- return supportedFunctons;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,54 @@
+/*
+ * 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.informix;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+
+/**
+ */
+public class InformixExecutionFactory extends JDBCExecutionFactory {
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, new ConvertModifier());
+ }
+
+ @Override
+ public List getSupportedFunctions() {
+ List supportedFunctons = new ArrayList();
+ supportedFunctons.addAll(super.getSupportedFunctions());
+ supportedFunctons.add("CAST"); //$NON-NLS-1$
+ supportedFunctons.add("CONVERT"); //$NON-NLS-1$
+ return supportedFunctons;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,50 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.informix;
-
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.Translator;
-
-
-/**
- */
-public class InformixSQLTranslator extends Translator {
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.CONVERT, new ConvertModifier());
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return InformixCapabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,126 +0,0 @@
-/*
- * Copyright © 2000-2005 MetaMatrix, Inc. All rights reserved.
- */
-/*
- */
-package org.teiid.translator.jdbc.mm;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-/**
- * Capabilities compatible with MM 5.5.x
- */
-public class MMCapabilities extends JDBCCapabilities {
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("CEILING"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("FORMATBIGDECIMAL"); //$NON-NLS-1$
- supportedFunctions.add("FORMATBIGINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("FORMATDOUBLE"); //$NON-NLS-1$
- supportedFunctions.add("FORMATFLOAT"); //$NON-NLS-1$
- supportedFunctions.add("FORMATINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("FORMATLONG"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("PARSEBIGDECIMAL"); //$NON-NLS-1$
- supportedFunctions.add("PARSEBIGINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("PARSEDOUBLE"); //$NON-NLS-1$
- supportedFunctions.add("PARSEFLOAT"); //$NON-NLS-1$
- supportedFunctions.add("PARSEINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("PARSELONG"); //$NON-NLS-1$
- supportedFunctions.add("PI"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- supportedFunctions.add("RAND"); //$NON-NLS-1$
- supportedFunctions.add("ROUND"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT2"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("INITCAP"); //$NON-NLS-1$
- supportedFunctions.add("INSERT"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LOCATE"); //$NON-NLS-1$
- supportedFunctions.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("REPEAT"); //$NON-NLS-1$
- supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- supportedFunctions.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("CURDATE"); //$NON-NLS-1$
- supportedFunctions.add("CURTIME"); //$NON-NLS-1$
- supportedFunctions.add("NOW"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
- supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
- supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
- supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
- supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("MODIFYTIMEZONE"); //$NON-NLS-1$
- supportedFunctions.add("DECODESTRING"); //$NON-NLS-1$
- supportedFunctions.add("DECODEINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("USER"); //$NON-NLS-1$
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- public boolean supportsFunctionsInGroupBy() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- public boolean supportsRowOffset() {
- return true;
- }
-}
\ No newline at end of file
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MetaMatrixExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,130 @@
+/*
+ * Copyright © 2000-2005 MetaMatrix, Inc. All rights reserved.
+ */
+/*
+ */
+package org.teiid.translator.jdbc.mm;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+/**
+ * Capabilities compatible with MM 5.5.x
+ */
+public class MetaMatrixExecutionFactory extends JDBCExecutionFactory {
+
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("CEILING"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATBIGDECIMAL"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATBIGINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATDOUBLE"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATFLOAT"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATLONG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEBIGDECIMAL"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEBIGINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEDOUBLE"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEFLOAT"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("PARSELONG"); //$NON-NLS-1$
+ supportedFunctions.add("PI"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ supportedFunctions.add("RAND"); //$NON-NLS-1$
+ supportedFunctions.add("ROUND"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT2"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ supportedFunctions.add("INITCAP"); //$NON-NLS-1$
+ supportedFunctions.add("INSERT"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("REPEAT"); //$NON-NLS-1$
+ supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ supportedFunctions.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("CURDATE"); //$NON-NLS-1$
+ supportedFunctions.add("CURTIME"); //$NON-NLS-1$
+ supportedFunctions.add("NOW"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
+ supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
+ supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("MODIFYTIMEZONE"); //$NON-NLS-1$
+ supportedFunctions.add("DECODESTRING"); //$NON-NLS-1$
+ supportedFunctions.add("DECODEINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("USER"); //$NON-NLS-1$
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+}
\ No newline at end of file
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,49 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.mysql;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.SourceSystemFunctions;
-
-
-
-/**
- * @since 4.3
- */
-public class MySQL5Capabilities extends MySQLCapabilities {
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
- supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
- return supportedFunctions;
- }
-
- @Override
- public boolean supportsInlineViews() {
- return true;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5ExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,62 @@
+/*
+ * 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.mysql;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Function;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.FunctionModifier;
+
+public class MySQL5ExecutionFactory extends MySQLExecutionFactory {
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new FunctionModifier() {
+
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("char(", function.getParameters().get(0), " USING ASCII)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
+ supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.mysql;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.Function;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-
-public class MySQL5Translator extends MySQLTranslator {
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.CHAR, new FunctionModifier() {
-
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("char(", function.getParameters().get(0), " USING ASCII)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return MySQL5Capabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,282 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.mysql;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-
-/**
- * @since 4.3
- */
-public class MySQLCapabilities extends JDBCCapabilities {
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
- supportedFunctions.add(SourceSystemFunctions.ABS);
- supportedFunctions.add(SourceSystemFunctions.ACOS);
- supportedFunctions.add(SourceSystemFunctions.ASIN);
- supportedFunctions.add(SourceSystemFunctions.ATAN);
- supportedFunctions.add(SourceSystemFunctions.ATAN2);
- supportedFunctions.add(SourceSystemFunctions.BITAND);
- supportedFunctions.add(SourceSystemFunctions.BITNOT);
- supportedFunctions.add(SourceSystemFunctions.BITOR);
- supportedFunctions.add(SourceSystemFunctions.BITXOR);
- supportedFunctions.add(SourceSystemFunctions.CEILING);
- 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.LOG10);
- supportedFunctions.add(SourceSystemFunctions.MOD);
- supportedFunctions.add(SourceSystemFunctions.PI);
- supportedFunctions.add(SourceSystemFunctions.POWER);
- supportedFunctions.add(SourceSystemFunctions.RADIANS);
- supportedFunctions.add(SourceSystemFunctions.ROUND);
- supportedFunctions.add(SourceSystemFunctions.SIGN);
- supportedFunctions.add(SourceSystemFunctions.SIN);
- supportedFunctions.add(SourceSystemFunctions.SQRT);
- supportedFunctions.add(SourceSystemFunctions.TAN);
-
- supportedFunctions.add(SourceSystemFunctions.ASCII);
- supportedFunctions.add(SourceSystemFunctions.CHAR);
- supportedFunctions.add(SourceSystemFunctions.CONCAT);
- supportedFunctions.add(SourceSystemFunctions.INSERT);
- supportedFunctions.add(SourceSystemFunctions.LCASE);
- supportedFunctions.add(SourceSystemFunctions.LEFT);
- supportedFunctions.add(SourceSystemFunctions.LENGTH);
- supportedFunctions.add(SourceSystemFunctions.LOCATE);
- supportedFunctions.add(SourceSystemFunctions.LPAD);
- supportedFunctions.add(SourceSystemFunctions.LTRIM);
- supportedFunctions.add(SourceSystemFunctions.REPEAT);
- supportedFunctions.add(SourceSystemFunctions.REPLACE);
- supportedFunctions.add(SourceSystemFunctions.RIGHT);
- supportedFunctions.add(SourceSystemFunctions.RPAD);
- supportedFunctions.add(SourceSystemFunctions.RTRIM);
- supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
- supportedFunctions.add(SourceSystemFunctions.UCASE);
-
- // These are executed within the server and never pushed down
-// supportedFunctions.add("CURDATE"); //$NON-NLS-1$
-// supportedFunctions.add("CURTIME"); //$NON-NLS-1$
-// supportedFunctions.add("NOW"); //$NON-NLS-1$
- supportedFunctions.add(SourceSystemFunctions.DAYNAME);
- supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
- supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
- supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
-
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add(SourceSystemFunctions.HOUR);
- supportedFunctions.add(SourceSystemFunctions.MINUTE);
- supportedFunctions.add(SourceSystemFunctions.MONTH);
- supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
-
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
-// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
-// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add(SourceSystemFunctions.QUARTER);
- supportedFunctions.add(SourceSystemFunctions.SECOND);
-// supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
-// supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
- supportedFunctions.add(SourceSystemFunctions.WEEK);
- supportedFunctions.add(SourceSystemFunctions.YEAR);
-
- supportedFunctions.add(SourceSystemFunctions.CONVERT);
- supportedFunctions.add(SourceSystemFunctions.IFNULL);
- supportedFunctions.add(SourceSystemFunctions.COALESCE);
-
-// supportedFunctions.add("GREATEST"); //$NON-NLS-1$
-// supportedFunctions.add("ISNULL"); //$NON-NLS-1$
-// supportedFunctions.add("LEAST"); //$NON-NLS-1$
-// supportedFunctions.add("STRCMP"); // String-specific //$NON-NLS-1$
-//
-// // String
-// supportedFunctions.add("BIN"); //$NON-NLS-1$
-// supportedFunctions.add("BIT_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("CHAR_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("CHARACTER_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("COMPRESS"); //$NON-NLS-1$
-// supportedFunctions.add("CONCAT_WS"); //$NON-NLS-1$
-// supportedFunctions.add("CONV"); //$NON-NLS-1$
-// supportedFunctions.add("ELT"); //$NON-NLS-1$
-// supportedFunctions.add("EXPORT_SET"); //$NON-NLS-1$
-// supportedFunctions.add("FIELD"); //$NON-NLS-1$
-// supportedFunctions.add("FIND_IN_SET"); //$NON-NLS-1$
-// supportedFunctions.add("FORMAT"); //$NON-NLS-1$
-// supportedFunctions.add("HEX"); //$NON-NLS-1$
-// supportedFunctions.add("INSTR"); //$NON-NLS-1$
-// supportedFunctions.add("LOAD_FILE"); //$NON-NLS-1$
-// supportedFunctions.add("MAKE_SET"); //$NON-NLS-1$
-// supportedFunctions.add("MID"); //$NON-NLS-1$
-// supportedFunctions.add("OCT"); //$NON-NLS-1$
-// supportedFunctions.add("OCTET_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("ORD"); //$NON-NLS-1$
-// supportedFunctions.add("QUOTE"); //$NON-NLS-1$
-// supportedFunctions.add("REVERSE"); //$NON-NLS-1$
-// supportedFunctions.add("SOUNDEX"); //$NON-NLS-1$
-// supportedFunctions.add("SPACE"); //$NON-NLS-1$
-// supportedFunctions.add("SUBSTR"); //$NON-NLS-1$
-// supportedFunctions.add("SUBSTRING_INDEX"); //$NON-NLS-1$
-// supportedFunctions.add("TRIM"); //$NON-NLS-1$
-// supportedFunctions.add("UNCOMPRESS"); //$NON-NLS-1$
-// supportedFunctions.add("UNHEX"); //$NON-NLS-1$
-//
-// // Math
-// supportedFunctions.add("CEIL"); //$NON-NLS-1$
-// supportedFunctions.add("CRC32"); //$NON-NLS-1$
-// // DIV is an operator equivalent to '/'
-// supportedFunctions.add("DIV"); //$NON-NLS-1$
-// supportedFunctions.add("FORMAT"); //$NON-NLS-1$
-// supportedFunctions.add("LN"); //$NON-NLS-1$
-// supportedFunctions.add("LOG2"); //$NON-NLS-1$
-// supportedFunctions.add("POW"); //$NON-NLS-1$
-// supportedFunctions.add("RAND"); //$NON-NLS-1$
-// supportedFunctions.add("TRUNCATE"); //$NON-NLS-1$
-//
-// // Date / Time
-// supportedFunctions.add("ADDDATE"); //$NON-NLS-1$
-// supportedFunctions.add("ADDTIME"); //$NON-NLS-1$
-// supportedFunctions.add("CONVERT_TZ"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_DATE"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_TIME"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_TIMESTAMP"); //$NON-NLS-1$
-// supportedFunctions.add("DATE"); //$NON-NLS-1$
-// supportedFunctions.add("DATEDIFF"); //$NON-NLS-1$
-//// supportedFunctions.add("DATE_ADD");
-//// supportedFunctions.add("DATE_SUB");
-// supportedFunctions.add("DATE_FORMAT"); //$NON-NLS-1$
-// supportedFunctions.add("DAY"); //$NON-NLS-1$
-//// supportedFunctions.add("EXTRACT");
-// supportedFunctions.add("FROM_DAYS"); //$NON-NLS-1$
-// supportedFunctions.add("FROM_UNIXTIME"); //$NON-NLS-1$
-// supportedFunctions.add("GET_FORMAT"); //$NON-NLS-1$
-// supportedFunctions.add("LAST_DAY"); //$NON-NLS-1$
-// supportedFunctions.add("LOCALTIME"); //$NON-NLS-1$
-// supportedFunctions.add("LOCALTIMESTAMP"); //$NON-NLS-1$
-// supportedFunctions.add("MAKEDATE"); //$NON-NLS-1$
-// supportedFunctions.add("MAKETIME"); //$NON-NLS-1$
-// supportedFunctions.add("MICROSECOND"); //$NON-NLS-1$
-// supportedFunctions.add("PERIOD_ADD"); //$NON-NLS-1$
-// supportedFunctions.add("PERIOD_DIFF"); //$NON-NLS-1$
-// supportedFunctions.add("SEC_TO_TIME"); //$NON-NLS-1$
-// supportedFunctions.add("STR_TO_DATE"); //$NON-NLS-1$
-// supportedFunctions.add("SUBDATE"); //$NON-NLS-1$
-// supportedFunctions.add("SUBTIME"); //$NON-NLS-1$
-// supportedFunctions.add("SYSDATE"); //$NON-NLS-1$
-// supportedFunctions.add("TIME"); //$NON-NLS-1$
-// supportedFunctions.add("TIMEDIFF"); //$NON-NLS-1$
-// supportedFunctions.add("TIMESTAMP"); //$NON-NLS-1$
-// supportedFunctions.add("TIME_FORMAT"); //$NON-NLS-1$
-// supportedFunctions.add("TIME_TO_SEC"); //$NON-NLS-1$
-// supportedFunctions.add("TO_DAYS"); //$NON-NLS-1$
-// supportedFunctions.add("UNIX_TIMESTAMP"); //$NON-NLS-1$
-// supportedFunctions.add("UTC_DATE"); //$NON-NLS-1$
-// supportedFunctions.add("UTC_TIME"); //$NON-NLS-1$
-// supportedFunctions.add("UTC_TIMESTAMP"); //$NON-NLS-1$
-// supportedFunctions.add("WEEKDAY"); //$NON-NLS-1$
-// supportedFunctions.add("WEEKOFYEAR"); //$NON-NLS-1$
-// supportedFunctions.add("YEARWEEK"); //$NON-NLS-1$
-//
-// // Bit
-// supportedFunctions.add("|"); //$NON-NLS-1$
-// supportedFunctions.add("&"); //$NON-NLS-1$
-// supportedFunctions.add("^"); //$NON-NLS-1$
-// supportedFunctions.add("<<"); //$NON-NLS-1$
-// supportedFunctions.add(">>"); //$NON-NLS-1$
-// supportedFunctions.add("~"); //$NON-NLS-1$
-// supportedFunctions.add("BIT_COUNT"); //$NON-NLS-1$
-//
-// // Encryption
-// supportedFunctions.add("AES_ENCRYPT"); //$NON-NLS-1$
-// supportedFunctions.add("AES_DECRYPT"); //$NON-NLS-1$
-// supportedFunctions.add("DECODE"); //$NON-NLS-1$
-// supportedFunctions.add("ENCODE"); //$NON-NLS-1$
-// supportedFunctions.add("DES_ENCRYPT"); //$NON-NLS-1$
-// supportedFunctions.add("DES_DECRYPT"); //$NON-NLS-1$
-// supportedFunctions.add("MD5"); //$NON-NLS-1$
-// supportedFunctions.add("OLD_PASSWORD"); //$NON-NLS-1$
-// supportedFunctions.add("PASSWORD"); //$NON-NLS-1$
-// supportedFunctions.add("SHA"); //$NON-NLS-1$
-// supportedFunctions.add("SHA1"); //$NON-NLS-1$
-//
-// // Information
-// supportedFunctions.add("BENCHMARK"); //$NON-NLS-1$
-// supportedFunctions.add("CHARSET"); //$NON-NLS-1$
-// supportedFunctions.add("COERCIBILITY"); //$NON-NLS-1$
-// supportedFunctions.add("COLLATION"); //$NON-NLS-1$
-// supportedFunctions.add("CONNECTION_ID"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_USER"); //$NON-NLS-1$
-// supportedFunctions.add("DATABASE"); //$NON-NLS-1$
-// supportedFunctions.add("FOUND_ROWS"); //$NON-NLS-1$
-// supportedFunctions.add("LAST_INSERT_ID"); //$NON-NLS-1$
-// supportedFunctions.add("ROW_COUNT"); //$NON-NLS-1$
-// supportedFunctions.add("SCHEMA"); //$NON-NLS-1$
-// supportedFunctions.add("SESSION_USER"); //$NON-NLS-1$
-// supportedFunctions.add("SYSTEM_USER"); //$NON-NLS-1$
-// supportedFunctions.add("USER"); //$NON-NLS-1$
-// supportedFunctions.add("VERSION"); //$NON-NLS-1$
-//
-// // Misc.
-// supportedFunctions.add("DEFAULT"); //$NON-NLS-1$
-// supportedFunctions.add("FORMAT"); //$NON-NLS-1$
-//// supportedFunctions.add("GET_LOCK"); //$NON-NLS-1$
-// supportedFunctions.add("INET_ATON"); //$NON-NLS-1$
-// supportedFunctions.add("INET_NTOA"); //$NON-NLS-1$
-//// supportedFunctions.add("IS_FREE_LOCK"); //$NON-NLS-1$
-//// supportedFunctions.add("IS_USED_LOCK"); //$NON-NLS-1$
-//// supportedFunctions.add("MASTER_POS_WAIT"); //$NON-NLS-1$
-//// supportedFunctions.add("NAME_CONST"); //$NON-NLS-1$
-//// supportedFunctions.add("RELEASE_LOCK"); //$NON-NLS-1$
-//// supportedFunctions.add("SLEEP"); //$NON-NLS-1$
-// supportedFunctions.add("UUID"); //$NON-NLS-1$
-// supportedFunctions.add("VALUES"); //$NON-NLS-1$
- return supportedFunctions;
- }
-
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- public boolean supportsAggregatesDistinct() {
- return false;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
- public boolean supportsRowOffset() {
- return true;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,398 @@
+/*
+ * 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.mysql;
+
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Function;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.LocateFunctionModifier;
+
+
+/**
+ * @since 4.3
+ */
+public class MySQLExecutionFactory extends JDBCExecutionFactory {
+
+ /**
+ * Adds support for the 2 argument form of padding
+ */
+ private final class PadFunctionModifier extends FunctionModifier {
+ @Override
+ public List<?> translate(Function function) {
+ if (function.getParameters().size() == 2) {
+ function.getParameters().add(getLanguageFactory().createLiteral(" ", TypeFacility.RUNTIME_TYPES.STRING)); //$NON-NLS-1$
+ }
+ return null;
+ }
+ }
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ registerFunctionModifier(SourceSystemFunctions.BITAND, new BitFunctionModifier("&", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITNOT, new BitFunctionModifier("~", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITOR, new BitFunctionModifier("|", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITXOR, new BitFunctionModifier("^", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.LPAD, new PadFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.RPAD, new PadFunctionModifier());
+ //add in type conversion
+ ConvertModifier convertModifier = new ConvertModifier();
+ convertModifier.addTypeMapping("signed", FunctionModifier.BOOLEAN, FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG); //$NON-NLS-1$
+ //char(n) assume 4.1 or later
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convertModifier.addTypeMapping("char", FunctionModifier.STRING); //$NON-NLS-1$
+ convertModifier.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+ convertModifier.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+ convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("DATE")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("TIME")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("TIMESTAMP")); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%H:%i:%S")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d %H:%i:%S.%f")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addTypeConversion(new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0), " + 0.0"); //$NON-NLS-1$
+ }
+ }, FunctionModifier.BIGDECIMAL, FunctionModifier.BIGINTEGER, FunctionModifier.FLOAT, FunctionModifier.DOUBLE);
+ convertModifier.addNumericBooleanConversions();
+ convertModifier.setWideningNumericImplicit(true);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE('" + formatDateValue(dateValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME('" + formatDateValue(timeValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public boolean useParensForSetQueries() {
+ return true;
+ }
+
+ @Override
+ public int getTimestampNanoPrecision() {
+ return 0;
+ }
+
+ @Override
+ public void afterConnectionCreation(Connection connection) {
+ super.afterConnectionCreation(connection);
+
+ Statement stmt = null;
+ try {
+ stmt = connection.createStatement();
+ stmt.execute("set SESSION sql_mode = 'ANSI'"); //$NON-NLS-1$
+ } catch (SQLException e) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, e, "Error setting ANSI mode"); //$NON-NLS-1$
+ } finally {
+ if (stmt != null) {
+ try {
+ stmt.close();
+ } catch (SQLException e) {
+ LogManager.logDetail("Error closing statement", e); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ @Override
+ public boolean useParensForJoins() {
+ return true;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add(SourceSystemFunctions.ABS);
+ supportedFunctions.add(SourceSystemFunctions.ACOS);
+ supportedFunctions.add(SourceSystemFunctions.ASIN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN);
+ supportedFunctions.add(SourceSystemFunctions.ATAN2);
+ supportedFunctions.add(SourceSystemFunctions.BITAND);
+ supportedFunctions.add(SourceSystemFunctions.BITNOT);
+ supportedFunctions.add(SourceSystemFunctions.BITOR);
+ supportedFunctions.add(SourceSystemFunctions.BITXOR);
+ supportedFunctions.add(SourceSystemFunctions.CEILING);
+ 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.LOG10);
+ supportedFunctions.add(SourceSystemFunctions.MOD);
+ supportedFunctions.add(SourceSystemFunctions.PI);
+ supportedFunctions.add(SourceSystemFunctions.POWER);
+ supportedFunctions.add(SourceSystemFunctions.RADIANS);
+ supportedFunctions.add(SourceSystemFunctions.ROUND);
+ supportedFunctions.add(SourceSystemFunctions.SIGN);
+ supportedFunctions.add(SourceSystemFunctions.SIN);
+ supportedFunctions.add(SourceSystemFunctions.SQRT);
+ supportedFunctions.add(SourceSystemFunctions.TAN);
+
+ supportedFunctions.add(SourceSystemFunctions.ASCII);
+ supportedFunctions.add(SourceSystemFunctions.CHAR);
+ supportedFunctions.add(SourceSystemFunctions.CONCAT);
+ supportedFunctions.add(SourceSystemFunctions.INSERT);
+ supportedFunctions.add(SourceSystemFunctions.LCASE);
+ supportedFunctions.add(SourceSystemFunctions.LEFT);
+ supportedFunctions.add(SourceSystemFunctions.LENGTH);
+ supportedFunctions.add(SourceSystemFunctions.LOCATE);
+ supportedFunctions.add(SourceSystemFunctions.LPAD);
+ supportedFunctions.add(SourceSystemFunctions.LTRIM);
+ supportedFunctions.add(SourceSystemFunctions.REPEAT);
+ supportedFunctions.add(SourceSystemFunctions.REPLACE);
+ supportedFunctions.add(SourceSystemFunctions.RIGHT);
+ supportedFunctions.add(SourceSystemFunctions.RPAD);
+ supportedFunctions.add(SourceSystemFunctions.RTRIM);
+ supportedFunctions.add(SourceSystemFunctions.SUBSTRING);
+ supportedFunctions.add(SourceSystemFunctions.UCASE);
+
+ // These are executed within the server and never pushed down
+// supportedFunctions.add("CURDATE"); //$NON-NLS-1$
+// supportedFunctions.add("CURTIME"); //$NON-NLS-1$
+// supportedFunctions.add("NOW"); //$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.DAYNAME);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFMONTH);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFWEEK);
+ supportedFunctions.add(SourceSystemFunctions.DAYOFYEAR);
+
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.HOUR);
+ supportedFunctions.add(SourceSystemFunctions.MINUTE);
+ supportedFunctions.add(SourceSystemFunctions.MONTH);
+ supportedFunctions.add(SourceSystemFunctions.MONTHNAME);
+
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
+// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
+// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.QUARTER);
+ supportedFunctions.add(SourceSystemFunctions.SECOND);
+// supportedFunctions.add(SourceSystemFunctions.TIMESTAMPADD);
+// supportedFunctions.add(SourceSystemFunctions.TIMESTAMPDIFF);
+ supportedFunctions.add(SourceSystemFunctions.WEEK);
+ supportedFunctions.add(SourceSystemFunctions.YEAR);
+
+ supportedFunctions.add(SourceSystemFunctions.CONVERT);
+ supportedFunctions.add(SourceSystemFunctions.IFNULL);
+ supportedFunctions.add(SourceSystemFunctions.COALESCE);
+
+// supportedFunctions.add("GREATEST"); //$NON-NLS-1$
+// supportedFunctions.add("ISNULL"); //$NON-NLS-1$
+// supportedFunctions.add("LEAST"); //$NON-NLS-1$
+// supportedFunctions.add("STRCMP"); // String-specific //$NON-NLS-1$
+//
+// // String
+// supportedFunctions.add("BIN"); //$NON-NLS-1$
+// supportedFunctions.add("BIT_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("CHAR_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("CHARACTER_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("COMPRESS"); //$NON-NLS-1$
+// supportedFunctions.add("CONCAT_WS"); //$NON-NLS-1$
+// supportedFunctions.add("CONV"); //$NON-NLS-1$
+// supportedFunctions.add("ELT"); //$NON-NLS-1$
+// supportedFunctions.add("EXPORT_SET"); //$NON-NLS-1$
+// supportedFunctions.add("FIELD"); //$NON-NLS-1$
+// supportedFunctions.add("FIND_IN_SET"); //$NON-NLS-1$
+// supportedFunctions.add("FORMAT"); //$NON-NLS-1$
+// supportedFunctions.add("HEX"); //$NON-NLS-1$
+// supportedFunctions.add("INSTR"); //$NON-NLS-1$
+// supportedFunctions.add("LOAD_FILE"); //$NON-NLS-1$
+// supportedFunctions.add("MAKE_SET"); //$NON-NLS-1$
+// supportedFunctions.add("MID"); //$NON-NLS-1$
+// supportedFunctions.add("OCT"); //$NON-NLS-1$
+// supportedFunctions.add("OCTET_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("ORD"); //$NON-NLS-1$
+// supportedFunctions.add("QUOTE"); //$NON-NLS-1$
+// supportedFunctions.add("REVERSE"); //$NON-NLS-1$
+// supportedFunctions.add("SOUNDEX"); //$NON-NLS-1$
+// supportedFunctions.add("SPACE"); //$NON-NLS-1$
+// supportedFunctions.add("SUBSTR"); //$NON-NLS-1$
+// supportedFunctions.add("SUBSTRING_INDEX"); //$NON-NLS-1$
+// supportedFunctions.add("TRIM"); //$NON-NLS-1$
+// supportedFunctions.add("UNCOMPRESS"); //$NON-NLS-1$
+// supportedFunctions.add("UNHEX"); //$NON-NLS-1$
+//
+// // Math
+// supportedFunctions.add("CEIL"); //$NON-NLS-1$
+// supportedFunctions.add("CRC32"); //$NON-NLS-1$
+// // DIV is an operator equivalent to '/'
+// supportedFunctions.add("DIV"); //$NON-NLS-1$
+// supportedFunctions.add("FORMAT"); //$NON-NLS-1$
+// supportedFunctions.add("LN"); //$NON-NLS-1$
+// supportedFunctions.add("LOG2"); //$NON-NLS-1$
+// supportedFunctions.add("POW"); //$NON-NLS-1$
+// supportedFunctions.add("RAND"); //$NON-NLS-1$
+// supportedFunctions.add("TRUNCATE"); //$NON-NLS-1$
+//
+// // Date / Time
+// supportedFunctions.add("ADDDATE"); //$NON-NLS-1$
+// supportedFunctions.add("ADDTIME"); //$NON-NLS-1$
+// supportedFunctions.add("CONVERT_TZ"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_DATE"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_TIME"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_TIMESTAMP"); //$NON-NLS-1$
+// supportedFunctions.add("DATE"); //$NON-NLS-1$
+// supportedFunctions.add("DATEDIFF"); //$NON-NLS-1$
+//// supportedFunctions.add("DATE_ADD");
+//// supportedFunctions.add("DATE_SUB");
+// supportedFunctions.add("DATE_FORMAT"); //$NON-NLS-1$
+// supportedFunctions.add("DAY"); //$NON-NLS-1$
+//// supportedFunctions.add("EXTRACT");
+// supportedFunctions.add("FROM_DAYS"); //$NON-NLS-1$
+// supportedFunctions.add("FROM_UNIXTIME"); //$NON-NLS-1$
+// supportedFunctions.add("GET_FORMAT"); //$NON-NLS-1$
+// supportedFunctions.add("LAST_DAY"); //$NON-NLS-1$
+// supportedFunctions.add("LOCALTIME"); //$NON-NLS-1$
+// supportedFunctions.add("LOCALTIMESTAMP"); //$NON-NLS-1$
+// supportedFunctions.add("MAKEDATE"); //$NON-NLS-1$
+// supportedFunctions.add("MAKETIME"); //$NON-NLS-1$
+// supportedFunctions.add("MICROSECOND"); //$NON-NLS-1$
+// supportedFunctions.add("PERIOD_ADD"); //$NON-NLS-1$
+// supportedFunctions.add("PERIOD_DIFF"); //$NON-NLS-1$
+// supportedFunctions.add("SEC_TO_TIME"); //$NON-NLS-1$
+// supportedFunctions.add("STR_TO_DATE"); //$NON-NLS-1$
+// supportedFunctions.add("SUBDATE"); //$NON-NLS-1$
+// supportedFunctions.add("SUBTIME"); //$NON-NLS-1$
+// supportedFunctions.add("SYSDATE"); //$NON-NLS-1$
+// supportedFunctions.add("TIME"); //$NON-NLS-1$
+// supportedFunctions.add("TIMEDIFF"); //$NON-NLS-1$
+// supportedFunctions.add("TIMESTAMP"); //$NON-NLS-1$
+// supportedFunctions.add("TIME_FORMAT"); //$NON-NLS-1$
+// supportedFunctions.add("TIME_TO_SEC"); //$NON-NLS-1$
+// supportedFunctions.add("TO_DAYS"); //$NON-NLS-1$
+// supportedFunctions.add("UNIX_TIMESTAMP"); //$NON-NLS-1$
+// supportedFunctions.add("UTC_DATE"); //$NON-NLS-1$
+// supportedFunctions.add("UTC_TIME"); //$NON-NLS-1$
+// supportedFunctions.add("UTC_TIMESTAMP"); //$NON-NLS-1$
+// supportedFunctions.add("WEEKDAY"); //$NON-NLS-1$
+// supportedFunctions.add("WEEKOFYEAR"); //$NON-NLS-1$
+// supportedFunctions.add("YEARWEEK"); //$NON-NLS-1$
+//
+// // Bit
+// supportedFunctions.add("|"); //$NON-NLS-1$
+// supportedFunctions.add("&"); //$NON-NLS-1$
+// supportedFunctions.add("^"); //$NON-NLS-1$
+// supportedFunctions.add("<<"); //$NON-NLS-1$
+// supportedFunctions.add(">>"); //$NON-NLS-1$
+// supportedFunctions.add("~"); //$NON-NLS-1$
+// supportedFunctions.add("BIT_COUNT"); //$NON-NLS-1$
+//
+// // Encryption
+// supportedFunctions.add("AES_ENCRYPT"); //$NON-NLS-1$
+// supportedFunctions.add("AES_DECRYPT"); //$NON-NLS-1$
+// supportedFunctions.add("DECODE"); //$NON-NLS-1$
+// supportedFunctions.add("ENCODE"); //$NON-NLS-1$
+// supportedFunctions.add("DES_ENCRYPT"); //$NON-NLS-1$
+// supportedFunctions.add("DES_DECRYPT"); //$NON-NLS-1$
+// supportedFunctions.add("MD5"); //$NON-NLS-1$
+// supportedFunctions.add("OLD_PASSWORD"); //$NON-NLS-1$
+// supportedFunctions.add("PASSWORD"); //$NON-NLS-1$
+// supportedFunctions.add("SHA"); //$NON-NLS-1$
+// supportedFunctions.add("SHA1"); //$NON-NLS-1$
+//
+// // Information
+// supportedFunctions.add("BENCHMARK"); //$NON-NLS-1$
+// supportedFunctions.add("CHARSET"); //$NON-NLS-1$
+// supportedFunctions.add("COERCIBILITY"); //$NON-NLS-1$
+// supportedFunctions.add("COLLATION"); //$NON-NLS-1$
+// supportedFunctions.add("CONNECTION_ID"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_USER"); //$NON-NLS-1$
+// supportedFunctions.add("DATABASE"); //$NON-NLS-1$
+// supportedFunctions.add("FOUND_ROWS"); //$NON-NLS-1$
+// supportedFunctions.add("LAST_INSERT_ID"); //$NON-NLS-1$
+// supportedFunctions.add("ROW_COUNT"); //$NON-NLS-1$
+// supportedFunctions.add("SCHEMA"); //$NON-NLS-1$
+// supportedFunctions.add("SESSION_USER"); //$NON-NLS-1$
+// supportedFunctions.add("SYSTEM_USER"); //$NON-NLS-1$
+// supportedFunctions.add("USER"); //$NON-NLS-1$
+// supportedFunctions.add("VERSION"); //$NON-NLS-1$
+//
+// // Misc.
+// supportedFunctions.add("DEFAULT"); //$NON-NLS-1$
+// supportedFunctions.add("FORMAT"); //$NON-NLS-1$
+//// supportedFunctions.add("GET_LOCK"); //$NON-NLS-1$
+// supportedFunctions.add("INET_ATON"); //$NON-NLS-1$
+// supportedFunctions.add("INET_NTOA"); //$NON-NLS-1$
+//// supportedFunctions.add("IS_FREE_LOCK"); //$NON-NLS-1$
+//// supportedFunctions.add("IS_USED_LOCK"); //$NON-NLS-1$
+//// supportedFunctions.add("MASTER_POS_WAIT"); //$NON-NLS-1$
+//// supportedFunctions.add("NAME_CONST"); //$NON-NLS-1$
+//// supportedFunctions.add("RELEASE_LOCK"); //$NON-NLS-1$
+//// supportedFunctions.add("SLEEP"); //$NON-NLS-1$
+// supportedFunctions.add("UUID"); //$NON-NLS-1$
+// supportedFunctions.add("VALUES"); //$NON-NLS-1$
+ return supportedFunctions;
+ }
+ @Override
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+ @Override
+ public boolean supportsAggregatesDistinct() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,156 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.mysql;
-
-import java.sql.Connection;
-import java.sql.Date;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.Function;
-import org.teiid.logging.LogConstants;
-import org.teiid.logging.LogManager;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.LocateFunctionModifier;
-import org.teiid.translator.jdbc.Translator;
-
-
-/**
- * @since 4.3
- */
-public class MySQLTranslator extends Translator {
-
- /**
- * Adds support for the 2 argument form of padding
- */
- private final class PadFunctionModifier extends FunctionModifier {
- @Override
- public List<?> translate(Function function) {
- if (function.getParameters().size() == 2) {
- function.getParameters().add(getLanguageFactory().createLiteral(" ", TypeFacility.RUNTIME_TYPES.STRING)); //$NON-NLS-1$
- }
- return null;
- }
- }
-
- @Override
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.BITAND, new BitFunctionModifier("&", getLanguageFactory())); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITNOT, new BitFunctionModifier("~", getLanguageFactory())); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITOR, new BitFunctionModifier("|", getLanguageFactory())); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITXOR, new BitFunctionModifier("^", getLanguageFactory())); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.LPAD, new PadFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.RPAD, new PadFunctionModifier());
- //add in type conversion
- ConvertModifier convertModifier = new ConvertModifier();
- convertModifier.addTypeMapping("signed", FunctionModifier.BOOLEAN, FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG); //$NON-NLS-1$
- //char(n) assume 4.1 or later
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convertModifier.addTypeMapping("char", FunctionModifier.STRING); //$NON-NLS-1$
- convertModifier.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
- convertModifier.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
- convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("DATE")); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("TIME")); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("TIMESTAMP")); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%H:%i:%S")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("date_format", "%Y-%m-%d %H:%i:%S.%f")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addTypeConversion(new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList(function.getParameters().get(0), " + 0.0"); //$NON-NLS-1$
- }
- }, FunctionModifier.BIGDECIMAL, FunctionModifier.BIGINTEGER, FunctionModifier.FLOAT, FunctionModifier.DOUBLE);
- convertModifier.addNumericBooleanConversions();
- convertModifier.setWideningNumericImplicit(true);
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
- }
-
- @Override
- public String translateLiteralDate(Date dateValue) {
- return "DATE('" + formatDateValue(dateValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTime(Time timeValue) {
- return "TIME('" + formatDateValue(timeValue) + "')"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "{ts '" + formatDateValue(timestampValue) + "'}"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public boolean useParensForSetQueries() {
- return true;
- }
-
- @Override
- public int getTimestampNanoPrecision() {
- return 0;
- }
-
- @Override
- public void afterConnectionCreation(Connection connection) {
- super.afterConnectionCreation(connection);
-
- Statement stmt = null;
- try {
- stmt = connection.createStatement();
- stmt.execute("set SESSION sql_mode = 'ANSI'"); //$NON-NLS-1$
- } catch (SQLException e) {
- LogManager.logError(LogConstants.CTX_CONNECTOR, e, "Error setting ANSI mode"); //$NON-NLS-1$
- } finally {
- if (stmt != null) {
- try {
- stmt.close();
- } catch (SQLException e) {
- LogManager.logDetail("Error closing statement", e); //$NON-NLS-1$
- }
- }
- }
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return MySQLCapabilities.class;
- }
-
- public boolean useParensForJoins() {
- return true;
- }
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,154 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.oracle;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-/**
- */
-public class OracleCapabilities extends JDBCCapabilities {
-
- public OracleCapabilities() {
- }
-
- /**
- * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add(SourceSystemFunctions.COT);
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("CEILING"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("INITCAP"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LOCATE"); //$NON-NLS-1$
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- supportedFunctions.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- supportedFunctions.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("DAY"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- //supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
- //supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
- //supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
- //supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
- //supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
- //supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
- supportedFunctions.add("COALESCE"); //$NON-NLS-1$
-
- supportedFunctions.add(OracleSQLTranslator.RELATE);
- supportedFunctions.add(OracleSQLTranslator.NEAREST_NEIGHBOR);
- supportedFunctions.add(OracleSQLTranslator.FILTER);
- supportedFunctions.add(OracleSQLTranslator.NEAREST_NEIGHBOR_DISTANCE);
- supportedFunctions.add(OracleSQLTranslator.WITHIN_DISTANCE);
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
- public boolean supportsRowOffset() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
- */
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
- */
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,549 @@
+/*
+ * 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.oracle;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.Insert;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.language.SQLReservedWords.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.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
+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.JDBCPlugin;
+import org.teiid.translator.jdbc.LocateFunctionModifier;
+
+
+
+public class OracleExecutionFactory extends JDBCExecutionFactory {
+
+ /*
+ * Spatial Functions
+ */
+ public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
+ public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
+ public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
+ public static final String WITHIN_DISTANCE = "sdo_within_distance"; //$NON-NLS-1$
+ public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance"; //$NON-NLS-1$
+
+ public final static String HINT_PREFIX = "/*+"; //$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$
+
+ public void start() throws ConnectorException {
+ super.start();
+
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("nvl")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG10, new Log10FunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.WEEK, new DayWeekQuarterFunctionModifier("WW"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new DayWeekQuarterFunctionModifier("Q"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new DayWeekQuarterFunctionModifier("D"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new DayWeekQuarterFunctionModifier("DDD"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), "INSTR", true)); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ function.setName(SourceSystemFunctions.TAN);
+ return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
+ }
+ });
+
+ //spatial functions
+ registerFunctionModifier(RELATE, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(FILTER, new OracleSpatialFunctionModifier());
+ registerFunctionModifier(WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
+
+ //add in type conversion
+ ConvertModifier convertModifier = new ConvertModifier();
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convertModifier.addTypeMapping("date", FunctionModifier.DATE, FunctionModifier.TIME); //$NON-NLS-1$
+ convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("case when ", function.getParameters().get(0), " is null then null else to_date('1970-01-01 ' || to_char(",function.getParameters().get(0),", 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') end"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("trunc(cast(",function.getParameters().get(0)," AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ //if column and type is date, just use date format
+ Expression ex = function.getParameters().get(0);
+ String format = "YYYY-MM-DD HH24:MI:SS.FF"; //$NON-NLS-1$
+ if (ex instanceof ColumnReference) {
+ if ("date".equals(((ColumnReference)ex).getMetadataObject().getNativeType())) { //$NON-NLS-1$
+ format = "YYYY-MM-DD HH24:MI:SS"; //$NON-NLS-1$
+ }
+ } else if (!(ex instanceof Function) && !(ex instanceof Literal)) {
+ //this isn't needed in every case, but it's simpler than inspecting the expression more
+ ex = ConvertModifier.createConvertFunction(getLanguageFactory(), function.getParameters().get(0), TypeFacility.RUNTIME_NAMES.TIMESTAMP);
+ }
+ return Arrays.asList("to_char(", ex, ", '", format, "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("to_date", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("to_date", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("to_timestamp", "YYYY-MM-DD HH24:MI:SS.FF")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addTypeConversion(new ConvertModifier.FormatModifier("to_char"), FunctionModifier.STRING); //$NON-NLS-1$
+ //NOTE: numeric handling in Oracle is split only between integral vs. floating/decimal types
+ convertModifier.addTypeConversion(new ConvertModifier.FormatModifier("to_number"), //$NON-NLS-1$
+ FunctionModifier.FLOAT, FunctionModifier.DOUBLE, FunctionModifier.BIGDECIMAL);
+ convertModifier.addTypeConversion(new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ if (Number.class.isAssignableFrom(function.getParameters().get(0).getType())) {
+ return Arrays.asList("trunc(", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return Arrays.asList("trunc(to_number(", function.getParameters().get(0), "))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ },
+ FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG, FunctionModifier.BIGINTEGER);
+ convertModifier.addNumericBooleanConversions();
+ convertModifier.setWideningNumericImplicit(true);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+ }
+
+ public void handleInsertSequences(Insert insert) throws ConnectorException {
+ /*
+ * If a missing auto_increment column is modeled with name in source indicating that an Oracle Sequence
+ * then pull the Sequence name out of the name in source of the column.
+ */
+ if (!(insert.getValueSource() instanceof ExpressionValueSource)) {
+ return;
+ }
+ ExpressionValueSource values = (ExpressionValueSource)insert.getValueSource();
+ List<Column> allElements = insert.getTable().getMetadataObject().getColumns();
+ if (allElements.size() == values.getValues().size()) {
+ return;
+ }
+
+ int index = 0;
+ List<ColumnReference> elements = insert.getColumns();
+
+ for (Column element : allElements) {
+ if (!element.isAutoIncremented()) {
+ continue;
+ }
+ String name = element.getNameInSource();
+ int seqIndex = name.indexOf(SEQUENCE);
+ if (seqIndex == -1) {
+ continue;
+ }
+ boolean found = false;
+ while (index < elements.size()) {
+ if (element.equals(elements.get(index).getMetadataObject())) {
+ found = true;
+ break;
+ }
+ index++;
+ }
+ if (found) {
+ continue;
+ }
+
+ String sequence = name.substring(seqIndex + SEQUENCE.length());
+
+ int delimiterIndex = sequence.indexOf(Tokens.DOT);
+ if (delimiterIndex == -1) {
+ throw new ConnectorException("Invalid name in source sequence format. Expected <element name>" + SEQUENCE + "<sequence name>.<sequence value>, but was " + name); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String sequenceGroupName = sequence.substring(0, delimiterIndex);
+ String sequenceElementName = sequence.substring(delimiterIndex + 1);
+
+ NamedTable sequenceGroup = this.getLanguageFactory().createNamedTable(sequenceGroupName, null, null);
+ ColumnReference sequenceElement = this.getLanguageFactory().createColumnReference(sequenceElementName, sequenceGroup, null, element.getJavaType());
+ insert.getColumns().add(index, this.getLanguageFactory().createColumnReference(element.getName(), insert.getTable(), element, element.getJavaType()));
+ values.getValues().add(index, sequenceElement);
+ }
+ }
+
+ @Override
+ public List<?> translateCommand(Command command, ExecutionContext context) {
+ if (command instanceof Insert) {
+ try {
+ handleInsertSequences((Insert)command);
+ } catch (ConnectorException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (!(command instanceof QueryExpression)) {
+ return null;
+ }
+ QueryExpression queryCommand = (QueryExpression)command;
+ if (queryCommand.getLimit() == null) {
+ return null;
+ }
+ Limit limit = queryCommand.getLimit();
+ queryCommand.setLimit(null);
+ List<Object> parts = new ArrayList<Object>();
+ parts.add("SELECT "); //$NON-NLS-1$
+ /*
+ * if all of the columns are aliased, assume that names matter - it actually only seems to matter for
+ * the first query of a set op when there is a order by. Rather than adding logic to traverse up,
+ * we just use the projected names
+ */
+ boolean allAliased = true;
+ for (DerivedColumn selectSymbol : queryCommand.getProjectedQuery().getDerivedColumns()) {
+ if (selectSymbol.getAlias() == null) {
+ allAliased = false;
+ break;
+ }
+ }
+ if (allAliased) {
+ String[] columnNames = queryCommand.getColumnNames();
+ for (int i = 0; i < columnNames.length; i++) {
+ if (i > 0) {
+ parts.add(", "); //$NON-NLS-1$
+ }
+ parts.add(columnNames[i]);
+ }
+ } else {
+ parts.add("*"); //$NON-NLS-1$
+ }
+ if (limit.getRowOffset() > 0) {
+ parts.add(" FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM ("); //$NON-NLS-1$
+ } else {
+ parts.add(" FROM ("); //$NON-NLS-1$
+ }
+ parts.add(queryCommand);
+ if (limit.getRowOffset() > 0) {
+ parts.add(") VIEW_FOR_LIMIT WHERE ROWNUM <= "); //$NON-NLS-1$
+ parts.add(limit.getRowLimit() + limit.getRowOffset());
+ parts.add(") WHERE ROWNUM_ > "); //$NON-NLS-1$
+ parts.add(limit.getRowOffset());
+ } else {
+ parts.add(") WHERE ROWNUM <= "); //$NON-NLS-1$
+ parts.add(limit.getRowLimit());
+ }
+ return parts;
+ }
+
+ @Override
+ public boolean useAsInGroupAlias(){
+ return false;
+ }
+
+ @Override
+ public String getSetOperationString(Operation operation) {
+ if (operation == Operation.EXCEPT) {
+ return "MINUS"; //$NON-NLS-1$
+ }
+ return super.getSetOperationString(operation);
+ }
+
+ @Override
+ public String getSourceComment(ExecutionContext context, Command command) {
+ String comment = super.getSourceComment(context, command);
+
+ 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$
+ }
+ }
+ }
+
+ if (command instanceof Select) {
+ //
+ // This simple algorithm determines the hint which will be added to the
+ // query.
+ // Right now, we look through all functions passed in the query
+ // (returned as a collection)
+ // Then we check if any of those functions are sdo_relate
+ // If so, the ORDERED hint is added, if not, it isn't
+ Collection<Function> col = CollectorVisitor.collectObjects(Function.class, command);
+ for (Function func : col) {
+ if (func.getName().equalsIgnoreCase(RELATE)) {
+ return comment + "/*+ ORDERED */ "; //$NON-NLS-1$
+ }
+ }
+ }
+ return comment;
+ }
+
+ /**
+ * Don't fully qualify elements if table = DUAL or element = ROWNUM or special stuff is packed into name in source value.
+ *
+ * @see org.teiid.language.visitor.SQLStringVisitor#skipGroupInElement(java.lang.String, java.lang.String)
+ * @since 5.0
+ */
+ @Override
+ public String replaceElementName(String group, String element) {
+
+ // Check if the element was modeled as using a Sequence
+ int useIndex = element.indexOf(SEQUENCE);
+ if (useIndex >= 0) {
+ String name = element.substring(0, useIndex);
+ if (group != null) {
+ return group + Tokens.DOT + name;
+ }
+ return name;
+ }
+
+ // Check if the group name should be discarded
+ if((group != null && DUAL.equalsIgnoreCase(group)) || element.equalsIgnoreCase(ROWNUM)) {
+ // Strip group if group or element are pseudo-columns
+ return element;
+ }
+
+ return null;
+ }
+
+ @Override
+ public boolean hasTimeType() {
+ return false;
+ }
+
+ @Override
+ public void bindValue(PreparedStatement stmt, Object param, Class<?> paramType, int i) throws SQLException {
+ if(param == null && Object.class.equals(paramType)){
+ //Oracle drive does not support JAVA_OBJECT type
+ stmt.setNull(i, Types.LONGVARBINARY);
+ return;
+ }
+ super.bindValue(stmt, param, paramType, i);
+ }
+
+ @Override
+ public void afterInitialConnectionCreation(Connection connection) {
+ String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_oracle_connection_details"); //$NON-NLS-1$
+ ResultSet rs = null;
+ Statement stmt = null;
+ try {
+ stmt = connection.createStatement();
+ rs = stmt.executeQuery("select * from v$instance"); //$NON-NLS-1$
+
+ int columnCount = rs.getMetaData().getColumnCount();
+ while (rs.next()) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 1; i <= columnCount; i++) {
+ sb.append(rs.getMetaData().getColumnName(i)).append("=").append(rs.getString(i)).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ // log the queried information
+ LogManager.logInfo(LogConstants.CTX_CONNECTOR, sb.toString());
+ }
+
+ } catch (SQLException e) {
+ LogManager.logInfo(LogConstants.CTX_CONNECTOR, errorStr);
+ }finally {
+ try {
+ if (rs != null) {
+ rs.close();
+ }
+ if (stmt != null) {
+ stmt.close();
+ }
+ } catch (SQLException e1) {
+ LogManager.logInfo(LogConstants.CTX_CONNECTOR, errorStr);
+ }
+ }
+ }
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.HIGH;
+ }
+
+ @Override
+ public boolean supportsExplicitNullOrdering() {
+ return true;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add(SourceSystemFunctions.COT);
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("CEILING"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ supportedFunctions.add("INITCAP"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LOWER"); //$NON-NLS-1$
+ supportedFunctions.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ supportedFunctions.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("UPPER"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("DAY"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ //supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
+ //supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
+ //supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+ //supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
+ //supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
+ //supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+
+ supportedFunctions.add(OracleExecutionFactory.RELATE);
+ supportedFunctions.add(OracleExecutionFactory.NEAREST_NEIGHBOR);
+ supportedFunctions.add(OracleExecutionFactory.FILTER);
+ supportedFunctions.add(OracleExecutionFactory.NEAREST_NEIGHBOR_DISTANCE);
+ supportedFunctions.add(OracleExecutionFactory.WITHIN_DISTANCE);
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @since 5.0
+ */
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
+ */
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
+ */
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,439 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.oracle;
-
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
-import java.sql.Types;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.List;
-
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Command;
-import org.teiid.language.DerivedColumn;
-import org.teiid.language.Expression;
-import org.teiid.language.ExpressionValueSource;
-import org.teiid.language.Function;
-import org.teiid.language.Insert;
-import org.teiid.language.Limit;
-import org.teiid.language.Literal;
-import org.teiid.language.NamedTable;
-import org.teiid.language.QueryExpression;
-import org.teiid.language.Select;
-import org.teiid.language.SQLReservedWords.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.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.TypeFacility;
-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.JDBCPlugin;
-import org.teiid.translator.jdbc.LocateFunctionModifier;
-import org.teiid.translator.jdbc.Translator;
-
-
-
-public class OracleSQLTranslator extends Translator {
-
- /*
- * Spatial Functions
- */
- public static final String RELATE = "sdo_relate"; //$NON-NLS-1$
- public static final String NEAREST_NEIGHBOR = "sdo_nn"; //$NON-NLS-1$
- public static final String FILTER = "sdo_filter"; //$NON-NLS-1$
- public static final String WITHIN_DISTANCE = "sdo_within_distance"; //$NON-NLS-1$
- public static final String NEAREST_NEIGHBOR_DISTANCE = "sdo_nn_distance"; //$NON-NLS-1$
-
- public final static String HINT_PREFIX = "/*+"; //$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$
-
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("nvl")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CEILING, new AliasModifier("ceil")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOG10, new Log10FunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.WEEK, new DayWeekQuarterFunctionModifier("WW"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.QUARTER, new DayWeekQuarterFunctionModifier("Q"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new DayWeekQuarterFunctionModifier("D"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new DayWeekQuarterFunctionModifier("DDD"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), "INSTR", true)); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new ConcatFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.COT, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- function.setName(SourceSystemFunctions.TAN);
- return Arrays.asList(getLanguageFactory().createFunction(SourceSystemFunctions.DIVIDE_OP, new Expression[] {new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER), function}, TypeFacility.RUNTIME_TYPES.DOUBLE));
- }
- });
-
- //spatial functions
- registerFunctionModifier(RELATE, new OracleSpatialFunctionModifier());
- registerFunctionModifier(NEAREST_NEIGHBOR, new OracleSpatialFunctionModifier());
- registerFunctionModifier(FILTER, new OracleSpatialFunctionModifier());
- registerFunctionModifier(WITHIN_DISTANCE, new OracleSpatialFunctionModifier());
-
- //add in type conversion
- ConvertModifier convertModifier = new ConvertModifier();
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convertModifier.addTypeMapping("date", FunctionModifier.DATE, FunctionModifier.TIME); //$NON-NLS-1$
- convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("case when ", function.getParameters().get(0), " is null then null else to_date('1970-01-01 ' || to_char(",function.getParameters().get(0),", 'HH24:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') end"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- });
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("trunc(cast(",function.getParameters().get(0)," AS date))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- //if column and type is date, just use date format
- Expression ex = function.getParameters().get(0);
- String format = "YYYY-MM-DD HH24:MI:SS.FF"; //$NON-NLS-1$
- if (ex instanceof ColumnReference) {
- if ("date".equals(((ColumnReference)ex).getMetadataObject().getNativeType())) { //$NON-NLS-1$
- format = "YYYY-MM-DD HH24:MI:SS"; //$NON-NLS-1$
- }
- } else if (!(ex instanceof Function) && !(ex instanceof Literal)) {
- //this isn't needed in every case, but it's simpler than inspecting the expression more
- ex = ConvertModifier.createConvertFunction(getLanguageFactory(), function.getParameters().get(0), TypeFacility.RUNTIME_NAMES.TIMESTAMP);
- }
- return Arrays.asList("to_char(", ex, ", '", format, "')"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- });
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.DATE, new ConvertModifier.FormatModifier("to_date", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIME, new ConvertModifier.FormatModifier("to_date", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.STRING, FunctionModifier.TIMESTAMP, new ConvertModifier.FormatModifier("to_timestamp", "YYYY-MM-DD HH24:MI:SS.FF")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addTypeConversion(new ConvertModifier.FormatModifier("to_char"), FunctionModifier.STRING); //$NON-NLS-1$
- //NOTE: numeric handling in Oracle is split only between integral vs. floating/decimal types
- convertModifier.addTypeConversion(new ConvertModifier.FormatModifier("to_number"), //$NON-NLS-1$
- FunctionModifier.FLOAT, FunctionModifier.DOUBLE, FunctionModifier.BIGDECIMAL);
- convertModifier.addTypeConversion(new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- if (Number.class.isAssignableFrom(function.getParameters().get(0).getType())) {
- return Arrays.asList("trunc(", function.getParameters().get(0), ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return Arrays.asList("trunc(to_number(", function.getParameters().get(0), "))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- },
- FunctionModifier.BYTE, FunctionModifier.SHORT, FunctionModifier.INTEGER, FunctionModifier.LONG, FunctionModifier.BIGINTEGER);
- convertModifier.addNumericBooleanConversions();
- convertModifier.setWideningNumericImplicit(true);
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
- }
-
- public void handleInsertSequences(Insert insert) throws ConnectorException {
- /*
- * If a missing auto_increment column is modeled with name in source indicating that an Oracle Sequence
- * then pull the Sequence name out of the name in source of the column.
- */
- if (!(insert.getValueSource() instanceof ExpressionValueSource)) {
- return;
- }
- ExpressionValueSource values = (ExpressionValueSource)insert.getValueSource();
- List<Column> allElements = insert.getTable().getMetadataObject().getColumns();
- if (allElements.size() == values.getValues().size()) {
- return;
- }
-
- int index = 0;
- List<ColumnReference> elements = insert.getColumns();
-
- for (Column element : allElements) {
- if (!element.isAutoIncremented()) {
- continue;
- }
- String name = element.getNameInSource();
- int seqIndex = name.indexOf(SEQUENCE);
- if (seqIndex == -1) {
- continue;
- }
- boolean found = false;
- while (index < elements.size()) {
- if (element.equals(elements.get(index).getMetadataObject())) {
- found = true;
- break;
- }
- index++;
- }
- if (found) {
- continue;
- }
-
- String sequence = name.substring(seqIndex + SEQUENCE.length());
-
- int delimiterIndex = sequence.indexOf(Tokens.DOT);
- if (delimiterIndex == -1) {
- throw new ConnectorException("Invalid name in source sequence format. Expected <element name>" + SEQUENCE + "<sequence name>.<sequence value>, but was " + name); //$NON-NLS-1$ //$NON-NLS-2$
- }
- String sequenceGroupName = sequence.substring(0, delimiterIndex);
- String sequenceElementName = sequence.substring(delimiterIndex + 1);
-
- NamedTable sequenceGroup = this.getLanguageFactory().createNamedTable(sequenceGroupName, null, null);
- ColumnReference sequenceElement = this.getLanguageFactory().createColumnReference(sequenceElementName, sequenceGroup, null, element.getJavaType());
- insert.getColumns().add(index, this.getLanguageFactory().createColumnReference(element.getName(), insert.getTable(), element, element.getJavaType()));
- values.getValues().add(index, sequenceElement);
- }
- }
-
- @Override
- public List<?> translateCommand(Command command, ExecutionContext context) {
- if (command instanceof Insert) {
- try {
- handleInsertSequences((Insert)command);
- } catch (ConnectorException e) {
- throw new RuntimeException(e);
- }
- }
-
- if (!(command instanceof QueryExpression)) {
- return null;
- }
- QueryExpression queryCommand = (QueryExpression)command;
- if (queryCommand.getLimit() == null) {
- return null;
- }
- Limit limit = queryCommand.getLimit();
- queryCommand.setLimit(null);
- List<Object> parts = new ArrayList<Object>();
- parts.add("SELECT "); //$NON-NLS-1$
- /*
- * if all of the columns are aliased, assume that names matter - it actually only seems to matter for
- * the first query of a set op when there is a order by. Rather than adding logic to traverse up,
- * we just use the projected names
- */
- boolean allAliased = true;
- for (DerivedColumn selectSymbol : queryCommand.getProjectedQuery().getDerivedColumns()) {
- if (selectSymbol.getAlias() == null) {
- allAliased = false;
- break;
- }
- }
- if (allAliased) {
- String[] columnNames = queryCommand.getColumnNames();
- for (int i = 0; i < columnNames.length; i++) {
- if (i > 0) {
- parts.add(", "); //$NON-NLS-1$
- }
- parts.add(columnNames[i]);
- }
- } else {
- parts.add("*"); //$NON-NLS-1$
- }
- if (limit.getRowOffset() > 0) {
- parts.add(" FROM (SELECT VIEW_FOR_LIMIT.*, ROWNUM ROWNUM_ FROM ("); //$NON-NLS-1$
- } else {
- parts.add(" FROM ("); //$NON-NLS-1$
- }
- parts.add(queryCommand);
- if (limit.getRowOffset() > 0) {
- parts.add(") VIEW_FOR_LIMIT WHERE ROWNUM <= "); //$NON-NLS-1$
- parts.add(limit.getRowLimit() + limit.getRowOffset());
- parts.add(") WHERE ROWNUM_ > "); //$NON-NLS-1$
- parts.add(limit.getRowOffset());
- } else {
- parts.add(") WHERE ROWNUM <= "); //$NON-NLS-1$
- parts.add(limit.getRowLimit());
- }
- return parts;
- }
-
- @Override
- public boolean useAsInGroupAlias(){
- return false;
- }
-
- @Override
- public String getSetOperationString(Operation operation) {
- if (operation == Operation.EXCEPT) {
- return "MINUS"; //$NON-NLS-1$
- }
- return super.getSetOperationString(operation);
- }
-
- @Override
- public String getSourceComment(ExecutionContext context, Command command) {
- String comment = super.getSourceComment(context, command);
-
- 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$
- }
- }
- }
-
- if (command instanceof Select) {
- //
- // This simple algorithm determines the hint which will be added to the
- // query.
- // Right now, we look through all functions passed in the query
- // (returned as a collection)
- // Then we check if any of those functions are sdo_relate
- // If so, the ORDERED hint is added, if not, it isn't
- Collection<Function> col = CollectorVisitor.collectObjects(Function.class, command);
- for (Function func : col) {
- if (func.getName().equalsIgnoreCase(RELATE)) {
- return comment + "/*+ ORDERED */ "; //$NON-NLS-1$
- }
- }
- }
- return comment;
- }
-
- /**
- * Don't fully qualify elements if table = DUAL or element = ROWNUM or special stuff is packed into name in source value.
- *
- * @see org.teiid.language.visitor.SQLStringVisitor#skipGroupInElement(java.lang.String, java.lang.String)
- * @since 5.0
- */
- @Override
- public String replaceElementName(String group, String element) {
-
- // Check if the element was modeled as using a Sequence
- int useIndex = element.indexOf(SEQUENCE);
- if (useIndex >= 0) {
- String name = element.substring(0, useIndex);
- if (group != null) {
- return group + Tokens.DOT + name;
- }
- return name;
- }
-
- // Check if the group name should be discarded
- if((group != null && DUAL.equalsIgnoreCase(group)) || element.equalsIgnoreCase(ROWNUM)) {
- // Strip group if group or element are pseudo-columns
- return element;
- }
-
- return null;
- }
-
- @Override
- public boolean hasTimeType() {
- return false;
- }
-
- @Override
- public void bindValue(PreparedStatement stmt, Object param, Class<?> paramType, int i) throws SQLException {
- if(param == null && Object.class.equals(paramType)){
- //Oracle drive does not support JAVA_OBJECT type
- stmt.setNull(i, Types.LONGVARBINARY);
- return;
- }
- super.bindValue(stmt, param, paramType, i);
- }
-
- @Override
- public void afterInitialConnectionCreation(Connection connection) {
- String errorStr = JDBCPlugin.Util.getString("ConnectionListener.failed_to_report_oracle_connection_details"); //$NON-NLS-1$
- ResultSet rs = null;
- Statement stmt = null;
- try {
- stmt = connection.createStatement();
- rs = stmt.executeQuery("select * from v$instance"); //$NON-NLS-1$
-
- int columnCount = rs.getMetaData().getColumnCount();
- while (rs.next()) {
- StringBuffer sb = new StringBuffer();
- for (int i = 1; i <= columnCount; i++) {
- sb.append(rs.getMetaData().getColumnName(i)).append("=").append(rs.getString(i)).append(";"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- // log the queried information
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, sb.toString());
- }
-
- } catch (SQLException e) {
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, errorStr);
- }finally {
- try {
- if (rs != null) {
- rs.close();
- }
- if (stmt != null) {
- stmt.close();
- }
- } catch (SQLException e1) {
- LogManager.logInfo(LogConstants.CTX_CONNECTOR, errorStr);
- }
- }
- }
-
- @Override
- public NullOrder getDefaultNullOrder() {
- return NullOrder.HIGH;
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return OracleCapabilities.class;
- }
-
- public boolean supportsExplicitNullOrdering() {
- return true;
- }
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/SequeLinkOracleCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/SequeLinkOracleCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/SequeLinkOracleCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,37 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.oracle;
-
-
-
-/**
- * @since 5.0
- */
-public class SequeLinkOracleCapabilities extends OracleCapabilities {
-
- @Override
- public boolean supportsBulkUpdate() {
- return false;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,284 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.postgresql;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-
-/**
- * @since 4.3
- */
-public class PostgreSQLCapabilities extends JDBCCapabilities {
-
- public static final String EIGHT_0 = "8.0"; //$NON-NLS-1$
- public static final String EIGHT_1 = "8.1"; //$NON-NLS-1$
- public static final String EIGHT_2 = "8.2"; //$NON-NLS-1$
- public static final String EIGHT_3 = "8.3"; //$NON-NLS-1$
- public static final String EIGHT_4 = "8.4"; //$NON-NLS-1$
-
- private String version = EIGHT_0;
-
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
-
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("BITAND"); //$NON-NLS-1$
- supportedFunctions.add("BITNOT"); //$NON-NLS-1$
- supportedFunctions.add("BITOR"); //$NON-NLS-1$
- supportedFunctions.add("BITXOR"); //$NON-NLS-1$
- supportedFunctions.add("CEILING"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("FORMATBIGDECIMAL"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATBIGINTEGER"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATDOUBLE"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATFLOAT"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATINTEGER"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATLONG"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("PI"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- supportedFunctions.add("ROUND"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
-
- supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("INITCAP"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LOCATE"); //$NON-NLS-1$
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- supportedFunctions.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("REPEAT"); //$NON-NLS-1$
- supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- supportedFunctions.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
-
- // These are executed within the server and never pushed down
-// supportedFunctions.add("CURDATE"); //$NON-NLS-1$
-// supportedFunctions.add("CURTIME"); //$NON-NLS-1$
-// supportedFunctions.add("NOW"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
-// supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- // These should not be pushed down since the grammar for string conversion is different
-// supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
-// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
-// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- if (this.version.compareTo(EIGHT_2) >= 0) {
- supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
- }
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
-
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
-
- // Additional functions
-// // Math
-// supportedFunctions.add("%"); //$NON-NLS-1$
-// supportedFunctions.add("^"); //$NON-NLS-1$
-// supportedFunctions.add("|/"); //$NON-NLS-1$
-// supportedFunctions.add("||/"); //$NON-NLS-1$
-// supportedFunctions.add("!"); //$NON-NLS-1$
-// supportedFunctions.add("!!"); //$NON-NLS-1$
-// supportedFunctions.add("@"); //$NON-NLS-1$
-// // Bit manipulation
-// supportedFunctions.add("&"); //$NON-NLS-1$
-// supportedFunctions.add("|"); //$NON-NLS-1$
-// supportedFunctions.add("#"); //$NON-NLS-1$
-// supportedFunctions.add("~"); //$NON-NLS-1$
-// supportedFunctions.add("<<"); //$NON-NLS-1$
-// supportedFunctions.add(">>"); //$NON-NLS-1$
-//
-// supportedFunctions.add("CBRT"); //$NON-NLS-1$
-// supportedFunctions.add("CEIL"); //$NON-NLS-1$
-// supportedFunctions.add("LN"); //$NON-NLS-1$
-// supportedFunctions.add("MOD"); //$NON-NLS-1$
-// supportedFunctions.add("RANDOM"); //$NON-NLS-1$
-// supportedFunctions.add("SETSEED"); //$NON-NLS-1$
-// supportedFunctions.add("TRUNC"); //$NON-NLS-1$
-// supportedFunctions.add("WIDTH_BUCKET"); //$NON-NLS-1$
-//
-// // String
-// supportedFunctions.add("BIT_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("BTRIM"); //$NON-NLS-1$
-// supportedFunctions.add("CHAR_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("CHARACTER_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("DECODE"); //$NON-NLS-1$
-// supportedFunctions.add("ENCODE"); //$NON-NLS-1$
-// supportedFunctions.add("MD5"); //$NON-NLS-1$
-// supportedFunctions.add("OCTET_LENGTH"); //$NON-NLS-1$
-// supportedFunctions.add("PG_CLIENT_ENCODING"); //$NON-NLS-1$
-// supportedFunctions.add("QUOTE_IDENT"); //$NON-NLS-1$
-// supportedFunctions.add("QUOTE_LITERAL"); //$NON-NLS-1$
-// supportedFunctions.add("SPLIT_PART"); //$NON-NLS-1$
-// supportedFunctions.add("STRPOS"); //$NON-NLS-1$
-// supportedFunctions.add("SUBSTR"); //$NON-NLS-1$
-// supportedFunctions.add("TO_ASCII"); //$NON-NLS-1$
-// supportedFunctions.add("TO_HEX"); //$NON-NLS-1$
-// supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
-//
-// // Bit operations
-// supportedFunctions.add("GET_BIT"); //$NON-NLS-1$
-// supportedFunctions.add("GET_BYTE"); //$NON-NLS-1$
-// supportedFunctions.add("SET_BIT"); //$NON-NLS-1$
-// supportedFunctions.add("SET_BYTE"); //$NON-NLS-1$
-//
-// // Formatting
-// supportedFunctions.add("TO_CHAR"); //$NON-NLS-1$
-// supportedFunctions.add("TO_DATE"); //$NON-NLS-1$
-// supportedFunctions.add("TO_TIMESTAMP"); //$NON-NLS-1$
-// supportedFunctions.add("TO_NUMBER"); //$NON-NLS-1$
-//
-// // Date / Time
-// supportedFunctions.add("AGE"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_DATE"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("CURRENT_TIME"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("CURRENT_TIMESTAMP"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("DATE_PART"); //$NON-NLS-1$
-// supportedFunctions.add("DATE_TRUNC"); //$NON-NLS-1$
-// supportedFunctions.add("ISFINITE"); //$NON-NLS-1$
-// supportedFunctions.add("JUSTIFY_HOURS"); //$NON-NLS-1$
-// supportedFunctions.add("JUSTIFY_DAYS"); //$NON-NLS-1$
-// supportedFunctions.add("LOCALTIME"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("LOCALTIMESTAMP"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("TIMEOFDAY"); //$NON-NLS-1$
-//
-// // Conditional
- supportedFunctions.add("COALESCE"); //$NON-NLS-1$
-// supportedFunctions.add("NULLIF"); //$NON-NLS-1$
-// supportedFunctions.add("GREATEST"); //$NON-NLS-1$
-// supportedFunctions.add("LEAST"); //$NON-NLS-1$
-//
-// // Network Addresses
-//// supportedFunctions.add("BROADCAST"); //$NON-NLS-1$
-//// supportedFunctions.add("HOST"); //$NON-NLS-1$
-//// supportedFunctions.add("MASKLEN"); //$NON-NLS-1$
-//// supportedFunctions.add("SET_MASKLEN"); //$NON-NLS-1$
-//// supportedFunctions.add("NETMASK"); //$NON-NLS-1$
-//// supportedFunctions.add("HOSTMASK"); //$NON-NLS-1$
-//// supportedFunctions.add("NETWORK"); //$NON-NLS-1$
-//// supportedFunctions.add("TEXT"); //$NON-NLS-1$
-//// supportedFunctions.add("ABBREV"); //$NON-NLS-1$
-//// supportedFunctions.add("FAMILY"); //$NON-NLS-1$
-//// supportedFunctions.add("TRUNC"); //$NON-NLS-1$
-//
-// // Set generator
-// supportedFunctions.add("GENERATE_SERIES"); //$NON-NLS-1$
-//
-// // Information
-// supportedFunctions.add("CURRENT_DATABASE"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_SCHEMA"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_SCHEMAS"); //$NON-NLS-1$
-// supportedFunctions.add("CURRENT_USER"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("INET_CLIENT_ADDR"); //$NON-NLS-1$
-// supportedFunctions.add("INET_CLIENT_PORT"); //$NON-NLS-1$
-// supportedFunctions.add("INET_SERVER_ADDR"); //$NON-NLS-1$
-// supportedFunctions.add("INET_SERVER_PORT"); //$NON-NLS-1$
-// supportedFunctions.add("SESSION_USER"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("USER"); //$NON-NLS-1$ // no ()
-// supportedFunctions.add("VERSION"); //$NON-NLS-1$
-//
- return supportedFunctions;
- }
-
- /**
- * This is true only after Postgre version 7.1
- * However, since version 7 was released in 2000 we'll assume a post 7 instance.
- *
- * @see org.teiid.translator.jdbc.JDBCCapabilities#supportsInlineViews()
- */
- public boolean supportsInlineViews() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
- public boolean supportsRowOffset() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
- */
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
- */
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
- public void setDatabaseVersion(String version) {
- this.version = version;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,473 @@
+/*
+ * 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.postgresql;
+
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.EscapeSyntaxModifier;
+import org.teiid.translator.jdbc.ExtractFunctionModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.ModFunctionModifier;
+import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
+import org.teiid.translator.jdbc.oracle.MonthOrDayNameFunctionModifier;
+
+
+
+/**
+ * Translator class for PostgreSQL. Updated to expect a 8.0+ jdbc client
+ * @since 4.3
+ */
+public class PostgreSQLExecutionFactory extends JDBCExecutionFactory {
+
+ public static final String EIGHT_0 = "8.0"; //$NON-NLS-1$
+ public static final String EIGHT_1 = "8.1"; //$NON-NLS-1$
+ public static final String EIGHT_2 = "8.2"; //$NON-NLS-1$
+ public static final String EIGHT_3 = "8.3"; //$NON-NLS-1$
+ public static final String EIGHT_4 = "8.4"; //$NON-NLS-1$
+
+ private String version = EIGHT_0;
+
+ public void start() throws ConnectorException {
+ //TODO: all of the functions (except for convert) can be handled through just the escape syntax
+ super.start();
+
+ registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LOG10, new AliasModifier("log")); //$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("&")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("~")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("|")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("#")); //$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("||")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.WEEK, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
+ registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
+
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory(), Arrays.asList(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, TypeFacility.RUNTIME_TYPES.BIG_DECIMAL))); //$NON-NLS-1$
+
+ //specific to 8.2 client or later
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
+
+ //add in type conversion
+ ConvertModifier convertModifier = new ConvertModifier();
+ convertModifier.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
+ convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("integer", FunctionModifier.INTEGER); //$NON-NLS-1$
+ convertModifier.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
+ convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("float8", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(38)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convertModifier.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
+ convertModifier.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
+ convertModifier.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
+ convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList(function.getParameters().get(0), " + TIMESTAMP '1970-01-01'"); //$NON-NLS-1$
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return Arrays.asList("cast(date_trunc('second', ", function.getParameters().get(0), ") AS time)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD HH24:MI:SS.UF")); //$NON-NLS-1$ //$NON-NLS-2$
+ convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ Expression stringValue = function.getParameters().get(0);
+ return Arrays.asList("CASE WHEN ", stringValue, " THEN 'true' WHEN not(", stringValue, ") THEN 'false' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ });
+ convertModifier.addSourceConversion(new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ ((Literal)function.getParameters().get(1)).setValue("integer"); //$NON-NLS-1$
+ return null;
+ }
+ }, FunctionModifier.BOOLEAN);
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+ }
+
+ @Override
+ public String translateLiteralBoolean(Boolean booleanValue) {
+ if(booleanValue.booleanValue()) {
+ return "TRUE"; //$NON-NLS-1$
+ }
+ return "FALSE"; //$NON-NLS-1$
+ }
+
+ @Override
+ public String translateLiteralDate(Date dateValue) {
+ return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTime(Time timeValue) {
+ return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public String translateLiteralTimestamp(Timestamp timestampValue) {
+ return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ @Override
+ public int getTimestampNanoPrecision() {
+ return 6;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ if (limit.getRowOffset() > 0) {
+ return Arrays.asList("LIMIT ", limit.getRowLimit(), " OFFSET ", limit.getRowOffset()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ return null;
+ }
+
+ /**
+ * Postgres doesn't provide min/max(boolean), so this conversion writes a min(BooleanValue) as
+ * bool_and(BooleanValue)
+ * @see org.teiid.language.visitor.LanguageObjectVisitor#visit(org.teiid.language.AggregateFunction)
+ * @since 4.3
+ */
+ @Override
+ public List<?> translate(LanguageObject obj, ExecutionContext context) {
+ if (obj instanceof AggregateFunction) {
+ AggregateFunction agg = (AggregateFunction)obj;
+ if (agg.getExpression() != null && TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(agg.getExpression().getType())) {
+ if (agg.getName().equalsIgnoreCase(SQLReservedWords.MIN)) {
+ agg.setName("bool_and"); //$NON-NLS-1$
+ } else if (agg.getName().equalsIgnoreCase(SQLReservedWords.MAX)) {
+ agg.setName("bool_or"); //$NON-NLS-1$
+ }
+ }
+ }
+ return super.translate(obj, context);
+ }
+
+ @Override
+ public NullOrder getDefaultNullOrder() {
+ return NullOrder.HIGH;
+ }
+
+ @Override
+ public boolean supportsExplicitNullOrdering() {
+ return version.compareTo(EIGHT_4) >= 0;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("BITAND"); //$NON-NLS-1$
+ supportedFunctions.add("BITNOT"); //$NON-NLS-1$
+ supportedFunctions.add("BITOR"); //$NON-NLS-1$
+ supportedFunctions.add("BITXOR"); //$NON-NLS-1$
+ supportedFunctions.add("CEILING"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("FORMATBIGDECIMAL"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATBIGINTEGER"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATDOUBLE"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATFLOAT"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATINTEGER"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATLONG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("PI"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ supportedFunctions.add("ROUND"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+
+ supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("INITCAP"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LOWER"); //$NON-NLS-1$
+ supportedFunctions.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("REPEAT"); //$NON-NLS-1$
+ supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ supportedFunctions.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("UPPER"); //$NON-NLS-1$
+
+ // These are executed within the server and never pushed down
+// supportedFunctions.add("CURDATE"); //$NON-NLS-1$
+// supportedFunctions.add("CURTIME"); //$NON-NLS-1$
+// supportedFunctions.add("NOW"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
+// supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ // These should not be pushed down since the grammar for string conversion is different
+// supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
+// supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
+// supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ if (this.version.compareTo(EIGHT_2) >= 0) {
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ }
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+
+ // Additional functions
+// // Math
+// supportedFunctions.add("%"); //$NON-NLS-1$
+// supportedFunctions.add("^"); //$NON-NLS-1$
+// supportedFunctions.add("|/"); //$NON-NLS-1$
+// supportedFunctions.add("||/"); //$NON-NLS-1$
+// supportedFunctions.add("!"); //$NON-NLS-1$
+// supportedFunctions.add("!!"); //$NON-NLS-1$
+// supportedFunctions.add("@"); //$NON-NLS-1$
+// // Bit manipulation
+// supportedFunctions.add("&"); //$NON-NLS-1$
+// supportedFunctions.add("|"); //$NON-NLS-1$
+// supportedFunctions.add("#"); //$NON-NLS-1$
+// supportedFunctions.add("~"); //$NON-NLS-1$
+// supportedFunctions.add("<<"); //$NON-NLS-1$
+// supportedFunctions.add(">>"); //$NON-NLS-1$
+//
+// supportedFunctions.add("CBRT"); //$NON-NLS-1$
+// supportedFunctions.add("CEIL"); //$NON-NLS-1$
+// supportedFunctions.add("LN"); //$NON-NLS-1$
+// supportedFunctions.add("MOD"); //$NON-NLS-1$
+// supportedFunctions.add("RANDOM"); //$NON-NLS-1$
+// supportedFunctions.add("SETSEED"); //$NON-NLS-1$
+// supportedFunctions.add("TRUNC"); //$NON-NLS-1$
+// supportedFunctions.add("WIDTH_BUCKET"); //$NON-NLS-1$
+//
+// // String
+// supportedFunctions.add("BIT_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("BTRIM"); //$NON-NLS-1$
+// supportedFunctions.add("CHAR_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("CHARACTER_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("DECODE"); //$NON-NLS-1$
+// supportedFunctions.add("ENCODE"); //$NON-NLS-1$
+// supportedFunctions.add("MD5"); //$NON-NLS-1$
+// supportedFunctions.add("OCTET_LENGTH"); //$NON-NLS-1$
+// supportedFunctions.add("PG_CLIENT_ENCODING"); //$NON-NLS-1$
+// supportedFunctions.add("QUOTE_IDENT"); //$NON-NLS-1$
+// supportedFunctions.add("QUOTE_LITERAL"); //$NON-NLS-1$
+// supportedFunctions.add("SPLIT_PART"); //$NON-NLS-1$
+// supportedFunctions.add("STRPOS"); //$NON-NLS-1$
+// supportedFunctions.add("SUBSTR"); //$NON-NLS-1$
+// supportedFunctions.add("TO_ASCII"); //$NON-NLS-1$
+// supportedFunctions.add("TO_HEX"); //$NON-NLS-1$
+// supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
+//
+// // Bit operations
+// supportedFunctions.add("GET_BIT"); //$NON-NLS-1$
+// supportedFunctions.add("GET_BYTE"); //$NON-NLS-1$
+// supportedFunctions.add("SET_BIT"); //$NON-NLS-1$
+// supportedFunctions.add("SET_BYTE"); //$NON-NLS-1$
+//
+// // Formatting
+// supportedFunctions.add("TO_CHAR"); //$NON-NLS-1$
+// supportedFunctions.add("TO_DATE"); //$NON-NLS-1$
+// supportedFunctions.add("TO_TIMESTAMP"); //$NON-NLS-1$
+// supportedFunctions.add("TO_NUMBER"); //$NON-NLS-1$
+//
+// // Date / Time
+// supportedFunctions.add("AGE"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_DATE"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("CURRENT_TIME"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("CURRENT_TIMESTAMP"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("DATE_PART"); //$NON-NLS-1$
+// supportedFunctions.add("DATE_TRUNC"); //$NON-NLS-1$
+// supportedFunctions.add("ISFINITE"); //$NON-NLS-1$
+// supportedFunctions.add("JUSTIFY_HOURS"); //$NON-NLS-1$
+// supportedFunctions.add("JUSTIFY_DAYS"); //$NON-NLS-1$
+// supportedFunctions.add("LOCALTIME"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("LOCALTIMESTAMP"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("TIMEOFDAY"); //$NON-NLS-1$
+//
+// // Conditional
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+// supportedFunctions.add("NULLIF"); //$NON-NLS-1$
+// supportedFunctions.add("GREATEST"); //$NON-NLS-1$
+// supportedFunctions.add("LEAST"); //$NON-NLS-1$
+//
+// // Network Addresses
+//// supportedFunctions.add("BROADCAST"); //$NON-NLS-1$
+//// supportedFunctions.add("HOST"); //$NON-NLS-1$
+//// supportedFunctions.add("MASKLEN"); //$NON-NLS-1$
+//// supportedFunctions.add("SET_MASKLEN"); //$NON-NLS-1$
+//// supportedFunctions.add("NETMASK"); //$NON-NLS-1$
+//// supportedFunctions.add("HOSTMASK"); //$NON-NLS-1$
+//// supportedFunctions.add("NETWORK"); //$NON-NLS-1$
+//// supportedFunctions.add("TEXT"); //$NON-NLS-1$
+//// supportedFunctions.add("ABBREV"); //$NON-NLS-1$
+//// supportedFunctions.add("FAMILY"); //$NON-NLS-1$
+//// supportedFunctions.add("TRUNC"); //$NON-NLS-1$
+//
+// // Set generator
+// supportedFunctions.add("GENERATE_SERIES"); //$NON-NLS-1$
+//
+// // Information
+// supportedFunctions.add("CURRENT_DATABASE"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_SCHEMA"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_SCHEMAS"); //$NON-NLS-1$
+// supportedFunctions.add("CURRENT_USER"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("INET_CLIENT_ADDR"); //$NON-NLS-1$
+// supportedFunctions.add("INET_CLIENT_PORT"); //$NON-NLS-1$
+// supportedFunctions.add("INET_SERVER_ADDR"); //$NON-NLS-1$
+// supportedFunctions.add("INET_SERVER_PORT"); //$NON-NLS-1$
+// supportedFunctions.add("SESSION_USER"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("USER"); //$NON-NLS-1$ // no ()
+// supportedFunctions.add("VERSION"); //$NON-NLS-1$
+//
+ return supportedFunctions;
+ }
+
+ /**
+ * This is true only after Postgre version 7.1
+ * However, since version 7 was released in 2000 we'll assume a post 7 instance.
+ *
+ * @see org.teiid.translator.jdbc.JDBCCapabilities#supportsInlineViews()
+ */
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+ @Override
+ public boolean supportsRowOffset() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
+ */
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
+ */
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+
+ @TranslatorProperty(name="DatabaseVersion", description= "Version of the postgres", defaultValue=EIGHT_0)
+ public String getDatabaseVersion() {
+ return this.version;
+ }
+
+ public void setDatabaseVersion(String version) {
+ this.version = version;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,224 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.postgresql;
-
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.AggregateFunction;
-import org.teiid.language.Expression;
-import org.teiid.language.Function;
-import org.teiid.language.LanguageObject;
-import org.teiid.language.Limit;
-import org.teiid.language.Literal;
-import org.teiid.language.SQLReservedWords;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.AliasModifier;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.EscapeSyntaxModifier;
-import org.teiid.translator.jdbc.ExtractFunctionModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.ModFunctionModifier;
-import org.teiid.translator.jdbc.Translator;
-import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
-import org.teiid.translator.jdbc.oracle.MonthOrDayNameFunctionModifier;
-
-
-
-/**
- * Translator class for PostgreSQL. Updated to expect a 8.0+ jdbc client
- * @since 4.3
- */
-public class PostgreSQLTranslator extends Translator {
-
- private String version = PostgreSQLCapabilities.EIGHT_0;
-
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- //TODO: all of the functions (except for convert) can be handled through just the escape syntax
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.LOG, new AliasModifier("ln")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LOG10, new AliasModifier("log")); //$NON-NLS-1$
-
- registerFunctionModifier(SourceSystemFunctions.BITAND, new AliasModifier("&")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITNOT, new AliasModifier("~")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITOR, new AliasModifier("|")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.BITXOR, new AliasModifier("#")); //$NON-NLS-1$
-
- registerFunctionModifier(SourceSystemFunctions.CHAR, new AliasModifier("chr")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("||")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LEFT, new LeftOrRightFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.RIGHT, new LeftOrRightFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$
-
- registerFunctionModifier(SourceSystemFunctions.DAYNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Day"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.HOUR, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.MINUTE, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.MONTH, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new MonthOrDayNameFunctionModifier(getLanguageFactory(), "Month"));//$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.QUARTER, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.SECOND, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.WEEK, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.YEAR, new ExtractFunctionModifier());
- registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
-
- registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory(), Arrays.asList(TypeFacility.RUNTIME_TYPES.BIG_INTEGER, TypeFacility.RUNTIME_TYPES.BIG_DECIMAL))); //$NON-NLS-1$
-
- //specific to 8.2 client or later
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
-
- //add in type conversion
- ConvertModifier convertModifier = new ConvertModifier();
- convertModifier.addTypeMapping("boolean", FunctionModifier.BOOLEAN); //$NON-NLS-1$
- convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
- convertModifier.addTypeMapping("integer", FunctionModifier.INTEGER); //$NON-NLS-1$
- convertModifier.addTypeMapping("bigint", FunctionModifier.LONG); //$NON-NLS-1$
- convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
- convertModifier.addTypeMapping("float8", FunctionModifier.DOUBLE); //$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(38)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convertModifier.addTypeMapping("decimal", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convertModifier.addTypeMapping("varchar(4000)", FunctionModifier.STRING); //$NON-NLS-1$
- convertModifier.addTypeMapping("date", FunctionModifier.DATE); //$NON-NLS-1$
- convertModifier.addTypeMapping("time", FunctionModifier.TIME); //$NON-NLS-1$
- convertModifier.addTypeMapping("timestamp", FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.TIMESTAMP, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList(function.getParameters().get(0), " + TIMESTAMP '1970-01-01'"); //$NON-NLS-1$
- }
- });
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return Arrays.asList("cast(date_trunc('second', ", function.getParameters().get(0), ") AS time)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "HH24:MI:SS")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new ConvertModifier.FormatModifier("to_char", "YYYY-MM-DD HH24:MI:SS.UF")); //$NON-NLS-1$ //$NON-NLS-2$
- convertModifier.addConvert(FunctionModifier.BOOLEAN, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- Expression stringValue = function.getParameters().get(0);
- return Arrays.asList("CASE WHEN ", stringValue, " THEN 'true' WHEN not(", stringValue, ") THEN 'false' END"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- });
- convertModifier.addSourceConversion(new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- ((Literal)function.getParameters().get(1)).setValue("integer"); //$NON-NLS-1$
- return null;
- }
- }, FunctionModifier.BOOLEAN);
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
- }
-
- @Override
- public String translateLiteralBoolean(Boolean booleanValue) {
- if(booleanValue.booleanValue()) {
- return "TRUE"; //$NON-NLS-1$
- }
- return "FALSE"; //$NON-NLS-1$
- }
-
- @Override
- public String translateLiteralDate(Date dateValue) {
- return "DATE '" + formatDateValue(dateValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTime(Time timeValue) {
- return "TIME '" + formatDateValue(timeValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public String translateLiteralTimestamp(Timestamp timestampValue) {
- return "TIMESTAMP '" + formatDateValue(timestampValue) + "'"; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- @Override
- public int getTimestampNanoPrecision() {
- return 6;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List<?> translateLimit(Limit limit, ExecutionContext context) {
- if (limit.getRowOffset() > 0) {
- return Arrays.asList("LIMIT ", limit.getRowLimit(), " OFFSET ", limit.getRowOffset()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return null;
- }
-
- /**
- * Postgres doesn't provide min/max(boolean), so this conversion writes a min(BooleanValue) as
- * bool_and(BooleanValue)
- * @see org.teiid.language.visitor.LanguageObjectVisitor#visit(org.teiid.language.AggregateFunction)
- * @since 4.3
- */
- @Override
- public List<?> translate(LanguageObject obj, ExecutionContext context) {
- if (obj instanceof AggregateFunction) {
- AggregateFunction agg = (AggregateFunction)obj;
- if (agg.getExpression() != null && TypeFacility.RUNTIME_TYPES.BOOLEAN.equals(agg.getExpression().getType())) {
- if (agg.getName().equalsIgnoreCase(SQLReservedWords.MIN)) {
- agg.setName("bool_and"); //$NON-NLS-1$
- } else if (agg.getName().equalsIgnoreCase(SQLReservedWords.MAX)) {
- agg.setName("bool_or"); //$NON-NLS-1$
- }
- }
- }
- return super.translate(obj, context);
- }
-
- @Override
- public NullOrder getDefaultNullOrder() {
- return NullOrder.HIGH;
- }
-
- @Override
- public boolean supportsExplicitNullOrdering() {
- return version.compareTo(PostgreSQLCapabilities.EIGHT_4) >= 0;
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return PostgreSQLCapabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,138 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.sqlserver;
-
-import java.util.*;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-/**
- */
-public class SQLServerCapabilities extends JDBCCapabilities {
-
- public SQLServerCapabilities() {
- }
-
- /**
- * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("PI"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- //supportedFunctons.add("INITCAP"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- //supportedFunctons.add("LOCATE"); //$NON-NLS-1$
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- //supportedFunctons.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("REPEAT"); //$NON-NLS-1$
- //supportedFunctions.add("RAND"); //$NON-NLS-1$
- supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- //supportedFunctons.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SPACE"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- //supportedFunctons.add("TRANSLATE"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- //supportedFunctons.add("CURDATE"); //$NON-NLS-1$
- //supportedFunctons.add("CURTIME"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- //supportedFunctions.add("NOW"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
-
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
- public boolean supportsExcept() {
- return true;
- };
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,173 @@
+/*
+ * 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.sqlserver;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.sybase.SybaseExecutionFactory;
+
+/**
+ * Updated to assume the use of the DataDirect, 2005 driver, or later.
+ */
+public class SQLServerExecutionFactory extends SybaseExecutionFactory {
+
+ //TEIID-31 remove mod modifier for SQL Server 2008
+
+ @Override
+ protected List<Object> convertDateToString(Function function) {
+ return Arrays.asList("replace(convert(varchar, ", function.getParameters().get(0), ", 102), '.', '-')"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ protected List<?> convertTimestampToString(Function function) {
+ return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ", 21)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public List<?> translate(LanguageObject obj, ExecutionContext context) {
+ if (obj instanceof ColumnReference) {
+ ColumnReference elem = (ColumnReference)obj;
+ if (TypeFacility.RUNTIME_TYPES.STRING.equals(elem.getType()) && elem.getMetadataObject() != null && "uniqueidentifier".equalsIgnoreCase(elem.getMetadataObject().getNativeType())) { //$NON-NLS-1$
+ return Arrays.asList("cast(", elem, " as char(36))"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ return super.translate(obj, context);
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getDefaultSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("PI"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ //supportedFunctons.add("INITCAP"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ //supportedFunctons.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LOWER"); //$NON-NLS-1$
+ //supportedFunctons.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("REPEAT"); //$NON-NLS-1$
+ //supportedFunctions.add("RAND"); //$NON-NLS-1$
+ supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ //supportedFunctons.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SPACE"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ //supportedFunctons.add("TRANSLATE"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("UPPER"); //$NON-NLS-1$
+ //supportedFunctons.add("CURDATE"); //$NON-NLS-1$
+ //supportedFunctons.add("CURTIME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ //supportedFunctions.add("NOW"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ };
+
+ @Override
+ public int getMaxFromGroups() {
+ return DEFAULT_MAX_FROM_GROUPS;
+ }
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return JDBCExecutionFactory.DEFAULT_MAX_IN_CRITERIA;
+ }
+
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,71 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.sqlserver;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.ColumnReference;
-import org.teiid.language.Function;
-import org.teiid.language.LanguageObject;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
-
-/**
- * Updated to assume the use of the DataDirect, 2005 driver, or later.
- */
-public class SQLServerSQLTranslator extends SybaseSQLTranslator {
-
- //TEIID-31 remove mod modifier for SQL Server 2008
-
- @Override
- protected List<Object> convertDateToString(Function function) {
- return Arrays.asList("replace(convert(varchar, ", function.getParameters().get(0), ", 102), '.', '-')"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- protected List<?> convertTimestampToString(Function function) {
- return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ", 21)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return SQLServerCapabilities.class;
- }
-
- @Override
- public List<?> translate(LanguageObject obj, ExecutionContext context) {
- if (obj instanceof ColumnReference) {
- ColumnReference elem = (ColumnReference)obj;
- if (TypeFacility.RUNTIME_TYPES.STRING.equals(elem.getType()) && elem.getMetadataObject() != null && "uniqueidentifier".equalsIgnoreCase(elem.getMetadataObject().getNativeType())) { //$NON-NLS-1$
- return Arrays.asList("cast(", elem, " as char(36))"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return super.translate(obj, context);
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,134 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.sybase;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-/**
- */
-public class SybaseCapabilities extends JDBCCapabilities {
-
- public SybaseCapabilities() {
- }
-
- @Override
- public int getMaxInCriteriaSize() {
- return 250;
- }
-
- /**
- * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("PI"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("REPEAT"); //$NON-NLS-1$
- //supportedFunctions.add("RAND"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SPACE"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- //supportedFunctons.add("CURDATE"); //$NON-NLS-1$
- //supportedFunctons.add("CURTIME"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- //supportedFunctions.add("NOW"); //$NON-NLS-1$
- supportedFunctions.add("QUARTER"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
- //supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
-
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.BasicConnectorCapabilities#getMaxFromGroups()
- */
- public int getMaxFromGroups() {
- return 50;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,292 @@
+/*
+ * 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.sybase;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Command;
+import org.teiid.language.Function;
+import org.teiid.language.Limit;
+import org.teiid.language.OrderBy;
+import org.teiid.language.SetQuery;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.AliasModifier;
+import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.EscapeSyntaxModifier;
+import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.ModFunctionModifier;
+
+
+/**
+ */
+public class SybaseExecutionFactory extends JDBCExecutionFactory {
+
+ public void start() throws ConnectorException {
+ super.start();
+
+ registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory())); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("+")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("isnull")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.REPEAT, new AliasModifier("replicate")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier(getLanguageFactory()));
+ registerFunctionModifier(SourceSystemFunctions.DAYNAME, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.HOUR, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.MINUTE, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.QUARTER, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.SECOND, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.LENGTH, new EscapeSyntaxModifier());
+ registerFunctionModifier(SourceSystemFunctions.ATAN2, new EscapeSyntaxModifier());
+
+ //add in type conversion
+ ConvertModifier convertModifier = new ConvertModifier();
+ //boolean isn't treated as bit, since it doesn't support null
+ //byte is treated as smallint, since tinyint is unsigned
+ convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(19,0)", FunctionModifier.LONG); //$NON-NLS-1$
+ convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
+ convertModifier.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(38, 0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
+ convertModifier.addTypeMapping("numeric(38, 19)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
+ convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
+ convertModifier.addTypeMapping("varchar(40)", FunctionModifier.STRING); //$NON-NLS-1$
+ convertModifier.addTypeMapping("datetime", FunctionModifier.DATE, FunctionModifier.TIME, FunctionModifier.TIMESTAMP); //$NON-NLS-1$
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ List<Object> result = new ArrayList<Object>();
+ result.add("cast("); //$NON-NLS-1$
+ result.add("'1970-01-01 ' + "); //$NON-NLS-1$
+ result.addAll(convertTimeToString(function));
+ result.add(" AS datetime)"); //$NON-NLS-1$
+ return result;
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ List<Object> result = new ArrayList<Object>();
+ result.add("cast("); //$NON-NLS-1$
+ result.addAll(convertDateToString(function));
+ result.add(" AS datetime)"); //$NON-NLS-1$
+ return result;
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return convertTimeToString(function);
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return convertDateToString(function);
+ }
+ });
+ convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
+ @Override
+ public List<?> translate(Function function) {
+ return convertTimestampToString(function);
+ }
+ });
+ convertModifier.addNumericBooleanConversions();
+ registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
+ }
+
+ private List<Object> convertTimeToString(Function function) {
+ return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ", 8)"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ protected List<Object> convertDateToString(Function function) {
+ return Arrays.asList("stuff(stuff(convert(varchar, ", function.getParameters().get(0), ", 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Written to only support version 15
+ * @param function
+ * @return
+ */
+ protected List<?> convertTimestampToString(Function function) {
+ return Arrays.asList("stuff(convert(varchar, ", function.getParameters().get(0), ", 123), 11, 1, ' ')"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Override
+ public boolean useAsInGroupAlias() {
+ return false;
+ }
+
+ @Override
+ public boolean hasTimeType() {
+ return false;
+ }
+
+ @Override
+ public int getTimestampNanoPrecision() {
+ return 3;
+ }
+
+ /**
+ * SetQueries don't have a concept of TOP, an inline view is needed.
+ */
+ @Override
+ public List<?> translateCommand(Command command, ExecutionContext context) {
+ if (!(command instanceof SetQuery)) {
+ return null;
+ }
+ SetQuery queryCommand = (SetQuery)command;
+ if (queryCommand.getLimit() == null) {
+ return null;
+ }
+ Limit limit = queryCommand.getLimit();
+ OrderBy orderBy = queryCommand.getOrderBy();
+ queryCommand.setLimit(null);
+ queryCommand.setOrderBy(null);
+ List<Object> parts = new ArrayList<Object>(6);
+ parts.add("SELECT "); //$NON-NLS-1$
+ parts.addAll(translateLimit(limit, context));
+ parts.add(" * FROM ("); //$NON-NLS-1$
+ parts.add(queryCommand);
+ parts.add(") AS X"); //$NON-NLS-1$
+ if (orderBy != null) {
+ parts.add(" "); //$NON-NLS-1$
+ parts.add(orderBy);
+ }
+ return parts;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> translateLimit(Limit limit, ExecutionContext context) {
+ return Arrays.asList("TOP ", limit.getRowLimit()); //$NON-NLS-1$
+ }
+
+ @Override
+ public boolean useSelectLimit() {
+ return true;
+ }
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return 250;
+ }
+
+ @Override
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("PI"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LOWER"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("REPEAT"); //$NON-NLS-1$
+ //supportedFunctions.add("RAND"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SPACE"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("UPPER"); //$NON-NLS-1$
+ //supportedFunctons.add("CURDATE"); //$NON-NLS-1$
+ //supportedFunctons.add("CURTIME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ //supportedFunctions.add("NOW"); //$NON-NLS-1$
+ supportedFunctions.add("QUARTER"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+ //supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+
+ @Override
+ public int getMaxFromGroups() {
+ return 50;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,214 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.sybase;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.language.Command;
-import org.teiid.language.Function;
-import org.teiid.language.Limit;
-import org.teiid.language.OrderBy;
-import org.teiid.language.SetQuery;
-import org.teiid.translator.ConnectorCapabilities;
-import org.teiid.translator.ConnectorException;
-import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.AliasModifier;
-import org.teiid.translator.jdbc.ConvertModifier;
-import org.teiid.translator.jdbc.EscapeSyntaxModifier;
-import org.teiid.translator.jdbc.FunctionModifier;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.ModFunctionModifier;
-import org.teiid.translator.jdbc.Translator;
-
-
-/**
- */
-public class SybaseSQLTranslator extends Translator {
-
- /*
- * @see com.metamatrix.connector.jdbc.extension.SQLTranslator#initialize(com.metamatrix.data.api.ConnectorEnvironment, com.metamatrix.data.metadata.runtime.RuntimeMetadata)
- */
- public void initialize(JDBCExecutionFactory env) throws ConnectorException {
- super.initialize(env);
- registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("%", getLanguageFactory())); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.CONCAT, new AliasModifier("+")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.LCASE, new AliasModifier("lower")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("isnull")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.UCASE, new AliasModifier("upper")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.REPEAT, new AliasModifier("replicate")); //$NON-NLS-1$
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.DAYNAME, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.MONTHNAME, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFWEEK, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFYEAR, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.HOUR, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.MINUTE, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.QUARTER, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.SECOND, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.WEEK, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPADD, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.TIMESTAMPDIFF, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.LENGTH, new EscapeSyntaxModifier());
- registerFunctionModifier(SourceSystemFunctions.ATAN2, new EscapeSyntaxModifier());
-
- //add in type conversion
- ConvertModifier convertModifier = new ConvertModifier();
- //boolean isn't treated as bit, since it doesn't support null
- //byte is treated as smallint, since tinyint is unsigned
- convertModifier.addTypeMapping("smallint", FunctionModifier.BYTE, FunctionModifier.SHORT); //$NON-NLS-1$
- convertModifier.addTypeMapping("int", FunctionModifier.INTEGER); //$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(19,0)", FunctionModifier.LONG); //$NON-NLS-1$
- convertModifier.addTypeMapping("real", FunctionModifier.FLOAT); //$NON-NLS-1$
- convertModifier.addTypeMapping("double precision", FunctionModifier.DOUBLE); //$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(38, 0)", FunctionModifier.BIGINTEGER); //$NON-NLS-1$
- convertModifier.addTypeMapping("numeric(38, 19)", FunctionModifier.BIGDECIMAL); //$NON-NLS-1$
- convertModifier.addTypeMapping("char(1)", FunctionModifier.CHAR); //$NON-NLS-1$
- convertModifier.addTypeMapping("varchar(40)", FunctionModifier.STRING); //$NON-NLS-1$
- convertModifier.addTypeMapping("datetime", FunctionModifier.DATE, FunctionModifier.TIME, FunctionModifier.TIMESTAMP); //$NON-NLS-1$
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.TIME, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- List<Object> result = new ArrayList<Object>();
- result.add("cast("); //$NON-NLS-1$
- result.add("'1970-01-01 ' + "); //$NON-NLS-1$
- result.addAll(convertTimeToString(function));
- result.add(" AS datetime)"); //$NON-NLS-1$
- return result;
- }
- });
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.DATE, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- List<Object> result = new ArrayList<Object>();
- result.add("cast("); //$NON-NLS-1$
- result.addAll(convertDateToString(function));
- result.add(" AS datetime)"); //$NON-NLS-1$
- return result;
- }
- });
- convertModifier.addConvert(FunctionModifier.TIME, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return convertTimeToString(function);
- }
- });
- convertModifier.addConvert(FunctionModifier.DATE, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return convertDateToString(function);
- }
- });
- convertModifier.addConvert(FunctionModifier.TIMESTAMP, FunctionModifier.STRING, new FunctionModifier() {
- @Override
- public List<?> translate(Function function) {
- return convertTimestampToString(function);
- }
- });
- convertModifier.addNumericBooleanConversions();
- registerFunctionModifier(SourceSystemFunctions.CONVERT, convertModifier);
- }
-
- private List<Object> convertTimeToString(Function function) {
- return Arrays.asList("convert(varchar, ", function.getParameters().get(0), ", 8)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected List<Object> convertDateToString(Function function) {
- return Arrays.asList("stuff(stuff(convert(varchar, ", function.getParameters().get(0), ", 102), 5, 1, '-'), 8, 1, '-')"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Written to only support version 15
- * @param function
- * @return
- */
- protected List<?> convertTimestampToString(Function function) {
- return Arrays.asList("stuff(convert(varchar, ", function.getParameters().get(0), ", 123), 11, 1, ' ')"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Override
- public boolean useAsInGroupAlias() {
- return false;
- }
-
- @Override
- public boolean hasTimeType() {
- return false;
- }
-
- @Override
- public int getTimestampNanoPrecision() {
- return 3;
- }
-
- /**
- * SetQueries don't have a concept of TOP, an inline view is needed.
- */
- @Override
- public List<?> translateCommand(Command command, ExecutionContext context) {
- if (!(command instanceof SetQuery)) {
- return null;
- }
- SetQuery queryCommand = (SetQuery)command;
- if (queryCommand.getLimit() == null) {
- return null;
- }
- Limit limit = queryCommand.getLimit();
- OrderBy orderBy = queryCommand.getOrderBy();
- queryCommand.setLimit(null);
- queryCommand.setOrderBy(null);
- List<Object> parts = new ArrayList<Object>(6);
- parts.add("SELECT "); //$NON-NLS-1$
- parts.addAll(translateLimit(limit, context));
- parts.add(" * FROM ("); //$NON-NLS-1$
- parts.add(queryCommand);
- parts.add(") AS X"); //$NON-NLS-1$
- if (orderBy != null) {
- parts.add(" "); //$NON-NLS-1$
- parts.add(orderBy);
- }
- return parts;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public List<?> translateLimit(Limit limit, ExecutionContext context) {
- return Arrays.asList("TOP ", limit.getRowLimit()); //$NON-NLS-1$
- }
-
- @Override
- public boolean useSelectLimit() {
- return true;
- }
-
- @Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return SybaseCapabilities.class;
- }
-
-}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,167 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-/*
- */
-package org.teiid.translator.jdbc.teiid;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-/**
- * @since 4.3
- */
-public class TeiidCapabilities extends JDBCCapabilities {
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
- * @since 4.3
- */
- public List<String> getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("CEILING"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("COT"); //$NON-NLS-1$
- supportedFunctions.add("DEGREES"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
- supportedFunctions.add("FLOOR"); //$NON-NLS-1$
- supportedFunctions.add("FORMATBIGDECIMAL"); //$NON-NLS-1$
- supportedFunctions.add("FORMATBIGINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("FORMATDOUBLE"); //$NON-NLS-1$
- supportedFunctions.add("FORMATFLOAT"); //$NON-NLS-1$
- supportedFunctions.add("FORMATINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("FORMATLONG"); //$NON-NLS-1$
- supportedFunctions.add("LOG"); //$NON-NLS-1$
- supportedFunctions.add("LOG10"); //$NON-NLS-1$
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("PARSEBIGDECIMAL"); //$NON-NLS-1$
- supportedFunctions.add("PARSEBIGINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("PARSEDOUBLE"); //$NON-NLS-1$
- supportedFunctions.add("PARSEFLOAT"); //$NON-NLS-1$
- supportedFunctions.add("PARSEINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("PARSELONG"); //$NON-NLS-1$
- supportedFunctions.add("PI"); //$NON-NLS-1$
- supportedFunctions.add("POWER"); //$NON-NLS-1$
- supportedFunctions.add("RADIANS"); //$NON-NLS-1$
- supportedFunctions.add("RAND"); //$NON-NLS-1$
- supportedFunctions.add("ROUND"); //$NON-NLS-1$
- supportedFunctions.add("SIGN"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("ASCII"); //$NON-NLS-1$
- supportedFunctions.add("CHAR"); //$NON-NLS-1$
- supportedFunctions.add("CHR"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT"); //$NON-NLS-1$
- supportedFunctions.add("CONCAT2"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
- supportedFunctions.add("INITCAP"); //$NON-NLS-1$
- supportedFunctions.add("INSERT"); //$NON-NLS-1$
- supportedFunctions.add("LCASE"); //$NON-NLS-1$
- supportedFunctions.add("LENGTH"); //$NON-NLS-1$
- supportedFunctions.add("LEFT"); //$NON-NLS-1$
- supportedFunctions.add("LOCATE"); //$NON-NLS-1$
- supportedFunctions.add("LPAD"); //$NON-NLS-1$
- supportedFunctions.add("LTRIM"); //$NON-NLS-1$
- supportedFunctions.add("REPEAT"); //$NON-NLS-1$
- supportedFunctions.add("REPLACE"); //$NON-NLS-1$
- supportedFunctions.add("RPAD"); //$NON-NLS-1$
- supportedFunctions.add("RIGHT"); //$NON-NLS-1$
- supportedFunctions.add("RTRIM"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
- supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
- supportedFunctions.add("UCASE"); //$NON-NLS-1$
- supportedFunctions.add("CURDATE"); //$NON-NLS-1$
- supportedFunctions.add("CURTIME"); //$NON-NLS-1$
- supportedFunctions.add("NOW"); //$NON-NLS-1$
- supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
- supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
- supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
- supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
- supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
- supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
- supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
- supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
- supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
- supportedFunctions.add("WEEK"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("MODIFYTIMEZONE"); //$NON-NLS-1$
- supportedFunctions.add("DECODESTRING"); //$NON-NLS-1$
- supportedFunctions.add("DECODEINTEGER"); //$NON-NLS-1$
- supportedFunctions.add("IFNULL"); //$NON-NLS-1$
- supportedFunctions.add("NVL"); //$NON-NLS-1$
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- supportedFunctions.add("CONVERT"); //$NON-NLS-1$
- supportedFunctions.add("USER"); //$NON-NLS-1$
- supportedFunctions.add("FROM_UNIXTIME"); //$NON-NLS-1$
- supportedFunctions.add("NULLIF"); //$NON-NLS-1$
- supportedFunctions.add("COALESCE"); //$NON-NLS-1$
- return supportedFunctions;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- /**
- * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- public boolean supportsRowOffset() {
- return true;
- }
-
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,164 @@
+/*
+ * 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.teiid;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+
+/**
+ * @since 4.3
+ */
+public class TeiidExecutionFactory extends JDBCExecutionFactory {
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
+ * @since 4.3
+ */
+ public List<String> getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("CEILING"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("COT"); //$NON-NLS-1$
+ supportedFunctions.add("DEGREES"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+ supportedFunctions.add("FLOOR"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATBIGDECIMAL"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATBIGINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATDOUBLE"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATFLOAT"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATLONG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG"); //$NON-NLS-1$
+ supportedFunctions.add("LOG10"); //$NON-NLS-1$
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEBIGDECIMAL"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEBIGINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEDOUBLE"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEFLOAT"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("PARSELONG"); //$NON-NLS-1$
+ supportedFunctions.add("PI"); //$NON-NLS-1$
+ supportedFunctions.add("POWER"); //$NON-NLS-1$
+ supportedFunctions.add("RADIANS"); //$NON-NLS-1$
+ supportedFunctions.add("RAND"); //$NON-NLS-1$
+ supportedFunctions.add("ROUND"); //$NON-NLS-1$
+ supportedFunctions.add("SIGN"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ supportedFunctions.add("ASCII"); //$NON-NLS-1$
+ supportedFunctions.add("CHAR"); //$NON-NLS-1$
+ supportedFunctions.add("CHR"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT"); //$NON-NLS-1$
+ supportedFunctions.add("CONCAT2"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+ supportedFunctions.add("INITCAP"); //$NON-NLS-1$
+ supportedFunctions.add("INSERT"); //$NON-NLS-1$
+ supportedFunctions.add("LCASE"); //$NON-NLS-1$
+ supportedFunctions.add("LENGTH"); //$NON-NLS-1$
+ supportedFunctions.add("LEFT"); //$NON-NLS-1$
+ supportedFunctions.add("LOCATE"); //$NON-NLS-1$
+ supportedFunctions.add("LPAD"); //$NON-NLS-1$
+ supportedFunctions.add("LTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("REPEAT"); //$NON-NLS-1$
+ supportedFunctions.add("REPLACE"); //$NON-NLS-1$
+ supportedFunctions.add("RPAD"); //$NON-NLS-1$
+ supportedFunctions.add("RIGHT"); //$NON-NLS-1$
+ supportedFunctions.add("RTRIM"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+ supportedFunctions.add("TRANSLATE"); //$NON-NLS-1$
+ supportedFunctions.add("UCASE"); //$NON-NLS-1$
+ supportedFunctions.add("CURDATE"); //$NON-NLS-1$
+ supportedFunctions.add("CURTIME"); //$NON-NLS-1$
+ supportedFunctions.add("NOW"); //$NON-NLS-1$
+ supportedFunctions.add("DAYNAME"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFMONTH"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFWEEK"); //$NON-NLS-1$
+ supportedFunctions.add("DAYOFYEAR"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATDATE"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATTIME"); //$NON-NLS-1$
+ supportedFunctions.add("FORMATTIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("MONTHNAME"); //$NON-NLS-1$
+ supportedFunctions.add("PARSEDATE"); //$NON-NLS-1$
+ supportedFunctions.add("PARSETIME"); //$NON-NLS-1$
+ supportedFunctions.add("PARSETIMESTAMP"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPADD"); //$NON-NLS-1$
+ supportedFunctions.add("TIMESTAMPDIFF"); //$NON-NLS-1$
+ supportedFunctions.add("WEEK"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("MODIFYTIMEZONE"); //$NON-NLS-1$
+ supportedFunctions.add("DECODESTRING"); //$NON-NLS-1$
+ supportedFunctions.add("DECODEINTEGER"); //$NON-NLS-1$
+ supportedFunctions.add("IFNULL"); //$NON-NLS-1$
+ supportedFunctions.add("NVL"); //$NON-NLS-1$
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ supportedFunctions.add("CONVERT"); //$NON-NLS-1$
+ supportedFunctions.add("USER"); //$NON-NLS-1$
+ supportedFunctions.add("FROM_UNIXTIME"); //$NON-NLS-1$
+ supportedFunctions.add("NULLIF"); //$NON-NLS-1$
+ supportedFunctions.add("COALESCE"); //$NON-NLS-1$
+ return supportedFunctions;
+ }
+
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFunctionsInGroupBy() {
+ return true;
+ }
+
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ public boolean supportsRowOffset() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
+}
Deleted: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,87 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc.teradata;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.jdbc.JDBCCapabilities;
-
-
-
-/**
- * for Teradata database Release V2R5.1
- */
-public class TeradataCapabilities extends JDBCCapabilities {
-
- public TeradataCapabilities() {
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- /**
- * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List getSupportedFunctions() {
- List supportedFunctions = new ArrayList();
- supportedFunctions.addAll(super.getSupportedFunctions());
- supportedFunctions.add("ABS"); //$NON-NLS-1$
- supportedFunctions.add("ACOS"); //$NON-NLS-1$
- supportedFunctions.add("ASIN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN"); //$NON-NLS-1$
- supportedFunctions.add("ATAN2"); //$NON-NLS-1$
- supportedFunctions.add("COS"); //$NON-NLS-1$
- supportedFunctions.add("EXP"); //$NON-NLS-1$
-// supportedFunctions.add("LOG"); //$NON-NLS-1$ // "LN"
-// supportedFunctions.add("LOG10"); //$NON-NLS-1$ // "LOG"
- supportedFunctions.add("MOD"); //$NON-NLS-1$
- supportedFunctions.add("SIN"); //$NON-NLS-1$
- supportedFunctions.add("SQRT"); //$NON-NLS-1$
- supportedFunctions.add("TAN"); //$NON-NLS-1$
- supportedFunctions.add("||"); //$NON-NLS-1$
-// supportedFunctions.add("CONCAT"); //$NON-NLS-1$ // "||"
-// supportedFunctions.add("LCASE"); //$NON-NLS-1$ // "LOWER"
-// supportedFunctions.add("LOCATE"); //$NON-NLS-1$ //"POSITION", "INDEX" ?
- supportedFunctions.add("LOWER"); //$NON-NLS-1$
- supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
-// supportedFunctions.add("UCASE"); //$NON-NLS-1$ // "UPPER"
- supportedFunctions.add("UPPER"); //$NON-NLS-1$
- supportedFunctions.add("HOUR"); //$NON-NLS-1$
- supportedFunctions.add("MONTH"); //$NON-NLS-1$
- supportedFunctions.add("YEAR"); //$NON-NLS-1$
- supportedFunctions.add("DAY"); //$NON-NLS-1$
- supportedFunctions.add("MINUTE"); //$NON-NLS-1$
- supportedFunctions.add("SECOND"); //$NON-NLS-1$
-
- supportedFunctions.add("CAST"); //$NON-NLS-1$
- //supportedFunctions.add("CONVERT"); //$NON-NLS-1$ "CAST"
-
- return supportedFunctions;
- }
-
-}
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java (from rev 2121, trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -0,0 +1,87 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.jdbc.teradata;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+
+
+
+/**
+ * for Teradata database Release V2R5.1
+ */
+public class TeradataExecutionFactory extends JDBCExecutionFactory {
+
+ public TeradataExecutionFactory() {
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsFullOuterJoins()
+ */
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.resource.cci.data.ConnectorCapabilities#getSupportedFunctions()
+ */
+ public List getSupportedFunctions() {
+ List supportedFunctions = new ArrayList();
+ supportedFunctions.addAll(super.getSupportedFunctions());
+ supportedFunctions.add("ABS"); //$NON-NLS-1$
+ supportedFunctions.add("ACOS"); //$NON-NLS-1$
+ supportedFunctions.add("ASIN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN"); //$NON-NLS-1$
+ supportedFunctions.add("ATAN2"); //$NON-NLS-1$
+ supportedFunctions.add("COS"); //$NON-NLS-1$
+ supportedFunctions.add("EXP"); //$NON-NLS-1$
+// supportedFunctions.add("LOG"); //$NON-NLS-1$ // "LN"
+// supportedFunctions.add("LOG10"); //$NON-NLS-1$ // "LOG"
+ supportedFunctions.add("MOD"); //$NON-NLS-1$
+ supportedFunctions.add("SIN"); //$NON-NLS-1$
+ supportedFunctions.add("SQRT"); //$NON-NLS-1$
+ supportedFunctions.add("TAN"); //$NON-NLS-1$
+ supportedFunctions.add("||"); //$NON-NLS-1$
+// supportedFunctions.add("CONCAT"); //$NON-NLS-1$ // "||"
+// supportedFunctions.add("LCASE"); //$NON-NLS-1$ // "LOWER"
+// supportedFunctions.add("LOCATE"); //$NON-NLS-1$ //"POSITION", "INDEX" ?
+ supportedFunctions.add("LOWER"); //$NON-NLS-1$
+ supportedFunctions.add("SUBSTRING"); //$NON-NLS-1$
+// supportedFunctions.add("UCASE"); //$NON-NLS-1$ // "UPPER"
+ supportedFunctions.add("UPPER"); //$NON-NLS-1$
+ supportedFunctions.add("HOUR"); //$NON-NLS-1$
+ supportedFunctions.add("MONTH"); //$NON-NLS-1$
+ supportedFunctions.add("YEAR"); //$NON-NLS-1$
+ supportedFunctions.add("DAY"); //$NON-NLS-1$
+ supportedFunctions.add("MINUTE"); //$NON-NLS-1$
+ supportedFunctions.add("SECOND"); //$NON-NLS-1$
+
+ supportedFunctions.add("CAST"); //$NON-NLS-1$
+ //supportedFunctions.add("CONVERT"); //$NON-NLS-1$ "CAST"
+
+ return supportedFunctions;
+ }
+
+}
Modified: trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/main/resources/META-INF/jboss-beans.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -10,7 +10,7 @@
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.resource.adapter.jdbc.JDBCExecutionFactory</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.jdbc.JDBCExecutionFactory</parameter>
<parameter class="java.lang.String">${project.artifactId}-${project.version}</parameter>
<parameter class="java.lang.String">${project.description}</parameter>
</constructor>
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -29,8 +29,6 @@
import org.teiid.language.Command;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.TranslatedCommand;
-import org.teiid.translator.jdbc.Translator;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
@@ -52,7 +50,7 @@
return util.parseCommand(sql);
}
- public static void helpTestVisitor(String vdb, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ public static void helpTestVisitor(String vdb, String input, String expectedOutput, JDBCExecutionFactory translator) throws ConnectorException {
// Convert from sql to objects
Command obj = helpTranslate(vdb, input);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -36,9 +36,6 @@
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.ExtractFunctionModifier;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.Translator;
/**
@@ -61,9 +58,9 @@
Integer.class);
ExtractFunctionModifier mod = new ExtractFunctionModifier ();
- Translator trans = new Translator();
+ JDBCExecutionFactory trans = new JDBCExecutionFactory();
trans.registerFunctionModifier(target, mod);
- trans.initialize(new JDBCExecutionFactory());
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
Deleted: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,44 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.jdbc;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.Translator;
-import org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator;
-public class TestJDBCExecutionFactory {
-
- @Test public void testGetExtensionTranslationClassDefault() throws Exception {
- JDBCExecutionFactory mcf = new JDBCExecutionFactory();
- assertSame(Translator.class, mcf.getTranslator().getClass());
- }
-
- @Test public void testGetExtensionTranslationClass() throws Exception {
- JDBCExecutionFactory mcf = new JDBCExecutionFactory();
- mcf.setExtensionTranslationClassName(SQLServerSQLTranslator.class.getName());
- assertSame(SQLServerSQLTranslator.class, mcf.getTranslator().getClass());
- }
-
-}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -33,9 +33,6 @@
import org.mockito.Mockito;
import org.teiid.language.Command;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.JDBCProcedureExecution;
-import org.teiid.translator.jdbc.Translator;
public class TestJDBCProcedureExecution {
@@ -46,12 +43,9 @@
Mockito.stub(cs.getUpdateCount()).toReturn(-1);
Mockito.stub(cs.getInt(1)).toReturn(5);
Mockito.stub(connection.prepareCall("{ call spTest8a(?)}")).toReturn(cs); //$NON-NLS-1$
- Translator sqlTranslator = new Translator();
+ JDBCExecutionFactory ef = new JDBCExecutionFactory();
- JDBCExecutionFactory config = Mockito.mock(JDBCExecutionFactory.class);
- Mockito.stub(config.getTranslator()).toReturn(sqlTranslator);
-
- JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command, connection, Mockito.mock(ExecutionContext.class), config, sqlTranslator);
+ JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command, connection, Mockito.mock(ExecutionContext.class), ef);
procedureExecution.execute();
assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
Mockito.verify(cs, Mockito.times(1)).registerOutParameter(1, Types.INTEGER);
@@ -63,12 +57,9 @@
Mockito.stub(cs.getUpdateCount()).toReturn(-1);
Mockito.stub(cs.getInt(2)).toReturn(5);
Mockito.stub(connection.prepareCall("{ call spTest8(?,?)}")).toReturn(cs); //$NON-NLS-1$
- Translator sqlTranslator = new Translator();
+ JDBCExecutionFactory config = new JDBCExecutionFactory();
- JDBCExecutionFactory config = Mockito.mock(JDBCExecutionFactory.class);
- Mockito.stub(config.getTranslator()).toReturn(sqlTranslator);
-
- JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command, connection, Mockito.mock(ExecutionContext.class), config, sqlTranslator);
+ JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command, connection, Mockito.mock(ExecutionContext.class), config);
procedureExecution.execute();
assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
Mockito.verify(cs, Mockito.times(1)).registerOutParameter(2, Types.INTEGER);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -33,9 +33,6 @@
import org.teiid.language.Insert;
import org.teiid.language.Literal;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
-import org.teiid.translator.jdbc.JDBCUpdateExecution;
-import org.teiid.translator.jdbc.Translator;
public class TestJDBCUpdateExecution {
@@ -54,10 +51,9 @@
Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
- JDBCExecutionFactory config = Mockito.mock(JDBCExecutionFactory.class);
- Mockito.stub(config.getTranslator()).toReturn(new Translator());
+ JDBCExecutionFactory config = new JDBCExecutionFactory();
- JDBCUpdateExecution updateExecution = new JDBCUpdateExecution(command, connection, Mockito.mock(ExecutionContext.class), config, config.getTranslator());
+ JDBCUpdateExecution updateExecution = new JDBCUpdateExecution(command, connection, Mockito.mock(ExecutionContext.class), config);
updateExecution.execute();
Mockito.verify(p, Mockito.times(2)).addBatch();
}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -32,9 +32,6 @@
import org.teiid.language.LanguageFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.LocateFunctionModifier;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.Translator;
/**
* Test <code>LOCATEFunctionModifier</code> by invoking its methods with varying
@@ -97,16 +94,15 @@
Arrays.asList(param1, param2), Integer.class);
}
- Translator trans = new Translator() {
+ JDBCExecutionFactory trans = new JDBCExecutionFactory() {
@Override
- public void initialize(JDBCExecutionFactory env)
- throws ConnectorException {
- super.initialize(env);
+ public void start() throws ConnectorException {
+ super.start();
registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory(), locateFunctionName, parameterOrder));
}
};
- trans.initialize(new JDBCExecutionFactory());
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -33,9 +33,6 @@
import org.teiid.language.LanguageFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.ModFunctionModifier;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.Translator;
/**
* Test <code>ModFunctionModifier</code> by invoking its methods with varying
@@ -90,16 +87,15 @@
Function func = LANG_FACTORY.createFunction(modFunctionName,
Arrays.asList(param1, param2), param1.getType());
- Translator trans = new Translator() {
+ JDBCExecutionFactory trans = new JDBCExecutionFactory() {
@Override
- public void initialize(JDBCExecutionFactory env)
- throws ConnectorException {
- super.initialize(env);
+ public void start() throws ConnectorException {
+ super.start();
registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier(modFunctionName, getLanguageFactory()));
}
};
- trans.initialize(new JDBCExecutionFactory());
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -37,8 +37,6 @@
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.Translator;
/**
*/
@@ -53,13 +51,12 @@
"PartID", //$NON-NLS-1$
"ExecCount"); //$NON-NLS-1$
- private static Translator TRANSLATOR;
+ private static JDBCExecutionFactory TRANSLATOR;
@BeforeClass public static void oneTimeSetup() throws ConnectorException {
- TRANSLATOR = new Translator();
- JDBCExecutionFactory env = new JDBCExecutionFactory();
- env.setTrimStrings(true);
- TRANSLATOR.initialize(env);
+ TRANSLATOR = new JDBCExecutionFactory();
+ TRANSLATOR.setTrimStrings(true);
+ TRANSLATOR.start();
}
public String getTestVDB() {
@@ -71,13 +68,12 @@
}
public void helpTestVisitor(String vdb, String input, String expectedOutput, boolean usePreparedStatement) {
- Translator trans = new Translator();
- JDBCExecutionFactory env = new JDBCExecutionFactory();
+ JDBCExecutionFactory trans = new JDBCExecutionFactory();
if (usePreparedStatement) {
- env.setUseBindVariables(true);
+ trans.setUseBindVariables(true);
}
try {
- trans.initialize(env);
+ trans.start();
TranslationHelper.helpTestVisitor(vdb, input, expectedOutput, trans);
} catch (ConnectorException e) {
throw new RuntimeException(e);
@@ -89,9 +85,9 @@
private String getStringWithContext(LanguageObject obj) throws ConnectorException {
JDBCExecutionFactory env = new JDBCExecutionFactory();
env.setUseCommentsInSourceQuery(true);
- Translator trans = new Translator();
- trans.initialize(env);
- SQLConversionVisitor visitor = trans.getSQLConversionVisitor();
+ env.start();
+
+ SQLConversionVisitor visitor = env.getSQLConversionVisitor();
visitor.setExecutionContext(context);
visitor.append(obj);
return visitor.toString();
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -36,8 +36,6 @@
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.TranslatedCommand;
-import org.teiid.translator.jdbc.Translator;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
@@ -72,19 +70,18 @@
return util.parseCommand(sql);
}
- public static void helpTestVisitor(String vdb, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ public static void helpTestVisitor(String vdb, String input, String expectedOutput, JDBCExecutionFactory translator) throws ConnectorException {
helpTestVisitor(vdb,null,input, expectedOutput, translator);
}
- public static void helpTestVisitor(String vdb, String udf, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ public static void helpTestVisitor(String vdb, String udf, String input, String expectedOutput, JDBCExecutionFactory translator) throws ConnectorException {
// Convert from sql to objects
Command obj = helpTranslate(vdb, udf, input);
helpTestVisitor(expectedOutput, translator, obj);
}
- public static void helpTestVisitor(String expectedOutput,
- Translator translator, Command obj) throws ConnectorException {
+ public static void helpTestVisitor(String expectedOutput, JDBCExecutionFactory translator, Command obj) throws ConnectorException {
TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), translator);
tc.translateCommand(obj);
assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -30,8 +30,6 @@
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
-import org.teiid.translator.jdbc.Translator;
-import org.teiid.translator.jdbc.access.AccessSQLTranslator;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
@@ -41,12 +39,12 @@
*/
public class TestAccessSQLTranslator extends TestCase {
- private static Translator TRANSLATOR;
+ private static JDBCExecutionFactory TRANSLATOR;
static {
try {
- TRANSLATOR = new AccessSQLTranslator();
- TRANSLATOR.initialize(Mockito.mock(JDBCExecutionFactory.class));
+ TRANSLATOR = new AccessExecutionFactory();
+ TRANSLATOR.start();
} catch(ConnectorException e) {
e.printStackTrace();
}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -34,9 +34,7 @@
import org.teiid.language.LanguageFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
/**
@@ -54,8 +52,8 @@
}
public String helpGetString(Expression expr) throws Exception {
- DB2SQLTranslator trans = new DB2SQLTranslator();
- trans.initialize(new JDBCExecutionFactory());
+ DB2ExecutionFactory trans = new DB2ExecutionFactory();
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(expr);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -31,10 +31,8 @@
import org.teiid.language.Command;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
import com.metamatrix.cdk.api.TranslationUtility;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
@@ -43,12 +41,12 @@
*/
public class TestDB2SqlTranslator {
- private static DB2SQLTranslator TRANSLATOR;
+ private static DB2ExecutionFactory TRANSLATOR;
@BeforeClass
public static void setUp() throws ConnectorException {
- TRANSLATOR = new DB2SQLTranslator();
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR = new DB2ExecutionFactory();
+ TRANSLATOR.start();
}
public String getTestVDB() {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbyCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbyCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbyCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -22,24 +22,25 @@
package org.teiid.translator.jdbc.derby;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import org.junit.Test;
-import org.teiid.translator.jdbc.derby.DerbyCapabilities;
public class TestDerbyCapabilities {
@Test public void testLimitSupport() {
- DerbyCapabilities derbyCapabilities = new DerbyCapabilities();
+ DerbyExecutionFactory derbyCapabilities = new DerbyExecutionFactory();
assertFalse(derbyCapabilities.supportsRowLimit());
- derbyCapabilities.setDatabaseVersion(DerbyCapabilities.TEN_5);
+ derbyCapabilities.setDatabaseVersion(DerbyExecutionFactory.TEN_5);
assertTrue(derbyCapabilities.supportsRowLimit());
}
@Test public void testFunctionSupport() {
- DerbyCapabilities derbyCapabilities = new DerbyCapabilities();
+ DerbyExecutionFactory derbyCapabilities = new DerbyExecutionFactory();
assertEquals(27, derbyCapabilities.getSupportedFunctions().size());
- derbyCapabilities.setDatabaseVersion(DerbyCapabilities.TEN_4);
+ derbyCapabilities.setDatabaseVersion(DerbyExecutionFactory.TEN_4);
assertEquals(43, derbyCapabilities.getSupportedFunctions().size());
}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -24,23 +24,20 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.mockito.Mockito;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.derby.DerbySQLTranslator;
/**
*/
public class TestDerbySQLTranslator {
- private static DerbySQLTranslator TRANSLATOR;
+ private static DerbyExecutionFactory TRANSLATOR;
@BeforeClass
public static void setUp() throws ConnectorException {
- TRANSLATOR = new DerbySQLTranslator();
- TRANSLATOR.initialize(Mockito.mock(JDBCExecutionFactory.class));
+ TRANSLATOR = new DerbyExecutionFactory();
+ TRANSLATOR.start();
}
@Test
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -25,18 +25,16 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.h2.H2Translator;
public class TestH2Translator {
- private static H2Translator TRANSLATOR;
+ private static H2ExecutionFactory TRANSLATOR;
@BeforeClass
public static void setUp() throws ConnectorException {
- TRANSLATOR = new H2Translator();
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR = new H2ExecutionFactory();
+ TRANSLATOR.start();
}
@Test public void testTimestampDiff() throws Exception {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -25,19 +25,17 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.mysql.MySQL5Translator;
/**
*/
public class TestMySQL5Translator {
- private static MySQL5Translator TRANSLATOR;
+ private static MySQL5ExecutionFactory TRANSLATOR;
@BeforeClass public static void oneTimeSetup() throws ConnectorException {
- TRANSLATOR = new MySQL5Translator();
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR = new MySQL5ExecutionFactory();
+ TRANSLATOR.start();
}
@Test public void testChar() throws Exception {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -26,19 +26,17 @@
import org.junit.Ignore;
import org.junit.Test;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.mysql.MySQLTranslator;
/**
*/
public class TestMySQLTranslator {
- private static MySQLTranslator TRANSLATOR;
+ private static MySQLExecutionFactory TRANSLATOR;
@BeforeClass public static void oneTimeSetup() throws ConnectorException {
- TRANSLATOR = new MySQLTranslator();
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR = new MySQLExecutionFactory();
+ TRANSLATOR.start();
}
private String getTestVDB() {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -32,9 +32,7 @@
import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.SourceSystemFunctions;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
/**
@@ -56,8 +54,8 @@
Arrays.asList(c),
String.class);
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(new JDBCExecutionFactory());
+ OracleExecutionFactory trans = new OracleExecutionFactory();
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -29,9 +29,7 @@
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
/**
*/
@@ -52,8 +50,8 @@
Arrays.asList( c, d ),
String.class);
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(new JDBCExecutionFactory());
+ OracleExecutionFactory trans = new OracleExecutionFactory();
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -31,9 +31,7 @@
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
/**
@@ -55,8 +53,8 @@
Arrays.asList( c ),
String.class);
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(new JDBCExecutionFactory());
+ OracleExecutionFactory trans = new OracleExecutionFactory();
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -36,10 +36,7 @@
import org.teiid.language.LanguageFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.Translator;
-import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
/**
@@ -48,15 +45,15 @@
private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
- private static Translator TRANSLATOR = new OracleSQLTranslator();
+ private static OracleExecutionFactory TRANSLATOR = new OracleExecutionFactory();
@BeforeClass public static void oneTimeSetup() throws Exception {
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR.start();
}
public String helpGetString(Expression expr) throws Exception {
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(new JDBCExecutionFactory());
+ OracleExecutionFactory trans = new OracleExecutionFactory();
+ trans.start();
SQLConversionVisitor sqlVisitor = TRANSLATOR.getSQLConversionVisitor();
sqlVisitor.append(expr);
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 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -45,27 +45,21 @@
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.Translator;
-import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
import com.metamatrix.cdk.api.TranslationUtility;
public class TestOracleTranslator {
- /**
- * An instance of {@link Translator} which has already been initialized.
- */
- private Translator TRANSLATOR;
+ private OracleExecutionFactory TRANSLATOR;
private String UDF = "/OracleSpatialFunctions.xmi"; //$NON-NLS-1$;
private static ExecutionContext EMPTY_CONTEXT = new FakeExecutionContextImpl();
@Before
public void setup() throws Exception {
- TRANSLATOR = new OracleSQLTranslator();
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR = new OracleExecutionFactory();
+ TRANSLATOR.start();
}
private void helpTestVisitor(String input, String expectedOutput) throws ConnectorException {
@@ -522,13 +516,12 @@
}
private void helpTestVisitor(Command obj, ExecutionContext context, String dbmsTimeZone, String expectedOutput) throws ConnectorException {
- OracleSQLTranslator translator = new OracleSQLTranslator();
- JDBCExecutionFactory f = new JDBCExecutionFactory();
+ OracleExecutionFactory translator = new OracleExecutionFactory();
if (dbmsTimeZone != null) {
- f.setDatabaseTimeZone(dbmsTimeZone);
+ translator.setDatabaseTimeZone(dbmsTimeZone);
}
- translator.initialize(f);
+ translator.start();
// Convert back to SQL
TranslatedCommand tc = new TranslatedCommand(context, translator);
tc.translateCommand(obj);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -30,9 +30,7 @@
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.translator.TypeFacility;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
/**
*/
@@ -53,8 +51,8 @@
Function func = LANG_FACTORY.createFunction("substring", //$NON-NLS-1$
Arrays.asList(args), TypeFacility.RUNTIME_TYPES.STRING);
- OracleSQLTranslator trans = new OracleSQLTranslator();
- trans.initialize(new JDBCExecutionFactory());
+ OracleExecutionFactory trans = new OracleExecutionFactory();
+ trans.start();
SQLConversionVisitor sqlVisitor = trans.getSQLConversionVisitor();
sqlVisitor.append(func);
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -25,17 +25,15 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.postgresql.PostgreSQLTranslator;
public class TestPostgreSQLTranslator {
- private static PostgreSQLTranslator TRANSLATOR;
+ private static PostgreSQLExecutionFactory TRANSLATOR;
@BeforeClass public static void setupOnce() throws Exception {
- TRANSLATOR = new PostgreSQLTranslator();
- TRANSLATOR.initialize(new JDBCExecutionFactory());
+ TRANSLATOR = new PostgreSQLExecutionFactory();
+ TRANSLATOR.start();
}
public String getTestVDB() {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -37,9 +37,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator;
import com.metamatrix.cdk.api.TranslationUtility;
@@ -47,11 +45,11 @@
*/
public class TestSqlServerConversionVisitor {
- private static SQLServerSQLTranslator trans = new SQLServerSQLTranslator();
+ private static SQLServerExecutionFactory trans = new SQLServerExecutionFactory();
@BeforeClass
public static void setup() throws ConnectorException {
- trans.initialize(new JDBCExecutionFactory());
+ trans.start();
}
public String getTestVDB() {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -37,9 +37,7 @@
import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.ConnectorException;
-import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
-import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
/**
@@ -47,11 +45,11 @@
public class TestSybaseConvertModifier {
private static final LanguageFactory LANG_FACTORY = new LanguageFactory();
- private static SybaseSQLTranslator trans = new SybaseSQLTranslator();
+ private static SybaseExecutionFactory trans = new SybaseExecutionFactory();
@BeforeClass
public static void setup() throws ConnectorException {
- trans.initialize(new JDBCExecutionFactory());
+ trans.start();
}
public String helpGetString(Expression expr) throws Exception {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -33,17 +33,17 @@
import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.TranslationHelper;
-import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
+import org.teiid.translator.jdbc.sybase.SybaseExecutionFactory;
/**
*/
public class TestSybaseSQLConversionVisitor {
- private static SybaseSQLTranslator trans = new SybaseSQLTranslator();
+ private static SybaseExecutionFactory trans = new SybaseExecutionFactory();
@BeforeClass
public static void setup() throws ConnectorException {
- trans.initialize(new JDBCExecutionFactory());
+ trans.start();
}
public String getTestVDB() {
Deleted: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,82 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.translator.ldap;
-
-import org.teiid.translator.BasicConnectorCapabilities;
-
-/**
- * This class extends the BasicConnectorCapabilities class, and establishes
- * the capabilities that are supported by the LDAPConnector.
- */
-public class LDAPConnectorCapabilities extends BasicConnectorCapabilities {
-
- @Override
- public int getMaxInCriteriaSize() {
- return 1000;
- }
-
- public boolean supportsCompareCriteriaEquals() {
- return true;
- }
-
- public boolean supportsInCriteria() {
- return true;
- }
-
- public boolean supportsLikeCriteria() {
- return true;
- }
-
- public boolean supportsOrCriteria() {
- return true;
- }
-
- public boolean supportsOrderBy() {
- // Removed this support -- see LDAPSyncQueryExecution comments for details.
- return false;
- }
-
- public boolean supportsRowLimit() {
- // GHH 20080408 - turned this on, because I fixed issue
- // in nextBatch that was causing this to fail
- return true;
- }
-
- public boolean supportsRowOffset() {
- // TODO This might actually be possible in future releases,
- // when using virtual list views/Sun. note that this requires the ability
- // to set the count limit, as well as an offset, so setCountLimit::searchControls
- // won't do it alone.
- return false;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return true;
- }
-
- @Override
- public boolean supportsNotCriteria() {
- return true;
- }
-
-}
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -29,28 +29,24 @@
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.TranslatorProperty;
import org.teiid.translator.UpdateExecution;
/**
- * LDAPConnector. This is responsible for initializing
+ * LDAP translator. This is responsible for initializing
* a connection factory, and obtaining connections to LDAP.
*/
-public class LDAPExecutionFactory extends BasicExecutionFactory {
+public class LDAPExecutionFactory extends ExecutionFactory {
private String searchDefaultBaseDN;
private boolean restrictToObjectClass = false;
private String searchDefaultScope = "SUBTREE_SCOPE"; //$NON-NLS-1$
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return LDAPConnectorCapabilities.class;
- }
@TranslatorProperty(name="SearchDefaultBaseDN", display="Default Search Base DN", description="Default Base DN for LDAP Searches",advanced=true, defaultValue="")
public String getSearchDefaultBaseDN() {
@@ -100,4 +96,61 @@
throw new ConnectorException(e);
}
}
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return 1000;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrderBy() {
+ // Removed this support -- see LDAPSyncQueryExecution comments for details.
+ return false;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ // GHH 20080408 - turned this on, because I fixed issue
+ // in nextBatch that was causing this to fail
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowOffset() {
+ // TODO This might actually be possible in future releases,
+ // when using virtual list views/Sun. note that this requires the ability
+ // to set the count limit, as well as an offset, so setCountLimit::searchControls
+ // won't do it alone.
+ return false;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return 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 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -97,7 +97,6 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ResultSetExecution;
@@ -107,7 +106,7 @@
* LDAPSyncQueryExecution is responsible for executing an LDAP search
* corresponding to a read-only "select" query from MetaMatrix.
*/
-public class LDAPSyncQueryExecution extends BasicExecution implements ResultSetExecution {
+public class LDAPSyncQueryExecution implements ResultSetExecution {
private LDAPSearchDetails searchDetails;
private LdapContext ldapConnection;
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -47,7 +47,6 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.AbstractMetadataRecord;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.UpdateExecution;
@@ -69,7 +68,7 @@
* item in the WHERE clause for UPDATE and DELETE operations, and in the list
* of attributes to assign values in an INSERT operation * Responsible for update/insert/delete operations against LDAP
*/
-public class LDAPUpdateExecution extends BasicExecution implements UpdateExecution {
+public class LDAPUpdateExecution implements UpdateExecution {
private LdapContext ldapConnection;
private LdapContext ldapCtx;
private Command command;
Modified: trunk/connectors/translator-ldap/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-ldap/src/main/resources/META-INF/jboss-beans.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-ldap/src/main/resources/META-INF/jboss-beans.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -10,7 +10,7 @@
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.resource.adapter.ldap.LDAPExecutionFactory</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.ldap.LDAPExecutionFactory</parameter>
<parameter class="java.lang.String">${project.artifactId}-${project.version}</parameter>
<parameter class="java.lang.String">${project.description}</parameter>
</constructor>
Deleted: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,317 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.loopback;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.teiid.translator.BasicConnectorCapabilities;
-
-
-/**
- * Specifies the capabilities of this connector. Since we want this
- * connector to be able to emulate most other connectors, these
- * capabilities support everything.
- */
-public class LoopbackCapabilities extends BasicConnectorCapabilities {
-
- /**
- * Construct the capabilities class
- */
- public LoopbackCapabilities() {
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#getSupportedFunctions()
- */
- public List getSupportedFunctions() {
- List functions = Arrays.asList(new String[] {
- "+", "-", "*", "/", "abs", "acos", "asin", "atan", "atan2", "ceiling", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
- "bitand", "bitnot", "bitor", "bitxor", "cos", "cot", "degrees", "cos", "cot", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
- "degrees", "exp", "floor", "log", "log10", "mod", "pi", "power", "radians", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
- "round", "sign", "sin", "sqrt", "tan", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- "ascii", "chr", "char", "concat", "initcap", "insert", "lcase", "left", "length", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
- "locate", "lower", "lpad", "ltrim", "repeat", "replace", "right", "rpad", "rtrim", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
- "substring", "translate", "ucase", "upper", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- "curdate", "curtime", "now", "dayname", "dayofmonth", "dayofweek", "dayofyear", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "hour", "minute", "month", "monthname", "quarter", "second", "timestampadd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- "timestampdiff", "week", "year", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "cast", "convert", "ifnull", "nvl" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- });
- return functions;
- }
-
- @Override
- public boolean supportsGroupBy() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesAvg()
- */
- public boolean supportsAggregatesAvg() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesCount()
- */
- public boolean supportsAggregatesCount() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesCountStar()
- */
- public boolean supportsAggregatesCountStar() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesDistinct()
- */
- public boolean supportsAggregatesDistinct() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesMax()
- */
- public boolean supportsAggregatesMax() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesMin()
- */
- public boolean supportsAggregatesMin() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesSum()
- */
- public boolean supportsAggregatesSum() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsAliasedGroup()
- */
- public boolean supportsAliasedGroup() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsBetweenCriteria()
- */
- public boolean supportsBetweenCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsCaseExpressions()
- */
- public boolean supportsCaseExpressions() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsCompareCriteriaEquals()
- */
- public boolean supportsCompareCriteriaEquals() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsCorrelatedSubqueries()
- */
- public boolean supportsCorrelatedSubqueries() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsExistsCriteria()
- */
- public boolean supportsExistsCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsInCriteria()
- */
- public boolean supportsInCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsInCriteriaSubquery()
- */
- public boolean supportsInCriteriaSubquery() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsIsNullCriteria()
- */
- public boolean supportsIsNullCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsLikeCriteria()
- */
- public boolean supportsLikeCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
- */
- public boolean supportsLikeCriteriaEscapeCharacter() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsNotCriteria()
- */
- public boolean supportsNotCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOrCriteria()
- */
- public boolean supportsOrCriteria() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsOuterJoins()
- */
- public boolean supportsOuterJoins() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
- */
- public boolean supportsQuantifiedCompareCriteriaAll() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsScalarSubqueries()
- */
- public boolean supportsScalarSubqueries() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsSearchedCaseExpressions()
- */
- public boolean supportsSearchedCaseExpressions() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsSelectDistinct()
- */
- public boolean supportsSelectDistinct() {
- return true;
- }
-
- /*
- * @see com.metamatrix.data.ConnectorCapabilities#supportsSelfJoins()
- */
- public boolean supportsSelfJoins() {
- return true;
- }
-
- public boolean supportsInlineViews() {
- return true;
- }
-
- public boolean supportsQuantifiedCompareCriteriaSome() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- @Override
- public boolean supportsSelectExpression() {
- return true;
- }
-
- @Override
- public boolean supportsSetQueryOrderBy() {
- return true;
- }
-
- @Override
- public boolean supportsUnions() {
- return true;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return true;
- }
-
- @Override
- public boolean supportsInnerJoins() {
- return true;
- }
-
- @Override
- public boolean supportsExcept() {
- return true;
- }
-
- @Override
- public boolean supportsHaving() {
- return true;
- }
-
- @Override
- public boolean supportsIntersect() {
- return true;
- }
-
-}
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -40,8 +40,6 @@
import org.teiid.language.Argument.Direction;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ProcedureExecution;
@@ -52,7 +50,7 @@
/**
* Represents the execution of a command.
*/
-public class LoopbackExecution extends BasicExecution implements UpdateExecution, ProcedureExecution {
+public class LoopbackExecution implements UpdateExecution, ProcedureExecution {
private static final String ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; //$NON-NLS-1$
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -22,19 +22,21 @@
package org.teiid.translator.loopback;
+import java.util.Arrays;
+import java.util.List;
+
import org.teiid.language.Command;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.TranslatorProperty;
/**
- * Loopback connector.
+ * Loopback translator.
*/
-public class LoopbackExecutionFactory extends BasicExecutionFactory {
+public class LoopbackExecutionFactory extends ExecutionFactory {
private int waitTime = 0;
private int rowCount = 1;
@@ -83,11 +85,6 @@
}
@Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return LoopbackCapabilities.class;
- }
-
- @Override
public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionfactory)
throws ConnectorException {
return new LoopbackExecution(command, this);
@@ -97,4 +94,220 @@
public boolean isSourceRequired() {
return false;
}
+
+ @Override
+ public List getSupportedFunctions() {
+ List functions = Arrays.asList(new String[] {
+ "+", "-", "*", "/", "abs", "acos", "asin", "atan", "atan2", "ceiling", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
+ "bitand", "bitnot", "bitor", "bitxor", "cos", "cot", "degrees", "cos", "cot", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ "degrees", "exp", "floor", "log", "log10", "mod", "pi", "power", "radians", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ "round", "sign", "sin", "sqrt", "tan", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ "ascii", "chr", "char", "concat", "initcap", "insert", "lcase", "left", "length", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ "locate", "lower", "lpad", "ltrim", "repeat", "replace", "right", "rpad", "rtrim", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ "substring", "translate", "ucase", "upper", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ "curdate", "curtime", "now", "dayname", "dayofmonth", "dayofweek", "dayofyear", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ "hour", "minute", "month", "monthname", "quarter", "second", "timestampadd", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ "timestampdiff", "week", "year", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ "cast", "convert", "ifnull", "nvl" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ });
+ return functions;
+ }
+
+ @Override
+ public boolean supportsGroupBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesAvg() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesCount() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesDistinct() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesMax() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesMin() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAggregatesSum() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsAliasedGroup() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsBetweenCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCaseExpressions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCorrelatedSubqueries() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExistsCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsFullOuterJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteriaSubquery() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIsNullCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrderBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsScalarSubqueries() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSearchedCaseExpressions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelectDistinct() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelfJoins() {
+ return true;
+ }
+ @Override
+ public boolean supportsInlineViews() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return true;
+ }
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelectExpression() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInnerJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsExcept() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsHaving() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsIntersect() {
+ return true;
+ }
}
Modified: trunk/connectors/translator-loopback/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-loopback/src/main/resources/META-INF/jboss-beans.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-loopback/src/main/resources/META-INF/jboss-beans.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -10,7 +10,7 @@
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.resource.adapter.loopback.LoopbackExecutionFactory</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.loopback.LoopbackExecutionFactory</parameter>
<parameter class="java.lang.String">${project.artifactId}-${project.version}</parameter>
<parameter class="java.lang.String">${project.description}</parameter>
</constructor>
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -22,6 +22,9 @@
package org.teiid.translator.salesforce;
+import java.util.ArrayList;
+import java.util.List;
+
import org.teiid.language.Call;
import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
@@ -29,9 +32,9 @@
import org.teiid.logging.LogManager;
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.MetadataProvider;
import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.ResultSetExecution;
@@ -44,7 +47,7 @@
import org.teiid.translator.salesforce.execution.UpdateExecutionImpl;
-public class SalesForceExecutionFactory extends org.teiid.translator.BasicExecutionFactory implements MetadataProvider {
+public class SalesForceExecutionFactory extends ExecutionFactory implements MetadataProvider {
private String connectorStateClass;
private boolean auditModelFields = false;
@@ -74,11 +77,6 @@
@Override
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return SalesforceCapabilities.class;
- }
-
- @Override
public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
throws ConnectorException {
return new QueryExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
@@ -108,4 +106,74 @@
MetadataProcessor processor = new MetadataProcessor((SalesforceConnection)connectionFactory,metadataFactory, this);
processor.processMetadata();
}
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return 700;
+ }
+
+ @Override
+ public List getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.add("includes"); //$NON-NLS-1$
+ supportedFunctions.add("excludes"); //$NON-NLS-1$
+ return supportedFunctions;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ // http://jira.jboss.org/jira/browse/JBEDSP-306
+ // Salesforce supports ORDER BY, but not on all column types
+ @Override
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return true;
+ }
+
+ @Override
+ public SupportedJoinCriteria getSupportedJoinCriteria() {
+ return SupportedJoinCriteria.KEY;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() {
+ return true;
+ }
}
Deleted: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.translator.salesforce;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.teiid.translator.BasicConnectorCapabilities;
-
-public class SalesforceCapabilities extends BasicConnectorCapabilities {
-
- public int getMaxInCriteriaSize() {
- return 700;
- }
-
- public List getSupportedFunctions() {
- List<String> supportedFunctions = new ArrayList<String>();
- supportedFunctions.add("includes");
- supportedFunctions.add("excludes");
- return supportedFunctions;
- }
-
- public boolean supportsCompareCriteriaEquals() {
- return true;
- }
-
- public boolean supportsInCriteria() {
- return true;
- }
-
- public boolean supportsLikeCriteria() {
- return true;
- }
-
- public boolean supportsRowLimit() {
- return true;
- }
-
- // http://jira.jboss.org/jira/browse/JBEDSP-306
- // Salesforce supports ORDER BY, but not on all column types
- public boolean supportsOrderBy() {
- return false;
- }
-
- @Override
- public boolean supportsAggregatesCountStar() {
- return true;
- }
-
- @Override
- public boolean supportsNotCriteria() {
- return true;
- }
-
- @Override
- public boolean supportsOrCriteria() {
- return true;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return true;
- }
-
- @Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.KEY;
- }
-
- @Override
- public boolean supportsOuterJoins() {
- return true;
- }
-
-
-
-}
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -27,7 +27,6 @@
import org.teiid.language.Comparison;
import org.teiid.language.Condition;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ExecutionContext;
@@ -46,7 +45,7 @@
* get IDs of Salesforce objects.
*
*/
-public abstract class AbstractUpdateExecution extends BasicExecution implements UpdateExecution {
+public abstract class AbstractUpdateExecution implements UpdateExecution {
protected SalesforceConnection connection;
protected RuntimeMetadata metadata;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -44,7 +44,6 @@
import org.teiid.metadata.Column;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ExecutionContext;
@@ -59,7 +58,7 @@
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.sobject.SObject;
-public class QueryExecutionImpl extends BasicExecution implements ResultSetExecution {
+public class QueryExecutionImpl implements ResultSetExecution {
private SalesforceConnection connection;
Modified: trunk/connectors/translator-salesforce/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-salesforce/src/main/resources/META-INF/jboss-beans.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-salesforce/src/main/resources/META-INF/jboss-beans.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -10,7 +10,7 @@
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.resource.adapter.salesforce.SalesForceExecutionFactory</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.salesforce.SalesForceExecutionFactory</parameter>
<parameter class="java.lang.String">${project.artifactId}-${project.version}</parameter>
<parameter class="java.lang.String">${project.description}</parameter>
</constructor>
Deleted: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -1,31 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.translator.text;
-
-import org.teiid.translator.BasicConnectorCapabilities;
-
-public class TextCapabilities extends BasicConnectorCapabilities {
-
- static TextCapabilities INSTANCE = new TextCapabilities();
-
-}
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -45,9 +45,9 @@
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
-import org.teiid.translator.BasicExecutionFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.FileConnection;
import org.teiid.translator.MetadataProvider;
import org.teiid.translator.ResultSetExecution;
@@ -58,7 +58,7 @@
/**
* Implementation of text connector.
*/
-public class TextExecutionFactory extends BasicExecutionFactory implements MetadataProvider{
+public class TextExecutionFactory extends ExecutionFactory implements MetadataProvider{
private boolean enforceColumnCount = false;
private String dateResultFormatsDelimiter;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -39,7 +39,6 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ResultSetExecution;
@@ -49,7 +48,7 @@
* The essential part that executes the query. It keeps all the execution
* states.
*/
-public class TextSynchExecution extends BasicExecution implements ResultSetExecution {
+public class TextSynchExecution implements ResultSetExecution {
// Command to be executed
private Select cmd;
Modified: trunk/connectors/translator-text/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-text/src/main/resources/META-INF/jboss-beans.xml 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/connectors/translator-text/src/main/resources/META-INF/jboss-beans.xml 2010-05-13 13:40:34 UTC (rev 2122)
@@ -10,7 +10,7 @@
<constructor factoryMethod="createTemplateInfo">
<factory bean="TranslatorDeploymentTemplateInfoFactory"/>
<parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
- <parameter class="java.lang.Class">org.teiid.resource.adapter.text.TextExecutionFactory</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.text.TextExecutionFactory</parameter>
<parameter class="java.lang.String">${project.artifactId}-${project.version}</parameter>
<parameter class="java.lang.String">${project.description}</parameter>
</constructor>
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -144,9 +144,8 @@
}
checkStatus();
- ExecutionFactory connector = getExecutionFactory();
- ConnectorCapabilities caps = connector.getCapabilities();
- BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(caps, this.connectorId, connector.isXaCapable());
+ ExecutionFactory translator = getExecutionFactory();
+ BasicSourceCapabilities resultCaps = CapabilitiesConverter.convertCapabilities(translator, this.connectorId, translator.isXaCapable());
resultCaps.setScope(Scope.SCOPE_GLOBAL);
cachedCapabilities = resultCaps;
return resultCaps;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -30,18 +30,15 @@
import org.teiid.language.Command;
import org.teiid.language.QueryExpression;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.translator.BasicConnectorCapabilities;
-import org.teiid.translator.BasicExecution;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.Execution;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.UpdateExecution;
-public class FakeConnector extends BasicExecutionFactory {
+public class FakeConnector extends ExecutionFactory {
private static final int RESULT_SIZE = 5;
private boolean executeBlocks;
@@ -67,9 +64,6 @@
executionCount++;
return new FakeBlockingExecution(executionContext);
}
- public ConnectorCapabilities getCapabilities() {
- return new BasicConnectorCapabilities();
- }
public Object getConnection() {
return new FakeConnection();
@@ -87,7 +81,7 @@
}
}
- private final class FakeBlockingExecution extends BasicExecution implements ResultSetExecution, UpdateExecution {
+ private final class FakeBlockingExecution implements ResultSetExecution, UpdateExecution {
private boolean closed = false;
private boolean cancelled = false;
private int rowCount;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -26,13 +26,12 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.translator.BasicExecution;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.DataNotAvailableException;
import org.teiid.translator.ProcedureExecution;
-final class FakeProcedureExecution extends BasicExecution implements ProcedureExecution {
+final class FakeProcedureExecution implements ProcedureExecution {
int resultSetSize;
int rowNum;
Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -21,11 +21,11 @@
*/
package org.teiid.deployers;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.*;
import org.junit.Test;
import org.teiid.adminapi.impl.TranslatorMetaData;
-import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.TranslatorProperty;
@SuppressWarnings("nls")
@@ -35,18 +35,17 @@
public void testBuildExecutionFactory() throws Exception {
TranslatorMetaData tm = new TranslatorMetaData();
- tm.setCapabilitiesClass("capabilities");
tm.setXaCapable(true);
tm.addProperty("my-property", "correctly-assigned");
TranslatorDeployer td = new TranslatorDeployer();
MyTranslator my = (MyTranslator)td.buildTranslator(MyTranslator.class.getName(), tm);
- assertEquals("capabilities", my.getCapabilitiesClass());
+ assertTrue(my.isXaCapable());
assertEquals("correctly-assigned", my.getMyProperty());
}
- public static class MyTranslator extends BasicExecutionFactory {
+ public static class MyTranslator extends ExecutionFactory {
String mine;
@TranslatorProperty(name="my-property")
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -15,23 +15,16 @@
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.BaseColumn.NullType;
import org.teiid.metadata.Column.SearchType;
-import org.teiid.translator.BasicConnectorCapabilities;
-import org.teiid.translator.BasicExecutionFactory;
-import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.ResultSetExecution;
-public class MockConnector extends BasicExecutionFactory {
+public class MockConnector extends ExecutionFactory {
- @Override
- public ConnectorCapabilities getCapabilities() {
- return new BasicConnectorCapabilities();
- }
-
@Override
public ProcedureExecution createProcedureExecution(
Call procedure, ExecutionContext executionContext,
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2010-05-12 22:19:30 UTC (rev 2121)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2010-05-13 13:40:34 UTC (rev 2122)
@@ -34,8 +34,8 @@
import org.teiid.query.processor.HardcodedDataManager;
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.translator.jdbc.oracle.OracleCapabilities;
-import org.teiid.translator.jdbc.sqlserver.SQLServerCapabilities;
+import org.teiid.translator.jdbc.oracle.OracleExecutionFactory;
+import org.teiid.translator.jdbc.sqlserver.SQLServerExecutionFactory;
@@ -54,7 +54,7 @@
*/
public void testQuery3() throws Exception{
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("TPCR_Oracle_9i", CapabilitiesConverter.convertCapabilities(new OracleCapabilities())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_Oracle_9i", CapabilitiesConverter.convertCapabilities(new OracleExecutionFactory())); //$NON-NLS-1$
HardcodedDataManager dataMgr = new HardcodedDataManager();
@@ -80,7 +80,7 @@
public void testQueryCase3042() throws Exception{
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("TPCR_Ora", CapabilitiesConverter.convertCapabilities(new OracleCapabilities())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_Ora", CapabilitiesConverter.convertCapabilities(new OracleExecutionFactory())); //$NON-NLS-1$
HardcodedDataManager dataMgr = new HardcodedDataManager();
List[] expected =
@@ -112,8 +112,8 @@
*/
public void testQueryCase3047() throws Exception{
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("TPCR_Ora", CapabilitiesConverter.convertCapabilities(new OracleCapabilities())); //$NON-NLS-1$
- finder.addCapabilities("TPCR_SQLS", CapabilitiesConverter.convertCapabilities(new SQLServerCapabilities())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_Ora", CapabilitiesConverter.convertCapabilities(new OracleExecutionFactory())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_SQLS", CapabilitiesConverter.convertCapabilities(new SQLServerExecutionFactory())); //$NON-NLS-1$
HardcodedDataManager dataMgr = new HardcodedDataManager();
@@ -152,8 +152,8 @@
*/
public void testQueryCase3047workaround() throws Exception{
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("TPCR_Ora", CapabilitiesConverter.convertCapabilities(new OracleCapabilities())); //$NON-NLS-1$
- finder.addCapabilities("TPCR_SQLS", CapabilitiesConverter.convertCapabilities(new SQLServerCapabilities())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_Ora", CapabilitiesConverter.convertCapabilities(new OracleExecutionFactory())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_SQLS", CapabilitiesConverter.convertCapabilities(new SQLServerExecutionFactory())); //$NON-NLS-1$
HardcodedDataManager dataMgr = new HardcodedDataManager();
@@ -187,7 +187,7 @@
public void testQuery22() throws Exception{
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("TPCR_Oracle_9i", CapabilitiesConverter.convertCapabilities(new OracleCapabilities())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_Oracle_9i", CapabilitiesConverter.convertCapabilities(new OracleExecutionFactory())); //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan("SELECT custsale.cntrycode, COUNT(*) AS numcust, SUM(c_acctbal) AS totacctbal FROM (SELECT left(C_PHONE, 2) AS cntrycode, CUSTOMER.C_ACCTBAL FROM CUSTOMER WHERE (left(C_PHONE, 2) IN ('13','31','23','29','30','18','17')) AND (CUSTOMER.C_ACCTBAL > (SELECT AVG(CUSTOMER.C_ACCTBAL) FROM CUSTOMER WHERE (CUSTOMER.C_ACCTBAL > 0.0) AND (left(C_PHONE, 2) IN ('13','31','23','29','30','18','17')))) AND (NOT (EXISTS (SELECT * FROM ORDERS WHERE O_CUSTKEY = C_CUSTKEY)))) AS custsale GROUP BY custsale.cntrycode ORDER BY custsale.cntrycode", //$NON-NLS-1$
METADATA, null, finder,
@@ -197,7 +197,7 @@
public void testDefect22475() throws Exception {
FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("TPCR_Oracle_9i", CapabilitiesConverter.convertCapabilities(new SQLServerCapabilities())); //$NON-NLS-1$
+ finder.addCapabilities("TPCR_Oracle_9i", CapabilitiesConverter.convertCapabilities(new SQLServerExecutionFactory())); //$NON-NLS-1$
ProcessorPlan plan = TestOptimizer.helpPlan("select S_ACCTBAL, S_NAME, N_NAME, P_PARTKEY, P_MFGR, S_ADDRESS, S_PHONE, S_COMMENT from (SELECT SUPPLIER.S_ACCTBAL, SUPPLIER.S_NAME, NATION.N_NAME, PART.P_PARTKEY, PART.P_MFGR, SUPPLIER.S_ADDRESS, SUPPLIER.S_PHONE, SUPPLIER.S_COMMENT FROM PART, SUPPLIER, PARTSUPP, NATION, REGION WHERE (PART.P_PARTKEY = PS_PARTKEY) AND (S_SUPPKEY = PS_SUPPKEY) AND (P_SIZE = 15) AND (P_TYPE LIKE '%BRASS') AND (S_NATIONKEY = N_NATIONKEY) AND (N_REGIONKEY = R_REGIONKEY) AND (R_NAME = 'EUROPE') AND (PS_SUPPLYCOST = (SELECT MIN(PS_SUPPLYCOST) FROM PARTSUPP, SUPPLIER, NATION, REGION WHERE (PART.P_PARTKEY = PS_PARTKEY) AND (S_SUPPKEY = PS_SUPPKEY) AND (S_NATIONKEY = N_NATIONKEY) AND (N_REGIONKEY = R_REGIONKEY) AND (R_NAME = 'EUROPE'))) ORDER BY SUPPLIER.S_ACCTBAL DESC, NATION.N_NAME, SUPPLIER.S_NAME, PART.P_PARTKEY) as x", //$NON-NLS-1$
METADATA, null, finder,
15 years, 11 months
teiid SVN: r2121 - in trunk: connector-api/src/main/java/org/teiid/resource and 87 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-12 18:19:30 -0400 (Wed, 12 May 2010)
New Revision: 2121
Added:
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/
trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/translator/
trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/translator/yahoo/
trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/translator/yahoo/i18n.properties
trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/translator/
trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/translator/yahoo/
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeConnection.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/
trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/
trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Constants.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Messages.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/MetadataProcessor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/NameUtil.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Relationship.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/RelationshipImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceConnection.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Util.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DataPayload.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeleteExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedObject.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedResult.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetDeletedExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetUpdatedExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/InsertExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParent.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/SalesforceProcedureExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdateExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdatedResult.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/
trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/
trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/
trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/
trunk/connectors/translator-text/src/main/java/org/teiid/translator/
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/
trunk/connectors/translator-text/src/main/resources/org/teiid/translator/
trunk/connectors/translator-text/src/main/resources/org/teiid/translator/text/
trunk/connectors/translator-text/src/main/resources/org/teiid/translator/text/i18n.properties
trunk/connectors/translator-text/src/test/java/org/teiid/translator/
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/
Removed:
trunk/connector-api/src/main/java/org/teiid/connector/metadata/
trunk/connector-api/src/main/java/org/teiid/connector/visitor/
trunk/connector-api/src/main/java/org/teiid/resource/adapter/
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/
trunk/connectors/connector-ldap/src/test/java/com/
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/
trunk/connectors/connector-salesforce/src/main/java/com/
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/
trunk/connectors/connector-salesforce/src/test/java/com/
trunk/connectors/connector-text/src/main/java/org/teiid/resource/cci/
trunk/connectors/connector-text/src/test/java/com/
trunk/connectors/connector-text/src/test/java/org/
trunk/connectors/sandbox/translator-yahoo/src/main/java/com/
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/
trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/resource/
trunk/connectors/sandbox/translator-yahoo/src/test/java/com/
trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo/
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/
trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/
trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/
trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/
trunk/connectors/translator-loopback/src/main/java/com/
trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/
trunk/connectors/translator-loopback/src/test/java/com/
trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/
trunk/connectors/translator-salesforce/src/main/resources/org/teiid/resource/
trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/
trunk/connectors/translator-text/src/main/java/org/teiid/resource/
trunk/connectors/translator-text/src/main/resources/org/teiid/resource/
trunk/connectors/translator-text/src/test/java/org/teiid/resource/
Modified:
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooPlugin.java
trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/translator/yahoo/TestYahooTranslation.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
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/TestSubstringFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/TestLoobackAsynch.java
trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/TestLoopbackExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/CriteriaVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/DeleteVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/ICriteriaVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/IQueryProvidingVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/InsertVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/JoinQueryVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/UpdateVisitor.java
trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/StringToDateTranslator.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextConnectionImpl.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextDescriptorPropertyNames.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextPlugin.java
trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestMultiFileTextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestRowHeaderTextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextConnection.java
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextConnector.java
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/Util.java
Log:
TEIID-1075:Fixing the package names to "adapter" for "connections" and "translator" for translators
Copied: trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap (from rev 2119, trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/ldap)
Modified: trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java
===================================================================
--- trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/ldap/TestLDAPConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestLDAPConnection.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci.ldap;
+package org.teiid.resource.adapter.ldap;
import java.util.Hashtable;
Copied: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce (from rev 2119, trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce)
Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesForceManagedConnectionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceManagedConnectionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci.salesforce;
+package org.teiid.resource.adapter.salesforce;
import java.net.MalformedURLException;
import java.net.URL;
Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesforceConnectionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnectionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci.salesforce;
+package org.teiid.resource.adapter.salesforce;
import java.net.URL;
import java.util.ArrayList;
@@ -32,14 +32,14 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.adapter.salesforce.Messages;
-import org.teiid.resource.adapter.salesforce.SalesforceConnection;
-import org.teiid.resource.adapter.salesforce.execution.DataPayload;
-import org.teiid.resource.adapter.salesforce.execution.DeletedObject;
-import org.teiid.resource.adapter.salesforce.execution.DeletedResult;
-import org.teiid.resource.adapter.salesforce.execution.UpdatedResult;
import org.teiid.resource.spi.BasicConnection;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.salesforce.Messages;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.execution.DataPayload;
+import org.teiid.translator.salesforce.execution.DeletedObject;
+import org.teiid.translator.salesforce.execution.DeletedResult;
+import org.teiid.translator.salesforce.execution.UpdatedResult;
import com.sforce.soap.partner.CallOptions;
import com.sforce.soap.partner.DeleteResult;
Modified: trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml
===================================================================
--- trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/connector-salesforce/src/main/rar/META-INF/ra.xml 2010-05-12 22:19:30 UTC (rev 2121)
@@ -38,7 +38,7 @@
<outbound-resourceadapter>
<connection-definition>
- <managedconnectionfactory-class>org.teiid.resource.cci.salesforce.SalesForceManagedConnectionFactory</managedconnectionfactory-class>
+ <managedconnectionfactory-class>org.teiid.resource.adapter.salesforce.SalesForceManagedConnectionFactory</managedconnectionfactory-class>
<config-property>
<description>{$display:"User Name",$description:"Name value for Salesforce authentication",$required:"true"}</description>
Copied: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo (from rev 2119, trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo)
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/TickerCollectorVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/TickerCollectorVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.yahoo;
+package org.teiid.translator.yahoo;
import java.util.*;
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.yahoo;
+package org.teiid.translator.yahoo;
import java.util.Collections;
import java.util.List;
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.yahoo;
+package org.teiid.translator.yahoo;
import java.io.BufferedReader;
import java.io.IOException;
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.yahoo;
+package org.teiid.translator.yahoo;
import org.teiid.language.QueryExpression;
import org.teiid.language.Select;
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooPlugin.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooPlugin.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/translator/yahoo/YahooPlugin.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.yahoo;
+package org.teiid.translator.yahoo;
import java.util.ResourceBundle;
@@ -28,6 +28,6 @@
public class YahooPlugin {
- public static final String PLUGIN_ID = "org.teiid.resource.adapter.yahoo" ; //$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.teiid.translator.yahoo" ; //$NON-NLS-1$
public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
}
Copied: trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/translator/yahoo/i18n.properties (from rev 2119, trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/resource/adapter/yahoo/i18n.properties)
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/translator/yahoo/i18n.properties (rev 0)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/resources/org/teiid/translator/yahoo/i18n.properties 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,33 @@
+#
+# 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.
+#
+
+YahooExecution.URL_BEGIN=http://finance.yahoo.com/d/quotes.csv?s=
+YahooExecution.URL_APPEND_CHAR=+
+YahooExecution.URL_END=&f=sl1d1t1c1ohgv&e=.csv
+TickerCollectorVisitor.Unexpected_type=Unable to parse literal of type: {0}
+TickerCollectorVisitor.Unexpected_expression=Unable to parse expression: {0}
+YahooExecution.No_tickers=Yahoo connector must be called with tickers in the criteria
+YahooExecution.Must_have_criteria=Query against Yahoo connector must have criteria
+YahooExecution.Parse_date_error=Unable to parse date value: {0}, got: {1}
+YahooExecution.Parse_time_value=Unable to parse time value: {0}, got: {1}
+YahooExecution.Invalid_select_symbol=Yahoo connector can''t handle {0} in SELECT
+YahooConnector.proxyPortNotSet=HTTP proxy port is not set. The default port number 80 will be used.
Copied: trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/translator/yahoo (from rev 2119, trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo)
Modified: trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/translator/yahoo/TestYahooTranslation.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo/TestYahooTranslation.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/translator/yahoo/TestYahooTranslation.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,11 +20,11 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.yahoo;
+package org.teiid.translator.yahoo;
import org.teiid.language.Command;
import org.teiid.language.Select;
-import org.teiid.resource.adapter.yahoo.YahooExecution;
+import org.teiid.translator.yahoo.YahooExecution;
import junit.framework.TestCase;
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCBaseExecution.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,219 @@
+/*
+ * 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;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.Statement;
+import java.util.List;
+
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+
+
+/**
+ */
+public abstract class JDBCBaseExecution extends BasicExecution {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ // Passed to constructor
+ protected Connection connection;
+ protected Translator sqlTranslator;
+ protected ExecutionContext context;
+
+ // Derived from properties
+ protected boolean trimString;
+ protected int fetchSize;
+ protected int maxResultRows;
+
+ // Set during execution
+ protected Statement statement;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ protected JDBCBaseExecution(Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
+ this.connection = connection;
+ this.sqlTranslator = translator;
+ this.context = context;
+
+ trimString = env.isTrimStrings();
+ fetchSize = (env.getFetchSize() != -1)?env.getFetchSize():context.getBatchSize();
+ maxResultRows = env.getMaxResultRows();
+
+ //if the connector work needs to throw an excpetion, set the size plus 1
+ if (maxResultRows > 0 && env.isExceptionOnMaxRows()) {
+ maxResultRows++;
+ }
+ if (maxResultRows > 0) {
+ fetchSize = Math.min(fetchSize, maxResultRows);
+ }
+ }
+
+ /**
+ * Return true if this is a batched update
+ */
+ protected void bindPreparedStatementValues(PreparedStatement stmt, TranslatedCommand tc, int rowCount) throws SQLException {
+ List<?> params = tc.getPreparedValues();
+
+ for (int row = 0; row < rowCount; row++) {
+ for (int i = 0; i< params.size(); i++) {
+ Literal paramValue = (Literal)params.get(i);
+ Object value = paramValue.getValue();
+ if (paramValue.isMultiValued()) {
+ value = ((List<?>)value).get(row);
+ }
+ Class<?> paramType = paramValue.getType();
+ sqlTranslator.bindValue(stmt, value, paramType, i+1);
+ }
+ if (rowCount > 1) {
+ stmt.addBatch();
+ }
+ }
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ protected TranslatedCommand translateCommand(Command command) throws ConnectorException {
+ TranslatedCommand translatedCommand = new TranslatedCommand(context, sqlTranslator);
+ translatedCommand.translateCommand(command);
+
+ if (translatedCommand.getSql() != null && LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) {
+ LogManager.logDetail("Source-specific command: " + translatedCommand.getSql()); //$NON-NLS-1$
+ }
+
+ return translatedCommand;
+ }
+
+ /*
+ * @see com.metamatrix.data.Execution#close()
+ */
+ public synchronized void close() throws ConnectorException {
+ try {
+ if (statement != null) {
+ statement.close();
+ }
+ if (connection != null) {
+ connection.close();
+ }
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ /*
+ * @see com.metamatrix.data.Execution#cancel()
+ */
+ public synchronized void cancel() throws ConnectorException {
+ // if both the DBMS and driver support aborting an SQL
+ try {
+ if (statement != null) {
+ statement.cancel();
+ }
+ } catch (SQLException e) {
+ // Defect 16187 - DataDirect does not support the cancel() method for
+ // Statement.cancel() for DB2 and Informix. Here we are tolerant
+ // of these and other JDBC drivers that do not support the cancel() operation.
+ }
+ }
+
+ protected void setSizeContraints(Statement statement) throws SQLException {
+ if (maxResultRows > 0) {
+ statement.setMaxRows(maxResultRows);
+ }
+ statement.setFetchSize(fetchSize);
+ }
+
+ protected synchronized Statement getStatement() throws SQLException {
+ if (statement != null) {
+ statement.close();
+ statement = null;
+ }
+ statement = connection.createStatement();
+ setSizeContraints(statement);
+ return statement;
+ }
+
+ protected synchronized CallableStatement getCallableStatement(String sql) throws SQLException {
+ if (statement != null) {
+ statement.close();
+ statement = null;
+ }
+ statement = connection.prepareCall(sql);
+ setSizeContraints(statement);
+ return (CallableStatement)statement;
+ }
+
+ protected synchronized PreparedStatement getPreparedStatement(String sql) throws SQLException {
+ if (statement != null) {
+ statement.close();
+ statement = null;
+ }
+ statement = connection.prepareStatement(sql);
+ setSizeContraints(statement);
+ return (PreparedStatement)statement;
+ }
+
+ /**
+ * Returns the JDBC connection used by the execution object.
+ *
+ * @return Returns the connection.
+ * @since 4.1.1
+ */
+ public Connection getConnection() {
+ return this.connection;
+ }
+
+ public Translator getSqlTranslator() {
+ return sqlTranslator;
+ }
+
+ public void addStatementWarnings() throws SQLException {
+ SQLWarning warning = this.statement.getWarnings();
+ while (warning != null) {
+ SQLWarning toAdd = warning;
+ warning = toAdd.getNextWarning();
+ toAdd.setNextException(null);
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_CONNECTOR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(context.getRequestIdentifier() + " Warning: ", warning); //$NON-NLS-1$
+ }
+ context.addWarning(toAdd);
+ }
+ this.statement.clearWarnings();
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCBaseExecution.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCCapabilities.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,331 @@
+/*
+ * 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;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.translator.BasicConnectorCapabilities;
+
+
+/**
+ */
+public class JDBCCapabilities extends BasicConnectorCapabilities {
+
+ /**
+ *
+ */
+ public JDBCCapabilities() {
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#getSupportedFunctions()
+ */
+ public List<String> getSupportedFunctions() {
+ return Arrays.asList(new String[] { "+", "-", "*", "/" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ /**
+ * @see org.teiid.translator.BasicConnectorCapabilities#getMaxInCriteriaSize()
+ * @since 4.2
+ */
+ public int getMaxInCriteriaSize() {
+ return 1000;
+ }
+
+ @Override
+ public boolean supportsGroupBy() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesAvg()
+ */
+ public boolean supportsAggregatesAvg() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesCount()
+ */
+ public boolean supportsAggregatesCount() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesCountStar()
+ */
+ public boolean supportsAggregatesCountStar() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesDistinct()
+ */
+ public boolean supportsAggregatesDistinct() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesMax()
+ */
+ public boolean supportsAggregatesMax() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesMin()
+ */
+ public boolean supportsAggregatesMin() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAggregatesSum()
+ */
+ public boolean supportsAggregatesSum() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsAliasedGroup()
+ */
+ public boolean supportsAliasedGroup() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsBetweenCriteria()
+ */
+ public boolean supportsBetweenCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsCaseExpressions()
+ */
+ public boolean supportsCaseExpressions() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsCompareCriteriaEquals()
+ */
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsCorrelatedSubqueries()
+ */
+ public boolean supportsCorrelatedSubqueries() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsExistsCriteria()
+ */
+ public boolean supportsExistsCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsFullOuterJoins()
+ */
+ public boolean supportsFullOuterJoins() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsInCriteria()
+ */
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsInCriteriaSubquery()
+ */
+ public boolean supportsInCriteriaSubquery() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsIsNullCriteria()
+ */
+ public boolean supportsIsNullCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsLikeCriteria()
+ */
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
+ */
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsNotCriteria()
+ */
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsOrCriteria()
+ */
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsOrderBy()
+ */
+ public boolean supportsOrderBy() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrderByUnrelated() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsOuterJoins()
+ */
+ public boolean supportsOuterJoins() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
+ */
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsScalarSubqueries()
+ */
+ public boolean supportsScalarSubqueries() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsSearchedCaseExpressions()
+ */
+ public boolean supportsSearchedCaseExpressions() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsSelectDistinct()
+ */
+ public boolean supportsSelectDistinct() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.ConnectorCapabilities#supportsSelfJoins()
+ */
+ public boolean supportsSelfJoins() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsInlineViews()
+ */
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
+ */
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsSetQueryOrderBy()
+ */
+ @Override
+ public boolean supportsSetQueryOrderBy() {
+ return true;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
+ */
+ public boolean supportsUnions() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsBulkUpdate() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsBatchedUpdates() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return true;
+ }
+
+ @Override
+ public SupportedJoinCriteria getSupportedJoinCriteria() {
+ return SupportedJoinCriteria.ANY;
+ }
+
+ @Override
+ public boolean supportsHaving() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInnerJoins() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsSelectExpression() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return true;
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCCapabilities.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionException.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,40 @@
+/*
+ * 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;
+
+import java.sql.SQLException;
+import java.util.Arrays;
+
+import org.teiid.translator.ConnectorException;
+
+
+public class JDBCExecutionException extends ConnectorException {
+
+ private static final long serialVersionUID = 1758087499488916573L;
+
+ public JDBCExecutionException(SQLException error,
+ TranslatedCommand... commands) {
+ super(error.getErrorCode(), commands == null ? error.getMessage() : JDBCPlugin.Util.getString("JDBCQueryExecution.Error_executing_query__1", //$NON-NLS-1$
+ error.getMessage(), Arrays.toString(commands)));
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionException.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,229 @@
+/*
+ * 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;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.ReflectionHelper;
+import org.teiid.core.util.StringUtil;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.UpdateExecution;
+
+
+/**
+ * JDBC implementation of Connector interface.
+ */
+public class JDBCExecutionFactory extends BasicExecutionFactory implements MetadataProvider {
+
+ private ConnectorCapabilities capabilities;
+ private Translator sqlTranslator;
+ private boolean useBindVariables;
+ private String databaseTimeZone;
+ private String extensionTranslationClassName;
+ private boolean trimStrings;
+ private boolean useCommentsInSourceQuery;
+ private int fetchSize;
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ capabilities = getTranslator().getConnectorCapabilities();
+ }
+
+ public Translator getTranslator() throws ConnectorException {
+ if (this.sqlTranslator == null) {
+ try {
+ String className = getExtensionTranslationClassName();
+ if (!StringUtil.isValid(className)) {
+ this.sqlTranslator = new Translator();
+ } else {
+ this.sqlTranslator = (Translator)ReflectionHelper.create(className, null, Thread.currentThread().getContextClassLoader());
+ }
+ sqlTranslator.initialize(this);
+ } catch (TeiidException e) {
+ throw new ConnectorException(e);
+ }
+ }
+ return this.sqlTranslator;
+ }
+
+ @Override
+ public ConnectorCapabilities getCapabilities() {
+ return capabilities;
+ }
+
+ @TranslatorProperty(name="UseBindVariables", display="Use Bind Variables", description="Use prepared statements and bind variables",advanced=true, defaultValue="false")
+ public boolean isUseBindVariables() {
+ return this.useBindVariables;
+ }
+
+ public void setUseBindVariables(boolean useBindVariables) {
+ this.useBindVariables = useBindVariables;
+ }
+
+ @TranslatorProperty(name="DatabaseTimeZone", display="Database time zone", description="Time zone of the database, if different than Integration Server", advanced=true)
+ public String getDatabaseTimeZone() {
+ return this.databaseTimeZone;
+ }
+
+ public void setDatabaseTimeZone(String databaseTimeZone) {
+ this.databaseTimeZone = databaseTimeZone;
+ }
+
+ @TranslatorProperty(name="ExtensionTranslationClassName", display="Extension SQL Translation Class", required=true,
+ defaultValue="org.teiid.translator.jdbc.translator.Translator",
+ allowed= {"org.teiid.translator.jdbc.translator.Translator",
+ "org.teiid.translator.jdbc.access.AccessSQLTranslator",
+ "org.teiid.translator.jdbc.db2.DB2SQLTranslator",
+ "org.teiid.translator.jdbc.derby.DerbySQLTranslator",
+ "org.teiid.translator.jdbc.h2.H2Translator",
+ "org.teiid.translator.jdbc.hsql.HsqlTranslator",
+ "org.teiid.translator.jdbc.mysql.MySQLTranslator",
+ "org.teiid.translator.jdbc.mysql.MySQL5Translator",
+ "org.teiid.translator.jdbc.oracle.OracleSQLTranslator",
+ "org.teiid.translator.jdbc.postgresql.PostgreSQLTranslator",
+ "org.teiid.translator.jdbc.sqlserver.SqlServerSQLTranslator",
+ "org.teiid.translator.jdbc.sybase.SybaseSQLTranslator"
+ })
+ public String getExtensionTranslationClassName() {
+ return this.extensionTranslationClassName;
+ }
+
+ public void setExtensionTranslationClassName(String extensionTranslationClassName) {
+ this.extensionTranslationClassName = extensionTranslationClassName;
+ }
+
+ @TranslatorProperty(name="TrimStrings",display="Trim string flag", description="Right Trim fixed character types returned as Strings - note that the native type must be char or nchar and the source must support the rtrim function.",advanced=true, defaultValue="false")
+ public boolean isTrimStrings() {
+ return this.trimStrings;
+ }
+
+ public void setTrimStrings(boolean trimStrings) {
+ this.trimStrings = trimStrings;
+ }
+
+ @TranslatorProperty(name="UseCommentsInSourceQuery", display="Use informational comments in Source Queries", description="This will embed /*comment*/ style comment with session/request id in source SQL query for informational purposes", advanced=true, defaultValue="false")
+ public boolean isUseCommentsInSourceQuery() {
+ return this.useCommentsInSourceQuery;
+ }
+
+ public void setUseCommentsInSourceQuery(boolean useCommentsInSourceQuery) {
+ this.useCommentsInSourceQuery = useCommentsInSourceQuery;
+ }
+
+
+ @TranslatorProperty(name="FetchSize", display="FetCh Size", description="fetch size used from the connector to its underlying source.", advanced=true, defaultValue="1024")
+ public int getFetchSize() {
+ return this.fetchSize;
+ }
+
+ @Override
+ public boolean isSourceRequired() {
+ return true;
+ }
+
+ public void setFetchSize(int fetchSize) {
+ this.fetchSize = fetchSize;
+ }
+
+ @Override
+ public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
+ throws ConnectorException {
+ try {
+ DataSource ds = (DataSource)connectionFactory;
+ Connection conn = ds.getConnection();
+ //TODO: This is not correct; this should be only called once for connection creation
+ getTranslator().afterConnectionCreation(conn);
+ return new JDBCQueryExecution(command, conn, executionContext, this, getTranslator());
+ } catch(SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ @Override
+ public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
+ throws ConnectorException {
+ try {
+ DataSource ds = (DataSource)connectionFactory;
+ Connection conn = ds.getConnection();
+ //TODO: This is not correct; this should be only called once for connection creation
+ getTranslator().afterConnectionCreation(conn);
+ return new JDBCProcedureExecution(command, conn, executionContext, this, getTranslator());
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ @Override
+ public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
+ throws ConnectorException {
+ try {
+ DataSource ds = (DataSource)connectionFactory;
+ Connection conn = ds.getConnection();
+
+ //TODO: This is not correct; this should be only called once for connection creation
+ getTranslator().afterConnectionCreation(conn);
+ return new JDBCUpdateExecution(command, conn, executionContext, this, getTranslator());
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ @Override
+ public void getConnectorMetadata(MetadataFactory metadataFactory, Object connectionFactory) throws ConnectorException {
+ try {
+ Connection conn = null;
+ try {
+ DataSource ds = (DataSource)connectionFactory;
+ conn = ds.getConnection();
+
+ JDBCMetdataProcessor metadataProcessor = new JDBCMetdataProcessor();
+ PropertiesUtils.setBeanProperties(metadataProcessor, metadataFactory.getImportProperties(), "importer"); //$NON-NLS-1$
+ metadataProcessor.getConnectorMetadata(conn, metadataFactory);
+ } finally {
+ if (conn != null) {
+ conn.close();
+ }
+ }
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCExecutionFactory.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,434 @@
+/*
+ * 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;
+
+import java.sql.Connection;
+import java.sql.DatabaseMetaData;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Types;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+import java.util.TreeMap;
+
+import org.teiid.core.util.StringUtil;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.BaseColumn;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.ProcedureParameter.Type;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.TypeFacility;
+
+
+/**
+ * Reads from {@link DatabaseMetaData} and creates metadata through the {@link MetadataFactory}.
+ */
+public class JDBCMetdataProcessor {
+
+ /**
+ * A holder for table records that keeps track of catalog and schema information.
+ */
+ private static class TableInfo {
+ private String catalog;
+ private String schema;
+ private String name;
+ private Table table;
+
+ public TableInfo(String catalog, String schema, String name, Table table) {
+ this.catalog = catalog;
+ this.schema = schema;
+ this.name = name;
+ this.table = table;
+ }
+ }
+
+ private boolean importProcedures;
+ private boolean importKeys;
+ private boolean importIndexes;
+ private String procedureNamePattern;
+ private boolean useFullSchemaName;
+ private String[] tableTypes;
+ private String tableNamePattern;
+ private String catalog;
+ private String schemaPattern;
+ private boolean importApproximateIndexes = true;
+ private boolean widenUnsingedTypes = true;
+ private boolean quoteNameInSource = true;
+ //TODO add an option to not fully qualify name in source
+
+ private Set<String> unsignedTypes = new HashSet<String>();
+ private String quoteString;
+
+ public void getConnectorMetadata(Connection conn, MetadataFactory metadataFactory)
+ throws SQLException, ConnectorException {
+ DatabaseMetaData metadata = conn.getMetaData();
+
+ quoteString = metadata.getIdentifierQuoteString();
+ if (quoteString != null && quoteString.trim().length() == 0) {
+ quoteString = null;
+ }
+
+ if (widenUnsingedTypes) {
+ ResultSet rs = metadata.getTypeInfo();
+ while (rs.next()) {
+ String name = rs.getString(1);
+ boolean unsigned = rs.getBoolean(10);
+ if (unsigned) {
+ unsignedTypes.add(name);
+ }
+ }
+ }
+
+ Map<String, TableInfo> tableMap = getTables(metadataFactory, metadata);
+
+ if (importKeys) {
+ getPrimaryKeys(metadataFactory, metadata, tableMap);
+
+ getForeignKeys(metadataFactory, metadata, tableMap);
+ }
+
+ if (importIndexes) {
+ getIndexes(metadataFactory, metadata, tableMap);
+ }
+
+ if (importProcedures) {
+ getProcedures(metadataFactory, metadata);
+ }
+
+ }
+
+ private void getProcedures(MetadataFactory metadataFactory,
+ DatabaseMetaData metadata) throws SQLException, ConnectorException {
+ LogManager.logDetail("JDBCMetadataProcessor - Importing procedures"); //$NON-NLS-1$
+ ResultSet procedures = metadata.getProcedures(catalog, schemaPattern, procedureNamePattern);
+ while (procedures.next()) {
+ String procedureCatalog = procedures.getString(1);
+ String procedureSchema = procedures.getString(2);
+ String procedureName = procedures.getString(3);
+ String fullProcedureName = getFullyQualifiedName(procedureCatalog, procedureSchema, procedureName);
+ Procedure procedure = metadataFactory.addProcedure(useFullSchemaName?fullProcedureName:procedureName);
+ procedure.setNameInSource(getFullyQualifiedName(procedureCatalog, procedureSchema, procedureName, true));
+ ResultSet columns = metadata.getProcedureColumns(catalog, procedureSchema, procedureName, null);
+ while (columns.next()) {
+ String columnName = columns.getString(4);
+ short columnType = columns.getShort(5);
+ int sqlType = columns.getInt(6);
+ String typeName = columns.getString(7);
+ sqlType = checkForUnsigned(sqlType, typeName);
+ if (columnType == DatabaseMetaData.procedureColumnUnknown) {
+ continue; //there's a good chance this won't work
+ }
+ BaseColumn record = null;
+ if (columnType == DatabaseMetaData.procedureColumnResult) {
+ Column column = metadataFactory.addProcedureResultSetColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(sqlType), procedure);
+ record = column;
+ column.setNativeType(typeName);
+ } else {
+ record = metadataFactory.addProcedureParameter(columnName, TypeFacility.getDataTypeNameFromSQLType(sqlType), Type.values()[columnType], procedure);
+ }
+ record.setPrecision(columns.getInt(8));
+ record.setLength(columns.getInt(9));
+ record.setScale(columns.getInt(10));
+ record.setRadix(columns.getInt(11));
+ record.setNullType(NullType.values()[columns.getShort(12)]);
+ record.setAnnotation(columns.getString(13));
+ }
+ }
+ procedures.close();
+ }
+
+ private int checkForUnsigned(int sqlType, String typeName) {
+ if (widenUnsingedTypes && unsignedTypes.contains(typeName)) {
+ switch (sqlType) {
+ case Types.TINYINT:
+ sqlType = Types.SMALLINT;
+ break;
+ case Types.SMALLINT:
+ sqlType = Types.INTEGER;
+ break;
+ case Types.INTEGER:
+ sqlType = Types.BIGINT;
+ break;
+ }
+ }
+ return sqlType;
+ }
+
+ private Map<String, TableInfo> getTables(MetadataFactory metadataFactory,
+ DatabaseMetaData metadata) throws SQLException, ConnectorException {
+ LogManager.logDetail("JDBCMetadataProcessor - Importing tables"); //$NON-NLS-1$
+ ResultSet tables = metadata.getTables(catalog, schemaPattern, tableNamePattern, tableTypes);
+ Map<String, TableInfo> tableMap = new HashMap<String, TableInfo>();
+ while (tables.next()) {
+ String tableCatalog = tables.getString(1);
+ String tableSchema = tables.getString(2);
+ String tableName = tables.getString(3);
+ String fullName = getFullyQualifiedName(tableCatalog, tableSchema, tableName);
+ Table table = metadataFactory.addTable(useFullSchemaName?fullName:tableName);
+ table.setNameInSource(getFullyQualifiedName(tableCatalog, tableSchema, tableName, true));
+ table.setSupportsUpdate(true);
+ String remarks = tables.getString(5);
+ table.setAnnotation(remarks);
+ tableMap.put(fullName, new TableInfo(tableCatalog, tableSchema, tableName, table));
+ tableMap.put(tableName, new TableInfo(tableCatalog, tableSchema, tableName, table));
+ }
+ tables.close();
+
+ getColumns(metadataFactory, metadata, tableMap);
+ return tableMap;
+ }
+
+ private void getColumns(MetadataFactory metadataFactory,
+ DatabaseMetaData metadata, Map<String, TableInfo> tableMap)
+ throws SQLException, ConnectorException {
+ LogManager.logDetail("JDBCMetadataProcessor - Importing columns"); //$NON-NLS-1$
+ ResultSet columns = metadata.getColumns(catalog, schemaPattern, tableNamePattern, null);
+ int rsColumns = columns.getMetaData().getColumnCount();
+ while (columns.next()) {
+ String tableCatalog = columns.getString(1);
+ String tableSchema = columns.getString(2);
+ String tableName = columns.getString(3);
+ String fullTableName = getFullyQualifiedName(tableCatalog, tableSchema, tableName);
+ TableInfo tableInfo = tableMap.get(fullTableName);
+ if (tableInfo == null) {
+ tableInfo = tableMap.get(tableName);
+ if (tableInfo == null) {
+ continue;
+ }
+ }
+ String columnName = columns.getString(4);
+ int type = columns.getInt(5);
+ String typeName = columns.getString(6);
+ type = checkForUnsigned(type, typeName);
+ //note that the resultset is already ordered by position, so we can rely on just adding columns in order
+ Column column = metadataFactory.addColumn(columnName, TypeFacility.getDataTypeNameFromSQLType(type), tableInfo.table);
+ column.setNameInSource(quoteName(columnName));
+ column.setNativeType(columns.getString(6));
+ column.setRadix(columns.getInt(10));
+ column.setNullType(NullType.values()[columns.getShort(11)]);
+ column.setUpdatable(true);
+ String remarks = columns.getString(12);
+ column.setAnnotation(remarks);
+ column.setCharOctetLength(columns.getInt(16));
+ if (rsColumns >= 23) {
+ column.setAutoIncremented("YES".equalsIgnoreCase(columns.getString(23))); //$NON-NLS-1$
+ }
+ }
+ columns.close();
+ }
+
+ private String quoteName(String name) {
+ if (quoteNameInSource) {
+ return quoteString + StringUtil.replaceAll(name, quoteString, quoteString + quoteString) + quoteString;
+ }
+ return name;
+ }
+
+ private void getPrimaryKeys(MetadataFactory metadataFactory,
+ DatabaseMetaData metadata, Map<String, TableInfo> tableMap)
+ throws SQLException, ConnectorException {
+ LogManager.logDetail("JDBCMetadataProcessor - Importing primary keys"); //$NON-NLS-1$
+ for (TableInfo tableInfo : tableMap.values()) {
+ ResultSet pks = metadata.getPrimaryKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
+ TreeMap<Short, String> keyColumns = null;
+ String pkName = null;
+ while (pks.next()) {
+ String columnName = pks.getString(4);
+ short seqNum = pks.getShort(5);
+ if (keyColumns == null) {
+ keyColumns = new TreeMap<Short, String>();
+ }
+ keyColumns.put(seqNum, columnName);
+ if (pkName == null) {
+ pkName = pks.getString(6);
+ if (pkName == null) {
+ pkName = "PK_" + tableInfo.table.getName().toUpperCase(); //$NON-NLS-1$
+ }
+ }
+ }
+ if (keyColumns != null) {
+ metadataFactory.addPrimaryKey(pkName, new ArrayList<String>(keyColumns.values()), tableInfo.table);
+ }
+ pks.close();
+ }
+ }
+
+ private void getForeignKeys(MetadataFactory metadataFactory,
+ DatabaseMetaData metadata, Map<String, TableInfo> tableMap) throws SQLException, ConnectorException {
+ LogManager.logDetail("JDBCMetadataProcessor - Importing foreign keys"); //$NON-NLS-1$
+ for (TableInfo tableInfo : tableMap.values()) {
+ ResultSet fks = metadata.getImportedKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
+ TreeMap<Short, String> keyColumns = null;
+ String fkName = null;
+ TableInfo pkTable = null;
+ short savedSeqNum = Short.MAX_VALUE;
+ while (fks.next()) {
+ String columnName = fks.getString(8);
+ short seqNum = fks.getShort(9);
+ if (seqNum <= savedSeqNum) {
+ if (keyColumns != null) {
+ metadataFactory.addForiegnKey(fkName, new ArrayList<String>(keyColumns.values()), pkTable.table, tableInfo.table);
+ }
+ keyColumns = new TreeMap<Short, String>();
+ fkName = null;
+ }
+ savedSeqNum = seqNum;
+ keyColumns.put(seqNum, columnName);
+ if (fkName == null) {
+ String tableCatalog = fks.getString(1);
+ String tableSchema = fks.getString(2);
+ String tableName = fks.getString(3);
+ String fullTableName = getFullyQualifiedName(tableCatalog, tableSchema, tableName);
+ pkTable = tableMap.get(fullTableName);
+ if (pkTable == null) {
+ throw new ConnectorException(JDBCPlugin.Util.getString("JDBCMetadataProcessor.cannot_find_primary", fullTableName)); //$NON-NLS-1$
+ }
+ fkName = fks.getString(12);
+ if (fkName == null) {
+ fkName = "FK_" + tableInfo.table.getName().toUpperCase(); //$NON-NLS-1$
+ }
+ }
+ }
+ if (keyColumns != null) {
+ metadataFactory.addForiegnKey(fkName, new ArrayList<String>(keyColumns.values()), pkTable.table, tableInfo.table);
+ }
+ fks.close();
+ }
+ }
+
+ private void getIndexes(MetadataFactory metadataFactory,
+ DatabaseMetaData metadata, Map<String, TableInfo> tableMap) throws SQLException, ConnectorException {
+ LogManager.logDetail("JDBCMetadataProcessor - Importing index info"); //$NON-NLS-1$
+ for (TableInfo tableInfo : tableMap.values()) {
+ ResultSet indexInfo = metadata.getIndexInfo(tableInfo.catalog, tableInfo.schema, tableInfo.name, false, importApproximateIndexes);
+ TreeMap<Short, String> indexColumns = null;
+ String indexName = null;
+ short savedOrdinalPosition = Short.MAX_VALUE;
+ boolean nonUnique = false;
+ while (indexInfo.next()) {
+ short type = indexInfo.getShort(7);
+ if (type == DatabaseMetaData.tableIndexStatistic) {
+ tableInfo.table.setCardinality(indexInfo.getInt(11));
+ continue;
+ }
+ short ordinalPosition = indexInfo.getShort(8);
+ if (ordinalPosition <= savedOrdinalPosition) {
+ if (indexColumns != null) {
+ metadataFactory.addIndex(indexName, nonUnique, new ArrayList<String>(indexColumns.values()), tableInfo.table);
+ }
+ indexColumns = new TreeMap<Short, String>();
+ indexName = null;
+ }
+ savedOrdinalPosition = ordinalPosition;
+ String columnName = indexInfo.getString(9);
+ nonUnique = indexInfo.getBoolean(4);
+ indexColumns.put(ordinalPosition, columnName);
+ if (indexName == null) {
+ indexName = indexInfo.getString(6);
+ if (indexName == null) {
+ indexName = "NDX_" + tableInfo.table.getName().toUpperCase(); //$NON-NLS-1$
+ }
+ }
+ }
+ if (indexColumns != null) {
+ metadataFactory.addIndex(indexName, nonUnique, new ArrayList<String>(indexColumns.values()), tableInfo.table);
+ }
+ indexInfo.close();
+ }
+ }
+
+ private String getFullyQualifiedName(String catalogName, String schemaName, String objectName) {
+ return getFullyQualifiedName(catalogName, schemaName, objectName, false);
+ }
+
+ private String getFullyQualifiedName(String catalogName, String schemaName, String objectName, boolean quoted) {
+ String fullName = (quoted?quoteName(objectName):objectName);
+ if (schemaName != null && schemaName.length() > 0) {
+ fullName = (quoted?quoteName(schemaName):schemaName) + AbstractMetadataRecord.NAME_DELIM_CHAR + fullName;
+ }
+ if (catalogName != null && catalogName.length() > 0) {
+ fullName = (quoted?quoteName(catalogName):catalogName) + AbstractMetadataRecord.NAME_DELIM_CHAR + fullName;
+ }
+ return fullName;
+ }
+
+
+
+ public void setTableNamePattern(String tableNamePattern) {
+ this.tableNamePattern = tableNamePattern;
+ }
+
+ public void setTableTypes(String[] tableTypes) {
+ this.tableTypes = tableTypes;
+ }
+
+ public void setUseFullSchemaName(boolean useFullSchemaName) {
+ this.useFullSchemaName = useFullSchemaName;
+ }
+
+ public void setProcedureNamePattern(String procedureNamePattern) {
+ this.procedureNamePattern = procedureNamePattern;
+ }
+
+ public void setImportIndexes(boolean importIndexes) {
+ this.importIndexes = importIndexes;
+ }
+
+ public void setImportKeys(boolean importKeys) {
+ this.importKeys = importKeys;
+ }
+
+ public void setImportProcedures(boolean importProcedures) {
+ this.importProcedures = importProcedures;
+ }
+
+ public void setImportApproximateIndexes(boolean importApproximateIndexes) {
+ this.importApproximateIndexes = importApproximateIndexes;
+ }
+
+ public void setWidenUnsingedTypes(boolean widenUnsingedTypes) {
+ this.widenUnsingedTypes = widenUnsingedTypes;
+ }
+
+ public void setQuoteNameInSource(boolean quoteIdentifiers) {
+ this.quoteNameInSource = quoteIdentifiers;
+ }
+
+ // Importer specific properties
+ public void setCatalog(String catalog) {
+ this.catalog = catalog;
+ }
+
+ public void setSchemaPattern(String schema) {
+ this.schemaPattern = schema;
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCProcedureExecution.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,115 @@
+/*
+ * 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;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+
+/**
+ */
+public class JDBCProcedureExecution extends JDBCQueryExecution implements ProcedureExecution {
+
+ /**
+ * @param connection
+ * @param sqlTranslator
+ * @param logger
+ * @param props
+ * @param id
+ */
+ public JDBCProcedureExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
+ super(command, connection, context, env, translator);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ Call procedure = (Call)command;
+ columnDataTypes = procedure.getResultSetColumnTypes();
+
+ //translate command
+ TranslatedCommand translatedComm = translateCommand(procedure);
+
+ //create statement or CallableStatement and execute
+ String sql = translatedComm.getSql();
+ try{
+ //create parameter index map
+ CallableStatement cstmt = getCallableStatement(sql);
+ this.results = sqlTranslator.executeStoredProcedure(cstmt, translatedComm, procedure.getReturnType());
+ addStatementWarnings();
+ }catch(SQLException e){
+ throw new ConnectorException(e, JDBCPlugin.Util.getString("JDBCQueryExecution.Error_executing_query__1", sql)); //$NON-NLS-1$
+ }
+
+ }
+
+ @Override
+ public List<?> next() throws ConnectorException, DataNotAvailableException {
+ if (results == null) {
+ return null;
+ }
+ return super.next();
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws ConnectorException {
+ try {
+ Call proc = (Call)this.command;
+ List<Object> result = new ArrayList<Object>();
+ int paramIndex = 1;
+ if (proc.getReturnType() != null) {
+ addParameterValue(result, paramIndex++, proc.getReturnType());
+ }
+ for (Argument parameter : proc.getArguments()) {
+ switch (parameter.getDirection()) {
+ case IN:
+ paramIndex++;
+ break;
+ case INOUT:
+ case OUT:
+ addParameterValue(result, paramIndex++, parameter.getType());
+ break;
+ }
+ }
+ return result;
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+
+ private void addParameterValue(List<Object> result, int paramIndex,
+ Class<?> type) throws SQLException {
+ Object value = sqlTranslator.retrieveValue((CallableStatement)this.statement, paramIndex, type);
+ result.add(value);
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCProcedureExecution.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCQueryExecution.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,130 @@
+/*
+ * 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;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+
+
+/**
+ *
+ */
+public class JDBCQueryExecution extends JDBCBaseExecution implements ResultSetExecution {
+
+ // ===========================================================================================================================
+ // Fields
+ // ===========================================================================================================================
+
+ protected ResultSet results;
+ protected Command command;
+ protected Class<?>[] columnDataTypes;
+
+ // ===========================================================================================================================
+ // Constructors
+ // ===========================================================================================================================
+
+ public JDBCQueryExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
+ super(connection, context, env, translator);
+ this.command = command;
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ // get column types
+ columnDataTypes = ((QueryExpression)command).getColumnTypes();
+
+ // translate command
+ TranslatedCommand translatedComm = translateCommand(command);
+
+ String sql = translatedComm.getSql();
+
+ try {
+
+ if (!translatedComm.isPrepared()) {
+ results = getStatement().executeQuery(sql);
+ } else {
+ PreparedStatement pstatement = getPreparedStatement(sql);
+ bindPreparedStatementValues(pstatement, translatedComm, 1);
+ results = pstatement.executeQuery();
+ }
+ addStatementWarnings();
+ } catch (SQLException e) {
+ throw new JDBCExecutionException(e, translatedComm);
+ }
+ }
+
+ @Override
+ public List<?> next() throws ConnectorException, DataNotAvailableException {
+ try {
+ if (results.next()) {
+ // New row for result set
+ List<Object> vals = new ArrayList<Object>(columnDataTypes.length);
+
+ for (int i = 0; i < columnDataTypes.length; i++) {
+ // Convert from 0-based to 1-based
+ Object value = sqlTranslator.retrieveValue(results, i+1, columnDataTypes[i]);
+ vals.add(value);
+ }
+
+ return vals;
+ }
+ } catch (SQLException e) {
+ throw new ConnectorException(e,
+ JDBCPlugin.Util.getString("JDBCTranslator.Unexpected_exception_translating_results___8", e.getMessage())); //$NON-NLS-1$
+ }
+
+ return null;
+ }
+
+ /**
+ * @see org.teiid.translator.jdbc.JDBCBaseExecution#close()
+ */
+ public synchronized void close() throws ConnectorException {
+ // first we would need to close the result set here then we can close
+ // the statement, using the base class.
+ if (results != null) {
+ try {
+ results.close();
+ results = null;
+ } catch (SQLException e) {
+ throw new ConnectorException(e);
+ }
+ }
+ super.close();
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCQueryExecution.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCUpdateExecution.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,255 @@
+/*
+ * 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;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.UpdateExecution;
+
+
+/**
+ */
+public class JDBCUpdateExecution extends JDBCBaseExecution implements UpdateExecution {
+
+ private Command command;
+ private int[] result;
+
+ /**
+ * @param connection
+ * @param sqlTranslator
+ * @param logger
+ * @param props
+ * @param id
+ */
+ public JDBCUpdateExecution(Command command, Connection connection, ExecutionContext context, JDBCExecutionFactory env, Translator translator) {
+ super(connection, context, env, translator);
+ this.command = command;
+ }
+
+ // ===========================================================================================================================
+ // Methods
+ // ===========================================================================================================================
+
+ @Override
+ public void execute() throws ConnectorException {
+ if (command instanceof BatchedUpdates) {
+ result = execute(((BatchedUpdates)command));
+ } else {
+ // translate command
+ TranslatedCommand translatedComm = translateCommand(command);
+
+ result = executeTranslatedCommand(translatedComm);
+ }
+ }
+
+ /**
+ * @see com.metamatrix.data.api.BatchedUpdatesExecution#execute(org.teiid.language.Command[])
+ * @since 4.2
+ */
+ public int[] execute(BatchedUpdates batchedCommand) throws ConnectorException {
+ boolean succeeded = false;
+
+ boolean commitType = getAutoCommit(null);
+ Command[] commands = batchedCommand.getUpdateCommands().toArray(new Command[batchedCommand.getUpdateCommands().size()]);
+ int[] results = new int[commands.length];
+
+ TranslatedCommand tCommand = null;
+
+ try {
+ // temporarily turn the auto commit off, and set it back to what it was
+ // before at the end of the command execution.
+ if (commitType) {
+ connection.setAutoCommit(false);
+ }
+
+ List<TranslatedCommand> executedCmds = new ArrayList<TranslatedCommand>();
+
+ TranslatedCommand previousCommand = null;
+
+ for (int i = 0; i < commands.length; i++) {
+ tCommand = translateCommand(commands[i]);
+ if (tCommand.isPrepared()) {
+ PreparedStatement pstmt = null;
+ if (previousCommand != null && previousCommand.isPrepared() && previousCommand.getSql().equals(tCommand.getSql())) {
+ pstmt = (PreparedStatement)statement;
+ } else {
+ if (!executedCmds.isEmpty()) {
+ executeBatch(i, results, executedCmds);
+ }
+ pstmt = getPreparedStatement(tCommand.getSql());
+ }
+ bindPreparedStatementValues(pstmt, tCommand, 1);
+ pstmt.addBatch();
+ } else {
+ if (previousCommand != null && previousCommand.isPrepared()) {
+ executeBatch(i, results, executedCmds);
+ getStatement();
+ }
+ if (statement == null) {
+ getStatement();
+ }
+ statement.addBatch(tCommand.getSql());
+ }
+ executedCmds.add(tCommand);
+ previousCommand = tCommand;
+ }
+ if (!executedCmds.isEmpty()) {
+ executeBatch(commands.length, results, executedCmds);
+ }
+ succeeded = true;
+ } catch (SQLException e) {
+ throw new JDBCExecutionException(e, tCommand);
+ } finally {
+ if (commitType) {
+ restoreAutoCommit(!succeeded, null);
+ }
+ }
+
+ return results;
+ }
+
+ private void executeBatch(int commandCount,
+ int[] results,
+ List<TranslatedCommand> commands) throws ConnectorException {
+ try {
+ int[] batchResults = statement.executeBatch();
+ addStatementWarnings();
+ for (int j = 0; j < batchResults.length; j++) {
+ results[commandCount - 1 - j] = batchResults[batchResults.length - 1 - j];
+ }
+ commands.clear();
+ } catch (SQLException err) {
+ throw new JDBCExecutionException(err, commands.toArray(new TranslatedCommand[commands.size()]));
+ }
+ }
+
+ /**
+ * @param translatedComm
+ * @throws ConnectorException
+ * @since 4.3
+ */
+ private int[] executeTranslatedCommand(TranslatedCommand translatedComm) throws ConnectorException {
+ // create statement or PreparedStatement and execute
+ String sql = translatedComm.getSql();
+ boolean commitType = false;
+ boolean succeeded = false;
+ try {
+ int updateCount = 0;
+ if (!translatedComm.isPrepared()) {
+ updateCount = getStatement().executeUpdate(sql);
+ } else {
+ PreparedStatement pstatement = getPreparedStatement(sql);
+ int rowCount = 1;
+ for (int i = 0; i< translatedComm.getPreparedValues().size(); i++) {
+ Literal paramValue = (Literal)translatedComm.getPreparedValues().get(i);
+ if (paramValue.isMultiValued()) {
+ rowCount = ((List<?>)paramValue.getValue()).size();
+ break;
+ }
+ }
+ if (rowCount > 1) {
+ commitType = getAutoCommit(translatedComm);
+ if (commitType) {
+ connection.setAutoCommit(false);
+ }
+ }
+ bindPreparedStatementValues(pstatement, translatedComm, rowCount);
+ if (rowCount > 1) {
+ int[] results = pstatement.executeBatch();
+
+ for (int i=0; i<results.length; i++) {
+ updateCount += results[i];
+ }
+ succeeded = true;
+ } else {
+ updateCount = pstatement.executeUpdate();
+ }
+ }
+ addStatementWarnings();
+ return new int[] {updateCount};
+ } catch (SQLException err) {
+ throw new JDBCExecutionException(err, translatedComm);
+ } finally {
+ if (commitType) {
+ restoreAutoCommit(!succeeded, translatedComm);
+ }
+ }
+ }
+
+ /**
+ * @param command
+ * @return
+ * @throws ConnectorException
+ */
+ private boolean getAutoCommit(TranslatedCommand tCommand) throws ConnectorException {
+ if (this.context.isTransactional()) {
+ return false;
+ }
+ try {
+ return connection.getAutoCommit();
+ } catch (SQLException err) {
+ throw new JDBCExecutionException(err, tCommand);
+ }
+ }
+
+ /**
+ * If the auto comm
+ *
+ * @param exceptionOccurred
+ * @param command
+ * @throws ConnectorException
+ */
+ private void restoreAutoCommit(boolean exceptionOccurred,
+ TranslatedCommand tCommand) throws ConnectorException {
+ try {
+ if (exceptionOccurred) {
+ connection.rollback();
+ }
+ } catch (SQLException err) {
+ throw new JDBCExecutionException(err, tCommand);
+ } finally {
+ try {
+ connection.commit(); // in JbossAs setAutocommit = true does not trigger the commit.
+ connection.setAutoCommit(true);
+ } catch (SQLException err) {
+ throw new JDBCExecutionException(err, tCommand);
+ }
+ }
+ }
+
+ @Override
+ public int[] getUpdateCounts() throws DataNotAvailableException,
+ ConnectorException {
+ return result;
+ }
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCUpdateExecution.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java (from rev 2119, trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/SimpleCapabilities.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,274 @@
+/*
+ * 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;
+
+import java.util.List;
+
+
+/**
+ * This is a "simple" capabilities class that allows criteria but no
+ * complicated joins, subqueries, etc to be passed to the connector.
+ * This capabilities class may come in handy for testing and for
+ * sources that support JDBC but don't support extended JDBC capabilities.
+ */
+public class SimpleCapabilities extends JDBCCapabilities {
+
+ public SimpleCapabilities() {
+ }
+
+ @Override
+ public int getMaxInCriteriaSize() {
+ return 250;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCompareCriteriaEquals()
+ */
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteria()
+ */
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsIsNullCriteria()
+ */
+ public boolean supportsIsNullCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteria()
+ */
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsNotCriteria()
+ */
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrCriteria()
+ */
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelectDistinct()
+ */
+ public boolean supportsSelectDistinct() {
+ return true;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAliasedGroup()
+ */
+ public boolean supportsAliasedGroup() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelfJoins()
+ */
+ public boolean supportsSelfJoins() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOuterJoins()
+ */
+ public boolean supportsOuterJoins() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsFullOuterJoins()
+ */
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsBetweenCriteria()
+ */
+ public boolean supportsBetweenCriteria() {
+ return false;
+ }
+
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
+ */
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteriaSubquery()
+ */
+ public boolean supportsInCriteriaSubquery() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsExistsCriteria()
+ */
+ public boolean supportsExistsCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
+ */
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
+ */
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrderBy()
+ */
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesSum()
+ */
+ public boolean supportsAggregatesSum() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesAvg()
+ */
+ public boolean supportsAggregatesAvg() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMin()
+ */
+ public boolean supportsAggregatesMin() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMax()
+ */
+ public boolean supportsAggregatesMax() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCount()
+ */
+ public boolean supportsAggregatesCount() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCountStar()
+ */
+ public boolean supportsAggregatesCountStar() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesDistinct()
+ */
+ public boolean supportsAggregatesDistinct() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsScalarSubqueries()
+ */
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCorrelatedSubqueries()
+ */
+ public boolean supportsCorrelatedSubqueries() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCaseExpressions()
+ */
+ public boolean supportsCaseExpressions() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSearchedCaseExpressions()
+ */
+ public boolean supportsSearchedCaseExpressions() {
+ return false;
+ }
+
+ /**
+ * Return null to indicate no functions are supported.
+ * @return null
+ * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
+ */
+ public List getSupportedFunctions() {
+ return null;
+ }
+
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
+ * @since 4.2
+ */
+ public boolean supportsUnions() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return false;
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SimpleCapabilities.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -55,8 +55,6 @@
import org.teiid.language.Argument.Direction;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -24,7 +24,7 @@
*/
package org.teiid.translator.jdbc.access;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
public class AccessCapabilities extends JDBCCapabilities{
/*
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -27,7 +27,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -34,7 +34,6 @@
import org.teiid.language.Literal;
import org.teiid.language.Comparison.Operator;
import org.teiid.language.Join.JoinType;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
@@ -43,6 +42,7 @@
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.LocateFunctionModifier;
import org.teiid.translator.jdbc.ModFunctionModifier;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -22,11 +22,11 @@
package org.teiid.translator.jdbc.derby;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,8 +25,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.JDBCCapabilities;
public class H2Capabilities extends JDBCCapabilities {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -26,13 +26,13 @@
import java.sql.Time;
import java.sql.Timestamp;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.ModFunctionModifier;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.hsql.AddDiffModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,8 +25,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.JDBCCapabilities;
public class HsqlCapabilities extends JDBCCapabilities {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -26,12 +26,12 @@
import java.sql.Time;
import java.sql.Timestamp;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.Translator;
public class HsqlTranslator extends Translator {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -26,7 +26,7 @@
import java.util.*;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -24,11 +24,11 @@
*/
package org.teiid.translator.jdbc.informix;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.ConvertModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mm/MMCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -8,7 +8,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
* Capabilities compatible with MM 5.5.x
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -26,11 +26,11 @@
import java.util.List;
import org.teiid.language.Function;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
public class MySQL5Translator extends MySQLTranslator {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,8 +25,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.JDBCCapabilities;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -34,13 +34,13 @@
import org.teiid.language.Function;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.LocateFunctionModifier;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -27,8 +27,8 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -53,7 +53,6 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.metadata.Column;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
@@ -63,6 +62,7 @@
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.JDBCPlugin;
import org.teiid.translator.jdbc.LocateFunctionModifier;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
@@ -249,7 +249,7 @@
* This is true only after Postgre version 7.1
* However, since version 7 was released in 2000 we'll assume a post 7 instance.
*
- * @see org.teiid.resource.adapter.jdbc.JDBCCapabilities#supportsInlineViews()
+ * @see org.teiid.translator.jdbc.JDBCCapabilities#supportsInlineViews()
*/
public boolean supportsInlineViews() {
return true;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -35,7 +35,6 @@
import org.teiid.language.Limit;
import org.teiid.language.Literal;
import org.teiid.language.SQLReservedWords;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
@@ -46,6 +45,7 @@
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
import org.teiid.translator.jdbc.ExtractFunctionModifier;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.ModFunctionModifier;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -26,7 +26,7 @@
import java.util.*;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -27,7 +27,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -33,7 +33,6 @@
import org.teiid.language.Limit;
import org.teiid.language.OrderBy;
import org.teiid.language.SetQuery;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
@@ -42,6 +41,7 @@
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
import org.teiid.translator.jdbc.FunctionModifier;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.ModFunctionModifier;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -27,7 +27,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teradata/TeradataCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
+import org.teiid.translator.jdbc.JDBCCapabilities;
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeConnection.java (from rev 2119, trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeConnection.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeConnection.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeConnection.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,56 @@
+/*
+ * 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;
+
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.teiid.core.util.SimpleMock;
+
+
+/**
+ * FakeConnection for unit testing
+ */
+public class FakeConnection {
+
+ boolean closed;
+ boolean fail;
+
+ /* (non-Javadoc)
+ * @see java.sql.Connection#createStatement()
+ */
+ public Statement createStatement() throws SQLException {
+ if (fail) {
+ throw new SQLException();
+ }
+ return SimpleMock.createSimpleMock(Statement.class);
+ }
+
+ /* (non-Javadoc)
+ * @see java.sql.Connection#isClosed()
+ */
+ public boolean isClosed() {
+ return closed;
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeConnection.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java (from rev 2119, trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeMetadataFactory.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,66 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+import junit.framework.Assert;
+
+import org.mockito.Mockito;
+import org.teiid.language.Command;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.jdbc.Translator;
+
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+
+public class FakeMetadataFactory {
+
+ public static final String PARTS_VDB = "/PartsSupplier.vdb"; //$NON-NLS-1$
+ public static final String BQT_VDB = "/bqt.vdb"; //$NON-NLS-1$
+
+ public static Command helpTranslate(String vdbFileName, String sql) {
+ TranslationUtility util = null;
+ if (PARTS_VDB.equals(vdbFileName)) {
+ util = new TranslationUtility(FakeMetadataFactory.class.getResource(vdbFileName));
+ } else if (BQT_VDB.equals(vdbFileName)){
+ util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
+ } else {
+ Assert.fail("unknown vdb"); //$NON-NLS-1$
+ }
+ return util.parseCommand(sql);
+ }
+
+ public static void helpTestVisitor(String vdb, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ // Convert from sql to objects
+ Command obj = helpTranslate(vdb, input);
+
+ TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), translator);
+ tc.translateCommand(obj);
+
+ // Check stuff
+ assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/FakeMetadataFactory.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -34,7 +34,6 @@
import org.teiid.language.Literal;
import org.teiid.language.NamedTable;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.ExtractFunctionModifier;
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java (from rev 2119, trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCExecutionFactory.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.Translator;
+import org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator;
+public class TestJDBCExecutionFactory {
+
+ @Test public void testGetExtensionTranslationClassDefault() throws Exception {
+ JDBCExecutionFactory mcf = new JDBCExecutionFactory();
+ assertSame(Translator.class, mcf.getTranslator().getClass());
+ }
+
+ @Test public void testGetExtensionTranslationClass() throws Exception {
+ JDBCExecutionFactory mcf = new JDBCExecutionFactory();
+ mcf.setExtensionTranslationClassName(SQLServerSQLTranslator.class.getName());
+ assertSame(SQLServerSQLTranslator.class, mcf.getTranslator().getClass());
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCExecutionFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java (from rev 2119, trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCProcedureExecution.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,77 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.Types;
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.language.Command;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.JDBCProcedureExecution;
+import org.teiid.translator.jdbc.Translator;
+
+public class TestJDBCProcedureExecution {
+
+ @Test public void testProcedureExecution() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec pm2.spTest8a()"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ CallableStatement cs = Mockito.mock(CallableStatement.class);
+ Mockito.stub(cs.getUpdateCount()).toReturn(-1);
+ Mockito.stub(cs.getInt(1)).toReturn(5);
+ Mockito.stub(connection.prepareCall("{ call spTest8a(?)}")).toReturn(cs); //$NON-NLS-1$
+ Translator sqlTranslator = new Translator();
+
+ JDBCExecutionFactory config = Mockito.mock(JDBCExecutionFactory.class);
+ Mockito.stub(config.getTranslator()).toReturn(sqlTranslator);
+
+ JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command, connection, Mockito.mock(ExecutionContext.class), config, sqlTranslator);
+ procedureExecution.execute();
+ assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
+ Mockito.verify(cs, Mockito.times(1)).registerOutParameter(1, Types.INTEGER);
+ }
+ @Test public void testProcedureExecution1() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "exec pm2.spTest8(1)"); //$NON-NLS-1$
+ Connection connection = Mockito.mock(Connection.class);
+ CallableStatement cs = Mockito.mock(CallableStatement.class);
+ Mockito.stub(cs.getUpdateCount()).toReturn(-1);
+ Mockito.stub(cs.getInt(2)).toReturn(5);
+ Mockito.stub(connection.prepareCall("{ call spTest8(?,?)}")).toReturn(cs); //$NON-NLS-1$
+ Translator sqlTranslator = new Translator();
+
+ JDBCExecutionFactory config = Mockito.mock(JDBCExecutionFactory.class);
+ Mockito.stub(config.getTranslator()).toReturn(sqlTranslator);
+
+ JDBCProcedureExecution procedureExecution = new JDBCProcedureExecution(command, connection, Mockito.mock(ExecutionContext.class), config, sqlTranslator);
+ procedureExecution.execute();
+ assertEquals(Arrays.asList(5), procedureExecution.getOutputParameterValues());
+ Mockito.verify(cs, Mockito.times(1)).registerOutParameter(2, Types.INTEGER);
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCProcedureExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java (from rev 2119, trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCUpdateExecution.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,65 @@
+/*
+ * 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;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.util.Arrays;
+
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.teiid.language.Command;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Insert;
+import org.teiid.language.Literal;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.JDBCUpdateExecution;
+import org.teiid.translator.jdbc.Translator;
+
+public class TestJDBCUpdateExecution {
+
+ @Test public void testBulkUpdate() throws Exception {
+ Command command = TranslationHelper.helpTranslate(TranslationHelper.BQT_VDB, "insert into BQT1.SmallA (IntKey, IntNum) values (1, 2)"); //$NON-NLS-1$
+ Literal value = ((Literal)((ExpressionValueSource)((Insert)command).getValueSource()).getValues().get(0));
+ Literal value1 = ((Literal)((ExpressionValueSource)((Insert)command).getValueSource()).getValues().get(1));
+ value.setMultiValued(true);
+ value.setBindValue(true);
+ value.setValue(Arrays.asList(1, 2));
+ value1.setMultiValued(true);
+ value1.setBindValue(true);
+ value1.setValue(Arrays.asList(2, 3));
+ Connection connection = Mockito.mock(Connection.class);
+ PreparedStatement p = Mockito.mock(PreparedStatement.class);
+ Mockito.stub(p.executeBatch()).toReturn(new int [] {1, 1});
+ Mockito.stub(connection.prepareStatement("INSERT INTO SmallA (IntKey, IntNum) VALUES (?, ?)")).toReturn(p); //$NON-NLS-1$
+
+ JDBCExecutionFactory config = Mockito.mock(JDBCExecutionFactory.class);
+ Mockito.stub(config.getTranslator()).toReturn(new Translator());
+
+ JDBCUpdateExecution updateExecution = new JDBCUpdateExecution(command, connection, Mockito.mock(ExecutionContext.class), config, config.getTranslator());
+ updateExecution.execute();
+ Mockito.verify(p, Mockito.times(2)).addBatch();
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestJDBCUpdateExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -30,7 +30,6 @@
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.LocateFunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -31,7 +31,6 @@
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.ModFunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -35,8 +35,6 @@
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
import org.teiid.language.LanguageObject;
import org.teiid.metadata.RuntimeMetadata;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.SQLConversionVisitor;
Copied: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java (from rev 2119, trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java)
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,93 @@
+/*
+ * 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;
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.IOException;
+import java.util.Collection;
+
+import junit.framework.Assert;
+
+import org.mockito.Mockito;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.language.Command;
+import org.teiid.query.function.metadata.FunctionMetadataReader;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.jdbc.Translator;
+
+import com.metamatrix.cdk.api.TranslationUtility;
+import com.metamatrix.cdk.unittest.FakeTranslationFactory;
+
+public class TranslationHelper {
+
+ public static final String PARTS_VDB = "/PartsSupplier.vdb"; //$NON-NLS-1$
+ public static final String BQT_VDB = "/bqt.vdb"; //$NON-NLS-1$
+
+ public static Command helpTranslate(String vdbFileName, String sql) {
+ return helpTranslate(vdbFileName, null, sql);
+ }
+
+ public static Command helpTranslate(String vdbFileName, String udf, String sql) {
+ TranslationUtility util = null;
+ if (PARTS_VDB.equals(vdbFileName)) {
+ util = new TranslationUtility(TranslationHelper.class.getResource(vdbFileName));
+ } else if (BQT_VDB.equals(vdbFileName)){
+ util = FakeTranslationFactory.getInstance().getBQTTranslationUtility();
+ } else {
+ Assert.fail("unknown vdb"); //$NON-NLS-1$
+ }
+
+ if (udf != null) {
+ try {
+ Collection <FunctionMethod> methods = FunctionMetadataReader.loadFunctionMethods(TranslationHelper.class.getResource(udf).openStream());
+ util.setUDF(methods);
+ } catch (IOException e) {
+ throw new TeiidRuntimeException("failed to load UDF"); //$NON-NLS-1$
+ }
+ }
+ return util.parseCommand(sql);
+ }
+
+ public static void helpTestVisitor(String vdb, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ helpTestVisitor(vdb,null,input, expectedOutput, translator);
+ }
+
+ public static void helpTestVisitor(String vdb, String udf, String input, String expectedOutput, Translator translator) throws ConnectorException {
+ // Convert from sql to objects
+ Command obj = helpTranslate(vdb, udf, input);
+
+ helpTestVisitor(expectedOutput, translator, obj);
+ }
+
+ public static void helpTestVisitor(String expectedOutput,
+ Translator translator, Command obj) throws ConnectorException {
+ TranslatedCommand tc = new TranslatedCommand(Mockito.mock(ExecutionContext.class), translator);
+ tc.translateCommand(obj);
+ assertEquals("Did not get correct sql", expectedOutput, tc.getSql()); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TranslationHelper.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -26,9 +26,9 @@
import org.mockito.Mockito;
import org.teiid.language.Command;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.access.AccessSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -33,8 +33,8 @@
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -29,11 +29,11 @@
import org.mockito.Mockito;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.language.Command;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,9 +25,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.derby.DerbySQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -24,9 +24,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.h2.H2Translator;
public class TestH2Translator {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -24,9 +24,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.mysql.MySQL5Translator;
/**
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -25,9 +25,9 @@
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.mysql.MySQLTranslator;
/**
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -31,8 +31,8 @@
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -29,7 +29,7 @@
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -31,7 +31,7 @@
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -35,8 +35,8 @@
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
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 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -43,11 +43,11 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -29,8 +29,8 @@
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.LanguageFactory;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -24,9 +24,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.postgresql.PostgreSQLTranslator;
public class TestPostgreSQLTranslator {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -36,9 +36,9 @@
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -36,8 +36,8 @@
import org.teiid.language.LanguageFactory;
import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-05-12 19:17:10 UTC (rev 2120)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -28,11 +28,11 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.language.Command;
-import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.adapter.jdbc.TranslationHelper;
import org.teiid.translator.ConnectorException;
import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.TranslatedCommand;
+import org.teiid.translator.jdbc.TranslationHelper;
import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
/**
Copied: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap (from rev 2119, trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap)
Modified: trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import static org.mockito.Mockito.mock;
Copied: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback (from rev 2119, trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback)
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.loopback;
+package org.teiid.translator.loopback;
import java.util.Arrays;
import java.util.List;
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.loopback;
+package org.teiid.translator.loopback;
import java.math.BigDecimal;
import java.math.BigInteger;
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/translator/loopback/LoopbackExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.loopback;
+package org.teiid.translator.loopback;
import org.teiid.language.Command;
import org.teiid.metadata.RuntimeMetadata;
Copied: trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback (from rev 2119, trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback)
Modified: trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/TestLoobackAsynch.java
===================================================================
--- trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback/TestLoobackAsynch.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/TestLoobackAsynch.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,13 +20,13 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adaptor.loopback;
+package org.teiid.translator.loopback;
import java.util.List;
import junit.framework.TestCase;
-import org.teiid.resource.adapter.loopback.LoopbackExecutionFactory;
+import org.teiid.translator.loopback.LoopbackExecutionFactory;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
Modified: trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/TestLoopbackExecution.java
===================================================================
--- trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback/TestLoopbackExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-loopback/src/test/java/org/teiid/translator/loopback/TestLoopbackExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adaptor.loopback;
+package org.teiid.translator.loopback;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -28,9 +28,9 @@
import junit.framework.TestCase;
-import org.teiid.resource.adapter.loopback.LoopbackExecution;
-import org.teiid.resource.adapter.loopback.LoopbackExecutionFactory;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.loopback.LoopbackExecution;
+import org.teiid.translator.loopback.LoopbackExecutionFactory;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Constants.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Constants.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Constants.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Constants.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,51 @@
+package org.teiid.translator.salesforce;
+
+public interface Constants {
+
+ public static final String PICKLIST_TYPE = "picklist"; //$NON-NLS-1$
+
+ public static final String MULTIPICKLIST_TYPE = "multipicklist"; //$NON-NLS-1$
+
+ public static final String COMBOBOX_TYPE = "combobox"; //$NON-NLS-1$
+
+ public static final String ANYTYPE_TYPE = "anyType"; //$NON-NLS-1$
+
+ public static final String REFERENCE_TYPE = "reference"; //$NON-NLS-1$
+
+ public static final String STRING_TYPE = "string"; //$NON-NLS-1$
+
+ public static final String BASE64_TYPE = "base64"; //$NON-NLS-1$
+
+ public static final String BOOLEAN_TYPE = "boolean"; //$NON-NLS-1$
+
+ public static final String CURRENCY_TYPE = "currency"; //$NON-NLS-1$
+
+ public static final String TEXTAREA_TYPE = "textarea"; //$NON-NLS-1$
+
+ public static final String INT_TYPE = "int"; //$NON-NLS-1$
+
+ public static final String DOUBLE_TYPE = "double"; //$NON-NLS-1$
+
+ public static final String PERCENT_TYPE = "percent"; //$NON-NLS-1$
+
+ public static final String PHONE_TYPE = "phone"; //$NON-NLS-1$
+
+ public static final String ID_TYPE = "id"; //$NON-NLS-1$
+
+ public static final String DATE_TYPE = "date"; //$NON-NLS-1$
+
+ public static final String DATETIME_TYPE = "datetime"; //$NON-NLS-1$
+
+ public static final String URL_TYPE = "url"; //$NON-NLS-1$
+
+ public static final String EMAIL_TYPE = "email"; //$NON-NLS-1$
+
+ public static final String RESTRICTED_PICKLIST_TYPE = "restrictedpicklist"; //$NON-NLS-1$
+
+ public static final String RESTRICTED_MULTISELECT_PICKLIST_TYPE = "restrictedmultiselectpicklist"; //$NON-NLS-1$
+
+ public static final String SUPPORTS_QUERY = "Supports Query";//$NON-NLS-1$
+
+ public static final String SUPPORTS_RETRIEVE = "Supports Retrieve";//$NON-NLS-1$
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Messages.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Messages.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Messages.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Messages.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,41 @@
+/*
+ * 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.salesforce;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class Messages {
+
+ private static final String BUNDLE_NAME = "com.metamatrix.connector.salesforce.i18n"; //$NON-NLS-1$
+
+ private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
+
+ public static String getString(String key) {
+ try {
+ return RESOURCE_BUNDLE.getString(key);
+ } catch (MissingResourceException e) {
+ return '!' + key + '!';
+ }
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/MetadataProcessor.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/MetadataProcessor.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/MetadataProcessor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,292 @@
+package org.teiid.translator.salesforce;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
+import org.teiid.translator.ConnectorException;
+
+import com.sforce.soap.partner.ChildRelationship;
+import com.sforce.soap.partner.DescribeGlobalResult;
+import com.sforce.soap.partner.DescribeGlobalSObjectResult;
+import com.sforce.soap.partner.DescribeSObjectResult;
+import com.sforce.soap.partner.Field;
+import com.sforce.soap.partner.FieldType;
+import com.sforce.soap.partner.PicklistEntry;
+
+public class MetadataProcessor {
+ private MetadataFactory metadataFactory;
+ private SalesforceConnection connection;
+ private SalesForceExecutionFactory connectorEnv;
+
+ private Map<String, Table> tableMap = new HashMap<String, Table>();
+ private List<Relationship> relationships = new ArrayList<Relationship>();
+ private boolean hasUpdateableColumn = false;
+ private List<Column> columns;
+
+ // Audit Fields
+ public static final String AUDIT_FIELD_CREATED_BY_ID = "CreatedById"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_CREATED_DATE = "CreatedDate"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_LAST_MODIFIED_BY_ID = "LastModifiedById"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_LAST_MODIFIED_DATE = "LastModifiedDate"; //$NON-NLS-1$
+ public static final String AUDIT_FIELD_SYSTEM_MOD_STAMP = "SystemModstamp"; //$NON-NLS-1$
+
+ // Model Extensions
+ static final String TABLE_SUPPORTS_CREATE = "Supports Create"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_DELETE = "Supports Delete"; //$NON-NLS-1$
+ static final String TABLE_CUSTOM = "Custom"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_LOOKUP = "Supports ID Lookup"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_MERGE = "Supports Merge"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_QUERY = "Supports Query"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_REPLICATE = "Supports Replicate"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_RETRIEVE = "Supports Retrieve"; //$NON-NLS-1$
+ static final String TABLE_SUPPORTS_SEARCH = "Supports Search"; //$NON-NLS-1$
+
+ static final String COLUMN_DEFAULTED = "Defaulted on Create"; //$NON-NLS-1$
+ static final String COLUMN_CUSTOM = "Custom"; //$NON-NLS-1$
+ static final String COLUMN_CALCULATED = "Calculated"; //$NON-NLS-1$
+ static final String COLUMN_PICKLIST_VALUES = "Picklist Values"; //$NON-NLS-1$
+
+ public MetadataProcessor(SalesforceConnection connection, MetadataFactory metadataFactory, SalesForceExecutionFactory env) {
+ this.connection = connection;
+ this.metadataFactory = metadataFactory;
+ this.connectorEnv = env;
+ }
+
+ public void processMetadata() throws ConnectorException {
+ DescribeGlobalResult globalResult = connection.getObjects();
+ List<DescribeGlobalSObjectResult> objects = globalResult.getSobjects();
+ for (DescribeGlobalSObjectResult object : objects) {
+ addTable(object);
+ }
+ addRelationships();
+ }
+
+ private void addRelationships() throws ConnectorException {
+ for (Iterator<Relationship> iterator = relationships.iterator(); iterator.hasNext();) {
+ Relationship relationship = iterator.next();
+ if (!this.connectorEnv.isModelAuditFields() && isAuditField(relationship.getForeignKeyField())) {
+ continue;
+ }
+
+ Table parent = tableMap.get(NameUtil.normalizeName(relationship.getParentTable()));
+ KeyRecord pk = parent.getPrimaryKey();
+ if (null == pk) {
+ throw new RuntimeException("ERROR !!primary key column not found!!"); //$NON-NLS-1$
+ }
+ ArrayList<String> columnNames = new ArrayList<String>();
+ columnNames.add(pk.getName());
+
+
+ Table child = tableMap.get(NameUtil.normalizeName(relationship.getChildTable()));
+
+ Column col = null;
+ columns = child.getColumns();
+ for (Iterator colIter = columns.iterator(); colIter.hasNext();) {
+ Column column = (Column) colIter.next();
+ if(column.getName().equals(relationship.getForeignKeyField())) {
+ col = column;
+ }
+ }
+ if (null == col) throw new RuntimeException(
+ "ERROR !!foreign key column not found!! " + child.getName() + relationship.getForeignKeyField()); //$NON-NLS-1$
+
+
+ String columnName = "FK_" + parent.getName() + "_" + col.getName();//$NON-NLS-1$ //$NON-NLS-2$
+ ArrayList<String> columnNames2 = new ArrayList<String>();
+ columnNames2.add(col.getName());
+ metadataFactory.addForiegnKey(columnName, columnNames2, parent, child);
+
+ }
+
+
+ }
+
+ public static boolean isAuditField(String name) {
+ boolean result = false;
+ if(name.equals(AUDIT_FIELD_CREATED_BY_ID) ||
+ name.equals(AUDIT_FIELD_CREATED_DATE) ||
+ name.equals(AUDIT_FIELD_LAST_MODIFIED_BY_ID) ||
+ name.equals(AUDIT_FIELD_LAST_MODIFIED_DATE) ||
+ name.equals(AUDIT_FIELD_SYSTEM_MOD_STAMP)) {
+ result = true;
+ }
+ return result;
+ }
+
+ private void addTable(DescribeGlobalSObjectResult object) throws ConnectorException {
+ DescribeSObjectResult objectMetadata = connection.getObjectMetaData(object.getName());
+ String name = NameUtil.normalizeName(objectMetadata.getName());
+ Table table = metadataFactory.addTable(name);
+
+ table.setNameInSource(objectMetadata.getName());
+ tableMap.put(name, table);
+ getRelationships(objectMetadata);
+
+ table.setProperty(TABLE_CUSTOM, String.valueOf(objectMetadata.isCustom()));
+ table.setProperty(TABLE_SUPPORTS_CREATE, String.valueOf(objectMetadata.isCreateable()));
+ table.setProperty(TABLE_SUPPORTS_DELETE, String.valueOf(objectMetadata.isDeletable()));
+ table.setProperty(TABLE_SUPPORTS_MERGE, String.valueOf(objectMetadata.isMergeable()));
+ table.setProperty(TABLE_SUPPORTS_QUERY, String.valueOf(objectMetadata.isQueryable()));
+ table.setProperty(TABLE_SUPPORTS_REPLICATE, String.valueOf(objectMetadata.isReplicateable()));
+ table.setProperty(TABLE_SUPPORTS_RETRIEVE, String.valueOf(objectMetadata.isRetrieveable()));
+ table.setProperty(TABLE_SUPPORTS_SEARCH, String.valueOf(objectMetadata.isSearchable()));
+
+ hasUpdateableColumn = false;
+ addColumns(objectMetadata, table);
+
+ // Some SF objects return true for isUpdateable() but have no updateable columns.
+ if(hasUpdateableColumn && objectMetadata.isUpdateable()) {
+ table.setSupportsUpdate(true);
+ }
+ }
+
+ private void getRelationships(DescribeSObjectResult objectMetadata) {
+ List<ChildRelationship> children = objectMetadata.getChildRelationships();
+ if(children != null && children.size() != 0) {
+ for (ChildRelationship childRelation : children) {
+ Relationship newRelation = new RelationshipImpl();
+ newRelation.setParentTable(objectMetadata.getName());
+ newRelation.setChildTable(childRelation.getChildSObject());
+ newRelation.setForeignKeyField(childRelation.getField());
+ newRelation.setCascadeDelete(childRelation.isCascadeDelete());
+ relationships.add(newRelation);
+ }
+ }
+ }
+
+ private void addColumns(DescribeSObjectResult objectMetadata, Table table) throws ConnectorException {
+ List<Field> fields = objectMetadata.getFields();
+ for (Field field : fields) {
+ String normalizedName = NameUtil.normalizeName(field.getName());
+ FieldType fieldType = field.getType();
+ if(!this.connectorEnv.isModelAuditFields() && isAuditField(field.getName())) {
+ continue;
+ }
+ String sfTypeName = fieldType.value();
+ Column column = null;
+ if(sfTypeName.equals(FieldType.STRING) || //string
+ sfTypeName.equals(FieldType.COMBOBOX) || //"combobox"
+ sfTypeName.equals(FieldType.REFERENCE) || //"reference"
+ sfTypeName.equals(FieldType.PHONE) || //"phone"
+ sfTypeName.equals(FieldType.ID) || //"id"
+ sfTypeName.equals(FieldType.URL) || //"url"
+ sfTypeName.equals(FieldType.EMAIL) || //"email"
+ sfTypeName.equals(FieldType.ENCRYPTEDSTRING) || //"encryptedstring"
+ sfTypeName.equals(FieldType.ANY_TYPE)) { //"anytype"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ column.setNativeType(sfTypeName);
+ if(sfTypeName.equals(FieldType.ID)) {
+ column.setNullType(NullType.No_Nulls);
+ ArrayList<String> columnNames = new ArrayList<String>();
+ columnNames.add(field.getName());
+ metadataFactory.addPrimaryKey(field.getName()+"_PK", columnNames, table);
+ }
+ }
+ else if(sfTypeName.equals(FieldType.PICKLIST)) { // "picklist"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ if(field.isRestrictedPicklist()) {
+ column.setNativeType("restrictedpicklist");
+ } else {
+ column.setNativeType(sfTypeName);
+ }
+
+ column.setProperty(COLUMN_PICKLIST_VALUES, getPicklistValues(field));
+ }
+ else if(sfTypeName.equals(FieldType.MULTIPICKLIST)) { //"multipicklist"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ if(field.isRestrictedPicklist()) {
+ column.setNativeType("restrictedmultiselectpicklist");
+ } else {
+ column.setNativeType(sfTypeName);
+ }
+ column.setProperty(COLUMN_PICKLIST_VALUES, getPicklistValues(field));
+ }
+ else if(sfTypeName.equals(FieldType.BASE_64)) { //"base64"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.BLOB, table);
+ column.setNativeType(sfTypeName);
+ }
+ else if(sfTypeName.equals(FieldType.BOOLEAN)) { //"boolean"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.BOOLEAN, table);
+ column.setNativeType(sfTypeName);
+ }
+ else if(sfTypeName.equals(FieldType.CURRENCY)) { //"currency"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DOUBLE, table);
+ column.setNativeType(sfTypeName);
+ column.setCurrency(true);
+ column.setScale(field.getScale());
+ column.setPrecision(field.getPrecision());
+ }
+ else if(sfTypeName.equals(FieldType.TEXTAREA)) { //"textarea"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.STRING, table);
+ column.setNativeType(sfTypeName);
+ column.setSearchType(SearchType.Unsearchable);
+ }
+ else if(sfTypeName.equals(FieldType.INT)) { //"int"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.INTEGER, table);
+ column.setNativeType(sfTypeName);
+ column.setPrecision(field.getPrecision());
+ }
+ else if(sfTypeName.equals(FieldType.DOUBLE) || //"double"
+ sfTypeName.equals(FieldType.PERCENT)) { //"percent"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DOUBLE, table);
+ column.setNativeType(sfTypeName);
+ column.setScale(field.getScale());
+ column.setPrecision(field.getPrecision());
+ }
+ else if(sfTypeName.equals(FieldType.DATE)) { //"date"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.DATE, table);
+ column.setNativeType(sfTypeName);
+ }
+ else if(sfTypeName.equals(FieldType.DATETIME)) { //"datetime"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.TIMESTAMP, table);
+ column.setNativeType(sfTypeName);
+ }
+ else if(sfTypeName.equals(FieldType.TIME)) { //"time"
+ column = metadataFactory.addColumn(normalizedName, DataTypeManager.DefaultDataTypes.TIME, table);
+ column.setNativeType(sfTypeName);
+ }
+ if(null == column) {
+ LogManager.logError(LogConstants.CTX_CONNECTOR, "Unknown type returned by SalesForce: " + sfTypeName);
+ continue;
+ } else {
+ column.setNameInSource(field.getName());
+ column.setLength(field.getLength());
+ if(field.isUpdateable()) {
+ column.setUpdatable(true);
+ hasUpdateableColumn = true;
+ }
+ column.setProperty(COLUMN_CALCULATED, String.valueOf(field.isCalculated()));
+ column.setProperty(COLUMN_CUSTOM, String.valueOf(field.isCustom()));
+ column.setProperty(COLUMN_DEFAULTED, String.valueOf(field.isDefaultedOnCreate()));
+ }
+
+ }
+ }
+
+ private String getPicklistValues(Field field) {
+ StringBuffer picklistValues = new StringBuffer();
+ if(null != field.getPicklistValues() && 0 != field.getPicklistValues().size()) {
+ List<PicklistEntry> entries = field.getPicklistValues();
+ for (Iterator<PicklistEntry> iterator = entries.iterator(); iterator.hasNext();) {
+ PicklistEntry entry = iterator.next();
+ picklistValues.append(entry.getValue());
+ if(iterator.hasNext()) {
+ picklistValues.append(',');
+ }
+ }
+ }
+ return picklistValues.toString();
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/NameUtil.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/NameUtil.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/NameUtil.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/NameUtil.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,85 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ *
+ * See the LEGAL.txt file distributed with this work for information regarding copyright ownership and licensing.
+ *
+ * See the AUTHORS.txt file distributed with this work for a full listing of individual contributors.
+ */
+package org.teiid.translator.salesforce;
+
+import org.teiid.language.SQLReservedWords;
+
+public class NameUtil {
+
+ public static String normalizeName( String nameIn ) {
+ String normal = nameIn.trim();
+ normal = removeDuplicate(normal);
+ normal = removeSpaces(normal);
+ normal = removeIllegalChars(normal);
+ normal = removeTrailingUnderscore(normal);
+ normal = removeLeadingUnderscore(normal);
+ normal = checkReservedWords(normal);
+ return normal;
+
+ }
+
+ /**
+ * @param normal
+ * @return
+ */
+ private static String checkReservedWords( String normal ) {
+ if (SQLReservedWords.isReservedWord(normal)) {
+ normal = normal + "_"; //$NON-NLS-1$
+ }
+ return normal;
+ }
+
+ private static String removeTrailingUnderscore( String normal ) {
+ if (normal.endsWith("_")) { //$NON-NLS-1$
+ return normal.substring(0, normal.lastIndexOf('_'));
+ }
+ return normal;
+ }
+
+ private static String removeIllegalChars( String normal ) {
+ String edit = normal;
+ edit = edit.replace('.', '_');
+ edit = edit.replace('(', '_');
+ edit = edit.replace(')', '_');
+ edit = edit.replace('/', '_');
+ edit = edit.replace('\\', '_');
+ edit = edit.replace(':', '_');
+ edit = edit.replace('\'', '_');
+ edit = edit.replace('-', '_');
+ edit = edit.replace("%", "percentage");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("#", "number");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("$", "_");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("{", "_");//$NON-NLS-1$ //$NON-NLS-2$
+ edit = edit.replace("}", "_");//$NON-NLS-1$ //$NON-NLS-2$
+ return edit;
+ }
+
+ private static String removeSpaces( String normal ) {
+ return normal.replace(' ', '_');
+ }
+
+ private static String removeDuplicate( String normal ) {
+ if (normal.indexOf('(') < 0 || normal.indexOf(')') != normal.length() - 1) return normal;
+ String firstPart = normal.substring(0, normal.indexOf('(')).trim();
+ String secondPart = normal.substring(normal.indexOf('(') + 1, normal.length() - 1).trim();
+ if (firstPart.equals(secondPart) || secondPart.equals("null")) return firstPart; //$NON-NLS-1$
+ return normal;
+ }
+
+ /**
+ * @param normal
+ * @return
+ */
+ private static String removeLeadingUnderscore( String normal ) {
+ while (normal.indexOf('_') == 0) {
+ normal = normal.substring(1);
+ }
+ return normal;
+ }
+
+}
\ No newline at end of file
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Relationship.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Relationship.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Relationship.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Relationship.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,21 @@
+package org.teiid.translator.salesforce;
+
+public interface Relationship {
+
+ void setParentTable(String name);
+
+ void setChildTable(String childSObject);
+
+ void setForeignKeyField(String field);
+
+ void setCascadeDelete(boolean cascadeDelete);
+
+ public boolean isCascadeDelete();
+
+ public String getChildTable();
+
+ public String getForeignKeyField();
+
+ public String getParentTable();
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/RelationshipImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/RelationshipImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/RelationshipImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/RelationshipImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,40 @@
+package org.teiid.translator.salesforce;
+
+public class RelationshipImpl implements Relationship {
+ boolean cascadeDelete;
+ public String childTablename;
+ public String parentTableName;
+ public String foreignKeyField;
+
+ public void setCascadeDelete(boolean delete) {
+ cascadeDelete = delete;
+ }
+
+ public boolean isCascadeDelete() {
+ return cascadeDelete;
+ }
+
+ public void setChildTable(String childTable) {
+ childTablename = childTable;
+ }
+
+ public String getChildTable() {
+ return childTablename;
+ }
+
+ public String getForeignKeyField() {
+ return foreignKeyField;
+ }
+
+ public void setForeignKeyField(String foreignKeyField) {
+ this.foreignKeyField = foreignKeyField;
+ }
+
+ public String getParentTable() {
+ return parentTableName;
+ }
+
+ public void setParentTable(String parentTableName) {
+ this.parentTableName = parentTableName;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceExecutionFactory.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForceExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,111 @@
+/*
+ * 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.salesforce;
+
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.UpdateExecution;
+import org.teiid.translator.salesforce.execution.DeleteExecutionImpl;
+import org.teiid.translator.salesforce.execution.InsertExecutionImpl;
+import org.teiid.translator.salesforce.execution.ProcedureExecutionParentImpl;
+import org.teiid.translator.salesforce.execution.QueryExecutionImpl;
+import org.teiid.translator.salesforce.execution.UpdateExecutionImpl;
+
+
+public class SalesForceExecutionFactory extends org.teiid.translator.BasicExecutionFactory implements MetadataProvider {
+
+ private String connectorStateClass;
+ private boolean auditModelFields = false;
+
+
+ public String getConnectorStateClass() {
+ return this.connectorStateClass;
+ }
+ public void setConnectorStateClass(String connectorStateClass) {
+ this.connectorStateClass = connectorStateClass;
+ }
+
+ @TranslatorProperty(name="ModelAuditFields", display="Audit Model Fields", advanced=true, defaultValue="false")
+ public boolean isModelAuditFields() {
+ return this.auditModelFields;
+ }
+
+ public void setModelAuditFields(boolean modelAuditFields) {
+ this.auditModelFields = modelAuditFields;
+ }
+
+ @Override
+ public void start() throws ConnectorException {
+ super.start();
+ LogManager.logTrace(LogConstants.CTX_CONNECTOR, "Started"); //$NON-NLS-1$
+ }
+
+
+ @Override
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return SalesforceCapabilities.class;
+ }
+
+ @Override
+ public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
+ throws ConnectorException {
+ return new QueryExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
+ }
+
+ @Override
+ public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException {
+ UpdateExecution result = null;
+ if(command instanceof org.teiid.language.Delete) {
+ result = new DeleteExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
+ } else if (command instanceof org.teiid.language.Insert) {
+ result = new InsertExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
+ } else if (command instanceof org.teiid.language.Update) {
+ result = new UpdateExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
+ }
+ return result;
+
+ }
+
+ @Override
+ public ProcedureExecution createProcedureExecution(Call command,ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory)
+ throws ConnectorException {
+ return new ProcedureExecutionParentImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
+ }
+ @Override
+ public void getConnectorMetadata(MetadataFactory metadataFactory, Object connectionFactory) throws ConnectorException {
+ MetadataProcessor processor = new MetadataProcessor((SalesforceConnection)connectionFactory,metadataFactory, this);
+ processor.processMetadata();
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForcePlugin.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesForcePlugin.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,46 @@
+/*
+ * 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.salesforce;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+
+/**
+ * For logging purposes
+ */
+public class SalesForcePlugin {
+
+ /**
+ * The plug-in identifier of this plugin
+ */
+ public static final String PLUGIN_ID = "org.teiid.translator.salesforce" ; //$NON-NLS-1$
+
+ /**
+ * Provides access to the plugin's log and to it's resources.
+ */
+ private static final String BUNDLE_NAME = PLUGIN_ID + ".i18n"; //$NON-NLS-1$
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,BUNDLE_NAME,ResourceBundle.getBundle(BUNDLE_NAME));
+
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceCapabilities.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,96 @@
+/*
+ * 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.salesforce;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.translator.BasicConnectorCapabilities;
+
+public class SalesforceCapabilities extends BasicConnectorCapabilities {
+
+ public int getMaxInCriteriaSize() {
+ return 700;
+ }
+
+ public List getSupportedFunctions() {
+ List<String> supportedFunctions = new ArrayList<String>();
+ supportedFunctions.add("includes");
+ supportedFunctions.add("excludes");
+ return supportedFunctions;
+ }
+
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
+
+ public boolean supportsInCriteria() {
+ return true;
+ }
+
+ public boolean supportsLikeCriteria() {
+ return true;
+ }
+
+ public boolean supportsRowLimit() {
+ return true;
+ }
+
+ // http://jira.jboss.org/jira/browse/JBEDSP-306
+ // Salesforce supports ORDER BY, but not on all column types
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsAggregatesCountStar() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsNotCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsOrCriteria() {
+ return true;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return true;
+ }
+
+ @Override
+ public SupportedJoinCriteria getSupportedJoinCriteria() {
+ return SupportedJoinCriteria.KEY;
+ }
+
+ @Override
+ public boolean supportsOuterJoins() {
+ return true;
+ }
+
+
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceConnection.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnection.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceConnection.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/SalesforceConnection.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,60 @@
+/*
+ * 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.salesforce;
+
+import java.util.List;
+
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.salesforce.execution.DataPayload;
+import org.teiid.translator.salesforce.execution.DeletedResult;
+import org.teiid.translator.salesforce.execution.UpdatedResult;
+
+import com.sforce.soap.partner.DescribeGlobalResult;
+import com.sforce.soap.partner.DescribeSObjectResult;
+import com.sforce.soap.partner.QueryResult;
+
+public interface SalesforceConnection {
+
+ public QueryResult query(String queryString, int maxBatchSize, Boolean queryAll) throws ConnectorException;
+
+ public QueryResult queryMore(String queryLocator, int batchSize) throws ConnectorException;
+
+ public boolean isAlive();
+
+ public int delete(String[] ids) throws ConnectorException ;
+
+ public int create(DataPayload data) throws ConnectorException;
+
+ public int update(List<DataPayload> updateDataList) throws ConnectorException;
+
+ public UpdatedResult getUpdated(String objectName, XMLGregorianCalendar startCalendar, XMLGregorianCalendar endCalendar) throws ConnectorException;
+
+ public DeletedResult getDeleted(String objectName, XMLGregorianCalendar startCalendar, XMLGregorianCalendar endCalendar) throws ConnectorException;
+
+ public QueryResult retrieve(String fieldList, String sObjectType, List<String> ids) throws ConnectorException;
+
+ public DescribeGlobalResult getObjects() throws ConnectorException;
+
+ public DescribeSObjectResult getObjectMetaData(String objectName) throws ConnectorException;
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Util.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Util.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Util.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/Util.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,71 @@
+/*
+ * 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.salesforce;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+
+import org.teiid.translator.ConnectorException;
+
+
+public class Util {
+
+ public static String stripQutes(String id) {
+ if((id.startsWith("'") && id.endsWith("'"))) {
+ id = id.substring(1,id.length()-1);
+ } else if ((id.startsWith("\"") && id.endsWith("\""))) {
+ id = id.substring(1,id.length()-1);
+ }
+ return id;
+ }
+
+ public static String addSingleQuotes(String text) {
+ StringBuffer result = new StringBuffer();
+ if(!text.startsWith("'")) {
+ result.append('\'');
+ }
+ result.append(text);
+ if(!text.endsWith("'")) {
+ result.append('\'');
+ }
+ return result.toString();
+ }
+
+ public static void validateQueryLength(StringBuffer query) throws ConnectorException {
+ if(query.length() >= 10000) {
+ throw new ConnectorException(Messages.getString("Util.query.exceeds.max.length"));
+ }
+ }
+
+ public static SimpleDateFormat getSalesforceDateTimeFormat() {
+ return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'");
+ }
+
+ public static SimpleDateFormat getTimeZoneOffsetFormat() {
+ return new SimpleDateFormat("Z");
+ }
+
+ public static DateFormat getSalesforceDateFormat() {
+ return new SimpleDateFormat("yyyy-MM-dd");
+ }
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/AbstractUpdateExecution.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/AbstractUpdateExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,115 @@
+/*
+ * 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.salesforce.execution;
+
+import java.util.ArrayList;
+
+import org.teiid.language.Command;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.UpdateExecution;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.Util;
+import org.teiid.translator.salesforce.execution.visitors.IQueryProvidingVisitor;
+
+import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
+
+/**
+ *
+ * Parent class to the Update, Delete, and Insert execution classes.
+ * Provisions the correct impl and contains some common code to
+ * get IDs of Salesforce objects.
+ *
+ */
+public abstract class AbstractUpdateExecution extends BasicExecution implements UpdateExecution {
+
+ protected SalesforceConnection connection;
+ protected RuntimeMetadata metadata;
+ protected ExecutionContext context;
+ protected Command command;
+ protected int result;
+
+ public AbstractUpdateExecution(Command command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context) {
+ this.connection = salesforceConnection;
+ this.metadata = metadata;
+ this.context = context;
+ this.command = command;
+ }
+
+ @Override
+ public void cancel() throws ConnectorException {
+ }
+
+ @Override
+ public void close() throws ConnectorException {
+ }
+
+ @Override
+ public int[] getUpdateCounts() throws DataNotAvailableException,
+ ConnectorException {
+ return new int[] {result};
+ }
+
+ public RuntimeMetadata getMetadata() {
+ return metadata;
+ }
+
+ public SalesforceConnection getConnection() {
+ return connection;
+ }
+
+ String[] getIDs(Condition criteria, IQueryProvidingVisitor visitor) throws ConnectorException {
+ String[] Ids = null;
+ if (visitor.hasOnlyIDCriteria()) {
+ try {
+ String Id = ((Comparison)criteria).getRightExpression().toString();
+ Id = Util.stripQutes(Id);
+ Ids = new String[] { Id };
+ } catch (ClassCastException cce) {
+ throw new RuntimeException(
+ "Error: The delete criteria is not a CompareCriteria");
+ }
+
+ } else if (visitor.hasCriteria()) {
+ String query = visitor.getQuery();
+ QueryResult results = getConnection().query(query, context.getBatchSize(), Boolean.FALSE);
+ if (null != results && results.getSize() > 0) {
+ ArrayList<String> idList = new ArrayList<String>(results
+ .getRecords().size());
+ for (int i = 0; i < results.getRecords().size(); i++) {
+ SObject sObject = results.getRecords().get(i);
+ idList.add(sObject.getId());
+ }
+ Ids = idList.toArray(new String[0]);
+ }
+ }
+ return Ids;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DataPayload.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DataPayload.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DataPayload.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DataPayload.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,65 @@
+/*
+ * 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.salesforce.execution;
+
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+
+/**
+ *
+ * A bucket to pass data to the Salesforce connection.
+ *
+ */
+public class DataPayload {
+
+ private String type;
+ @SuppressWarnings("unchecked")
+ private List<JAXBElement> messageElements;
+ private String id;
+
+ public void setType(String typeName) {
+ type = typeName;
+ }
+
+ @SuppressWarnings("unchecked")
+ public void setMessageElements(List<JAXBElement> elements) {
+ this.messageElements = elements;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<JAXBElement> getMessageElements() {
+ return messageElements;
+ }
+
+ public void setID(String id) {
+ this.id = id;
+ }
+
+ public String getID() {
+ return id;
+ }
+}
\ No newline at end of file
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeleteExecutionImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeleteExecutionImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeleteExecutionImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeleteExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,51 @@
+/*
+ * 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.salesforce.execution;
+
+import org.teiid.language.Command;
+import org.teiid.language.Delete;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.execution.visitors.DeleteVisitor;
+
+
+public class DeleteExecutionImpl extends AbstractUpdateExecution {
+
+
+ public DeleteExecutionImpl(Command command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context) {
+ super(command, salesforceConnection, metadata, context);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ DeleteVisitor dVisitor = new DeleteVisitor(getMetadata());
+ dVisitor.visitNode(command);
+ String[] Ids = getIDs(((Delete)command).getWhere(), dVisitor);
+ if(null != Ids && Ids.length > 0) {
+ result = getConnection().delete(Ids);
+ }
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedObject.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeletedObject.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedObject.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedObject.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,22 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.util.Calendar;
+
+public class DeletedObject {
+
+ String ID;
+ Calendar deletedDate;
+
+ public String getID() {
+ return ID;
+ }
+ public void setID(String id) {
+ ID = id;
+ }
+ public Calendar getDeletedDate() {
+ return deletedDate;
+ }
+ public void setDeletedDate(Calendar deletedDate) {
+ this.deletedDate = deletedDate;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedResult.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeletedResult.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedResult.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/DeletedResult.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,36 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.util.Calendar;
+import java.util.List;
+
+public class DeletedResult {
+
+ private Calendar latestDateCovered;
+ private Calendar earliestDateAvailable;
+ private List<DeletedObject> resultRecords;
+
+ public Calendar getLatestDateCovered() {
+ return latestDateCovered;
+ }
+
+ public void setLatestDateCovered(Calendar latestDateCovered) {
+ this.latestDateCovered = latestDateCovered;
+ }
+
+
+ public Calendar getEarliestDateAvailable() {
+ return earliestDateAvailable;
+ }
+
+ public void setEarliestDateAvailable(Calendar earliestDateAvailable) {
+ this.earliestDateAvailable = earliestDateAvailable;
+ }
+
+ public void setResultRecords(List<DeletedObject> resultRecords) {
+ this.resultRecords = resultRecords;
+ }
+
+ public List<DeletedObject> getResultRecords() {
+ return resultRecords;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetDeletedExecutionImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetDeletedExecutionImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetDeletedExecutionImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetDeletedExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,106 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.translator.ConnectorException;
+
+/**
+ *
+ * The structure of the getDeleted procedure is:
+ * Salesforce object type: String: IN param
+ * startDate: datatime: IN param
+ * enddate: datetime: IN param
+ * earliestDateAvailable: datetime: OUT param
+ * latestDateCovered: datetime: OUT param
+ * getUpdatedResult: resultset: OUT param
+ *
+ */
+
+public class GetDeletedExecutionImpl implements SalesforceProcedureExecution {
+
+ private static final int EARLIESTDATEAVAILABLE = 4;
+ private static final int RESULT = 5;
+
+ private ProcedureExecutionParent parent;
+
+ private DeletedResult deletedResult;
+ private int resultIndex = 0;
+ DatatypeFactory factory;
+
+ public GetDeletedExecutionImpl(
+ ProcedureExecutionParent procedureExecutionParent) throws ConnectorException {
+ this.parent = procedureExecutionParent;
+ try {
+ factory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new ConnectorException(e.getMessage());
+ }
+ }
+
+ @Override
+ public void cancel() {
+ // nothing to do here
+
+ }
+
+ @Override
+ public void close() {
+ // nothing to do here
+
+ }
+
+ @Override
+ public void execute(ProcedureExecutionParent procedureExecutionParent) throws ConnectorException {
+ Call command = parent.getCommand();
+ List<Argument> params = command.getArguments();
+
+ Argument object = params.get(OBJECT);
+ String objectName = (String) object.getArgumentValue().getValue();
+
+ Argument start = params.get(STARTDATE);
+ Timestamp startTime = (Timestamp) start.getArgumentValue().getValue();
+ GregorianCalendar tempCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
+ tempCalendar.setTime(startTime);
+ XMLGregorianCalendar startCalendar = factory.newXMLGregorianCalendar(tempCalendar);
+
+ Argument end = params.get(ENDDATE);
+ Timestamp endTime = (Timestamp) end.getArgumentValue().getValue();
+ tempCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
+ tempCalendar.setTime(endTime);
+ XMLGregorianCalendar endCalendar = factory.newXMLGregorianCalendar(tempCalendar);
+
+ deletedResult = parent.getConnection().getDeleted(objectName, startCalendar, endCalendar);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> getOutputParameterValues() {
+ List result = new ArrayList();
+ result.add(deletedResult.getLatestDateCovered());
+ result.add(deletedResult.getEarliestDateAvailable());
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List<?> next() {
+ List result = null;
+ if(deletedResult.getResultRecords() != null && resultIndex < deletedResult.getResultRecords().size()){
+ result = new ArrayList(2);
+ result.add(deletedResult.getResultRecords().get(resultIndex).getID());
+ result.add(deletedResult.getResultRecords().get(resultIndex).getDeletedDate());
+ resultIndex++;
+ }
+ return result;
+ }
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetUpdatedExecutionImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetUpdatedExecutionImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetUpdatedExecutionImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/GetUpdatedExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,99 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.GregorianCalendar;
+import java.util.List;
+
+import javax.xml.datatype.DatatypeConfigurationException;
+import javax.xml.datatype.DatatypeFactory;
+import javax.xml.datatype.XMLGregorianCalendar;
+
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.translator.ConnectorException;
+
+/**
+ *
+ * The structure of the getUpdated procedure is:
+ * Salesforce object type: String: IN param
+ * startDate: datatime: IN param
+ * enddate: datetime: IN param
+ * latestDateCovered: datetime: OUT param
+ * getUpdatedResult: resultset: OUT param
+ *
+ */
+
+public class GetUpdatedExecutionImpl implements SalesforceProcedureExecution {
+
+ private static final int RESULT = 4;
+
+ private ProcedureExecutionParent parent;
+ private UpdatedResult updatedResult;
+ private int idIndex = 0;
+ DatatypeFactory factory;
+
+ public GetUpdatedExecutionImpl(
+ ProcedureExecutionParent procedureExecutionParent) throws ConnectorException {
+ this.parent = procedureExecutionParent;
+ try {
+ factory = DatatypeFactory.newInstance();
+ } catch (DatatypeConfigurationException e) {
+ throw new ConnectorException(e.getMessage());
+ }
+ }
+
+ @Override
+ public void cancel() {
+ // nothing to do here
+ }
+
+ @Override
+ public void close() {
+ // nothing to do here
+ }
+
+ @Override
+ public void execute(ProcedureExecutionParent procedureExecutionParent) throws ConnectorException {
+ Call command = parent.getCommand();
+ List<Argument> params = command.getArguments();
+
+ Argument object = params.get(OBJECT);
+ String objectName = (String) object.getArgumentValue().getValue();
+
+ Argument start = params.get(STARTDATE);
+ Timestamp startTime = (Timestamp) start.getArgumentValue().getValue();
+ GregorianCalendar tempCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
+ tempCalendar.setTime(startTime);
+ XMLGregorianCalendar startCalendar = factory.newXMLGregorianCalendar(tempCalendar);
+
+ Argument end = params.get(ENDDATE);
+ Timestamp endTime = (Timestamp) end.getArgumentValue().getValue();
+ tempCalendar = (GregorianCalendar) GregorianCalendar.getInstance();
+ tempCalendar.setTime(endTime);
+ XMLGregorianCalendar endCalendar = factory.newXMLGregorianCalendar(tempCalendar);
+
+ updatedResult = parent.getConnection().getUpdated(objectName, startCalendar, endCalendar);
+ }
+
+ @Override
+ public List<Calendar> getOutputParameterValues() {
+ List<Calendar> result = new ArrayList<Calendar>(1);
+ result.add(updatedResult.getLatestDateCovered());
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List next() {
+ List result = null;
+ if(updatedResult.getIDs() != null && idIndex < updatedResult.getIDs().size()){
+ result = new ArrayList(1);
+ result.add(updatedResult.getIDs().get(idIndex));
+ idIndex++;
+ }
+ return result;
+ }
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/InsertExecutionImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/InsertExecutionImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/InsertExecutionImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/InsertExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,51 @@
+/*
+ * 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.salesforce.execution;
+
+
+import org.teiid.language.Command;
+import org.teiid.language.Insert;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.execution.visitors.InsertVisitor;
+
+
+public class InsertExecutionImpl extends AbstractUpdateExecution {
+
+ public InsertExecutionImpl(Command command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context) {
+ super(command, salesforceConnection, metadata, context);
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ InsertVisitor visitor = new InsertVisitor(getMetadata());
+ visitor.visit((Insert)command);
+ DataPayload data = new DataPayload();
+ data.setType(visitor.getTableName());
+ data.setMessageElements(visitor.getMessageElements());
+ result = getConnection().create(data);
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParent.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParent.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParent.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParent.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,18 @@
+package org.teiid.translator.salesforce.execution;
+
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.salesforce.SalesforceConnection;
+
+
+public interface ProcedureExecutionParent {
+
+ public Call getCommand();
+
+ public ExecutionContext getExecutionContext();
+
+ public RuntimeMetadata getMetadata();
+
+ public SalesforceConnection getConnection();
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParentImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/ProcedureExecutionParentImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,93 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.util.List;
+
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.salesforce.SalesforceConnection;
+
+
+public class ProcedureExecutionParentImpl implements ProcedureExecution, ProcedureExecutionParent {
+
+ private Call command;
+ private ExecutionContext executionContext;
+ private RuntimeMetadata metadata;
+ private SalesforceProcedureExecution execution;
+ private SalesforceConnection connection;
+
+ public ProcedureExecutionParentImpl(Call command,
+ SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext executionContext) {
+ this.setCommand(command);
+ this.setConnection(connection);
+ this.setMetadata(metadata);
+ this.setExecutionContext(executionContext);
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws ConnectorException {
+ return execution.getOutputParameterValues();
+ }
+
+ @Override
+ public List<?> next() throws ConnectorException, DataNotAvailableException {
+ return execution.next();
+ }
+
+ @Override
+ public void cancel() throws ConnectorException {
+ execution.cancel();
+ }
+
+ @Override
+ public void close() throws ConnectorException {
+ execution.close();
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ if(getCommand().getProcedureName().endsWith("getUpdated")) {
+ execution = new GetUpdatedExecutionImpl(this);
+ execution.execute(this);
+ }
+ else if(getCommand().getProcedureName().endsWith("getDeleted")) {
+ execution = new GetDeletedExecutionImpl(this);
+ execution.execute(this);
+ }
+ }
+
+ public void setCommand(Call command) {
+ this.command = command;
+ }
+
+ public Call getCommand() {
+ return command;
+ }
+
+ private void setConnection(SalesforceConnection connection) {
+ this.connection = connection;
+ }
+
+ public SalesforceConnection getConnection() {
+ return connection;
+ }
+
+ private void setExecutionContext(ExecutionContext executionContext) {
+ this.executionContext = executionContext;
+ }
+
+ public ExecutionContext getExecutionContext() {
+ return executionContext;
+ }
+
+ private void setMetadata(RuntimeMetadata metadata) {
+ this.metadata = metadata;
+ }
+
+ public RuntimeMetadata getMetadata() {
+ return metadata;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/QueryExecutionImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/QueryExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,365 @@
+/*
+ * 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.salesforce.execution;
+
+import java.sql.Timestamp;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.Join;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.language.TableReference;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.salesforce.Messages;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.Util;
+import org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor;
+import org.teiid.translator.salesforce.execution.visitors.SelectVisitor;
+import org.w3c.dom.Element;
+
+import com.sforce.soap.partner.QueryResult;
+import com.sforce.soap.partner.sobject.SObject;
+
+public class QueryExecutionImpl extends BasicExecution implements ResultSetExecution {
+
+ private SalesforceConnection connection;
+
+ private RuntimeMetadata metadata;
+
+ private ExecutionContext context;
+
+
+ private SelectVisitor visitor;
+
+ private QueryResult results;
+
+ private List<List<Object>> resultBatch;
+
+ // Identifying values
+ private String connectionIdentifier;
+
+ private String connectorIdentifier;
+
+ private String requestIdentifier;
+
+ private String partIdentifier;
+
+ private String logPreamble;
+
+ private QueryExpression query;
+
+ Map<String, Map<String,Integer>> sObjectToResponseField = new HashMap<String, Map<String,Integer>>();
+
+ private int topResultIndex = 0;
+
+ public QueryExecutionImpl(QueryExpression command, SalesforceConnection connection, RuntimeMetadata metadata, ExecutionContext context) {
+ this.connection = connection;
+ this.metadata = metadata;
+ this.context = context;
+ this.query = command;
+
+ connectionIdentifier = context.getConnectionIdentifier();
+ connectorIdentifier = context.getConnectorIdentifier();
+ requestIdentifier = context.getRequestIdentifier();
+ partIdentifier = context.getPartIdentifier();
+ }
+
+ public void cancel() throws ConnectorException {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, Messages.getString("SalesforceQueryExecutionImpl.cancel"));//$NON-NLS-1$
+ }
+
+ public void close() throws ConnectorException {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, Messages.getString("SalesforceQueryExecutionImpl.close")); //$NON-NLS-1$
+ }
+
+ @Override
+ public void execute() throws ConnectorException {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble() + "Incoming Query: " + query.toString()); //$NON-NLS-1$
+ List<TableReference> from = ((Select)query).getFrom();
+ String finalQuery;
+ if(from.get(0) instanceof Join) {
+ visitor = new JoinQueryVisitor(metadata);
+ visitor.visitNode(query);
+ finalQuery = visitor.getQuery().trim();
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble() + "Executing Query: " + finalQuery); //$NON-NLS-1$
+
+ results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
+ } else {
+ visitor = new SelectVisitor(metadata);
+ visitor.visitNode(query);
+ if(visitor.canRetrieve()) {
+ results = connection.retrieve(visitor.getRetrieveFieldList(),
+ visitor.getTableName(), visitor.getIdInCriteria());
+ } else {
+ finalQuery = visitor.getQuery().trim();
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, getLogPreamble() + "Executing Query: " + finalQuery); //$NON-NLS-1$
+ results = connection.query(finalQuery, this.context.getBatchSize(), visitor.getQueryAll());
+ }
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public List next() throws ConnectorException, DataNotAvailableException {
+ List<?> result;
+ if (query.getProjectedQuery().getDerivedColumns().get(0)
+ .getExpression() instanceof AggregateFunction) {
+ result = Arrays.asList(results.getSize());
+ results = null;
+
+ } else {
+ result = getRow(results);
+ }
+ return result;
+ }
+
+ private List<Object> getRow(QueryResult result) throws ConnectorException {
+ List<Object> row;
+ if(null == resultBatch) {
+ loadBatch();
+ }
+ if(resultBatch.size() == topResultIndex) {
+ row = null;
+ } else {
+ row = resultBatch.get(topResultIndex);
+ topResultIndex++;
+ if(resultBatch.size() == topResultIndex) {
+ if(!result.isDone()) {
+ loadBatch();
+ }
+ }
+
+ }
+ return row;
+ }
+
+ private void loadBatch() throws ConnectorException {
+ if(null != resultBatch) { // if we have an old batch, then we have to get new results
+ results = connection.queryMore(results.getQueryLocator(), context.getBatchSize());
+ }
+ resultBatch = new ArrayList<List<Object>>();
+
+ for(int resultIndex = 0; resultIndex < results.getSize(); resultIndex++) {
+ SObject sObject = results.getRecords().get(resultIndex);
+ List<Object[]> result = getObjectData(sObject);
+ for(Iterator<Object[]> i = result.iterator(); i.hasNext(); ) {
+ resultBatch.add(Arrays.asList(i.next()));
+ }
+ }
+ }
+
+ private List<Object[]> getObjectData(SObject sObject) throws ConnectorException {
+ List<Object> topFields = sObject.getAny();
+ logAndMapFields(sObject.getType(), topFields);
+ List<Object[]> result = new ArrayList<Object[]>();
+ for(int i = 0; i < topFields.size(); i++) {
+ Element element = (Element) topFields.get(i);
+ QName qName = new QName(element.getNamespaceURI(), element.getLocalName());
+ if(null != qName) {
+ String type = qName.getLocalPart();
+ if(type.equals("sObject")) { //$NON-NLS-1$
+ //SObject parent = (SObject)element.;
+ //result.addAll(getObjectData(parent));
+ } else if(type.equals("QueryResult")) { //$NON-NLS-1$
+ //QueryResult subResult = (QueryResult)element.getValue();
+ //for(int resultIndex = 0; resultIndex < subResult.getSize(); resultIndex++) {
+ // SObject subObject = subResult.getRecords().get(resultIndex);
+ // result.addAll(getObjectData(subObject));
+ //}
+ }
+ }
+ }
+ return extractDataFromFields(sObject, topFields, result);
+
+ }
+
+ private List<Object[]> extractDataFromFields(SObject sObject,
+ List<Object> fields, List<Object[]> result) throws ConnectorException {
+ Map<String,Integer> fieldToIndexMap = sObjectToResponseField.get(sObject.getType());
+ for (int j = 0; j < visitor.getSelectSymbolCount(); j++) {
+ Column element = visitor.getSelectSymbolMetadata(j);
+ AbstractMetadataRecord parent = element.getParent();
+ Table table;
+ if(parent instanceof Table) {
+ table = (Table)parent;
+ } else {
+ parent = parent.getParent();
+ if(parent instanceof Table) {
+ table = (Table)parent;
+ } else {
+ throw new ConnectorException("Could not resolve Table for column " + element.getName()); //$NON-NLS-1$
+ }
+ }
+ if(table.getNameInSource().equals(sObject.getType())) {
+ Integer index = fieldToIndexMap.get(element.getNameInSource());
+ // id gets dropped from the result if it is not the
+ // first field in the querystring. Add it back in.
+ if (null == index) {
+ if (element.getNameInSource().equalsIgnoreCase("id")) { //$NON-NLS-1$
+ setValueInColumn(j, sObject.getId(), result);
+ } else {
+ throw new ConnectorException("SalesforceQueryExecutionImpl.missing.field"+ element.getNameInSource()); //$NON-NLS-1$
+ }
+ } else {
+ Object cell;
+ cell = getCellDatum(element, (Element)fields.get(index));
+ setValueInColumn(j, cell, result);
+ }
+ }
+ }
+ return result;
+ }
+
+ private void setValueInColumn(int columnIndex, Object value, List<Object[]> result) {
+ if(result.isEmpty()) {
+ Object[] row = new Object[visitor.getSelectSymbolCount()];
+ result.add(row);
+ }
+ Iterator<Object[]> iter = result.iterator();
+ while (iter.hasNext()) {
+ Object[] row = iter.next();
+ row[columnIndex] = value;
+ }
+ }
+
+ /**
+ * Load the map of response field names to index.
+ * @param fields
+ * @throws ConnectorException
+ */
+ private void logAndMapFields(String sObjectName,
+ List<Object> fields) throws ConnectorException {
+ if (!sObjectToResponseField.containsKey(sObjectName)) {
+ logFields(sObjectName, fields);
+ Map<String, Integer> responseFieldToIndexMap;
+ responseFieldToIndexMap = new HashMap<String, Integer>();
+ for (int x = 0; x < fields.size(); x++) {
+ Element element = (Element) fields.get(x);
+ responseFieldToIndexMap.put(element.getLocalName(), x);
+ }
+ sObjectToResponseField.put(sObjectName, responseFieldToIndexMap);
+ }
+ }
+
+ private void logFields(String sObjectName, List<Object> fields) throws ConnectorException {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "SalesForce Object Name = " + sObjectName); //$NON-NLS-1$
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "FieldCount = " + fields.size()); //$NON-NLS-1$
+ for(int i = 0; i < fields.size(); i++) {
+ Element element;
+ element = (Element) fields.get(i);
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, "Field # " + i + " is " + element.getLocalName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ }
+
+ @SuppressWarnings("unchecked")
+ private Object getCellDatum(Column element, Element elem) throws ConnectorException {
+ if(!element.getNameInSource().equals(elem.getLocalName())) {
+ throw new ConnectorException("SalesforceQueryExecutionImpl.column.mismatch1" + element.getNameInSource() + "SalesforceQueryExecutionImpl.column.mismatch2" + elem.getLocalName()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ String value = elem.getTextContent();
+ Object result = null;
+ Class type = element.getJavaType();
+
+ if(type.equals(String.class)) {
+ result = value;
+ }
+ else if (type.equals(Boolean.class)) {
+ result = Boolean.valueOf(value);
+ } else if (type.equals(Double.class)) {
+ if (null != value) {
+ if(value.isEmpty()) {
+ result = null;
+ } else {
+ result = Double.valueOf(value);
+ }
+ }
+ } else if (type.equals(Integer.class)) {
+ if (null != value) {
+ if(value.isEmpty()) {
+ result = null;
+ } else {
+ result = Integer.valueOf(value);
+ }
+ }
+ } else if (type.equals(java.sql.Date.class)) {
+ if (null != value) {
+ if(value.isEmpty()) {
+ result = null;
+ } else {
+ result = java.sql.Date.valueOf(value);
+ }
+ }
+ } else if (type.equals(java.sql.Timestamp.class)) {
+ if (null != value) {
+ if(value.isEmpty()) {
+ result = null;
+ } else try {
+ Date date = Util.getSalesforceDateTimeFormat().parse(value);
+ result = new Timestamp(date.getTime());
+ } catch (ParseException e) {
+ throw new ConnectorException(e, "SalesforceQueryExecutionImpl.datatime.parse" + value); //$NON-NLS-1$
+ }
+ }
+ } else {
+ result = value;
+ }
+ return result;
+ }
+
+
+ private String getLogPreamble() {
+ if (null == logPreamble) {
+ StringBuffer preamble = new StringBuffer();
+ preamble.append(connectorIdentifier);
+ preamble.append('.');
+ preamble.append(connectionIdentifier);
+ preamble.append('.');
+ preamble.append(requestIdentifier);
+ preamble.append('.');
+ preamble.append(partIdentifier);
+ preamble.append(": "); //$NON-NLS-1$
+ logPreamble = preamble.toString();
+ }
+ return logPreamble;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/SalesforceProcedureExecution.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/SalesforceProcedureExecution.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/SalesforceProcedureExecution.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/SalesforceProcedureExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,24 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.util.List;
+
+import org.teiid.translator.ConnectorException;
+
+public interface SalesforceProcedureExecution {
+
+ static final int OBJECT = 0;
+ static final int STARTDATE = 1;
+ static final int ENDDATE = 2;
+ static final int LATESTDATECOVERED = 3;
+
+ List<?> getOutputParameterValues();
+
+ List<?> next();
+
+ void cancel();
+
+ void close();
+
+ void execute(ProcedureExecutionParent procedureExecutionParent) throws ConnectorException;
+
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdateExecutionImpl.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/UpdateExecutionImpl.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdateExecutionImpl.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdateExecutionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,84 @@
+/*
+ * 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.salesforce.execution;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.bind.JAXBElement;
+import javax.xml.namespace.QName;
+
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
+import org.teiid.language.SetClause;
+import org.teiid.language.Update;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.salesforce.SalesforceConnection;
+import org.teiid.translator.salesforce.Util;
+import org.teiid.translator.salesforce.execution.visitors.UpdateVisitor;
+
+
+public class UpdateExecutionImpl extends AbstractUpdateExecution {
+
+ @SuppressWarnings("unchecked")
+ private static final Class stringClazz = new String().getClass();
+
+ public UpdateExecutionImpl(Command command,
+ SalesforceConnection salesforceConnection,
+ RuntimeMetadata metadata, ExecutionContext context) {
+ super(command, salesforceConnection, metadata, context);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public void execute() throws ConnectorException {
+ UpdateVisitor visitor = new UpdateVisitor(getMetadata());
+ visitor.visit((Update)command);
+ String[] Ids = getIDs(((Update)command).getWhere(), visitor);
+
+ if (null != Ids && Ids.length > 0) {
+ List<JAXBElement> elements = new ArrayList<JAXBElement>();
+ for (SetClause clause : ((Update)command).getChanges()) {
+ ColumnReference element = clause.getSymbol();
+ Column column = element.getMetadataObject();
+ String val = ((Literal) clause.getValue()).toString();
+ JAXBElement messageElem = new JAXBElement(new QName(column.getNameInSource()), stringClazz, Util.stripQutes(val));
+ elements.add(messageElem);
+ }
+
+ List<DataPayload> updateDataList = new ArrayList<DataPayload>();
+ for (int i = 0; i < Ids.length; i++) {
+ DataPayload data = new DataPayload();
+ data.setType(visitor.getTableName());
+ data.setID(Ids[i]);
+ data.setMessageElements(elements);
+ updateDataList.add(data);
+ }
+
+ result = getConnection().update(updateDataList);
+ }
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdatedResult.java (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/UpdatedResult.java)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdatedResult.java (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/UpdatedResult.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,26 @@
+package org.teiid.translator.salesforce.execution;
+
+import java.util.Calendar;
+import java.util.List;
+
+public class UpdatedResult {
+
+ private Calendar latestDateCovered;
+ private List<String> IDs;
+
+ public Calendar getLatestDateCovered() {
+ return latestDateCovered;
+ }
+
+ public void setLatestDateCovered(Calendar latestDateCovered) {
+ this.latestDateCovered = latestDateCovered;
+ }
+
+ public List<String> getIDs() {
+ return IDs;
+ }
+
+ public void setIDs(List<String> list) {
+ this.IDs = list;
+ }
+}
Copied: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors (from rev 2119, trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors)
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/CriteriaVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/CriteriaVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/CriteriaVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import java.sql.Timestamp;
import java.util.ArrayList;
@@ -44,9 +44,9 @@
import org.teiid.metadata.Column;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
-import org.teiid.resource.adapter.salesforce.Messages;
-import org.teiid.resource.adapter.salesforce.Util;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.salesforce.Messages;
+import org.teiid.translator.salesforce.Util;
/**
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/DeleteVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/DeleteVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/DeleteVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import java.util.Iterator;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/ICriteriaVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/ICriteriaVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/ICriteriaVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import org.teiid.translator.ConnectorException;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/IQueryProvidingVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/IQueryProvidingVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/IQueryProvidingVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import org.teiid.translator.ConnectorException;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/InsertVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/InsertVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/InsertVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/JoinQueryVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/JoinQueryVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/JoinQueryVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -1,4 +1,4 @@
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import org.teiid.language.AggregateFunction;
import org.teiid.language.ColumnReference;
@@ -11,8 +11,8 @@
import org.teiid.metadata.Column;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
-import org.teiid.resource.adapter.salesforce.Util;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.salesforce.Util;
/**
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/SelectVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/SelectVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import java.util.ArrayList;
import java.util.HashMap;
@@ -38,10 +38,10 @@
import org.teiid.metadata.Column;
import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.Table;
-import org.teiid.resource.adapter.salesforce.Constants;
-import org.teiid.resource.adapter.salesforce.Messages;
-import org.teiid.resource.adapter.salesforce.Util;
import org.teiid.translator.ConnectorException;
+import org.teiid.translator.salesforce.Constants;
+import org.teiid.translator.salesforce.Messages;
+import org.teiid.translator.salesforce.Util;
public class SelectVisitor extends CriteriaVisitor implements IQueryProvidingVisitor {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/UpdateVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/UpdateVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/translator/salesforce/execution/visitors/UpdateVisitor.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import org.teiid.language.Update;
import org.teiid.metadata.RuntimeMetadata;
Copied: trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties (from rev 2119, trunk/connectors/translator-salesforce/src/main/resources/org/teiid/resource/adapter/salesforce/i18n.properties)
===================================================================
--- trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties (rev 0)
+++ trunk/connectors/translator-salesforce/src/main/resources/org/teiid/translator/salesforce/i18n.properties 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,48 @@
+#
+# 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.
+#
+SalesforceConnection.update.not.supported=Update Execution is not supported.
+SalesforceConnection.procedures.not.supported=Procedure Execution is not supported.
+SalesforceConnection.invalid.execution.mode=Execution mode not supported.
+SalesforceConnection.bad.IN.value=Exception parsing the IN Criteria Limit value.
+SalesforceConnection.bad.ping.value=Exception parsing the Data Source Test Connect Interval value.
+
+SalesforceSourceConnectionFactory.Invalid.username.password.pair=Invalid credential configuration. The Username and Password binding properties must both be empty or both have values.
+
+SalesforceQueryExecutionImpl.cancel=SynchQueryExecution.cancel() called
+SalesforceQueryExecutionImpl.close=SynchQueryExecution.close() called
+SalesforceQueryExecutionImpl.missing.field=No field in result for SelectSymbol
+SalesforceQueryExecutionImpl.column.mismatch1=Error: Column mismatch, expected
+SalesforceQueryExecutionImpl.column.mismatch2= received
+SalesforceQueryExecutionImpl.datatime.parse=Error parsing date_time: Value =
+SalesforceQueryExecutionImpl.reduced.batch.size=Reduced batch size to 2000
+
+SelectVisitor.distinct.not.supported=Distinct is not supported by the connector.
+
+CriteriaVisitor.query.not.supported= does not support the query statement.
+CriteriaVisitor.invalid.arg.count=The includes and excludes functions require two parameters.
+CriteriaVisitor.function.not.column.arg=The first parameter of the includes and excludes functions must be a column name.
+CriteriaVisitor.function.not.literal.arg=The second parameter of the includes and excludes functions must be a literal value.
+CriteriaVisitor.IN.not.supported.on.col=The IN criteria is not supported on multi-select columns:
+CriteriaVisitor.LIKE.not.supported.on.Id=LIKE criteria are not allowed on columns of native type Id
+CriteriaVisitor.LIKE.not.supported.on.multiselect=LIKE criteria are not allowed on columns of native type Multi-Select Picklist
+
+Util.query.exceeds.max.length=Queries cannot exceed 10,000 characters
\ No newline at end of file
Copied: trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors (from rev 2119, trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors)
Modified: trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.salesforce.execution.visitors;
+package org.teiid.translator.salesforce.execution.visitors;
import static org.junit.Assert.*;
@@ -38,8 +38,8 @@
import org.teiid.metadata.Column.SearchType;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.adapter.salesforce.execution.visitors.JoinQueryVisitor;
-import org.teiid.resource.adapter.salesforce.execution.visitors.SelectVisitor;
+import org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor;
+import org.teiid.translator.salesforce.execution.visitors.SelectVisitor;
import com.metamatrix.cdk.api.TranslationUtility;
Copied: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text (from rev 2119, trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text)
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/StringToDateTranslator.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/StringToDateTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/StringToDateTranslator.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.text.ParseException;
import java.text.SimpleDateFormat;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextCapabilities.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import org.teiid.translator.BasicConnectorCapabilities;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextConnectionImpl.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextConnectionImpl.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.io.BufferedReader;
import java.io.File;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextDescriptorPropertyNames.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextDescriptorPropertyNames.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextDescriptorPropertyNames.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
/**
* Property names used in the text descriptor file.
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextExecutionFactory.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.io.BufferedReader;
import java.io.IOException;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextPlugin.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextPlugin.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextPlugin.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.util.ResourceBundle;
@@ -28,7 +28,7 @@
public class TextPlugin {
- public static final String PLUGIN_ID = "org.teiid.resource.adapter.text" ; //$NON-NLS-1$
+ public static final String PLUGIN_ID = "org.teiid.translator.text" ; //$NON-NLS-1$
public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/translator/text/TextSynchExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.sql.Date;
import java.sql.Time;
Copied: trunk/connectors/translator-text/src/main/resources/org/teiid/translator/text/i18n.properties (from rev 2119, trunk/connectors/translator-text/src/main/resources/org/teiid/resource/adapter/text/i18n.properties)
===================================================================
--- trunk/connectors/translator-text/src/main/resources/org/teiid/translator/text/i18n.properties (rev 0)
+++ trunk/connectors/translator-text/src/main/resources/org/teiid/translator/text/i18n.properties 2010-05-12 22:19:30 UTC (rev 2121)
@@ -0,0 +1,71 @@
+#
+# 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.
+#
+
+StringToDateTranslator.Attempts_to_parse_String__{0}_to_a_java.util.Date_failed_for_the_following_reasons___1=Attempts to parse String: {0} to a java.util.Date failed for the following reasons:
+StringToDateTranslator.There_is_no_format_Strings_found_in_this_formatter_object._n_2=There is no format Strings found in this formatter object.\n
+StringToDateTranslator.Parse_Attempt__{0}_using_format__{1}_failed_for_the_following_reason__{2}_4=Parse Attempt: {0} using format: {1} failed for the following reason: {2}
+StringToDateTranslator.Failed_to_convert_String__{0}_to_a_Date_using_one_of_the_following_format_Strings_that_are_specified_in_the_properties_for_this_Connector__{1}_1=Failed to convert String: {0} to a Date using one of the following format Strings that are specified in the properties for this Connector: {1}
+TextConnection.Descriptor_file_name_is_not_specified._2=Descriptor file name is not specified.
+TextConnection.Error_trying_to_establish_connection_5=Error trying to establish connection
+TextConnection.Error_while_reading_text_file__{0}_1=Error while reading text file: {0}
+TextConnection.Text_file_name_is_not_specified_for_the_group___{0}_2=Text file name is not specified for the group : {0}
+TextConnection.The_value_for_the_property_should_be_an_integer._{0}_3=The value for the property should be an integer. {0}
+TextConnection.The_property_{0}_for_the_group_{1}_is_invalid._4=The property {0} for the group {1} is invalid.
+TextConnection.Error_parsing_property_string_{0}_5=Error parsing property string {0}
+TextConnection.Error_parsing_property_string_{0}__{1}_6=Error parsing property string {0}: {1}
+TextConnection.fileDoesNotExistForGroup=Data file not found at this location: {0}, for group {1}
+TextConnection.Data_file_{0}_found_but_does_not_have_Read_permissions_8=Data file {0} found but does not have Read permissions
+TextConnection.Descriptor_file_does_not_exist_at_this_location__{0}_9=Descriptor file does not exist at this location: {0}
+TextConnection.Descriptor_file_{0}_found_but_does_not_have_Read_permissions_10=Descriptor file {0} found but does not have Read permissions
+TextConnection.Couldn__t_find_the_file_of_name_{0}_11=Couldn''t find the file of name {0}
+TextConnection.Descriptor_file_does_not_exist_at_this_location__{0}_12=Descriptor file does not exist at this location: {0}
+TextSynchExecution.Request_is_null=The Request is null.
+TextSynchExecution.No_element_in_Select=There are no element in the Select clause.
+TextSynchExecution.Not_of_type_Map=Response submitted for the request is not of type Map as expected.
+TextSynchExecution.Error_reading_text_file=Error while reading text file: {0}: {1}
+TextSynchExecution.Error_translating_request=Error translating request: Command not supported. {0}
+TextSynchExecution.Cannot_be_translated_by_the_TextTranslator.=''{0}'' cannot be translated by the TextTranslator. {1}
+TextSynchExecution.Error_obtain_properties_for_group=Error trying to obtain connector metadata properties for {0}. Group properties are not specified in the descriptor file.
+TextSynchExecution.Unable_get_Reader=Unable to get the Reader for group {0}, exception: {1}
+TextSynchExecution.Unable_get_Reader_for_group=Unable to get the Reader for group {0}. Source file undefined - check log for errors.
+TextSynchExecution.Cant_read_column_number=Cannot read column number from name in source for element. {0}
+TextSynchExecution.Invalid_column_number=Column {0} not found for element {1} and no header row is defined. If a header row cannot be defined, element {1} must define a numeric column number for its name in source property.
+TextSynchExecution.Column_not_found_in_header_row=Column {0} not found for element {1}. Verify column name \"{0}\" is defined in the header row of the text file and that the header row number is correctly defined in the descriptor file.
+TextSynchExecution.Can_read_column_number=Cannot read column number from name in source for element. {0}
+TextSynchExecution.Text_has_no_ending_qualifier=Text file has no ending qualifier in column {0}: [{1}]
+TextSynchExecution.Text_file_must_have_delimiter=Text file must have delimiter after ending qualifier in column {0}: [{1}]
+TextSynchExecution.Column_length_must_be_positive=Error trying to query the text file, column length must be a positive value.
+TextSynchExecution.Got_unknown_type_of_criteria=Got unknown type of criteria: {0}
+TextSynchExecution.Functions_not_supported._14=The criteria: {0} could not be applied to the results. Functions not supported.
+TextSynchExecution.Values_of_different_types=The following criteria cannot be executed because values are of different types: {0}
+TextSynchExecution.Unknown_compare_criteria_type=Unknown compare criteria type: {0}
+TextSynchExecution.Joins_and_Functions_not_supported._18=The criteria: {0} could not be translated by the TextConnectorTranslator. Joins and Functions not supported.
+TextSynchExecution.The_expression_cannot_be_used_as_criteria=The expression: {0} cannot be used as a criteria value in a query against a text file.
+TextSynchExecution.Functions_in_criteria_not_supported._20=The criteria: {0} cannot be translated by the TextConnectorTranslator. Functions in criteria not supported.
+TextSynchExecution.Functions_in_set_criteria_not_supported._21=The criteria: {0} cannot be translated by the TextConnectorTranslator. Functions in set criteria not supported.
+TextSynchExecution.Unable_translate_String_to_Date=Unable to translate String to Date using the format specified. {0}
+TextSynchExecution.Unable_get_Tranform=Unable to get the Tranform from String to {0}
+TextSynchExecution.Unable_to_transform_value=Unable to transform value {0} to Object of type {1}
+TextSynchExecution.Input_column_cnt_incorrect=Expected input file to have {0} columns based on model, but found {1}. This could be caused by misplaced quotes, causing multiple columns to be treated as one.
+TextSynchExecution.Text_has_no_determined_ending_qualifier=Text file has no matching ending qualifier in row {0}
+TextSynchExecution.Property_contains_an_invalid_value_Using_value=Property {0} contains an invalid value of {1}. Using value {2}.
+TextConnector.column_mismatch=Specified types and columns do not match for text table {0}
\ No newline at end of file
Copied: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text (from rev 2119, trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text)
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestMultiFileTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestMultiFileTextSynchExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.util.ArrayList;
import java.util.HashSet;
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestRowHeaderTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestRowHeaderTextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestRowHeaderTextSynchExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import junit.framework.TestCase;
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextConnection.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextConnection.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,8 +20,10 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
+import org.teiid.translator.text.TextExecutionFactory;
+
import junit.framework.TestCase;
/**
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextConnector.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextConnector.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import static org.junit.Assert.*;
@@ -34,6 +34,7 @@
import org.teiid.metadata.MetadataFactory;
import org.teiid.metadata.Table;
import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.text.TextExecutionFactory;
/**
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/TestTextSynchExecution.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/Util.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/translator/text/Util.java 2010-05-12 22:19:30 UTC (rev 2121)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.text;
+package org.teiid.translator.text;
import java.io.File;
import java.util.List;
@@ -44,6 +44,7 @@
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.FileConnection;
+import org.teiid.translator.text.TextExecutionFactory;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
15 years, 11 months
teiid SVN: r2120 - trunk/runtime/src/test/java/org/teiid/deployers.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2010-05-12 15:17:10 -0400 (Wed, 12 May 2010)
New Revision: 2120
Modified:
trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java
Log:
TEIID-918: fixing a compilation issue
Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java 2010-05-12 15:27:10 UTC (rev 2119)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestTranslatorDeployer.java 2010-05-12 19:17:10 UTC (rev 2120)
@@ -21,11 +21,12 @@
*/
package org.teiid.deployers;
+import static org.junit.Assert.assertEquals;
+
import org.junit.Test;
import org.teiid.adminapi.impl.TranslatorMetaData;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.TranslatorProperty;
-import static org.junit.Assert.*;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.TranslatorProperty;
@SuppressWarnings("nls")
public class TestTranslatorDeployer {
15 years, 11 months
teiid SVN: r2119 - in trunk: connector-api/src/main/java/org/teiid and 105 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-05-12 11:27:10 -0400 (Wed, 12 May 2010)
New Revision: 2119
Added:
trunk/connector-api/src/main/java/org/teiid/language/
trunk/connector-api/src/main/java/org/teiid/language/AggregateFunction.java
trunk/connector-api/src/main/java/org/teiid/language/AndOr.java
trunk/connector-api/src/main/java/org/teiid/language/Argument.java
trunk/connector-api/src/main/java/org/teiid/language/BaseInCondition.java
trunk/connector-api/src/main/java/org/teiid/language/BaseLanguageObject.java
trunk/connector-api/src/main/java/org/teiid/language/BatchedUpdates.java
trunk/connector-api/src/main/java/org/teiid/language/Call.java
trunk/connector-api/src/main/java/org/teiid/language/ColumnReference.java
trunk/connector-api/src/main/java/org/teiid/language/Command.java
trunk/connector-api/src/main/java/org/teiid/language/Comparison.java
trunk/connector-api/src/main/java/org/teiid/language/Condition.java
trunk/connector-api/src/main/java/org/teiid/language/Delete.java
trunk/connector-api/src/main/java/org/teiid/language/DerivedColumn.java
trunk/connector-api/src/main/java/org/teiid/language/DerivedTable.java
trunk/connector-api/src/main/java/org/teiid/language/Exists.java
trunk/connector-api/src/main/java/org/teiid/language/Expression.java
trunk/connector-api/src/main/java/org/teiid/language/ExpressionValueSource.java
trunk/connector-api/src/main/java/org/teiid/language/Function.java
trunk/connector-api/src/main/java/org/teiid/language/GroupBy.java
trunk/connector-api/src/main/java/org/teiid/language/In.java
trunk/connector-api/src/main/java/org/teiid/language/Insert.java
trunk/connector-api/src/main/java/org/teiid/language/InsertValueSource.java
trunk/connector-api/src/main/java/org/teiid/language/IsNull.java
trunk/connector-api/src/main/java/org/teiid/language/Join.java
trunk/connector-api/src/main/java/org/teiid/language/LanguageFactory.java
trunk/connector-api/src/main/java/org/teiid/language/LanguageObject.java
trunk/connector-api/src/main/java/org/teiid/language/LanguageUtil.java
trunk/connector-api/src/main/java/org/teiid/language/Like.java
trunk/connector-api/src/main/java/org/teiid/language/Limit.java
trunk/connector-api/src/main/java/org/teiid/language/Literal.java
trunk/connector-api/src/main/java/org/teiid/language/MetadataReference.java
trunk/connector-api/src/main/java/org/teiid/language/NamedTable.java
trunk/connector-api/src/main/java/org/teiid/language/Not.java
trunk/connector-api/src/main/java/org/teiid/language/OrderBy.java
trunk/connector-api/src/main/java/org/teiid/language/Predicate.java
trunk/connector-api/src/main/java/org/teiid/language/QueryExpression.java
trunk/connector-api/src/main/java/org/teiid/language/SQLReservedWords.java
trunk/connector-api/src/main/java/org/teiid/language/ScalarSubquery.java
trunk/connector-api/src/main/java/org/teiid/language/SearchedCase.java
trunk/connector-api/src/main/java/org/teiid/language/SearchedWhenClause.java
trunk/connector-api/src/main/java/org/teiid/language/Select.java
trunk/connector-api/src/main/java/org/teiid/language/SetClause.java
trunk/connector-api/src/main/java/org/teiid/language/SetQuery.java
trunk/connector-api/src/main/java/org/teiid/language/SortSpecification.java
trunk/connector-api/src/main/java/org/teiid/language/SubqueryComparison.java
trunk/connector-api/src/main/java/org/teiid/language/SubqueryContainer.java
trunk/connector-api/src/main/java/org/teiid/language/SubqueryIn.java
trunk/connector-api/src/main/java/org/teiid/language/TableReference.java
trunk/connector-api/src/main/java/org/teiid/language/Update.java
trunk/connector-api/src/main/java/org/teiid/language/visitor/
trunk/connector-api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java
trunk/connector-api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java
trunk/connector-api/src/main/java/org/teiid/metadata/
trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java
trunk/connector-api/src/main/java/org/teiid/translator/
trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java
trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java
trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java
trunk/connector-api/src/main/java/org/teiid/translator/ConnectorException.java
trunk/connector-api/src/main/java/org/teiid/translator/FileConnection.java
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/
trunk/connectors/connector-ldap/src/main/resources/org/teiid/resource/adapter/
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/
trunk/connectors/translator-ldap/src/main/resources/org/teiid/translator/
Removed:
trunk/common-core/src/main/java/com/
trunk/connector-api/src/main/java/org/teiid/connector/language/
trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/
trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/
trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/
trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java
trunk/connector-api/src/main/java/org/teiid/resource/ConnectorException.java
trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicConnectorCapabilities.java
trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecution.java
trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java
trunk/connector-api/src/main/java/org/teiid/resource/adapter/FileConnection.java
trunk/connector-api/src/main/java/org/teiid/resource/cci/
trunk/connectors/connector-ldap/src/main/java/com/
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/
trunk/connectors/connector-ldap/src/main/resources/org/teiid/resource/cci/
trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/
trunk/connectors/translator-ldap/src/main/resources/org/teiid/resource/
Modified:
trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java
trunk/connector-api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java
trunk/connector-api/src/main/java/org/teiid/language/visitor/DelegatingHierarchyVisitor.java
trunk/connector-api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java
trunk/connector-api/src/main/java/org/teiid/language/visitor/LanguageObjectVisitor.java
trunk/connector-api/src/main/java/org/teiid/logging/CommandLogMessage.java
trunk/connector-api/src/main/java/org/teiid/metadata/BaseColumn.java
trunk/connector-api/src/main/java/org/teiid/metadata/Column.java
trunk/connector-api/src/main/java/org/teiid/metadata/ColumnSet.java
trunk/connector-api/src/main/java/org/teiid/metadata/Datatype.java
trunk/connector-api/src/main/java/org/teiid/metadata/ForeignKey.java
trunk/connector-api/src/main/java/org/teiid/metadata/KeyRecord.java
trunk/connector-api/src/main/java/org/teiid/metadata/MetadataStore.java
trunk/connector-api/src/main/java/org/teiid/metadata/Procedure.java
trunk/connector-api/src/main/java/org/teiid/metadata/ProcedureParameter.java
trunk/connector-api/src/main/java/org/teiid/metadata/RuntimeMetadata.java
trunk/connector-api/src/main/java/org/teiid/metadata/Schema.java
trunk/connector-api/src/main/java/org/teiid/metadata/Table.java
trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java
trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java
trunk/connector-api/src/main/java/org/teiid/translator/CacheScope.java
trunk/connector-api/src/main/java/org/teiid/translator/ConnectorCapabilities.java
trunk/connector-api/src/main/java/org/teiid/translator/DataNotAvailableException.java
trunk/connector-api/src/main/java/org/teiid/translator/Execution.java
trunk/connector-api/src/main/java/org/teiid/translator/ExecutionContext.java
trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java
trunk/connector-api/src/main/java/org/teiid/translator/MetadataProvider.java
trunk/connector-api/src/main/java/org/teiid/translator/ProcedureExecution.java
trunk/connector-api/src/main/java/org/teiid/translator/ResultSetExecution.java
trunk/connector-api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
trunk/connector-api/src/main/java/org/teiid/translator/TranslatorProperty.java
trunk/connector-api/src/main/java/org/teiid/translator/TypeFacility.java
trunk/connector-api/src/main/java/org/teiid/translator/UpdateExecution.java
trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPConnectionImpl.java
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPManagedConnectionFactory.java
trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java
trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/ldap/TestLDAPConnection.java
trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesforceConnectionImpl.java
trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/TickerCollectorVisitor.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooCapabilities.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecution.java
trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecutionFactory.java
trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo/TestYahooTranslation.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCBaseExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionException.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCQueryExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCUpdateExecution.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/SimpleCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/AliasModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ConvertModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/EscapeSyntaxModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ExtractFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ModFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/AddDiffModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/BitFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/ConcatFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/DayWeekQuarterFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/LeftOrRightFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/Log10FunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/MonthOrDayNameFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/LocateFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SubstringFunctionModifier.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeMetadataFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCProcedureExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCUpdateExecution.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLog10FunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
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/TestSubstringFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorConstants.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java
trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackCapabilities.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecution.java
trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecutionFactory.java
trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback/TestLoopbackExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/NameUtil.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceExecutionFactory.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceCapabilities.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnection.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Util.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/AbstractUpdateExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeleteExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetDeletedExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetUpdatedExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/InsertExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParent.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParentImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/QueryExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/SalesforceProcedureExecution.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/UpdateExecutionImpl.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/CriteriaVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/DeleteVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/ICriteriaVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/IQueryProvidingVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/InsertVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/JoinQueryVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/SelectVisitor.java
trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/UpdateVisitor.java
trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java
trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextCapabilities.java
trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java
trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextExecutionFactory.java
trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestRowHeaderTextSynchExecution.java
trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java
trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TranslatorRepository.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java
trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java
trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java
trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java
trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/TranslatorPropertyUtil.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfo.java
trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java
trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
trunk/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-918 updating connector language/metadata package names and changing ldap translator/resource adapter package names
Modified: trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/connector/DataPlugin.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,7 +28,7 @@
public class DataPlugin { // extends Plugin {
- public static final String PLUGIN_ID = "org.teiid.connector" ; //$NON-NLS-1$
+ public static final String PLUGIN_ID = DataPlugin.class.getPackage().getName();
public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
Copied: trunk/connector-api/src/main/java/org/teiid/language/AggregateFunction.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/AggregateFunction.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/AggregateFunction.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/AggregateFunction.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,131 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents an aggregate function.
+ */
+public class AggregateFunction extends BaseLanguageObject implements Expression {
+
+ public static final String COUNT = "COUNT"; //$NON-NLS-1$
+ public static final String AVG = "AVG"; //$NON-NLS-1$
+ public static final String SUM = "SUM"; //$NON-NLS-1$
+ public static final String MIN = "MIN"; //$NON-NLS-1$
+ public static final String MAX = "MAX"; //$NON-NLS-1$
+
+ private Expression expression;
+ private String aggName;
+ private boolean isDistinct;
+ private Class<?> type;
+
+ public AggregateFunction(String aggName, boolean isDistinct, Expression exp, Class<?> type) {
+ this.expression = exp;
+ this.aggName = aggName;
+ this.isDistinct = isDistinct;
+ this.type = type;
+ }
+
+ /**
+ * Get the name of the aggregate function. This will be one of the constants defined
+ * in this class.
+ * @see #COUNT
+ * @see #AVG
+ * @see #SUM
+ * @see #MIN
+ * @see #MAX
+ */
+ public String getName() {
+ return this.aggName;
+ }
+
+ /**
+ * Determine whether this function was executed with DISTINCT. Executing
+ * with DISTINCT will remove all duplicate values in a group when evaluating
+ * the aggregate function.
+ * @return True if DISTINCT mode is used
+ */
+ public boolean isDistinct() {
+ return this.isDistinct;
+ }
+
+ /**
+ * Get the expression within the aggregate function. The expression will be
+ * null for the special case COUNT(*). This is the only case where the
+ * expression will be null
+ * @return The expression or null for COUNT(*)
+ */
+ public Expression getExpression() {
+ return this.expression;
+ }
+
+ /**
+ * @see org.teiid.language.LanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
+ */
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set the name of the aggregate function. This will be one of the constants defined
+ * in this class.
+ * @param name New aggregate function name
+ * @see #COUNT
+ * @see #AVG
+ * @see #SUM
+ * @see #MIN
+ * @see #MAX
+ */
+ public void setName(String name) {
+ this.aggName = name;
+ }
+
+ /**
+ * Set whether this function was executed with DISTINCT. Executing
+ * with DISTINCT will remove all duplicate values in a group when evaluating
+ * the aggregate function.
+ * @param isDistinct True if DISTINCT mode should be used
+ */
+ public void setDistinct(boolean isDistinct) {
+ this.isDistinct = isDistinct;
+ }
+
+ /**
+ * Set the expression within the aggregate function. The expression will be
+ * null for the special case COUNT(*).
+ * @param expression The new expression
+ */
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/AndOr.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/AndOr.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/AndOr.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/AndOr.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,83 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a logical criteria such as AND, OR, or NOT.
+ */
+public class AndOr extends Condition {
+
+ public enum Operator {
+ AND,
+ OR,
+ }
+
+ private Condition leftCondition;
+ private Condition rightCondition;
+ private Operator operator = Operator.AND;
+
+ public AndOr(Condition left, Condition right, Operator operator) {
+ this.leftCondition = left;
+ this.rightCondition = right;
+ this.operator = operator;
+ }
+
+ /**
+ * Get operator used to connect these criteria.
+ * @return Operator constant
+ */
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set operator used to connect these criteria.
+ * @param operator Operator constant
+ */
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ public Condition getLeftCondition() {
+ return leftCondition;
+ }
+
+ public Condition getRightCondition() {
+ return rightCondition;
+ }
+
+ public void setLeftCondition(Condition left) {
+ this.leftCondition = left;
+ }
+
+ public void setRightCondition(Condition right) {
+ this.rightCondition = right;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Argument.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Argument.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Argument.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Argument.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,89 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+import org.teiid.metadata.ProcedureParameter;
+
+public class Argument extends BaseLanguageObject implements MetadataReference<ProcedureParameter> {
+
+ public enum Direction {
+ IN,
+ OUT,
+ INOUT,
+ }
+
+ private Direction direction;
+ private Literal argumentValue;
+ private ProcedureParameter metadataObject;
+ private Class<?> type;
+
+ public Argument(Direction direction, Literal value, Class<?> type, ProcedureParameter metadataObject) {
+ this.direction = direction;
+ this.argumentValue = value;
+ this.metadataObject = metadataObject;
+ this.type = type;
+ }
+
+ public Direction getDirection() {
+ return this.direction;
+ }
+
+ /**
+ * Get the argument value
+ * @return the value or null if this is an out parameter
+ */
+ public Literal getArgumentValue() {
+ return this.argumentValue;
+ }
+
+ public Class<?> getType() {
+ return type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setDirection(Direction direction) {
+ this.direction = direction;
+ }
+
+ public void setArgumentValue(Literal value) {
+ this.argumentValue = value;
+ }
+
+ @Override
+ public ProcedureParameter getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public void setMetadataObject(ProcedureParameter metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/BaseInCondition.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/BaseInCondition.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/BaseInCondition.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/BaseInCondition.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,65 @@
+/*
+ * 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.language;
+
+public abstract class BaseInCondition extends Condition implements Predicate {
+
+ private Expression leftExpression;
+ private boolean negated;
+
+ public BaseInCondition(Expression leftExpression, boolean negated) {
+ this.leftExpression = leftExpression;
+ this.negated = negated;
+ }
+
+ /**
+ * Get left expression of IN criteria
+ * @return Left expression
+ */
+ public Expression getLeftExpression() {
+ return leftExpression;
+ }
+
+ /**
+ * Set left expression of IN criteria
+ */
+ public void setLeftExpression(Expression leftExpression) {
+ this.leftExpression = leftExpression;
+ }
+
+ /**
+ * Returns whether this criteria is negated.
+ * @return flag indicating whether this criteria contains a NOT
+ */
+ public boolean isNegated() {
+ return negated;
+ }
+
+ /**
+ * Sets whether this criteria is negated.
+ * @param negated Flag indicating whether this criteria contains a NOT
+ */
+ public void setNegated(boolean negated) {
+ this.negated = negated;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/BaseLanguageObject.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/BaseLanguageObject.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/BaseLanguageObject.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/BaseLanguageObject.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,33 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.SQLStringVisitor;
+
+public abstract class BaseLanguageObject implements LanguageObject {
+
+ public String toString() {
+ return SQLStringVisitor.getSQLString(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/BatchedUpdates.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/BatchedUpdates.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/BatchedUpdates.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/BatchedUpdates.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,51 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a batch of INSERT, UPDATE and DELETE commands to be executed together.
+ */
+public class BatchedUpdates extends BaseLanguageObject implements Command {
+
+ private List<Command> updateCommands;
+
+ public BatchedUpdates(List<Command> updateCommands) {
+ this.updateCommands = updateCommands;
+ }
+
+ /**
+ * @return a list of IInsert, IUpdate and IDelete commands in this batched update.
+ */
+ public List<Command> getUpdateCommands() {
+ return updateCommands;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Call.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Call.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Call.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Call.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,110 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnSet;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.ProcedureParameter.Type;
+
+/**
+ * Represents a procedural execution (such as a stored procedure).
+ */
+public class Call extends BaseLanguageObject implements Command, MetadataReference<Procedure> {
+
+ private String name;
+ private List<Argument> arguments;
+ private Procedure metadataObject;
+ private Class<?> returnType;
+
+ public Call(String name, List<Argument> parameters, Procedure metadataObject) {
+ this.name = name;
+ this.arguments = parameters;
+ this.metadataObject = metadataObject;
+ }
+
+ /**
+ * Get the return type
+ * @return the return parameter type or null if not expecting a return value
+ */
+ public Class<?> getReturnType() {
+ return returnType;
+ }
+
+ public void setReturnType(Class<?> returnType) {
+ this.returnType = returnType;
+ }
+
+ public String getProcedureName() {
+ return this.name;
+ }
+
+ public List<Argument> getArguments() {
+ return arguments;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setProcedureName(String name) {
+ this.name = name;
+ }
+
+ public void setArguments(List<Argument> parameters) {
+ this.arguments = parameters;
+ }
+
+ @Override
+ public Procedure getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public ProcedureParameter getReturnParameter() {
+ for (ProcedureParameter param : this.metadataObject.getParameters()) {
+ if (param.getType() == Type.ReturnValue) {
+ return param;
+ }
+ }
+ return null;
+ }
+
+ public Class<?>[] getResultSetColumnTypes() {
+ ColumnSet<Procedure> resultSet = this.metadataObject.getResultSet();
+ if (resultSet == null) {
+ return new Class[0];
+ }
+ List<Column> columnMetadata = resultSet.getColumns();
+ int size = columnMetadata.size();
+ Class<?>[] coulmnDTs = new Class[size];
+ for(int i =0; i<size; i++ ){
+ coulmnDTs[i] = columnMetadata.get(i).getJavaType();
+ }
+ return coulmnDTs;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/ColumnReference.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/ColumnReference.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/ColumnReference.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/ColumnReference.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,96 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+import org.teiid.metadata.Column;
+
+/**
+ * Represents an element in the language. An example of an element
+ * would be a column reference in a SELECT clause.
+ */
+public class ColumnReference extends BaseLanguageObject implements MetadataReference<Column>, Expression {
+
+ private NamedTable table;
+ private String name;
+ private Column metadataObject;
+ private Class<?> type;
+
+ public ColumnReference(NamedTable group, String name, Column metadataObject, Class<?> type) {
+ this.table = group;
+ this.name = name;
+ this.metadataObject = metadataObject;
+ this.type = type;
+ }
+
+ /**
+ * Gets the name of the element.
+ * @return the name of the element
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Return the table that contains this column. May be null.
+ * @return The group reference
+ */
+ public NamedTable getTable() {
+ return table;
+ }
+
+ @Override
+ public Column getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public void setMetadataObject(Column metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ /**
+ * Sets the name of the element.
+ * @param name The name of the element
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Command.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Command.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Command.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Command.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,32 @@
+/*
+ * 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.language;
+
+/**
+ * Represents a command in the language objects. A command is an instruction of
+ * something to execute sent to the connector. Typical commands perform
+ * SELECT, INSERT, UPDATE, DELETE, etc type operations.
+ */
+public interface Command extends LanguageObject {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Comparison.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Comparison.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Comparison.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Comparison.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,117 @@
+/*
+ * 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.language;
+
+import org.teiid.language.SQLReservedWords.Tokens;
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a comparison between two expressions connected with
+ * one of the following operators: =, <>, <, <=, >, >=.
+ */
+public class Comparison extends Condition implements Predicate {
+
+ public enum Operator {
+ EQ(Tokens.EQ),
+ NE(Tokens.NE),
+ LT(Tokens.LT),
+ LE(Tokens.LE),
+ GT(Tokens.GT),
+ GE(Tokens.GE);
+
+ private String toString;
+ Operator(String toString) {
+ this.toString = toString;
+ }
+ @Override
+ public String toString() {
+ return toString;
+ }
+ }
+
+ private Expression leftExpression;
+ private Expression rightExpression;
+ private Operator operator;
+
+ public Comparison(Expression left, Expression right, Operator operator) {
+ leftExpression = left;
+ rightExpression = right;
+ this.operator = operator;
+ }
+
+ /**
+ * Get left expression.
+ * @return Left expression
+ */
+ public Expression getLeftExpression() {
+ return leftExpression;
+ }
+
+ /**
+ * Get right expression.
+ * @return Right expression
+ */
+ public Expression getRightExpression() {
+ return rightExpression;
+ }
+
+ /**
+ * Get the operator
+ * @return Operator constant
+ * @see Operator
+ */
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ /**
+ * Set left expression of criteria
+ */
+ public void setLeftExpression(Expression expression) {
+ this.leftExpression = expression;
+ }
+
+ /**
+ * Set right expression of criteria
+ */
+ public void setRightExpression(Expression expression) {
+ this.rightExpression = expression;
+ }
+
+ /**
+ * Set the operator
+ * @see Operator
+ */
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ /**
+ * @see org.teiid.language.LanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
+ */
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Condition.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Condition.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Condition.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Condition.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,37 @@
+/*
+ * 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.language;
+
+import org.teiid.translator.TypeFacility;
+
+/**
+ * Represents criteria, which is also a boolean expression
+ */
+public abstract class Condition extends BaseLanguageObject implements Expression {
+
+ @Override
+ public Class<?> getType() {
+ return TypeFacility.RUNTIME_TYPES.BOOLEAN;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Delete.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Delete.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Delete.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Delete.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,76 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a DELETE command.
+ */
+public class Delete extends BaseLanguageObject implements Command {
+
+ private NamedTable table;
+ private Condition where;
+
+ public Delete(NamedTable group, Condition criteria) {
+ this.table = group;
+ this.where = criteria;
+ }
+
+ /**
+ * Get group that is being deleted from.
+ * @return Insert group
+ */
+ public NamedTable getTable() {
+ return table;
+ }
+
+ /**
+ * Get criteria that is being used with the delete - may be null
+ * @return Criteria, may be null
+ */
+ public Condition getWhere() {
+ return where;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set group that is being deleted from.
+ * @param group Insert group
+ */
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ /**
+ * Set criteria that is being used with the delete - may be null
+ * @param criteria Criteria, may be null
+ */
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/DerivedColumn.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedColumn.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/DerivedColumn.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/DerivedColumn.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,57 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class DerivedColumn extends BaseLanguageObject {
+
+ private String alias;
+ private Expression expression;
+
+ public DerivedColumn(String name, Expression expression) {
+ this.alias = name;
+ this.expression = expression;
+ }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setAlias(String name) {
+ this.alias = name;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/DerivedTable.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/DerivedTable.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/DerivedTable.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/DerivedTable.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,60 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a derived table or inline view in the from clause.
+ */
+public class DerivedTable extends BaseLanguageObject implements TableReference {
+
+ private String correlationName;
+ private QueryExpression query;
+
+ public DerivedTable(QueryExpression query, String name) {
+ this.query = query;
+ this.correlationName = name;
+ }
+
+ public String getCorrelationName() {
+ return this.correlationName;
+ }
+
+ public void setCorrelationName(String name) {
+ this.correlationName = name;
+ }
+
+ public QueryExpression getQuery() {
+ return this.query;
+ }
+
+ public void setQuery(QueryExpression query) {
+ this.query = query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Exists.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Exists.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Exists.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Exists.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,51 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents an EXISTS criteria that checks whether any results would be
+ * returned from a subquery.
+ */
+public class Exists extends Condition implements Predicate, SubqueryContainer {
+
+ private QueryExpression query;
+
+ public Exists(QueryExpression query) {
+ this.query = query;
+ }
+
+ public QueryExpression getSubquery() {
+ return query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Expression.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Expression.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Expression.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Expression.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,39 @@
+/*
+ * 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.language;
+
+/**
+ * Represents an expression in the language. Subinterfaces define specific
+ * types of expressions, such as literal values, element references, and
+ * functions.
+ */
+public interface Expression extends LanguageObject {
+
+ /**
+ * Determine the type returned by this expression.
+ *
+ * @return The type, as defined by a Java class
+ */
+ Class<?> getType();
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/ExpressionValueSource.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/ExpressionValueSource.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/ExpressionValueSource.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/ExpressionValueSource.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,45 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class ExpressionValueSource extends BaseLanguageObject implements InsertValueSource {
+
+ private List<Expression> values;
+
+ public ExpressionValueSource(List<Expression> values) {
+ this.values = values;
+ }
+
+ public List<Expression> getValues() {
+ return values;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/language/ExpressionValueSource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/language/Function.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Function.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Function.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Function.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,86 @@
+/*
+ * 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.language;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a function. A function has a name and 0..n
+ * Expressions that are parameters.
+ */
+public class Function extends BaseLanguageObject implements Expression {
+
+ private String name;
+ private List<Expression> parameters;
+ private Class<?> type;
+
+ public Function(String name, List<? extends Expression> params, Class<?> type) {
+ this.name = name;
+ if (params == null) {
+ this.parameters = new ArrayList<Expression>(0);
+ } else {
+ this.parameters = new ArrayList<Expression>(params);
+ }
+ this.type = type;
+ }
+
+ /**
+ * Get name of the function
+ * @return Function name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Get the parameters used in this function.
+ * @return Array of IExpressions defining the parameters
+ */
+ public List<Expression> getParameters() {
+ return parameters;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set name of the function
+ * @param name Function name
+ */
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/GroupBy.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/GroupBy.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/GroupBy.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/GroupBy.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,56 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a GROUP BY clause in a query.
+ */
+public class GroupBy extends BaseLanguageObject {
+
+ private List<Expression> elements;
+
+ public GroupBy(List<Expression> elements) {
+ this.elements = elements;
+ }
+
+ /**
+ * Get list of IExpression that the GROUP BY should be grouped on.
+ * @return List of IExpression
+ */
+ public List<Expression> getElements() {
+ return elements;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setElements(List<Expression> elements) {
+ this.elements = elements;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/In.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/In.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/In.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/In.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,54 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class In extends BaseInCondition {
+
+ private List<Expression> rightExpressions;
+
+ public In(Expression left, List<Expression> right, boolean negated) {
+ super(left, negated);
+ rightExpressions = right;
+ }
+
+ /**
+ * Get List of IExpression in the set on the right side of the criteria.
+ * @return List of IExpression
+ */
+ public List<Expression> getRightExpressions() {
+ return rightExpressions;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setRightExpressions(List<Expression> expressions) {
+ this.rightExpressions = expressions;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Insert.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Insert.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Insert.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Insert.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,70 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+
+public class Insert extends BaseLanguageObject implements Command {
+
+ private NamedTable table;
+ private List<ColumnReference> columns;
+ private InsertValueSource valueSource;
+
+ public Insert(NamedTable group, List<ColumnReference> elements, InsertValueSource valueSource) {
+ this.table = group;
+ this.columns = elements;
+ this.valueSource = valueSource;
+ }
+
+ public NamedTable getTable() {
+ return table;
+ }
+
+ public List<ColumnReference> getColumns() {
+ return columns;
+ }
+
+ public InsertValueSource getValueSource() {
+ return valueSource;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ public void setColumns(List<ColumnReference> elements) {
+ this.columns = elements;
+ }
+
+ public void setValueSource(InsertValueSource values) {
+ this.valueSource = values;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/InsertValueSource.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/InsertValueSource.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/InsertValueSource.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/InsertValueSource.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -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.language;
+
+public interface InsertValueSource extends LanguageObject {
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/language/InsertValueSource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/language/IsNull.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/IsNull.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/IsNull.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/IsNull.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,60 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents an IS NULL predicate.
+ */
+public class IsNull extends Condition implements Predicate {
+
+ private Expression expression;
+ private boolean negated;
+
+ public IsNull(Expression expr, boolean isNegated) {
+ expression = expr;
+ this.negated = isNegated;
+ }
+
+ public Expression getExpression() {
+ return expression;
+ }
+
+ public boolean isNegated() {
+ return this.negated;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+ public void setNegated(boolean negated) {
+ this.negated = negated;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Join.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Join.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Join.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Join.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,85 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class Join extends BaseLanguageObject implements TableReference {
+
+ public enum JoinType {
+ INNER_JOIN,
+ CROSS_JOIN,
+ LEFT_OUTER_JOIN,
+ RIGHT_OUTER_JOIN,
+ FULL_OUTER_JOIN
+ }
+
+ private TableReference leftItem;
+ private TableReference rightItem;
+ private JoinType joinType;
+ private Condition condition;
+
+ public Join(TableReference left, TableReference right, JoinType joinType, Condition criteria) {
+ this.leftItem = left;
+ this.rightItem = right;
+ this.joinType = joinType;
+ this.condition = criteria;
+ }
+
+ public TableReference getLeftItem() {
+ return leftItem;
+ }
+
+ public TableReference getRightItem() {
+ return rightItem;
+ }
+
+ public JoinType getJoinType() {
+ return this.joinType;
+ }
+
+ public Condition getCondition() {
+ return condition;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setLeftItem(TableReference item) {
+ this.leftItem = item;
+ }
+
+ public void setRightItem(TableReference item) {
+ this.rightItem = item;
+ }
+
+ public void setJoinType(JoinType type) {
+ this.joinType = type;
+ }
+
+ public void setCondition(Condition criteria) {
+ this.condition = criteria;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/LanguageFactory.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageFactory.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/LanguageFactory.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/LanguageFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,206 @@
+/*
+ * 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.language;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.SortSpecification.Ordering;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Table;
+
+/**
+ * Factory for the construction of language objects that implement the language interfaces.
+ * This factory is provided by the connector environment and can be used in modifying the language
+ * interfaces if needed.
+ */
+public class LanguageFactory {
+
+ /**
+ * Public instance, holds no state so can be shared by everyone.
+ */
+ public static final LanguageFactory INSTANCE = new LanguageFactory();
+
+ public AggregateFunction createAggregate(String name, boolean isDistinct, Expression expression, Class<?> type) {
+ return new AggregateFunction(name, isDistinct, expression, type);
+ }
+
+ public Comparison createCompareCriteria(
+ Comparison.Operator operator,
+ Expression leftExpression,
+ Expression rightExpression) {
+ return new Comparison(leftExpression, rightExpression, operator);
+ }
+
+ public AndOr createAndOr(AndOr.Operator operator, Condition left, Condition right) {
+ return new AndOr(left, right, operator);
+ }
+
+ public Delete createDelete(NamedTable group, Condition where) {
+ return new Delete(group, where);
+ }
+
+ public ColumnReference createColumnReference(String name, NamedTable group, Column metadataReference, Class<?> type) {
+ return new ColumnReference(group, name, metadataReference, type);
+ }
+
+ public Exists createExists(Select query) {
+ return new Exists(query);
+ }
+
+ public Function createFunction(String functionName, Expression[] args, Class<?> type) {
+ return new Function(functionName, Arrays.asList(args), type);
+ }
+
+ public Function createFunction(String functionName, List<? extends Expression> args, Class<?> type) {
+ return new Function(functionName, args, type);
+ }
+
+ public NamedTable createNamedTable(String name, String correlationName, Table metadataReference) {
+ return new NamedTable(name, correlationName, metadataReference);
+ }
+
+ public GroupBy createGroupBy(List<Expression> items) {
+ return new GroupBy(items);
+ }
+
+ public In createIn(Expression leftExpression, List<Expression> rightExpressions, boolean isNegated) {
+ return new In(leftExpression, rightExpressions, isNegated);
+ }
+
+ public Insert createInsert(NamedTable group, List<ColumnReference> columns, InsertValueSource valueSource) {
+ return new Insert(group, columns, valueSource);
+ }
+
+ public ExpressionValueSource createInsertExpressionValueSource(List<Expression> values) {
+ return new ExpressionValueSource(values);
+ }
+
+ public IsNull createIsNullCriteria(Expression expression, boolean isNegated) {
+ return new IsNull(expression, isNegated);
+ }
+
+ public Join createJoin(Join.JoinType joinType, TableReference leftItem, TableReference rightItem, Condition condition) {
+ return new Join(leftItem, rightItem, joinType, condition);
+ }
+
+ public Like createLikeCriteria(
+ Expression leftExpression,
+ Expression rightExpression,
+ Character escapeCharacter,
+ boolean isNegated) {
+ return new Like(leftExpression, rightExpression, escapeCharacter, isNegated);
+ }
+
+ public Literal createLiteral(Object value, Class<?> type) {
+ return new Literal(value, type);
+ }
+
+ public Not createNot(Condition criteria) {
+ return new Not(criteria);
+ }
+
+ public OrderBy createOrderBy(List<SortSpecification> items) {
+ return new OrderBy(items);
+ }
+
+ public SortSpecification createOrderByItem(ColumnReference element, Ordering direction) {
+ return new SortSpecification(direction, element);
+ }
+
+ public Argument createArgument(Argument.Direction direction, Literal value, Class<?> type, ProcedureParameter metadataReference) {
+ return new Argument(direction, value, type, metadataReference);
+ }
+
+ public Call createCall(String name, List<Argument> parameters, Procedure metadataReference) {
+ return new Call(name, parameters, metadataReference);
+ }
+
+ public Select createQuery(
+ List<DerivedColumn> select,
+ boolean isDistinct,
+ List<TableReference> from,
+ Condition where,
+ GroupBy groupBy,
+ Condition having,
+ OrderBy orderBy) {
+ return new Select(select, isDistinct, from, where, groupBy, having, orderBy);
+ }
+
+ public ScalarSubquery createScalarSubquery(Select query) {
+ return new ScalarSubquery(query);
+ }
+
+ public SearchedCase createSearchedCaseExpression(
+ List<SearchedWhenClause> cases,
+ Expression elseExpression,
+ Class<?> type) {
+ return new SearchedCase(cases, elseExpression, type);
+ }
+
+ public SearchedWhenClause createSearchedWhenCondition(Condition condition, Expression result) {
+ return new SearchedWhenClause(condition, result);
+ }
+
+ public DerivedColumn createSelectSymbol(String name, Expression expression) {
+ return new DerivedColumn(name, expression);
+ }
+
+ public SubqueryComparison createSubqueryCompareCriteria(
+ Expression leftExpression,
+ Comparison.Operator operator,
+ SubqueryComparison.Quantifier quantifier,
+ Select subquery) {
+ return new SubqueryComparison(leftExpression, operator, quantifier, subquery);
+ }
+
+ public SubqueryIn createSubqueryInCriteria(Expression expression, Select subquery, boolean isNegated) {
+ return new SubqueryIn(expression, isNegated, subquery);
+ }
+
+ public Update createUpdate(NamedTable group, List<SetClause> updates, Condition criteria) {
+ return new Update(group, updates, criteria);
+ }
+
+ public DerivedTable createInlineView(QueryExpression query, String name) {
+ return new DerivedTable(query, name);
+ }
+
+ public SetQuery createSetOp(SetQuery.Operation operation, boolean all, QueryExpression leftQuery, QueryExpression rightQuery, OrderBy orderBy, Limit limit) {
+ SetQuery queryImpl = new SetQuery();
+ queryImpl.setOperation(operation);
+ queryImpl.setAll(all);
+ queryImpl.setLeftQuery(leftQuery);
+ queryImpl.setRightQuery(rightQuery);
+ queryImpl.setOrderBy(orderBy);
+ queryImpl.setLimit(limit);
+ return queryImpl;
+ }
+
+ public SetClause createSetClause(ColumnReference symbol, Expression value) {
+ return new SetClause(symbol, value);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/LanguageObject.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageObject.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/LanguageObject.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/LanguageObject.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,34 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Root interface for all language object interfaces.
+ */
+public interface LanguageObject {
+
+ void acceptVisitor(LanguageObjectVisitor visitor);
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/LanguageUtil.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/LanguageUtil.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/LanguageUtil.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/LanguageUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,100 @@
+/*
+ * 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.language;
+
+import java.util.*;
+
+import org.teiid.language.AndOr.Operator;
+
+
+/**
+ * Helpful utility methods to work with language interfaces.
+ */
+public final class LanguageUtil {
+
+ /**
+ * Can't construct - this contains only static utility methods
+ */
+ private LanguageUtil() {
+ }
+
+ /**
+ * Take a criteria, which may be null, a single IPredicateCriteria or a
+ * complex criteria built using ICompoundCriteria and breaks it apart
+ * at ANDs such that a List of ICriteria conjuncts are returned. For
+ * example, ((a=1 OR b=2) AND (c=3 AND d=4)) would return the list
+ * (a=1 OR b=2), c=3, d=4. If criteria is null, an empty list is
+ * returned.
+ * @param criteria Criteria to break, may be null
+ * @return List of ICriteria, never null
+ */
+ public static final List<Condition> separateCriteriaByAnd(Condition criteria) {
+ if(criteria == null) {
+ return Collections.emptyList();
+ }
+
+ List<Condition> parts = new ArrayList<Condition>();
+ separateCriteria(criteria, parts);
+ return parts;
+ }
+
+ /**
+ * Helper method for {@link #separateCriteriaByAnd(Condition)} that
+ * can be called recursively to collect parts.
+ * @param crit Crit to break apart
+ * @param parts List to add parts to
+ */
+ private static void separateCriteria(Condition crit, List<Condition> parts) {
+ if(crit instanceof AndOr) {
+ AndOr compCrit = (AndOr) crit;
+ if(compCrit.getOperator() == Operator.AND) {
+ separateCriteria(compCrit.getLeftCondition(), parts);
+ separateCriteria(compCrit.getRightCondition(), parts);
+ } else {
+ parts.add(crit);
+ }
+ } else {
+ parts.add(crit);
+ }
+ }
+
+ /**
+ * This utility method can be used to combine two criteria using an AND.
+ * If both criteria are null, then null will be returned. If either is null,
+ * then the other will be returned.
+ * @param primaryCrit Primary criteria - may be modified
+ * @param additionalCrit Won't be modified, but will likely be attached to the returned crit
+ * @param languageFactory Will be used to construct new ICompoundCriteria if necessary
+ * @return Combined criteria
+ */
+ public static Condition combineCriteria(Condition primaryCrit, Condition additionalCrit, LanguageFactory languageFactory) {
+ if(primaryCrit == null) {
+ return additionalCrit;
+ } else if(additionalCrit == null) {
+ return primaryCrit;
+ } else {
+ return languageFactory.createAndOr(Operator.AND, primaryCrit, additionalCrit);
+ }
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Like.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Like.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Like.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Like.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,78 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class Like extends Condition implements Predicate {
+
+ private Expression leftExpression;
+ private Expression rightExpression;
+ private Character escapeCharacter;
+ private boolean isNegated;
+
+ public Like(Expression left, Expression right, Character escapeCharacter, boolean negated) {
+ leftExpression = left;
+ rightExpression = right;
+ this.escapeCharacter = escapeCharacter;
+ this.isNegated = negated;
+
+ }
+
+ public Expression getLeftExpression() {
+ return leftExpression;
+ }
+
+ public Expression getRightExpression() {
+ return rightExpression;
+ }
+
+ public Character getEscapeCharacter() {
+ return this.escapeCharacter;
+ }
+
+ public boolean isNegated() {
+ return this.isNegated;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setLeftExpression(Expression expression) {
+ this.leftExpression = expression;
+ }
+
+ public void setRightExpression(Expression expression) {
+ this.rightExpression = expression;
+ }
+
+ public void setEscapeCharacter(Character character) {
+ this.escapeCharacter = character;
+ }
+
+ public void setNegated(boolean negated) {
+ this.isNegated = negated;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Limit.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Limit.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Limit.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Limit.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,66 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a LIMIT clause with row offset and row limit values to bound the resulting rows
+ */
+public class Limit extends BaseLanguageObject {
+
+ private int rowOffset;
+ private int rowLimit;
+
+ public Limit(int offset, int rowLimit) {
+ this.rowOffset = offset;
+ this.rowLimit = rowLimit;
+ }
+
+ /**
+ * Get the max number of rows returned.
+ */
+ public int getRowLimit() {
+ return rowLimit;
+ }
+
+ /**
+ * Get the row offset at which to begin returning rows.
+ */
+ public int getRowOffset() {
+ return rowOffset;
+ }
+
+ public void setRowLimit(int rowLimit) {
+ this.rowLimit = rowLimit;
+ }
+
+ public void setRowOffset(int rowOffset) {
+ this.rowOffset = rowOffset;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Literal.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Literal.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Literal.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Literal.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,80 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a literal value that is used in
+ * an expression. The value can be obtained and should match
+ * the type specified by {@link #getType()}
+ */
+public class Literal extends BaseLanguageObject implements Expression {
+
+ private Object value;
+ private Class<?> type;
+ private boolean bindValue;
+ private boolean multiValued;
+
+ public Literal(Object value, Class<?> type) {
+ this.value = value;
+ this.type = type;
+ }
+
+ public Object getValue() {
+ return this.value;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setValue(Object value) {
+ this.value = value;
+ }
+
+ public boolean isBindValue() {
+ return bindValue;
+ }
+
+ public void setBindValue(boolean bindValue) {
+ this.bindValue = bindValue;
+ }
+
+ public boolean isMultiValued() {
+ return multiValued;
+ }
+
+ public void setMultiValued(boolean multiValued) {
+ this.multiValued = multiValued;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/MetadataReference.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/MetadataReference.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/MetadataReference.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/MetadataReference.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,36 @@
+/*
+ * 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.language;
+
+import org.teiid.metadata.AbstractMetadataRecord;
+
+
+/**
+ * This interface is used to mark language objects as having a
+ * reference to a MetadataID.
+ */
+public interface MetadataReference<T extends AbstractMetadataRecord> {
+
+ T getMetadataObject();
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/NamedTable.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/NamedTable.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/NamedTable.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/NamedTable.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,77 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+import org.teiid.metadata.Table;
+
+/**
+ * Represents a table in the language objects. An example would
+ * be a table reference in the FROM clause.
+ */
+public class NamedTable extends BaseLanguageObject implements MetadataReference<Table>, TableReference {
+
+ private String correlationName;
+ private String name;
+ private Table metadataObject;
+
+ public NamedTable(String name, String correlationName, Table group) {
+ this.name = name;
+ this.correlationName = correlationName;
+ this.metadataObject = group;
+ }
+
+ public String getCorrelationName() {
+ return correlationName;
+ }
+
+ /**
+ * Gets the name of the table. Will typically match the name in the metadata.
+ * @return
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public Table getMetadataObject() {
+ return this.metadataObject;
+ }
+
+ public void setMetadataObject(Table metadataObject) {
+ this.metadataObject = metadataObject;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setName(String definition) {
+ this.name = definition;
+ }
+
+ public void setCorrelationName(String context) {
+ this.correlationName = context;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Not.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Not.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Not.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Not.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,47 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class Not extends Condition {
+
+ private Condition criteria;
+
+ public Not(Condition criteria) {
+ this.criteria = criteria;
+ }
+
+ public Condition getCriteria() {
+ return criteria;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setCriteria(Condition criteria) {
+ this.criteria = criteria;
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/language/Not.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/language/OrderBy.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/OrderBy.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/OrderBy.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/OrderBy.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,52 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents an ORDER BY clause in a command.
+ */
+public class OrderBy extends BaseLanguageObject {
+
+ private List<SortSpecification> sortSpecifications;
+
+ public OrderBy(List<SortSpecification> items) {
+ this.sortSpecifications = items;
+ }
+
+ public List<SortSpecification> getSortSpecifications() {
+ return sortSpecifications;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setSortSpecifications(List<SortSpecification> items) {
+ this.sortSpecifications = items;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Predicate.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Predicate.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Predicate.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Predicate.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,31 @@
+/*
+ * 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.language;
+
+/**
+ * Represents a criteria that can occur at the leaf of a tree of
+ * criteria.
+ */
+public interface Predicate {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/QueryExpression.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/QueryExpression.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/QueryExpression.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/QueryExpression.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,96 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+public abstract class QueryExpression extends BaseLanguageObject implements Command, InsertValueSource {
+
+ private OrderBy orderBy;
+ private Limit limit;
+
+ public abstract Select getProjectedQuery();
+
+ /**
+ * Get ORDER BY clause, may be null.
+ * @return An ORDER BY object
+ */
+ public OrderBy getOrderBy() {
+ return orderBy;
+ }
+
+ /**
+ * Get LIMIT clause, may be null.
+ * @return A LIMIT object
+ */
+ public Limit getLimit() {
+ return limit;
+ }
+
+ /**
+ * Get the derived column names. Note this only reports alias names.
+ * Any other names may not be consistent throughout the translation process.
+ * @return a String[] containing the column names
+ * @since 4.3
+ */
+ public String[] getColumnNames() {
+ List<DerivedColumn> selectSymbols = getProjectedQuery().getDerivedColumns();
+ String[] columnNames = new String[selectSymbols.size()];
+ int symbolIndex = 0;
+ for (DerivedColumn column : selectSymbols) {
+ columnNames[symbolIndex++] = column.getAlias();
+ }
+ return columnNames;
+ }
+
+ /**
+ * Get the column types of the output columns for this query
+ * @return a Class[] containing the column names
+ * @since 4.3
+ */
+ public Class<?>[] getColumnTypes() {
+ List<DerivedColumn> selectSymbols = getProjectedQuery().getDerivedColumns();
+ Class<?>[] columnTypes = new Class[selectSymbols.size()];
+ int symbolIndex = 0;
+ for (DerivedColumn column : selectSymbols) {
+ columnTypes[symbolIndex++] = column.getExpression().getType();
+ }
+ return columnTypes;
+ }
+
+ /**
+ * Set ORDER BY clause, may be null.
+ * @param orderBy An ORDER BY object
+ */
+ public void setOrderBy(OrderBy orderBy) {
+ this.orderBy = orderBy;
+ }
+
+ /**
+ * Set LIMIT clause, may be null.
+ * @param limit A LIMIT object
+ */
+ public void setLimit(Limit limit) {
+ this.limit = limit;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SQLReservedWords.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SQLReservedWords.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SQLReservedWords.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SQLReservedWords.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,354 @@
+/*
+ * 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.language;
+
+import java.lang.reflect.Field;
+import java.util.Set;
+import java.util.HashSet;
+
+/**
+ * Reserved words for Teiid.
+ */
+public class SQLReservedWords {
+
+ public interface Tokens {
+ public static final String ALL_COLS = "*"; //$NON-NLS-1$
+ public static final String SPACE = " "; //$NON-NLS-1$
+ public static final String COMMA = ","; //$NON-NLS-1$
+ public static final String DOT = "."; //$NON-NLS-1$
+ public static final String QUOTE = "'"; //$NON-NLS-1$
+ public static final String EQ = "="; //$NON-NLS-1$
+ public static final String NE = "<>"; //$NON-NLS-1$
+ public static final String LT = "<"; //$NON-NLS-1$
+ public static final String GT = ">"; //$NON-NLS-1$
+ public static final String LE = "<="; //$NON-NLS-1$
+ public static final String GE = ">="; //$NON-NLS-1$
+ public static final String LPAREN = "("; //$NON-NLS-1$
+ public static final String RPAREN = ")"; //$NON-NLS-1$
+ }
+
+ //Teiid specific
+ public static final String BIGDECIMAL = "BIGDECIMAL"; //$NON-NLS-1$
+ public static final String BIGINTEGER = "BIGINTEGER"; //$NON-NLS-1$
+ public static final String BREAK = "BREAK"; //$NON-NLS-1$
+ public static final String BYTE = "BYTE"; //$NON-NLS-1$
+ public static final String CRITERIA = "CRITERIA"; //$NON-NLS-1$
+ public static final String ERROR = "ERROR"; //$NON-NLS-1$
+ public static final String FN = "FN"; //$NON-NLS-1$
+ public static final String LIMIT = "LIMIT"; //$NON-NLS-1$
+ public static final String LONG = "LONG"; //$NON-NLS-1$
+ public static final String LOOP = "LOOP"; //$NON-NLS-1$
+ public static final String MAKEDEP = "MAKEDEP"; //$NON-NLS-1$
+ public static final String MAKENOTDEP = "MAKENOTDEP"; //$NON-NLS-1$
+ public static final String NOCACHE = "NOCACHE"; //$NON-NLS-1$
+ public static final String OJ = "OJ"; //$NON-NLS-1$
+ public static final String SQL_TSI_FRAC_SECOND = "SQL_TSI_FRAC_SECOND"; //$NON-NLS-1$
+ public static final String SQL_TSI_SECOND = "SQL_TSI_SECOND"; //$NON-NLS-1$
+ public static final String SQL_TSI_MINUTE = "SQL_TSI_MINUTE"; //$NON-NLS-1$
+ public static final String SQL_TSI_HOUR = "SQL_TSI_HOUR"; //$NON-NLS-1$
+ public static final String SQL_TSI_DAY = "SQL_TSI_DAY"; //$NON-NLS-1$
+ public static final String SQL_TSI_WEEK = "SQL_TSI_WEEK"; //$NON-NLS-1$
+ public static final String SQL_TSI_MONTH = "SQL_TSI_MONTH"; //$NON-NLS-1$
+ public static final String SQL_TSI_QUARTER = "SQL_TSI_QUARTER"; //$NON-NLS-1$
+ public static final String SQL_TSI_YEAR = "SQL_TSI_YEAR"; //$NON-NLS-1$
+ public static final String STRING = "STRING"; //$NON-NLS-1$
+ public static final String TIMESTAMPADD = "TIMESTAMPADD"; //$NON-NLS-1$
+ public static final String TIMESTAMPDIFF = "TIMESTAMPDIFF"; //$NON-NLS-1$
+ public static final String VIRTUAL = "VIRTUAL"; //$NON-NLS-1$
+ public static final String WHILE = "WHILE"; //$NON-NLS-1$
+
+ //SQL2003 keywords
+ public static final String ADD = "ADD"; //$NON-NLS-1$
+ public static final String ANY = "ANY"; //$NON-NLS-1$
+ public static final String ALL = "ALL"; //$NON-NLS-1$
+ public static final String ALTER = "ALTER"; //$NON-NLS-1$
+ public static final String AND = "AND"; //$NON-NLS-1$
+ public static final String ARRAY = "ARRAY"; //$NON-NLS-1$s
+ public static final String AS = "AS"; //$NON-NLS-1$
+ public static final String ASC = "ASC"; //$NON-NLS-1$
+ public static final String ATOMIC = "ATOMIC"; //$NON-NLS-1$
+ public static final String AUTHORIZATION = "AUTHORIZATION"; //$NON-NLS-1$
+ public static final String AVG = "AVG"; //$NON-NLS-1$
+ public static final String BEGIN = "BEGIN"; //$NON-NLS-1$
+ public static final String BETWEEN = "BETWEEN"; //$NON-NLS-1$
+ public static final String BIGINT = "BIGINT"; //$NON-NLS-1$
+ public static final String BINARY = "BINARY"; //$NON-NLS-1$
+ public static final String BLOB = "BLOB"; //$NON-NLS-1$
+ public static final String BOTH = "BOTH"; //$NON-NLS-1$
+ public static final String BY = "BY"; //$NON-NLS-1$
+ public static final String CALL = "CALL"; //$NON-NLS-1$
+ public static final String CALLED = "CALLED"; //$NON-NLS-1$
+ public static final String CASE = "CASE"; //$NON-NLS-1$
+ public static final String CAST = "CAST"; //$NON-NLS-1$
+ public static final String CASCADED = "CASCADED"; //$NON-NLS-1$
+ public static final String CHAR = "CHAR"; //$NON-NLS-1$
+ public static final String CHARACTER = "CHARACTER"; //$NON-NLS-1$
+ public static final String CHECK = "CHECK"; //$NON-NLS-1$
+ public static final String CLOB = "CLOB"; //$NON-NLS-1$
+ public static final String CLOSE = "CLOSE"; //$NON-NLS-1$
+ public static final String COLLATE = "COLLATE"; //$NON-NLS-1$
+ public static final String COLUMN = "COLUMN"; //$NON-NLS-1$
+ public static final String COMMIT = "COMMIT"; //$NON-NLS-1$
+ public static final String CONNECT = "CONNECT"; //$NON-NLS-1$
+ public static final String CONVERT = "CONVERT"; //$NON-NLS-1$
+ public static final String CONSTRAINT = "CONSTRAINT"; //$NON-NLS-1$
+ public static final String CONTINUE = "CONTINUE"; //$NON-NLS-1$
+ public static final String COUNT = "COUNT"; //$NON-NLS-1$
+ public static final String CORRESPONDING = "CORRESPONDING"; //$NON-NLS-1$
+ public static final String CREATE = "CREATE"; //$NON-NLS-1$
+ public static final String CROSS = "CROSS"; //$NON-NLS-1$
+ public static final String CURRENT_DATE = "CURRENT_DATE"; //$NON-NLS-1$
+ public static final String CURRENT_TIME = "CURRENT_TIME"; //$NON-NLS-1$
+ public static final String CURRENT_TIMESTAMP = "CURRENT_TIMESTAMP"; //$NON-NLS-1$
+ public static final String CURRENT_USER = "CURRENT_USER"; //$NON-NLS-1$
+ public static final String CURSOR = "CURSOR"; //$NON-NLS-1$
+ public static final String DATE = "DATE"; //$NON-NLS-1$
+ public static final String DAY = "DAY"; //$NON-NLS-1$
+ public static final String DEALLOCATE = "DEALLOCATE"; //$NON-NLS-1$
+ public static final String DECIMAL = "DECIMAL"; //$NON-NLS-1$
+ public static final String DECLARE = "DECLARE"; //$NON-NLS-1$
+ public static final String DEFAULT = "DEFAULT"; //$NON-NLS-1$
+ public static final String DELETE = "DELETE"; //$NON-NLS-1$
+ public static final String DESC = "DESC"; //$NON-NLS-1$
+ public static final String DESCRIBE = "DESCRIBE"; //$NON-NLS-1$
+ public static final String DETERMINISTIC = "DETERMINISTIC"; //$NON-NLS-1$
+ public static final String DISCONNECT = "DISCONNECT"; //$NON-NLS-1$
+ public static final String DISTINCT = "DISTINCT"; //$NON-NLS-1$
+ public static final String DOUBLE = "DOUBLE"; //$NON-NLS-1$
+ public static final String DROP = "DROP"; //$NON-NLS-1$
+ public static final String EACH = "EACH"; //$NON-NLS-1$
+ public static final String ELSE = "ELSE"; //$NON-NLS-1$
+ public static final String END = "END"; //$NON-NLS-1$
+ public static final String ESCAPE = "ESCAPE"; //$NON-NLS-1$
+ public static final String EXCEPT = "EXCEPT"; //$NON-NLS-1$
+ public static final String EXEC = "EXEC"; //$NON-NLS-1$
+ public static final String EXECUTE = "EXECUTE"; //$NON-NLS-1$
+ public static final String EXISTS = "EXISTS"; //$NON-NLS-1$
+ public static final String EXTERNAL = "EXTERNAL"; //$NON-NLS-1$
+ public static final String FALSE = "FALSE"; //$NON-NLS-1$
+ public static final String FETCH = "FETCH"; //$NON-NLS-1$
+ public static final String FILTER = "FILTER"; //$NON-NLS-1$
+ public static final String FLOAT = "FLOAT"; //$NON-NLS-1$
+ public static final String FOR = "FOR"; //$NON-NLS-1$
+ public static final String FOREIGN = "FOREIGN"; //$NON-NLS-1$
+ public static final String FROM = "FROM"; //$NON-NLS-1$
+ public static final String FULL = "FULL"; //$NON-NLS-1$
+ public static final String FUNCTION = "FUNCTION"; //$NON-NLS-1$
+ public static final String GET = "GET"; //$NON-NLS-1$
+ public static final String GLOBAL = "GLOBAL"; //$NON-NLS-1$
+ public static final String GRANT = "GRANT"; //$NON-NLS-1$
+ public static final String GROUP = "GROUP"; //$NON-NLS-1$
+ public static final String GROUPING = "GROUPING"; //$NON-NLS-1$
+ public static final String HAS = "HAS"; //$NON-NLS-1$
+ public static final String HAVING = "HAVING"; //$NON-NLS-1$
+ public static final String HOLD = "HOLD"; //$NON-NLS-1$
+ public static final String HOUR = "HOUR"; //$NON-NLS-1$
+ public static final String IDENTITY = "IDENTITY"; //$NON-NLS-1$
+ public static final String INDICATOR = "INDICATOR"; //$NON-NLS-1$
+ public static final String IF = "IF"; //$NON-NLS-1$
+ public static final String IMMEDIATE = "IMMEDIATE"; //$NON-NLS-1$
+ public static final String IN = "IN"; //$NON-NLS-1$
+ public static final String INOUT = "INOUT"; //$NON-NLS-1$
+ public static final String INNER = "INNER"; //$NON-NLS-1$
+ public static final String INPUT = "INPUT"; //$NON-NLS-1$
+ public static final String INSENSITIVE = "INSENSITIVE"; //$NON-NLS-1$
+ public static final String INSERT = "INSERT"; //$NON-NLS-1$
+ public static final String INTEGER = "INTEGER"; //$NON-NLS-1$
+ public static final String INTERSECT = "INTERSECT"; //$NON-NLS-1$
+ public static final String INTERVAL = "INTERVAL"; //$NON-NLS-1$
+ public static final String INTO = "INTO"; //$NON-NLS-1$
+ public static final String IS = "IS"; //$NON-NLS-1$
+ public static final String ISOLATION = "ISOLATION"; //$NON-NLS-1$
+ public static final String JOIN = "JOIN"; //$NON-NLS-1$
+ public static final String LANGUAGE = "LANGUAGE"; //$NON-NLS-1$
+ public static final String LARGE = "LARGE"; //$NON-NLS-1$
+ public static final String LEADING = "LEADING"; //$NON-NLS-1$
+ public static final String LEFT = "LEFT"; //$NON-NLS-1$
+ public static final String LIKE = "LIKE"; //$NON-NLS-1$
+ public static final String LOCAL = "LOCAL"; //$NON-NLS-1$
+ public static final String MATCH = "MATCH"; //$NON-NLS-1$
+ public static final String MAX = "MAX"; //$NON-NLS-1$
+ public static final String MIN = "MIN"; //$NON-NLS-1$
+ public static final String MERGE = "MERGE"; //$NON-NLS-1$
+ public static final String METHOD = "METHOD"; //$NON-NLS-1$
+ public static final String MINUTE = "MINUTE"; //$NON-NLS-1$
+ public static final String MODIFIES = "MODIFIES"; //$NON-NLS-1$
+ public static final String MODULE = "MODULE"; //$NON-NLS-1$
+ public static final String MONTH = "MONTH"; //$NON-NLS-1$
+ public static final String NATURAL = "NATURAL"; //$NON-NLS-1$
+ public static final String NEW = "NEW"; //$NON-NLS-1$
+ public static final String NO = "NO"; //$NON-NLS-1$
+ public static final String NONE = "NONE"; //$NON-NLS-1$
+ public static final String NOT = "NOT"; //$NON-NLS-1$
+ public static final String NULL = "NULL"; //$NON-NLS-1$
+ public static final String OBJECT = "OBJECT"; //$NON-NLS-1$
+ public static final String OF = "OF"; //$NON-NLS-1$
+ public static final String OLD = "OLD"; //$NON-NLS-1$
+ public static final String ON = "ON"; //$NON-NLS-1$
+ public static final String ONLY = "ONLY"; //$NON-NLS-1$
+ public static final String OPEN = "OPEN"; //$NON-NLS-1$
+ public static final String OR = "OR"; //$NON-NLS-1$
+ public static final String ORDER = "ORDER"; //$NON-NLS-1$
+ public static final String OUT = "OUT"; //$NON-NLS-1$
+ public static final String OUTER = "OUTER"; //$NON-NLS-1$
+ public static final String OUTPUT = "OUTPUT"; //$NON-NLS-1$
+ public static final String OPTION = "OPTION"; //$NON-NLS-1$
+ public static final String OVER = "OVER"; //$NON-NLS-1$
+ public static final String OVERLAPS = "OVERLAPS"; //$NON-NLS-1$
+ public static final String PARAMETER = "PARAMETER"; //$NON-NLS-1$
+ public static final String PARTITION = "PARTITION"; //$NON-NLS-1$
+ public static final String PRECISION = "PRECISION"; //$NON-NLS-1$
+ public static final String PREPARE = "PREPARE"; //$NON-NLS-1$
+ public static final String PRIMARY = "PRIMARY"; //$NON-NLS-1$
+ public static final String PROCEDURE = "PROCEDURE"; //$NON-NLS-1$
+ public static final String RANGE = "RANGE"; //$NON-NLS-1$
+ public static final String READS = "READS"; //$NON-NLS-1$
+ public static final String REAL = "REAL"; //$NON-NLS-1$
+ public static final String RECURSIVE = "RECURSIVE"; //$NON-NLS-1$
+ public static final String REFERENCES = "REFERENCES"; //$NON-NLS-1$
+ public static final String REFERENCING = "REFERENCING"; //$NON-NLS-1$
+ public static final String RETURN = "RETURN"; //$NON-NLS-1$
+ public static final String RETURNS = "RETURNS"; //$NON-NLS-1$
+ public static final String REVOKE = "REVOKE"; //$NON-NLS-1$
+ public static final String RIGHT = "RIGHT"; //$NON-NLS-1$
+ public static final String ROLLBACK = "ROLLBACK"; //$NON-NLS-1$
+ public static final String ROLLUP = "ROLLUP"; //$NON-NLS-1$
+ public static final String ROW = "ROW"; //$NON-NLS-1$
+ public static final String ROWS = "ROWS"; //$NON-NLS-1$
+ public static final String SAVEPOINT = "ROWS"; //$NON-NLS-1$
+ public static final String SCROLL = "ROWS"; //$NON-NLS-1$
+ public static final String SEARCH = "ROWS"; //$NON-NLS-1$
+ public static final String SECOND = "ROWS"; //$NON-NLS-1$
+ public static final String SELECT = "SELECT"; //$NON-NLS-1$
+ public static final String SENSITIVE = "ROWS"; //$NON-NLS-1$
+ public static final String SESSION_USER = "SESSION_USER"; //$NON-NLS-1$
+ public static final String SET = "SET"; //$NON-NLS-1$
+ public static final String SHORT = "SHORT"; //$NON-NLS-1$
+ public static final String SIILAR = "ROWS"; //$NON-NLS-1$
+ public static final String SMALLINT = "ROWS"; //$NON-NLS-1$
+ public static final String SOME = "SOME"; //$NON-NLS-1$
+ public static final String SPECIFIC = "ROWS"; //$NON-NLS-1$
+ public static final String SQL = "ROWS"; //$NON-NLS-1$
+ public static final String SQLEXCEPTION = "SQLEXCEPTION"; //$NON-NLS-1$
+ public static final String SQLSTATE = "SQLSTATE"; //$NON-NLS-1$
+ public static final String SQLWARNING = "SQLWARNING"; //$NON-NLS-1$
+ public static final String START = "START"; //$NON-NLS-1$
+ public static final String STATIC = "STATIC"; //$NON-NLS-1$
+ public static final String SYSTEM = "SYSTEM"; //$NON-NLS-1$
+ public static final String SYSTEM_USER = "SYSTEM_USER"; //$NON-NLS-1$
+ public static final String SUM = "SUM"; //$NON-NLS-1$
+ public static final String TABLE = "TABLE"; //$NON-NLS-1$
+ public static final String TEMPORARY = "TEMPORARY"; //$NON-NLS-1$
+ public static final String THEN = "THEN"; //$NON-NLS-1$
+ public static final String TIME = "TIME"; //$NON-NLS-1$
+ public static final String TIMESTAMP = "TIMESTAMP"; //$NON-NLS-1$
+ public static final String TIMEZONE_HOUR = "TIMEZONE_HOUR"; //$NON-NLS-1$
+ public static final String TIMEZONE_MINUTE = "TIMEZONE_MINUTE"; //$NON-NLS-1$
+ public static final String TO = "TO"; //$NON-NLS-1$
+ public static final String TRAILING = "TRAILING"; //$NON-NLS-1$
+ public static final String TRANSLATE = "TRANSLATE"; //$NON-NLS-1$
+ public static final String TRIGGER = "TRIGGER"; //$NON-NLS-1$
+ public static final String TRUE = "TRUE"; //$NON-NLS-1$
+ public static final String UNION = "UNION"; //$NON-NLS-1$
+ public static final String UNIQUE = "UNIQUE"; //$NON-NLS-1$
+ public static final String UNKNOWN = "UNKNOWN"; //$NON-NLS-1$
+ public static final String UPDATE = "UPDATE"; //$NON-NLS-1$
+ public static final String USER = "USER"; //$NON-NLS-1$
+ public static final String USING = "USING"; //$NON-NLS-1$
+ public static final String VALUE = "VALUE"; //$NON-NLS-1$
+ public static final String VALUES = "VALUES"; //$NON-NLS-1$
+ public static final String VARCHAR = "VARCHAR"; //$NON-NLS-1$
+ public static final String WHEN = "WHEN"; //$NON-NLS-1$
+ public static final String WHENEVER = "WHENEVER"; //$NON-NLS-1$
+ public static final String WHERE = "WHERE"; //$NON-NLS-1$
+ public static final String WINDOW = "WINDOW"; //$NON-NLS-1$
+ public static final String WITH = "WITH"; //$NON-NLS-1$
+ public static final String WITHIN = "WITHIN"; //$NON-NLS-1$
+ public static final String WITHOUT = "WITHOUT"; //$NON-NLS-1$
+ public static final String YEAR = "YEAR"; //$NON-NLS-1$
+
+ //SQL/XML
+
+ public static final String XML = "XML"; //$NON-NLS-1$
+ public static final String XMLAGG = "XMLAGG"; //$NON-NLS-1$
+ public static final String XMLATTRIBUTES = "XMLATTRIBUTES"; //$NON-NLS-1$
+ public static final String XMLBINARY = "XMLBINARY"; //$NON-NLS-1$
+ public static final String XMLCONCAT = "XMLCONCAT"; //$NON-NLS-1$
+ public static final String XMLCOMMENT = "XMLCOMMENT"; //$NON-NLS-1$
+ public static final String XMLELEMENT = "XMLELEMENT"; //$NON-NLS-1$
+ public static final String XMLFOREST = "XMLFOREST"; //$NON-NLS-1$
+ public static final String XMLNAMESPACES = "XMLNAMESPACES"; //$NON-NLS-1$
+ public static final String XMLPARSE = "XMLPARSE"; //$NON-NLS-1$
+ public static final String XMLPI = "XMLPI"; //$NON-NLS-1$
+ public static final String XMLROOT = "XMLROOT"; //$NON-NLS-1$
+ public static final String XMLSERIALIZE = "XMLSERIALIZE"; //$NON-NLS-1$
+
+ //SQL/MED
+
+ public static final String DATALINK = "DATALINK"; //$NON-NLS-1$
+ public static final String DLNEWCOPY = "DLNEWCOPY"; //$NON-NLS-1$
+ public static final String DLPREVIOUSCOPY = "DLPREVIOUSCOPY"; //$NON-NLS-1$
+ public static final String DLURLCOMPLETE = "DLURLCOMPLETE"; //$NON-NLS-1$
+ public static final String DLURLCOMPLETEWRITE = "DLURELCOMPLETEWRITE"; //$NON-NLS-1$
+ public static final String DLURLCOMPLETEONLY = "DLURLCOMPLETEONLY"; //$NON-NLS-1$
+ public static final String DLURLPATH = "DLURLPATH"; //$NON-NLS-1$
+ public static final String DLURLPATHWRITE = "DLURLPATHWRITE"; //$NON-NLS-1$
+ public static final String DLURLPATHONLY = "DLURLPATHONLY"; //$NON-NLS-1$
+ public static final String DLURLSCHEME = "DLURLSCHEME"; //$NON-NLS-1$
+ public static final String DLURLSERVER = "DLURLSEVER"; //$NON-NLS-1$
+ public static final String DLVALUE = "DLVALUE"; //$NON-NLS-1$
+ public static final String IMPORT = "XMLPI"; //$NON-NLS-1$
+
+ /**
+ * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
+ */
+ private static final Set<String> RESERVED_WORDS = new HashSet<String>();
+
+ // Initialize RESERVED_WORDS set - This is a poor man's enum. To much legacy code expects the constants to be Strings.
+ static {
+ Field[] fields = SQLReservedWords.class.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getType() == String.class) {
+ try {
+ RESERVED_WORDS.add((String)field.get(null));
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ /** Can't construct */
+ private SQLReservedWords() {}
+
+ /**
+ * Check whether a string is a reserved word.
+ * @param str String to check
+ * @return True if reserved word, false if not or null
+ */
+ public static final boolean isReservedWord(String str) {
+ if(str == null) {
+ return false;
+ }
+ return RESERVED_WORDS.contains(str.toUpperCase());
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/ScalarSubquery.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/ScalarSubquery.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/ScalarSubquery.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/ScalarSubquery.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,60 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a scalar subquery. That is, a query that is evaluated as a scalar
+ * expression and returns a single value. The inner subquery must return exactly
+ * 1 column as well.
+ */
+public class ScalarSubquery extends BaseLanguageObject implements Expression, SubqueryContainer {
+
+ private QueryExpression query;
+
+ public ScalarSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+ @Override
+ public QueryExpression getSubquery() {
+ return this.query;
+ }
+
+ @Override
+ public void setSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ @Override
+ public Class<?> getType() {
+ return query.getProjectedQuery().getDerivedColumns().get(0).getExpression().getType();
+ }
+
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SearchedCase.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedCase.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SearchedCase.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SearchedCase.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,69 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a searched CASE expression:
+ * <br/> CASE WHEN criteria THEN expression ... END
+ */
+public class SearchedCase extends BaseLanguageObject implements Expression {
+
+ private List<SearchedWhenClause> cases;
+ private Expression elseExpression;
+ private Class<?> type;
+
+ public SearchedCase(List<SearchedWhenClause> cases, Expression elseExpression, Class<?> type) {
+ this.cases = cases;
+ this.elseExpression = elseExpression;
+ this.type = type;
+ }
+
+ public Expression getElseExpression() {
+ return elseExpression;
+ }
+
+ public List<SearchedWhenClause> getCases() {
+ return cases;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setElseExpression(Expression expression) {
+ this.elseExpression = expression;
+ }
+
+ public Class<?> getType() {
+ return this.type;
+ }
+
+ public void setType(Class<?> type) {
+ this.type = type;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SearchedWhenClause.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SearchedWhenClause.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SearchedWhenClause.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SearchedWhenClause.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,57 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class SearchedWhenClause extends BaseLanguageObject {
+
+ private Condition condition;
+ private Expression result;
+
+ public SearchedWhenClause(Condition condition, Expression result) {
+ this.condition = condition;
+ this.result = result;
+ }
+
+ public Condition getCondition() {
+ return condition;
+ }
+
+ public Expression getResult() {
+ return result;
+ }
+
+ public void setCondition(Condition symbol) {
+ this.condition = symbol;
+ }
+
+ public void setResult(Expression value) {
+ this.result = value;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/language/SearchedWhenClause.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/language/Select.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Select.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Select.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Select.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,139 @@
+/*
+ * 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.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a simple SELECT query.
+ */
+public class Select extends QueryExpression {
+
+ private List<DerivedColumn> derivedColumns;
+ private boolean isDistinct;
+ private List<TableReference> from;
+ private Condition where;
+ private GroupBy groupBy;
+ private Condition having;
+
+ public Select(List<DerivedColumn> derivedColumns, boolean distinct, List<TableReference> from, Condition where,
+ GroupBy groupBy, Condition having, OrderBy orderBy) {
+ this.derivedColumns = derivedColumns;
+ this.isDistinct = distinct;
+ this.from = from;
+ this.where = where;
+ this.groupBy = groupBy;
+ this.having = having;
+ this.setOrderBy(orderBy);
+ }
+
+ public List<DerivedColumn> getDerivedColumns() {
+ return derivedColumns;
+ }
+
+ public boolean isDistinct() {
+ return this.isDistinct;
+ }
+
+ public void setDerivedColumns(List<DerivedColumn> symbols) {
+ this.derivedColumns = symbols;
+ }
+
+ public void setDistinct(boolean distinct) {
+ this.isDistinct = distinct;
+ }
+
+ /**
+ * Get FROM clause, should never be null.
+ * @return From clause object
+ */
+ public List<TableReference> getFrom() {
+ return from;
+ }
+
+ /**
+ * Get WHERE clause, may be null.
+ * @return A criteria object
+ */
+ public Condition getWhere() {
+ return where;
+ }
+
+ /**
+ * Get GROUP BY clause, may be null.
+ * @return A group by object
+ */
+ public GroupBy getGroupBy() {
+ return groupBy;
+ }
+
+ /**
+ * Get HAVING clause, may be null.
+ * @return A criteria object
+ */
+ public Condition getHaving() {
+ return having;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ /**
+ * Set FROM clause, should never be null.
+ * @param from From clause object
+ */
+ public void setFrom(List<TableReference> from) {
+ this.from = from;
+ }
+
+ /**
+ * Set WHERE clause, may be null.
+ * @param criteria A criteria object
+ */
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+ /**
+ * Set GROUP BY clause, may be null.
+ * @param groupBy A group by object
+ */
+ public void setGroupBy(GroupBy groupBy) {
+ this.groupBy = groupBy;
+ }
+
+ /**
+ * Set HAVING clause, may be null.
+ * @param criteria A criteria object
+ */
+ public void setHaving(Condition criteria) {
+ this.having = criteria;
+ }
+
+ public Select getProjectedQuery() {
+ return this;
+ }
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SetClause.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SetClause.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SetClause.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SetClause.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,57 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class SetClause extends BaseLanguageObject {
+
+ private ColumnReference symbol;
+ private Expression value;
+
+ public SetClause(ColumnReference symbol, Expression value) {
+ this.symbol = symbol;
+ this.value = value;
+ }
+
+ public ColumnReference getSymbol() {
+ return symbol;
+ }
+
+ public Expression getValue() {
+ return value;
+ }
+
+ public void setSymbol(ColumnReference symbol) {
+ this.symbol = symbol;
+ }
+
+ public void setValue(Expression value) {
+ this.value = value;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/language/SetClause.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/language/SetQuery.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SetQuery.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SetQuery.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SetQuery.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,116 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class SetQuery extends QueryExpression {
+
+ public enum Operation {
+ /** Represents UNION of two queries */
+ UNION,
+ /** Represents intersection of two queries */
+ INTERSECT,
+ /** Represents set difference of two queries */
+ EXCEPT
+ }
+
+ private boolean all;
+ private QueryExpression leftQuery;
+ private QueryExpression rightQuery;
+ private Operation operation;
+
+ /**
+ * @see org.teiid.language.QueryExpression#getProjectedQuery()
+ */
+ public Select getProjectedQuery() {
+ if (leftQuery instanceof Select) {
+ return (Select)leftQuery;
+ }
+ return leftQuery.getProjectedQuery();
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#getLeftQuery()
+ */
+ public QueryExpression getLeftQuery() {
+ return leftQuery;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#getOperation()
+ */
+ public Operation getOperation() {
+ return operation;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#getRightQuery()
+ */
+ public QueryExpression getRightQuery() {
+ return rightQuery;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#isAll()
+ */
+ public boolean isAll() {
+ return all;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#setAll(boolean)
+ */
+ public void setAll(boolean all) {
+ this.all = all;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#setLeftQuery(org.teiid.language.QueryExpression)
+ */
+ public void setLeftQuery(QueryExpression leftQuery) {
+ this.leftQuery = leftQuery;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#setOperation(org.teiid.language.SetQuery.Operation)
+ */
+ public void setOperation(Operation operation) {
+ this.operation = operation;
+ }
+
+ /**
+ * @see org.teiid.language.SetQuery#setRightQuery(org.teiid.language.QueryExpression)
+ */
+ public void setRightQuery(QueryExpression rightQuery) {
+ this.rightQuery = rightQuery;
+ }
+
+ /**
+ * @see org.teiid.language.LanguageObject#acceptVisitor(com.metamatrix.data.visitor.LanguageObjectVisitor)
+ */
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SortSpecification.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SortSpecification.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SortSpecification.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SortSpecification.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,62 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+public class SortSpecification extends BaseLanguageObject {
+
+ public enum Ordering {
+ ASC,
+ DESC
+ }
+
+ private Ordering ordering;
+ private Expression expression;
+
+ public SortSpecification(Ordering direction, Expression expression) {
+ this.ordering = direction;
+ this.expression = expression;
+ }
+
+ public Ordering getOrdering() {
+ return ordering;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setOrdering(Ordering direction) {
+ this.ordering = direction;
+ }
+
+ public Expression getExpression() {
+ return this.expression;
+ }
+
+ public void setExpression(Expression expression) {
+ this.expression = expression;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SubqueryComparison.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryComparison.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SubqueryComparison.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SubqueryComparison.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,91 @@
+/*
+ * 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.language;
+
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents a quantified comparison criteria. This criteria has an expression on the left,
+ * a comparison operator (such as =, <, etc), a quantification operator (ALL, ANY),
+ * and a subquery.
+ */
+public class SubqueryComparison extends Condition implements Predicate, SubqueryContainer {
+
+ public enum Quantifier {
+ SOME,
+ ALL
+ }
+
+ private Expression leftExpr;
+ private Operator operator;
+ private Quantifier quantifier;
+ private QueryExpression query;
+
+ /**
+ *
+ */
+ public SubqueryComparison(Expression leftExpr, Operator operator, Quantifier quantifier, QueryExpression query) {
+ this.leftExpr = leftExpr;
+ this.operator = operator;
+ this.quantifier = quantifier;
+ this.query = query;
+ }
+
+ public Expression getLeftExpression() {
+ return this.leftExpr;
+ }
+
+ public Operator getOperator() {
+ return this.operator;
+ }
+
+ public Quantifier getQuantifier() {
+ return this.quantifier;
+ }
+
+ public QueryExpression getSubquery() {
+ return this.query;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setLeftExpression(Expression expression) {
+ this.leftExpr = expression;
+ }
+
+ public void setOperator(Operator operator) {
+ this.operator = operator;
+ }
+
+ public void setQuantifier(Quantifier quantifier) {
+ this.quantifier = quantifier;
+ }
+
+ public void setSubquery(QueryExpression query) {
+ this.query = query;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SubqueryContainer.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryContainer.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SubqueryContainer.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SubqueryContainer.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,42 @@
+/*
+ * 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.language;
+
+/**
+ * This is a marker interface for language interfaces that contain a subquery.
+ */
+public interface SubqueryContainer {
+
+ /**
+ * Get the inner subquery
+ * @return Subquery
+ */
+ QueryExpression getSubquery();
+
+ /**
+ * Set the inner subquery
+ * @param query Subquery
+ */
+ void setSubquery(QueryExpression query);
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/SubqueryIn.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/SubqueryIn.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/SubqueryIn.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/SubqueryIn.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,52 @@
+/*
+ * 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.language;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents an IN criteria that uses a subquery on the right side rather than a
+ * list of values.
+ */
+public class SubqueryIn extends BaseInCondition implements SubqueryContainer {
+
+ private QueryExpression rightQuery;
+
+ public SubqueryIn(Expression leftExpr, boolean isNegated, QueryExpression rightQuery) {
+ super(leftExpr, isNegated);
+ this.rightQuery = rightQuery;
+ }
+
+ public QueryExpression getSubquery() {
+ return this.rightQuery;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setSubquery(QueryExpression query) {
+ this.rightQuery = query;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/TableReference.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/TableReference.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/TableReference.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/TableReference.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,30 @@
+/*
+ * 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.language;
+
+/**
+ * Represents an item in the FROM clause
+ */
+public interface TableReference extends LanguageObject {
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/Update.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/language/Update.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/Update.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/Update.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.language;
+
+import java.util.List;
+
+import org.teiid.language.visitor.LanguageObjectVisitor;
+
+/**
+ * Represents an UPDATE command in the language objects.
+ */
+public class Update extends BaseLanguageObject implements Command {
+
+ private NamedTable table;
+ private List<SetClause> changes;
+ private Condition where;
+
+ public Update(NamedTable group, List<SetClause> changes, Condition criteria) {
+ this.table = group;
+ this.changes = changes;
+ this.where = criteria;
+ }
+
+ public NamedTable getTable() {
+ return table;
+ }
+
+ public List<SetClause> getChanges() {
+ return changes;
+ }
+
+ public Condition getWhere() {
+ return where;
+ }
+
+ public void acceptVisitor(LanguageObjectVisitor visitor) {
+ visitor.visit(this);
+ }
+
+ public void setTable(NamedTable group) {
+ this.table = group;
+ }
+
+ public void setChanges(List<SetClause> changes) {
+ this.changes = changes;
+ }
+
+ public void setWhere(Condition criteria) {
+ this.where = criteria;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/language/visitor (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework)
Modified: trunk/connector-api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/AbstractLanguageVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/language/visitor/AbstractLanguageVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,45 +20,45 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.visitor.framework;
+package org.teiid.language.visitor;
import java.util.Collection;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.DerivedTable;
-import org.teiid.connector.language.Exists;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.GroupBy;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.IsNull;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Not;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.ScalarSubquery;
-import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.SearchedWhenClause;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetQuery;
-import org.teiid.connector.language.SortSpecification;
-import org.teiid.connector.language.SubqueryComparison;
-import org.teiid.connector.language.SubqueryIn;
-import org.teiid.connector.language.Update;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.Argument;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Delete;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.GroupBy;
+import org.teiid.language.In;
+import org.teiid.language.Insert;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Like;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.OrderBy;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SetClause;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.Update;
/**
Copied: trunk/connector-api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/CollectorVisitor.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/visitor/CollectorVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,284 @@
+/*
+ * 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.language.visitor;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.Argument;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Delete;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.GroupBy;
+import org.teiid.language.In;
+import org.teiid.language.Insert;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Like;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.OrderBy;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SetClause;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.Update;
+
+
+/**
+ * This visitor can be used to collect all objects of a certain type in a language
+ * tree. Each visit method does an instanceof method to check whether the object
+ * is of the expected type.
+ */
+public class CollectorVisitor<T> implements LanguageObjectVisitor {
+
+ private Class<T> type;
+ private Collection<T> objects = new ArrayList<T>();
+
+ public CollectorVisitor(Class<T> type) {
+ this.type = type;
+ }
+
+ @SuppressWarnings("unchecked")
+ private void checkInstance(LanguageObject obj) {
+ if(type.isInstance(obj)) {
+ this.objects.add((T)obj);
+ }
+ }
+
+ public Collection<T> getCollectedObjects() {
+ return this.objects;
+ }
+
+ public void visit(AggregateFunction obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(BatchedUpdates obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Comparison obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(AndOr obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Delete obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(ColumnReference obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Exists obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Function obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(NamedTable obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(GroupBy obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(In obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(DerivedTable obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Insert obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(ExpressionValueSource obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(IsNull obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Join obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Like obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Limit obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Literal obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Not obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(OrderBy obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(SortSpecification obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Argument obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Call obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Select obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(ScalarSubquery obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(SearchedCase obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(DerivedColumn obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(SubqueryComparison obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(SubqueryIn obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(Update obj) {
+ checkInstance(obj);
+ }
+
+ public void visit(SetQuery obj) {
+ checkInstance(obj);
+ }
+
+ @Override
+ public void visit(SetClause obj) {
+ checkInstance(obj);
+ }
+
+ @Override
+ public void visit(SearchedWhenClause obj) {
+ checkInstance(obj);
+ }
+
+ /**
+ * This is a utility method to instantiate and run the visitor in conjunction
+ * with a HierarchyVisitor to collect all objects of the specified type
+ * of the specified tree in the language object tree.
+ * @param type Language object type to look for
+ * @param object Root of the language object tree
+ * @return Collection of ILanguageObject of the specified type
+ */
+ public static <T> Collection<T> collectObjects(Class<T> type, LanguageObject object) {
+ CollectorVisitor<T> visitor = new CollectorVisitor<T>(type);
+ DelegatingHierarchyVisitor hierarchyVisitor = new DelegatingHierarchyVisitor(visitor, null);
+ object.acceptVisitor(hierarchyVisitor);
+ return visitor.getCollectedObjects();
+ }
+
+ /**
+ * This is a utility method for a common use of this visitor, which is to collect
+ * all elements in an object tree.
+ * @param type Language object type to look for
+ * @param object Root of the language object tree
+ * @return Collection of IElement of the specified type
+ */
+ public static Collection<ColumnReference> collectElements(LanguageObject object) {
+ return CollectorVisitor.collectObjects(ColumnReference.class, object);
+ }
+
+ /**
+ * This is a utility method for a common use of this visitor, which is to collect
+ * all groups in an object tree.
+ * @param type Language object type to look for
+ * @param object Root of the language object tree
+ * @return Collection of IGroup of the specified type
+ */
+ public static Collection<NamedTable> collectGroups(LanguageObject object) {
+ return CollectorVisitor.collectObjects(NamedTable.class, object);
+ }
+
+ /**
+ * This is a utility method for a common use of this visitor, which is to collect
+ * all groups used by all elements in an object tree.
+ * @param type Language object type to look for
+ * @param object Root of the language object tree
+ * @return Set of IGroup
+ */
+ public static Set<NamedTable> collectGroupsUsedByElements(LanguageObject object) {
+ Set<NamedTable> groups = new HashSet<NamedTable>();
+ for (ColumnReference element : CollectorVisitor.collectElements(object)) {
+ if(element.getTable() != null) {
+ groups.add(element.getTable());
+ }
+ }
+ return groups;
+ }
+
+}
Modified: trunk/connector-api/src/main/java/org/teiid/language/visitor/DelegatingHierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/DelegatingHierarchyVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/language/visitor/DelegatingHierarchyVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,43 +20,43 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.visitor.framework;
+package org.teiid.language.visitor;
import org.teiid.connector.DataPlugin;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.DerivedTable;
-import org.teiid.connector.language.Exists;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.GroupBy;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.IsNull;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Not;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.ScalarSubquery;
-import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.SearchedWhenClause;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetQuery;
-import org.teiid.connector.language.SortSpecification;
-import org.teiid.connector.language.SubqueryComparison;
-import org.teiid.connector.language.SubqueryIn;
-import org.teiid.connector.language.Update;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.Argument;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Delete;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.Function;
+import org.teiid.language.GroupBy;
+import org.teiid.language.In;
+import org.teiid.language.Insert;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Like;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.OrderBy;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SetClause;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.Update;
/**
* Delegates pre- and post-processing for each node in the hierarchy to
Modified: trunk/connector-api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/HierarchyVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/language/visitor/HierarchyVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,37 +20,37 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.visitor.framework;
+package org.teiid.language.visitor;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.DerivedTable;
-import org.teiid.connector.language.Exists;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.GroupBy;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.IsNull;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Not;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.ScalarSubquery;
-import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.SearchedWhenClause;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SetQuery;
-import org.teiid.connector.language.SubqueryComparison;
-import org.teiid.connector.language.SubqueryIn;
-import org.teiid.connector.language.Update;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Call;
+import org.teiid.language.Comparison;
+import org.teiid.language.Delete;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.GroupBy;
+import org.teiid.language.In;
+import org.teiid.language.Insert;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.Like;
+import org.teiid.language.Not;
+import org.teiid.language.OrderBy;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SetClause;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.Update;
/**
* Visits each node in a hierarchy of ILanguageObjects. The default
Modified: trunk/connector-api/src/main/java/org/teiid/language/visitor/LanguageObjectVisitor.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/visitor/framework/LanguageObjectVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/language/visitor/LanguageObjectVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.visitor.framework;
+package org.teiid.language.visitor;
-import org.teiid.connector.language.*;
+import org.teiid.language.*;
/**
*/
Copied: trunk/connector-api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/connector/visitor/util/SQLStringVisitor.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/language/visitor/SQLStringVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,903 @@
+/*
+ * 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.language.visitor;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.StringUtil;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Delete;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.GroupBy;
+import org.teiid.language.In;
+import org.teiid.language.Insert;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Like;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.OrderBy;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SetClause;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.TableReference;
+import org.teiid.language.Update;
+import org.teiid.language.Argument.Direction;
+import org.teiid.language.SQLReservedWords.Tokens;
+import org.teiid.language.SortSpecification.Ordering;
+import org.teiid.metadata.AbstractMetadataRecord;
+
+
+/**
+ * Creates a SQL string for a LanguageObject subtree. Instances of this class
+ * are not reusable, and are not thread-safe.
+ */
+public class SQLStringVisitor extends AbstractLanguageVisitor {
+
+ private Set<String> infixFunctions = new HashSet<String>(Arrays.asList("%", "+", "-", "*", "+", "/", "||", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ "&", "|", "^", "#")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ protected static final String UNDEFINED = "<undefined>"; //$NON-NLS-1$
+ protected static final String UNDEFINED_PARAM = "?"; //$NON-NLS-1$
+
+ protected StringBuilder buffer = new StringBuilder();
+
+ /**
+ * Gets the name of a group or element from the RuntimeMetadata
+ * @param id the id of the group or element
+ * @return the name of that element or group as defined in the source
+ */
+ protected String getName(AbstractMetadataRecord object) {
+ String nameInSource = object.getNameInSource();
+ if(nameInSource != null && nameInSource.length() > 0) {
+ return nameInSource;
+ }
+ return object.getName();
+ }
+
+ /**
+ * Appends the string form of the ILanguageObject to the current buffer.
+ * @param obj the language object instance
+ */
+ public void append(LanguageObject obj) {
+ if (obj == null) {
+ buffer.append(UNDEFINED);
+ } else {
+ visitNode(obj);
+ }
+ }
+
+ /**
+ * Simple utility to append a list of language objects to the current buffer
+ * by creating a comma-separated list.
+ * @param items a list of ILanguageObjects
+ */
+ protected void append(List<? extends LanguageObject> items) {
+ if (items != null && items.size() != 0) {
+ append(items.get(0));
+ for (int i = 1; i < items.size(); i++) {
+ buffer.append(Tokens.COMMA)
+ .append(Tokens.SPACE);
+ append(items.get(i));
+ }
+ }
+ }
+
+ /**
+ * Simple utility to append an array of language objects to the current buffer
+ * by creating a comma-separated list.
+ * @param items an array of ILanguageObjects
+ */
+ protected void append(LanguageObject[] items) {
+ if (items != null && items.length != 0) {
+ append(items[0]);
+ for (int i = 1; i < items.length; i++) {
+ buffer.append(Tokens.COMMA)
+ .append(Tokens.SPACE);
+ append(items[i]);
+ }
+ }
+ }
+
+ /**
+ * Creates a SQL-safe string. Simply replaces all occurrences of ' with ''
+ * @param str the input string
+ * @return a SQL-safe string
+ */
+ protected String escapeString(String str, String quote) {
+ return StringUtil.replaceAll(str, quote, quote + quote);
+ }
+
+ public String toString() {
+ return buffer.toString();
+ }
+
+ public void visit(AggregateFunction obj) {
+ buffer.append(obj.getName())
+ .append(Tokens.LPAREN);
+
+ if ( obj.isDistinct()) {
+ buffer.append(SQLReservedWords.DISTINCT)
+ .append(Tokens.SPACE);
+ }
+
+ if (obj.getExpression() == null) {
+ buffer.append(Tokens.ALL_COLS);
+ } else {
+ append(obj.getExpression());
+ }
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(Comparison obj) {
+ append(obj.getLeftExpression());
+ buffer.append(Tokens.SPACE);
+ buffer.append(obj.getOperator());
+ buffer.append(Tokens.SPACE);
+ append(obj.getRightExpression());
+ }
+
+ public void visit(AndOr obj) {
+ String opString = obj.getOperator().toString();
+
+ appendNestedCondition(obj, obj.getLeftCondition());
+ buffer.append(Tokens.SPACE)
+ .append(opString)
+ .append(Tokens.SPACE);
+ appendNestedCondition(obj, obj.getRightCondition());
+ }
+
+ protected void appendNestedCondition(AndOr parent, Condition condition) {
+ if (condition instanceof AndOr) {
+ AndOr nested = (AndOr)condition;
+ if (nested.getOperator() != parent.getOperator()) {
+ buffer.append(Tokens.LPAREN);
+ append(condition);
+ buffer.append(Tokens.RPAREN);
+ return;
+ }
+ }
+ append(condition);
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.language.Delete)
+ */
+ public void visit(Delete obj) {
+ buffer.append(SQLReservedWords.DELETE)
+ .append(Tokens.SPACE);
+ buffer.append(getSourceComment(obj));
+ buffer.append(SQLReservedWords.FROM)
+ .append(Tokens.SPACE);
+ append(obj.getTable());
+ if (obj.getWhere() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.WHERE)
+ .append(Tokens.SPACE);
+ append(obj.getWhere());
+ }
+ }
+
+ /**
+ * 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
+ * the group name if the group is a pseudo-group (DUAL) or the element is a pseudo-group
+ * (ROWNUM). It may also be used to strip special information out of the name in source
+ * value in some specialized cases.
+ *
+ * By default, this method returns null, indicating that the normal group and element
+ * name logic should be used (group + "." + element). Subclasses should override and
+ * implement this method if desired.
+ *
+ * @param group Group name, may be null
+ * @param element Element name, never null
+ * @return Replacement element name to be used as is (no modification will occur)
+ * @since 5.0
+ */
+ protected String replaceElementName(String group, String element) {
+ return null;
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.language.ColumnReference)
+ */
+ public void visit(ColumnReference obj) {
+ buffer.append(getElementName(obj, true));
+ }
+
+ private String getElementName(ColumnReference obj, boolean qualify) {
+ String groupName = null;
+ NamedTable group = obj.getTable();
+ if (group != null && qualify) {
+ if(group.getCorrelationName() != null) {
+ groupName = group.getCorrelationName();
+ } else {
+ AbstractMetadataRecord groupID = group.getMetadataObject();
+ if(groupID != null) {
+ groupName = getName(groupID);
+ } else {
+ groupName = group.getName();
+ }
+ }
+ }
+
+ String elemShortName = null;
+ AbstractMetadataRecord elementID = obj.getMetadataObject();
+ if(elementID != null) {
+ elemShortName = getName(elementID);
+ } else {
+ String elementName = obj.getName();
+ elemShortName = getShortName(elementName);
+ }
+
+ // Check whether a subclass wants to replace the element name to use in special circumstances
+ String replacementElement = replaceElementName(groupName, elemShortName);
+ if(replacementElement != null) {
+ // If so, use it as is
+ return replacementElement;
+ }
+ StringBuffer elementName = new StringBuffer(elemShortName.length());
+ // If not, do normal logic: [group + "."] + element
+ if(groupName != null) {
+ elementName.append(groupName);
+ elementName.append(Tokens.DOT);
+ }
+ elementName.append(elemShortName);
+ return elementName.toString();
+ }
+
+ /**
+ * @param elementName
+ * @return
+ * @since 4.3
+ */
+ public static String getShortName(String elementName) {
+ int lastDot = elementName.lastIndexOf("."); //$NON-NLS-1$
+ if(lastDot >= 0) {
+ elementName = elementName.substring(lastDot+1);
+ }
+ return elementName;
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExecute)
+ */
+ public void visit(Call obj) {
+ buffer.append(SQLReservedWords.EXEC)
+ .append(Tokens.SPACE);
+
+ if(obj.getMetadataObject() != null) {
+ buffer.append(getName(obj.getMetadataObject()));
+ } else {
+ buffer.append(obj.getProcedureName());
+ }
+
+ buffer.append(Tokens.LPAREN);
+ final List<Argument> params = obj.getArguments();
+ if (params != null && params.size() != 0) {
+ Argument param = null;
+ for (int i = 0; i < params.size(); i++) {
+ param = params.get(i);
+ if (param.getDirection() == Direction.IN || param.getDirection() == Direction.INOUT) {
+ if (i != 0) {
+ buffer.append(Tokens.COMMA)
+ .append(Tokens.SPACE);
+ }
+ append(param);
+ }
+ }
+ }
+ buffer.append(Tokens.RPAREN);
+ }
+
+ /*
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(com.metamatrix.data.language.IExistsCriteria)
+ */
+ public void visit(Exists obj) {
+ buffer.append(SQLReservedWords.EXISTS)
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ protected boolean isInfixFunction(String function) {
+ return infixFunctions.contains(function);
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.language.Function)
+ */
+ public void visit(Function obj) {
+
+ String name = obj.getName();
+ List<Expression> args = obj.getParameters();
+ if(name.equalsIgnoreCase(SQLReservedWords.CONVERT) || name.equalsIgnoreCase(SQLReservedWords.CAST)) {
+
+ Object typeValue = ((Literal)args.get(1)).getValue();
+
+ buffer.append(name);
+ buffer.append(Tokens.LPAREN);
+
+ append(args.get(0));
+
+ if(name.equalsIgnoreCase(SQLReservedWords.CONVERT)) {
+ buffer.append(Tokens.COMMA);
+ buffer.append(Tokens.SPACE);
+ } else {
+ buffer.append(Tokens.SPACE);
+ buffer.append(SQLReservedWords.AS);
+ buffer.append(Tokens.SPACE);
+ }
+ buffer.append(typeValue);
+ buffer.append(Tokens.RPAREN);
+ } else if(isInfixFunction(name)) {
+ buffer.append(Tokens.LPAREN);
+
+ if(args != null) {
+ for(int i=0; i<args.size(); i++) {
+ append(args.get(i));
+ if(i < (args.size()-1)) {
+ buffer.append(Tokens.SPACE);
+ buffer.append(name);
+ buffer.append(Tokens.SPACE);
+ }
+ }
+ }
+ buffer.append(Tokens.RPAREN);
+
+ } else if(name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPADD) || name.equalsIgnoreCase(SQLReservedWords.TIMESTAMPDIFF)) {
+ buffer.append(name);
+ buffer.append(Tokens.LPAREN);
+
+ if(args != null && args.size() > 0) {
+ buffer.append(((Literal)args.get(0)).getValue());
+
+ for(int i=1; i<args.size(); i++) {
+ buffer.append(Tokens.COMMA);
+ buffer.append(Tokens.SPACE);
+ append(args.get(i));
+ }
+ }
+ buffer.append(Tokens.RPAREN);
+
+ } else {
+
+ buffer.append(obj.getName())
+ .append(Tokens.LPAREN);
+ append(obj.getParameters());
+ buffer.append(Tokens.RPAREN);
+ }
+ }
+
+ public void visit(NamedTable obj) {
+ AbstractMetadataRecord groupID = obj.getMetadataObject();
+ if(groupID != null) {
+ buffer.append(getName(groupID));
+ } else {
+ buffer.append(obj.getName());
+ }
+
+ if (obj.getCorrelationName() != null) {
+ buffer.append(Tokens.SPACE);
+ if (useAsInGroupAlias()){
+ buffer.append(SQLReservedWords.AS)
+ .append(Tokens.SPACE);
+ }
+ buffer.append(obj.getCorrelationName());
+ }
+ }
+
+ /**
+ * Indicates whether group alias should be of the form
+ * "...FROM groupA AS X" or "...FROM groupA X". Certain
+ * data sources (such as Oracle) may not support the first
+ * form.
+ * @return boolean
+ */
+ protected boolean useAsInGroupAlias(){
+ return true;
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.language.GroupBy)
+ */
+ public void visit(GroupBy obj) {
+ buffer.append(SQLReservedWords.GROUP)
+ .append(Tokens.SPACE)
+ .append(SQLReservedWords.BY)
+ .append(Tokens.SPACE);
+ append(obj.getElements());
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.language.In)
+ */
+ public void visit(In obj) {
+ append(obj.getLeftExpression());
+ if (obj.isNegated()) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.NOT);
+ }
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.IN)
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
+ append(obj.getRightExpressions());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(DerivedTable obj) {
+ buffer.append(Tokens.LPAREN);
+ append(obj.getQuery());
+ buffer.append(Tokens.RPAREN);
+ buffer.append(Tokens.SPACE);
+ if(useAsInGroupAlias()) {
+ buffer.append(SQLReservedWords.AS);
+ buffer.append(Tokens.SPACE);
+ }
+ buffer.append(obj.getCorrelationName());
+ }
+
+ /**
+ * @see com.metamatrix.data.visitor.LanguageObjectVisitor#visit(org.teiid.language.Insert)
+ */
+ public void visit(Insert obj) {
+ buffer.append(SQLReservedWords.INSERT).append(Tokens.SPACE);
+ buffer.append(getSourceComment(obj));
+ buffer.append(SQLReservedWords.INTO).append(Tokens.SPACE);
+ append(obj.getTable());
+ buffer.append(Tokens.SPACE).append(Tokens.LPAREN);
+
+ int elementCount = obj.getColumns().size();
+ for (int i = 0; i < elementCount; i++) {
+ buffer.append(getElementName(obj.getColumns().get(i), false));
+ if (i < elementCount - 1) {
+ buffer.append(Tokens.COMMA);
+ buffer.append(Tokens.SPACE);
+ }
+ }
+
+ buffer.append(Tokens.RPAREN);
+ buffer.append(Tokens.SPACE);
+ append(obj.getValueSource());
+ }
+
+ @Override
+ public void visit(ExpressionValueSource obj) {
+ buffer.append(SQLReservedWords.VALUES).append(Tokens.SPACE).append(Tokens.LPAREN);
+ append(obj.getValues());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(IsNull obj) {
+ append(obj.getExpression());
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.IS)
+ .append(Tokens.SPACE);
+ if (obj.isNegated()) {
+ buffer.append(SQLReservedWords.NOT)
+ .append(Tokens.SPACE);
+ }
+ buffer.append(SQLReservedWords.NULL);
+ }
+
+ public void visit(Join obj) {
+ TableReference leftItem = obj.getLeftItem();
+ if(useParensForJoins() && leftItem instanceof Join) {
+ buffer.append(Tokens.LPAREN);
+ append(leftItem);
+ buffer.append(Tokens.RPAREN);
+ } else {
+ append(leftItem);
+ }
+ buffer.append(Tokens.SPACE);
+
+ switch(obj.getJoinType()) {
+ case CROSS_JOIN:
+ buffer.append(SQLReservedWords.CROSS);
+ break;
+ case FULL_OUTER_JOIN:
+ buffer.append(SQLReservedWords.FULL)
+ .append(Tokens.SPACE)
+ .append(SQLReservedWords.OUTER);
+ break;
+ case INNER_JOIN:
+ buffer.append(SQLReservedWords.INNER);
+ break;
+ case LEFT_OUTER_JOIN:
+ buffer.append(SQLReservedWords.LEFT)
+ .append(Tokens.SPACE)
+ .append(SQLReservedWords.OUTER);
+ break;
+ case RIGHT_OUTER_JOIN:
+ buffer.append(SQLReservedWords.RIGHT)
+ .append(Tokens.SPACE)
+ .append(SQLReservedWords.OUTER);
+ break;
+ default: buffer.append(UNDEFINED);
+ }
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.JOIN)
+ .append(Tokens.SPACE);
+
+ TableReference rightItem = obj.getRightItem();
+ if(rightItem instanceof Join && (useParensForJoins() || obj.getJoinType() == Join.JoinType.CROSS_JOIN)) {
+ buffer.append(Tokens.LPAREN);
+ append(rightItem);
+ buffer.append(Tokens.RPAREN);
+ } else {
+ append(rightItem);
+ }
+
+ final Condition condition = obj.getCondition();
+ if (condition != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.ON)
+ .append(Tokens.SPACE);
+ append(condition);
+ }
+ }
+
+ public void visit(Like obj) {
+ append(obj.getLeftExpression());
+ if (obj.isNegated()) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.NOT);
+ }
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.LIKE)
+ .append(Tokens.SPACE);
+ append(obj.getRightExpression());
+ if (obj.getEscapeCharacter() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.ESCAPE)
+ .append(Tokens.SPACE)
+ .append(Tokens.QUOTE)
+ .append(obj.getEscapeCharacter().toString())
+ .append(Tokens.QUOTE);
+ }
+
+ }
+
+ public void visit(Limit obj) {
+ buffer.append(SQLReservedWords.LIMIT)
+ .append(Tokens.SPACE);
+ if (obj.getRowOffset() > 0) {
+ buffer.append(obj.getRowOffset())
+ .append(Tokens.COMMA)
+ .append(Tokens.SPACE);
+ }
+ buffer.append(obj.getRowLimit());
+ }
+
+ public void visit(Literal obj) {
+ if (obj.isBindValue()) {
+ buffer.append("?"); //$NON-NLS-1$
+ } else if (obj.getValue() == null) {
+ buffer.append(SQLReservedWords.NULL);
+ } else {
+ Class<?> type = obj.getType();
+ String val = obj.getValue().toString();
+ if(Number.class.isAssignableFrom(type)) {
+ buffer.append(val);
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.BOOLEAN)) {
+ buffer.append("{b '") //$NON-NLS-1$
+ .append(val)
+ .append("'}"); //$NON-NLS-1$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.TIMESTAMP)) {
+ buffer.append("{ts '") //$NON-NLS-1$
+ .append(val)
+ .append("'}"); //$NON-NLS-1$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.TIME)) {
+ buffer.append("{t '") //$NON-NLS-1$
+ .append(val)
+ .append("'}"); //$NON-NLS-1$
+ } else if(type.equals(DataTypeManager.DefaultDataClasses.DATE)) {
+ buffer.append("{d '") //$NON-NLS-1$
+ .append(val)
+ .append("'}"); //$NON-NLS-1$
+ } else {
+ buffer.append(Tokens.QUOTE)
+ .append(escapeString(val, Tokens.QUOTE))
+ .append(Tokens.QUOTE);
+ }
+ }
+ }
+
+ public void visit(Not obj) {
+ buffer.append(SQLReservedWords.NOT)
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
+ append(obj.getCriteria());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(OrderBy obj) {
+ buffer.append(SQLReservedWords.ORDER)
+ .append(Tokens.SPACE)
+ .append(SQLReservedWords.BY)
+ .append(Tokens.SPACE);
+ append(obj.getSortSpecifications());
+ }
+
+ public void visit(SortSpecification obj) {
+ append(obj.getExpression());
+ if (obj.getOrdering() == Ordering.DESC) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.DESC);
+ } // Don't print default "ASC"
+ }
+
+ public void visit(Argument obj) {
+ buffer.append(obj.getArgumentValue());
+ }
+
+ public void visit(Select obj) {
+ buffer.append(SQLReservedWords.SELECT).append(Tokens.SPACE);
+ buffer.append(getSourceComment(obj));
+ if (obj.isDistinct()) {
+ buffer.append(SQLReservedWords.DISTINCT).append(Tokens.SPACE);
+ }
+ if (useSelectLimit() && obj.getLimit() != null) {
+ append(obj.getLimit());
+ buffer.append(Tokens.SPACE);
+ }
+ append(obj.getDerivedColumns());
+ if (obj.getFrom() != null && !obj.getFrom().isEmpty()) {
+ buffer.append(Tokens.SPACE).append(SQLReservedWords.FROM).append(Tokens.SPACE);
+ append(obj.getFrom());
+ }
+ if (obj.getWhere() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.WHERE)
+ .append(Tokens.SPACE);
+ append(obj.getWhere());
+ }
+ if (obj.getGroupBy() != null) {
+ buffer.append(Tokens.SPACE);
+ append(obj.getGroupBy());
+ }
+ if (obj.getHaving() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.HAVING)
+ .append(Tokens.SPACE);
+ append(obj.getHaving());
+ }
+ if (obj.getOrderBy() != null) {
+ buffer.append(Tokens.SPACE);
+ append(obj.getOrderBy());
+ }
+ if (!useSelectLimit() && obj.getLimit() != null) {
+ buffer.append(Tokens.SPACE);
+ append(obj.getLimit());
+ }
+ }
+
+ public void visit(SearchedCase obj) {
+ buffer.append(SQLReservedWords.CASE);
+ for (SearchedWhenClause swc : obj.getCases()) {
+ append(swc);
+ }
+ if (obj.getElseExpression() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.ELSE)
+ .append(Tokens.SPACE);
+ append(obj.getElseExpression());
+ }
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.END);
+ }
+
+ @Override
+ public void visit(SearchedWhenClause obj) {
+ buffer.append(Tokens.SPACE).append(SQLReservedWords.WHEN)
+ .append(Tokens.SPACE);
+ append(obj.getCondition());
+ buffer.append(Tokens.SPACE).append(SQLReservedWords.THEN)
+ .append(Tokens.SPACE);
+ append(obj.getResult());
+ }
+
+ protected String getSourceComment(Command command) {
+ return ""; //$NON-NLS-1$
+ }
+
+ public void visit(ScalarSubquery obj) {
+ buffer.append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(DerivedColumn obj) {
+ append(obj.getExpression());
+ if (obj.getAlias() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.AS)
+ .append(Tokens.SPACE)
+ .append(obj.getAlias());
+ }
+ }
+
+ public void visit(SubqueryComparison obj) {
+ append(obj.getLeftExpression());
+ buffer.append(Tokens.SPACE);
+
+ switch(obj.getOperator()) {
+ case EQ: buffer.append(Tokens.EQ); break;
+ case GE: buffer.append(Tokens.GE); break;
+ case GT: buffer.append(Tokens.GT); break;
+ case LE: buffer.append(Tokens.LE); break;
+ case LT: buffer.append(Tokens.LT); break;
+ case NE: buffer.append(Tokens.NE); break;
+ default: buffer.append(UNDEFINED);
+ }
+ buffer.append(Tokens.SPACE);
+ switch(obj.getQuantifier()) {
+ case ALL: buffer.append(SQLReservedWords.ALL); break;
+ case SOME: buffer.append(SQLReservedWords.SOME); break;
+ default: buffer.append(UNDEFINED);
+ }
+ buffer.append(Tokens.SPACE);
+ buffer.append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(SubqueryIn obj) {
+ append(obj.getLeftExpression());
+ if (obj.isNegated()) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.NOT);
+ }
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.IN)
+ .append(Tokens.SPACE)
+ .append(Tokens.LPAREN);
+ append(obj.getSubquery());
+ buffer.append(Tokens.RPAREN);
+ }
+
+ public void visit(Update obj) {
+ buffer.append(SQLReservedWords.UPDATE)
+ .append(Tokens.SPACE);
+ buffer.append(getSourceComment(obj));
+ append(obj.getTable());
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.SET)
+ .append(Tokens.SPACE);
+ append(obj.getChanges());
+ if (obj.getWhere() != null) {
+ buffer.append(Tokens.SPACE)
+ .append(SQLReservedWords.WHERE)
+ .append(Tokens.SPACE);
+ append(obj.getWhere());
+ }
+ }
+
+ public void visit(SetClause clause) {
+ buffer.append(getElementName(clause.getSymbol(), false));
+ buffer.append(Tokens.SPACE).append(Tokens.EQ).append(Tokens.SPACE);
+ append(clause.getValue());
+ }
+
+ public void visit(SetQuery obj) {
+ appendSetQuery(obj, obj.getLeftQuery(), false);
+
+ buffer.append(Tokens.SPACE);
+
+ appendSetOperation(obj.getOperation());
+
+ if(obj.isAll()) {
+ buffer.append(Tokens.SPACE);
+ buffer.append(SQLReservedWords.ALL);
+ }
+ buffer.append(Tokens.SPACE);
+
+ appendSetQuery(obj, obj.getRightQuery(), true);
+
+ OrderBy orderBy = obj.getOrderBy();
+ if(orderBy != null) {
+ buffer.append(Tokens.SPACE);
+ append(orderBy);
+ }
+
+ Limit limit = obj.getLimit();
+ if(limit != null) {
+ buffer.append(Tokens.SPACE);
+ append(limit);
+ }
+ }
+
+ protected void appendSetOperation(SetQuery.Operation operation) {
+ buffer.append(operation);
+ }
+
+ protected boolean useParensForSetQueries() {
+ return false;
+ }
+
+ protected void appendSetQuery(SetQuery parent, QueryExpression obj, boolean right) {
+ if((!(obj instanceof SetQuery) && useParensForSetQueries())
+ || (right && obj instanceof SetQuery
+ && ((parent.isAll() && !((SetQuery)obj).isAll())
+ || parent.getOperation() != ((SetQuery)obj).getOperation()))) {
+ buffer.append(Tokens.LPAREN);
+ append(obj);
+ buffer.append(Tokens.RPAREN);
+ } else {
+ if (!parent.isAll() && obj instanceof SetQuery) {
+ ((SetQuery)obj).setAll(false);
+ }
+ append(obj);
+ }
+ }
+
+ /**
+ * Gets the SQL string representation for a given ILanguageObject.
+ * @param obj the root of the ILanguageObject hierarchy that needs to be
+ * converted. This can be any subtree, and does not need to be a top-level
+ * command
+ * @return the SQL representation of that ILanguageObject hierarchy
+ */
+ public static String getSQLString(LanguageObject obj) {
+ SQLStringVisitor visitor = new SQLStringVisitor();
+ visitor.append(obj);
+ return visitor.toString();
+ }
+
+ protected boolean useParensForJoins() {
+ return false;
+ }
+
+ protected boolean useSelectLimit() {
+ return false;
+ }
+}
Modified: trunk/connector-api/src/main/java/org/teiid/logging/CommandLogMessage.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/logging/CommandLogMessage.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/logging/CommandLogMessage.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.text.DateFormat;
import java.util.Date;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ExecutionContext;
/**
* Log Message for source and user command events.
Copied: trunk/connector-api/src/main/java/org/teiid/metadata (from rev 2113, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime)
Deleted: trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,165 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.io.Serializable;
-import java.util.Collections;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.concurrent.atomic.AtomicLong;
-
-import com.metamatrix.core.util.EquivalenceUtil;
-
-/**
- * AbstractMetadataRecord
- */
-public abstract class AbstractMetadataRecord implements Serializable {
-
- private static final long serialVersionUID = 564092984812414058L;
-
- public final static char NAME_DELIM_CHAR = '.';
-
- private static AtomicLong UUID_SEQUENCE = new AtomicLong();
-
- private String uuid; //globally unique id
- private String name; //contextually unique name
-
- private String nameInSource;
-
- private LinkedHashMap<String, String> properties;
- private String annotation;
-
- public String getUUID() {
- if (uuid == null) {
- uuid = String.valueOf(UUID_SEQUENCE.getAndIncrement());
- }
- return uuid;
- }
-
- public void setUUID(String uuid) {
- this.uuid = uuid;
- }
-
- public String getNameInSource() {
- return nameInSource;
- }
-
- public void setNameInSource(String nameInSource) {
- this.nameInSource = nameInSource;
- }
-
- /**
- * WARNING - The name returned by this method may be ambiguous and
- * is not SQL safe - it may need quoted/escaped
- */
- public String getFullName() {
- AbstractMetadataRecord parent = getParent();
- if (parent != null) {
- return parent.getFullName() + NAME_DELIM_CHAR + getName();
- }
- return name;
- }
-
- public AbstractMetadataRecord getParent() {
- return null;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String toString() {
- StringBuffer sb = new StringBuffer(100);
- sb.append(getClass().getSimpleName());
- sb.append(" name="); //$NON-NLS-1$
- sb.append(getName());
- sb.append(", nameInSource="); //$NON-NLS-1$
- sb.append(getNameInSource());
- sb.append(", uuid="); //$NON-NLS-1$
- sb.append(getUUID());
- return sb.toString();
- }
-
- /**
- * Return the extension properties for this record - may be unmodifiable
- * if {@link #setProperties(LinkedHashMap)} or {@link #setProperty(String, String)}
- * has not been called.
- * @return
- */
- public Map<String, String> getProperties() {
- if (properties == null) {
- return Collections.emptyMap();
- }
- return properties;
- }
-
- /**
- * The preferred setter for extension properties.
- * @param key
- * @param value
- */
- public void setProperty(String key, String value) {
- if (this.properties == null) {
- this.properties = new LinkedHashMap<String, String>();
- }
- this.properties.put(key, value);
- }
-
- public void setProperties(LinkedHashMap<String, String> properties) {
- this.properties = properties;
- }
-
- public String getAnnotation() {
- return annotation;
- }
-
- public void setAnnotation(String annotation) {
- this.annotation = annotation;
- }
-
- /**
- * Compare two records for equality.
- */
- public boolean equals(Object obj) {
- if(obj == this) {
- return true;
- }
-
- if(obj.getClass() != this.getClass()) {
- return false;
- }
-
- AbstractMetadataRecord other = (AbstractMetadataRecord)obj;
-
- return EquivalenceUtil.areEqual(this.getUUID(), other.getUUID());
- }
-
- public int hashCode() {
- return getUUID().hashCode();
- }
-
-}
\ No newline at end of file
Copied: trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java (from rev 2116, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/AbstractMetadataRecord.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/AbstractMetadataRecord.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,166 @@
+/*
+ * 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.metadata;
+
+import java.io.Serializable;
+import java.util.Collections;
+import java.util.LinkedHashMap;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.teiid.core.util.EquivalenceUtil;
+
+
+/**
+ * AbstractMetadataRecord
+ */
+public abstract class AbstractMetadataRecord implements Serializable {
+
+ private static final long serialVersionUID = 564092984812414058L;
+
+ public final static char NAME_DELIM_CHAR = '.';
+
+ private static AtomicLong UUID_SEQUENCE = new AtomicLong();
+
+ private String uuid; //globally unique id
+ private String name; //contextually unique name
+
+ private String nameInSource;
+
+ private LinkedHashMap<String, String> properties;
+ private String annotation;
+
+ public String getUUID() {
+ if (uuid == null) {
+ uuid = String.valueOf(UUID_SEQUENCE.getAndIncrement());
+ }
+ return uuid;
+ }
+
+ public void setUUID(String uuid) {
+ this.uuid = uuid;
+ }
+
+ public String getNameInSource() {
+ return nameInSource;
+ }
+
+ public void setNameInSource(String nameInSource) {
+ this.nameInSource = nameInSource;
+ }
+
+ /**
+ * WARNING - The name returned by this method may be ambiguous and
+ * is not SQL safe - it may need quoted/escaped
+ */
+ public String getFullName() {
+ AbstractMetadataRecord parent = getParent();
+ if (parent != null) {
+ return parent.getFullName() + NAME_DELIM_CHAR + getName();
+ }
+ return name;
+ }
+
+ public AbstractMetadataRecord getParent() {
+ return null;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String toString() {
+ StringBuffer sb = new StringBuffer(100);
+ sb.append(getClass().getSimpleName());
+ sb.append(" name="); //$NON-NLS-1$
+ sb.append(getName());
+ sb.append(", nameInSource="); //$NON-NLS-1$
+ sb.append(getNameInSource());
+ sb.append(", uuid="); //$NON-NLS-1$
+ sb.append(getUUID());
+ return sb.toString();
+ }
+
+ /**
+ * Return the extension properties for this record - may be unmodifiable
+ * if {@link #setProperties(LinkedHashMap)} or {@link #setProperty(String, String)}
+ * has not been called.
+ * @return
+ */
+ public Map<String, String> getProperties() {
+ if (properties == null) {
+ return Collections.emptyMap();
+ }
+ return properties;
+ }
+
+ /**
+ * The preferred setter for extension properties.
+ * @param key
+ * @param value
+ */
+ public void setProperty(String key, String value) {
+ if (this.properties == null) {
+ this.properties = new LinkedHashMap<String, String>();
+ }
+ this.properties.put(key, value);
+ }
+
+ public void setProperties(LinkedHashMap<String, String> properties) {
+ this.properties = properties;
+ }
+
+ public String getAnnotation() {
+ return annotation;
+ }
+
+ public void setAnnotation(String annotation) {
+ this.annotation = annotation;
+ }
+
+ /**
+ * Compare two records for equality.
+ */
+ public boolean equals(Object obj) {
+ if(obj == this) {
+ return true;
+ }
+
+ if(obj.getClass() != this.getClass()) {
+ return false;
+ }
+
+ AbstractMetadataRecord other = (AbstractMetadataRecord)obj;
+
+ return EquivalenceUtil.areEqual(this.getUUID(), other.getUUID());
+ }
+
+ public int hashCode() {
+ return getUUID().hashCode();
+ }
+
+}
\ No newline at end of file
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/BaseColumn.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/BaseColumn.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/BaseColumn.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.TypeFacility;
public abstract class BaseColumn extends AbstractMetadataRecord {
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/Column.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Column.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/Column.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
/**
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/ColumnSet.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ColumnSet.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/ColumnSet.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/Datatype.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Datatype.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/Datatype.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,10 +20,10 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
public class Datatype extends AbstractMetadataRecord {
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/ForeignKey.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ForeignKey.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/ForeignKey.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
/**
* ForeignKeyRecordImpl
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/KeyRecord.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/KeyRecord.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/KeyRecord.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
public class KeyRecord extends ColumnSet<Table> {
Deleted: trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,280 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.connector.metadata.runtime;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-
-import org.teiid.connector.DataPlugin;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.TypeFacility;
-
-import com.metamatrix.core.id.UUIDFactory;
-
-/**
- * Allows connectors to build metadata for use by the engine.
- *
- * TODO: add support for datatype import
- * TODO: add support for unique constraints
- */
-public class MetadataFactory {
-
- private Schema schema;
- private UUIDFactory factory = new UUIDFactory();
- private Map<String, Datatype> dataTypes;
- private Properties importProperties;
- private MetadataStore store = new MetadataStore();
-
- public MetadataFactory(String modelName, Map<String, Datatype> dataTypes, Properties importProperties) {
- this.dataTypes = dataTypes;
- schema = new Schema();
- schema.setName(modelName);
- setUUID(schema);
- store.addSchema(schema);
- this.importProperties = importProperties;
- }
-
- public MetadataStore getMetadataStore() {
- return store;
- }
-
- public Properties getImportProperties() {
- return importProperties;
- }
-
- private void setUUID(AbstractMetadataRecord record) {
- record.setUUID(factory.create().toString());
- }
-
- /**
- * Add a table with the given name to the model.
- * @param name
- * @return
- * @throws ConnectorException
- */
- public Table addTable(String name) throws ConnectorException {
- Table table = new Table();
- table.setTableType(Table.Type.Table);
- table.setName(name);
- setUUID(table);
- this.schema.addTable(table);
- return table;
- }
-
- /**
- * Adds a column to the table with the given name and type.
- * @param name
- * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
- * @param table
- * @return
- * @throws ConnectorException
- */
- public Column addColumn(String name, String type, ColumnSet<?> table) throws ConnectorException {
- if (name.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR) != -1) {
- throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.invalid_name", name)); //$NON-NLS-1$
- }
- Column column = new Column();
- column.setName(name);
- table.addColumn(column);
- column.setPosition(table.getColumns().size()); //1 based indexing
- Datatype datatype = setColumnType(type, column);
- column.setCaseSensitive(datatype.isCaseSensitive());
- column.setAutoIncremented(datatype.isAutoIncrement());
- column.setSigned(datatype.isSigned());
- setUUID(column);
- return column;
- }
-
- private Datatype setColumnType(String type,
- BaseColumn column) throws ConnectorException {
- Datatype datatype = dataTypes.get(type);
- if (datatype == null) {
- throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.unknown_datatype", type)); //$NON-NLS-1$
- }
- column.setDatatype(datatype);
- column.setDatatypeUUID(datatype.getUUID());
- column.setLength(datatype.getLength());
- column.setPrecision(datatype.getPrecisionLength());
- column.setRadix(datatype.getRadix());
- column.setRuntimeType(datatype.getRuntimeTypeName());
- return datatype;
- }
-
- /**
- * Adds a primary key to the given table. The column names should be in key order.
- * @param name
- * @param columnNames
- * @param table
- * @return
- * @throws ConnectorException
- */
- public KeyRecord addPrimaryKey(String name, List<String> columnNames, Table table) throws ConnectorException {
- KeyRecord primaryKey = new KeyRecord(KeyRecord.Type.Primary);
- primaryKey.setParent(table);
- primaryKey.setColumns(new ArrayList<Column>(columnNames.size()));
- primaryKey.setName(name);
- setUUID(primaryKey);
- assignColumns(columnNames, table, primaryKey);
- table.setPrimaryKey(primaryKey);
- return primaryKey;
- }
-
- /**
- * Adds an access pattern to the given table.
- * @param name
- * @param columnNames
- * @param table
- * @return
- * @throws ConnectorException
- */
- public KeyRecord addAccessPattern(String name, List<String> columnNames, Table table) throws ConnectorException {
- KeyRecord ap = new KeyRecord(KeyRecord.Type.AccessPattern);
- ap.setParent(table);
- ap.setColumns(new ArrayList<Column>(columnNames.size()));
- ap.setName(name);
- setUUID(ap);
- assignColumns(columnNames, table, ap);
- table.getAccessPatterns().add(ap);
- return ap;
- }
-
- /**
- * Adds an index to the given table.
- * @param name
- * @param nonUnique true indicates that an index is being added.
- * @param columnNames
- * @param table
- * @return
- * @throws ConnectorException
- */
- public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table) throws ConnectorException {
- KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.NonUnique:KeyRecord.Type.Index);
- index.setParent(table);
- index.setColumns(new ArrayList<Column>(columnNames.size()));
- index.setName(name);
- setUUID(index);
- assignColumns(columnNames, table, index);
- table.getIndexes().add(index);
- return index;
- }
-
- /**
- * Adds a foreign key to the given table. The column names should be in key order.
- * @param name
- * @param columnNames
- * @param pkTable
- * @param table
- * @return
- * @throws ConnectorException
- */
- public ForeignKey addForiegnKey(String name, List<String> columnNames, Table pkTable, Table table) throws ConnectorException {
- ForeignKey foreignKey = new ForeignKey();
- foreignKey.setParent(table);
- foreignKey.setColumns(new ArrayList<Column>(columnNames.size()));
- foreignKey.setName(name);
- setUUID(foreignKey);
- if (pkTable.getPrimaryKey() == null) {
- throw new ConnectorException("No primary key defined for table " + pkTable); //$NON-NLS-1$
- }
- foreignKey.setPrimaryKey(pkTable.getPrimaryKey());
- foreignKey.setUniqueKeyID(pkTable.getPrimaryKey().getUUID());
- assignColumns(columnNames, table, foreignKey);
- table.getForeignKeys().add(foreignKey);
- return foreignKey;
- }
-
- /**
- * Add a procedure with the given name to the model.
- * @param name
- * @return
- * @throws ConnectorException
- */
- public Procedure addProcedure(String name) throws ConnectorException {
- Procedure procedure = new Procedure();
- procedure.setName(name);
- setUUID(procedure);
- procedure.setParameters(new LinkedList<ProcedureParameter>());
- this.schema.addProcedure(procedure);
- return procedure;
- }
-
- /**
- * Add a procedure parameter.
- * @param name
- * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
- * @param parameterType should be one of {@link ProcedureParameter.Type}
- * @param procedure
- * @return
- * @throws ConnectorException
- */
- public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure) throws ConnectorException {
- ProcedureParameter param = new ProcedureParameter();
- param.setName(name);
- setUUID(param);
- param.setType(parameterType);
- param.setProcedure(procedure);
- setColumnType(type, param);
- procedure.getParameters().add(param);
- param.setPosition(procedure.getParameters().size()); //1 based indexing
- return param;
- }
-
- /**
- * Add a procedure resultset column to the given procedure.
- * @param name
- * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
- * @param procedure
- * @return
- * @throws ConnectorException
- */
- public Column addProcedureResultSetColumn(String name, String type, Procedure procedure) throws ConnectorException {
- if (procedure.getResultSet() == null) {
- ColumnSet<Procedure> resultSet = new ColumnSet<Procedure>();
- resultSet.setParent(procedure);
- resultSet.setName("RSParam"); //$NON-NLS-1$
- setUUID(resultSet);
- procedure.setResultSet(resultSet);
- }
- return addColumn(name, type, procedure.getResultSet());
- }
-
- private void assignColumns(List<String> columnNames, Table table,
- ColumnSet<?> columns) throws ConnectorException {
- for (String columnName : columnNames) {
- boolean match = false;
- for (Column column : table.getColumns()) {
- if (column.getName().equals(columnName)) {
- match = true;
- columns.getColumns().add(column);
- break;
- }
- }
- if (!match) {
- throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.no_column_found", columnName)); //$NON-NLS-1$
- }
- }
- }
-}
Copied: trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java (from rev 2116, trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataFactory.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/MetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,280 @@
+/*
+ * 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.metadata;
+
+import java.util.ArrayList;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import org.teiid.connector.DataPlugin;
+import org.teiid.core.id.UUIDFactory;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.TypeFacility;
+
+
+/**
+ * Allows connectors to build metadata for use by the engine.
+ *
+ * TODO: add support for datatype import
+ * TODO: add support for unique constraints
+ */
+public class MetadataFactory {
+
+ private Schema schema;
+ private UUIDFactory factory = new UUIDFactory();
+ private Map<String, Datatype> dataTypes;
+ private Properties importProperties;
+ private MetadataStore store = new MetadataStore();
+
+ public MetadataFactory(String modelName, Map<String, Datatype> dataTypes, Properties importProperties) {
+ this.dataTypes = dataTypes;
+ schema = new Schema();
+ schema.setName(modelName);
+ setUUID(schema);
+ store.addSchema(schema);
+ this.importProperties = importProperties;
+ }
+
+ public MetadataStore getMetadataStore() {
+ return store;
+ }
+
+ public Properties getImportProperties() {
+ return importProperties;
+ }
+
+ private void setUUID(AbstractMetadataRecord record) {
+ record.setUUID(factory.create().toString());
+ }
+
+ /**
+ * Add a table with the given name to the model.
+ * @param name
+ * @return
+ * @throws ConnectorException
+ */
+ public Table addTable(String name) throws ConnectorException {
+ Table table = new Table();
+ table.setTableType(Table.Type.Table);
+ table.setName(name);
+ setUUID(table);
+ this.schema.addTable(table);
+ return table;
+ }
+
+ /**
+ * Adds a column to the table with the given name and type.
+ * @param name
+ * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
+ * @param table
+ * @return
+ * @throws ConnectorException
+ */
+ public Column addColumn(String name, String type, ColumnSet<?> table) throws ConnectorException {
+ if (name.indexOf(AbstractMetadataRecord.NAME_DELIM_CHAR) != -1) {
+ throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.invalid_name", name)); //$NON-NLS-1$
+ }
+ Column column = new Column();
+ column.setName(name);
+ table.addColumn(column);
+ column.setPosition(table.getColumns().size()); //1 based indexing
+ Datatype datatype = setColumnType(type, column);
+ column.setCaseSensitive(datatype.isCaseSensitive());
+ column.setAutoIncremented(datatype.isAutoIncrement());
+ column.setSigned(datatype.isSigned());
+ setUUID(column);
+ return column;
+ }
+
+ private Datatype setColumnType(String type,
+ BaseColumn column) throws ConnectorException {
+ Datatype datatype = dataTypes.get(type);
+ if (datatype == null) {
+ throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.unknown_datatype", type)); //$NON-NLS-1$
+ }
+ column.setDatatype(datatype);
+ column.setDatatypeUUID(datatype.getUUID());
+ column.setLength(datatype.getLength());
+ column.setPrecision(datatype.getPrecisionLength());
+ column.setRadix(datatype.getRadix());
+ column.setRuntimeType(datatype.getRuntimeTypeName());
+ return datatype;
+ }
+
+ /**
+ * Adds a primary key to the given table. The column names should be in key order.
+ * @param name
+ * @param columnNames
+ * @param table
+ * @return
+ * @throws ConnectorException
+ */
+ public KeyRecord addPrimaryKey(String name, List<String> columnNames, Table table) throws ConnectorException {
+ KeyRecord primaryKey = new KeyRecord(KeyRecord.Type.Primary);
+ primaryKey.setParent(table);
+ primaryKey.setColumns(new ArrayList<Column>(columnNames.size()));
+ primaryKey.setName(name);
+ setUUID(primaryKey);
+ assignColumns(columnNames, table, primaryKey);
+ table.setPrimaryKey(primaryKey);
+ return primaryKey;
+ }
+
+ /**
+ * Adds an access pattern to the given table.
+ * @param name
+ * @param columnNames
+ * @param table
+ * @return
+ * @throws ConnectorException
+ */
+ public KeyRecord addAccessPattern(String name, List<String> columnNames, Table table) throws ConnectorException {
+ KeyRecord ap = new KeyRecord(KeyRecord.Type.AccessPattern);
+ ap.setParent(table);
+ ap.setColumns(new ArrayList<Column>(columnNames.size()));
+ ap.setName(name);
+ setUUID(ap);
+ assignColumns(columnNames, table, ap);
+ table.getAccessPatterns().add(ap);
+ return ap;
+ }
+
+ /**
+ * Adds an index to the given table.
+ * @param name
+ * @param nonUnique true indicates that an index is being added.
+ * @param columnNames
+ * @param table
+ * @return
+ * @throws ConnectorException
+ */
+ public KeyRecord addIndex(String name, boolean nonUnique, List<String> columnNames, Table table) throws ConnectorException {
+ KeyRecord index = new KeyRecord(nonUnique?KeyRecord.Type.NonUnique:KeyRecord.Type.Index);
+ index.setParent(table);
+ index.setColumns(new ArrayList<Column>(columnNames.size()));
+ index.setName(name);
+ setUUID(index);
+ assignColumns(columnNames, table, index);
+ table.getIndexes().add(index);
+ return index;
+ }
+
+ /**
+ * Adds a foreign key to the given table. The column names should be in key order.
+ * @param name
+ * @param columnNames
+ * @param pkTable
+ * @param table
+ * @return
+ * @throws ConnectorException
+ */
+ public ForeignKey addForiegnKey(String name, List<String> columnNames, Table pkTable, Table table) throws ConnectorException {
+ ForeignKey foreignKey = new ForeignKey();
+ foreignKey.setParent(table);
+ foreignKey.setColumns(new ArrayList<Column>(columnNames.size()));
+ foreignKey.setName(name);
+ setUUID(foreignKey);
+ if (pkTable.getPrimaryKey() == null) {
+ throw new ConnectorException("No primary key defined for table " + pkTable); //$NON-NLS-1$
+ }
+ foreignKey.setPrimaryKey(pkTable.getPrimaryKey());
+ foreignKey.setUniqueKeyID(pkTable.getPrimaryKey().getUUID());
+ assignColumns(columnNames, table, foreignKey);
+ table.getForeignKeys().add(foreignKey);
+ return foreignKey;
+ }
+
+ /**
+ * Add a procedure with the given name to the model.
+ * @param name
+ * @return
+ * @throws ConnectorException
+ */
+ public Procedure addProcedure(String name) throws ConnectorException {
+ Procedure procedure = new Procedure();
+ procedure.setName(name);
+ setUUID(procedure);
+ procedure.setParameters(new LinkedList<ProcedureParameter>());
+ this.schema.addProcedure(procedure);
+ return procedure;
+ }
+
+ /**
+ * Add a procedure parameter.
+ * @param name
+ * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
+ * @param parameterType should be one of {@link ProcedureParameter.Type}
+ * @param procedure
+ * @return
+ * @throws ConnectorException
+ */
+ public ProcedureParameter addProcedureParameter(String name, String type, ProcedureParameter.Type parameterType, Procedure procedure) throws ConnectorException {
+ ProcedureParameter param = new ProcedureParameter();
+ param.setName(name);
+ setUUID(param);
+ param.setType(parameterType);
+ param.setProcedure(procedure);
+ setColumnType(type, param);
+ procedure.getParameters().add(param);
+ param.setPosition(procedure.getParameters().size()); //1 based indexing
+ return param;
+ }
+
+ /**
+ * Add a procedure resultset column to the given procedure.
+ * @param name
+ * @param type should be one of {@link TypeFacility.RUNTIME_NAMES}
+ * @param procedure
+ * @return
+ * @throws ConnectorException
+ */
+ public Column addProcedureResultSetColumn(String name, String type, Procedure procedure) throws ConnectorException {
+ if (procedure.getResultSet() == null) {
+ ColumnSet<Procedure> resultSet = new ColumnSet<Procedure>();
+ resultSet.setParent(procedure);
+ resultSet.setName("RSParam"); //$NON-NLS-1$
+ setUUID(resultSet);
+ procedure.setResultSet(resultSet);
+ }
+ return addColumn(name, type, procedure.getResultSet());
+ }
+
+ private void assignColumns(List<String> columnNames, Table table,
+ ColumnSet<?> columns) throws ConnectorException {
+ for (String columnName : columnNames) {
+ boolean match = false;
+ for (Column column : table.getColumns()) {
+ if (column.getName().equals(columnName)) {
+ match = true;
+ columns.getColumns().add(column);
+ break;
+ }
+ }
+ if (!match) {
+ throw new ConnectorException(DataPlugin.Util.getString("MetadataFactory.no_column_found", columnName)); //$NON-NLS-1$
+ }
+ }
+ }
+}
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/MetadataStore.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/MetadataStore.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/MetadataStore.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
import java.io.Serializable;
import java.util.ArrayList;
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/Procedure.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Procedure.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/Procedure.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
import java.util.LinkedList;
import java.util.List;
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/ProcedureParameter.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/ProcedureParameter.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/ProcedureParameter.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
/**
* ProcedureParameterRecordImpl
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/RuntimeMetadata.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/RuntimeMetadata.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/RuntimeMetadata.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
/**
* Helper methods that can be used to access runtime metadata.
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/Schema.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Schema.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/Schema.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
import java.util.LinkedHashMap;
import java.util.Map;
Modified: trunk/connector-api/src/main/java/org/teiid/metadata/Table.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/connector/metadata/runtime/Table.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/connector-api/src/main/java/org/teiid/metadata/Table.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.connector.metadata.runtime;
+package org.teiid.metadata;
import java.util.Collection;
import java.util.LinkedList;
Deleted: trunk/connector-api/src/main/java/org/teiid/resource/ConnectorException.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/ConnectorException.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/ConnectorException.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.resource;
-
-import javax.resource.ResourceException;
-
-/**
- * An exception the connector writer can return in case of an
- * error while using the connector.
- */
-public class ConnectorException extends ResourceException{
-
- private static final long serialVersionUID = -5980862789340592219L;
-
- /**
- * No-arg constructor required by Externalizable semantics.
- */
- public ConnectorException() {
- super();
- }
-
- /**
- * Construct an instance with the message specified.
- *
- * @param message A message describing the exception
- */
- public ConnectorException( String message ) {
- super( message );
- }
-
- public ConnectorException( String errorCode, String message ) {
- super( message, errorCode);
- }
-
- public ConnectorException( int errorCode, String message ) {
- super(message, Integer.toString(errorCode));
- }
-
-
- /**
- * Construct an instance from a message and an exception to chain to this one.
- *
- * @param code A code denoting the exception
- * @param e An exception to nest within this one
- */
- public ConnectorException( Throwable e, String message ) {
- super(message,e);
- }
-
- /**
- * Construct an instance with a linked exception specified.
- *
- * @param e An exception to chain to this exception
- */
- public ConnectorException( Throwable e ) {
- super( e );
- }
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicConnectorCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicConnectorCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,380 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.resource.adapter;
-
-import java.util.List;
-
-import org.teiid.resource.cci.ConnectorCapabilities;
-
-
-/**
- * This class is a base implementation of the ConnectorCapabilities interface.
- * It is implemented to return false for all capabilities. Subclass this base
- * class and override any methods necessary to specify capabilities the
- * connector actually supports.
- */
-public class BasicConnectorCapabilities implements ConnectorCapabilities {
-
- /**
- * Construct the basic capabilities class.
- */
- public BasicConnectorCapabilities() {
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelectDistinct()
- */
- public boolean supportsSelectDistinct() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAliasedGroup()
- */
- public boolean supportsAliasedGroup() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelfJoins()
- */
- public boolean supportsSelfJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOuterJoins()
- */
- public boolean supportsOuterJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsFullOuterJoins()
- */
- public boolean supportsFullOuterJoins() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsBetweenCriteria()
- */
- public boolean supportsBetweenCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCompareCriteriaEquals()
- */
- public boolean supportsCompareCriteriaEquals() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteria()
- */
- public boolean supportsLikeCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
- */
- public boolean supportsLikeCriteriaEscapeCharacter() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteria()
- */
- public boolean supportsInCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteriaSubquery()
- */
- public boolean supportsInCriteriaSubquery() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsIsNullCriteria()
- */
- public boolean supportsIsNullCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrCriteria()
- */
- public boolean supportsOrCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsNotCriteria()
- */
- public boolean supportsNotCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsExistsCriteria()
- */
- public boolean supportsExistsCriteria() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
- */
- public boolean supportsQuantifiedCompareCriteriaSome() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
- */
- public boolean supportsQuantifiedCompareCriteriaAll() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrderBy()
- */
- public boolean supportsOrderBy() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesSum()
- */
- public boolean supportsAggregatesSum() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesAvg()
- */
- public boolean supportsAggregatesAvg() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMin()
- */
- public boolean supportsAggregatesMin() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMax()
- */
- public boolean supportsAggregatesMax() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCount()
- */
- public boolean supportsAggregatesCount() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCountStar()
- */
- public boolean supportsAggregatesCountStar() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesDistinct()
- */
- public boolean supportsAggregatesDistinct() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsScalarSubqueries()
- */
- public boolean supportsScalarSubqueries() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCorrelatedSubqueries()
- */
- public boolean supportsCorrelatedSubqueries() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCaseExpressions()
- */
- public boolean supportsCaseExpressions() {
- return false;
- }
-
- /*
- * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSearchedCaseExpressions()
- */
- public boolean supportsSearchedCaseExpressions() {
- return false;
- }
-
- /**
- * Return null to indicate no functions are supported.
- * @return null
- * @see org.teiid.resource.cci.ConnectorCapabilities#getSupportedFunctions()
- */
- public List<String> getSupportedFunctions() {
- return null;
- }
-
- public boolean supportsInlineViews() {
- return false;
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsUnions()
- * @since 4.2
- */
- public boolean supportsUnions() {
- return false;
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#getMaxInCriteriaSize()
- * @since 4.2
- */
- public int getMaxInCriteriaSize() {
- return -1;
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFunctionsInGroupBy()
- * @since 5.0
- */
- public boolean supportsFunctionsInGroupBy() {
- return false;
- }
-
- public boolean supportsRowLimit() {
- return false;
- }
-
- public boolean supportsRowOffset() {
- return false;
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#getMaxFromGroups()
- */
- public int getMaxFromGroups() {
- return -1; //-1 indicates no max
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsExcept()
- */
- public boolean supportsExcept() {
- return false;
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsIntersect()
- */
- public boolean supportsIntersect() {
- return false;
- }
-
- /**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsSetQueryOrderBy()
- */
- public boolean supportsSetQueryOrderBy() {
- return false;
- }
-
- @Override
- public boolean useAnsiJoin() {
- return false;
- }
-
- @Override
- public boolean requiresCriteria() {
- return false;
- }
-
- @Override
- public boolean supportsBatchedUpdates() {
- return false;
- }
-
- @Override
- public boolean supportsGroupBy() {
- return false;
- }
-
- @Override
- public boolean supportsHaving() {
- return false;
- }
-
- @Override
- public boolean supportsInnerJoins() {
- return false;
- }
-
- @Override
- public boolean supportsSelectExpression() {
- return false;
- }
-
- @Override
- public SupportedJoinCriteria getSupportedJoinCriteria() {
- return SupportedJoinCriteria.ANY;
- }
-
- @Override
- public boolean supportsCompareCriteriaOrdered() {
- return false;
- }
-
- @Override
- public boolean supportsInsertWithQueryExpression() {
- return false;
- }
-
- @Override
- public boolean supportsBulkUpdate() {
- return false;
- }
-
- @Override
- public boolean supportsOrderByUnrelated() {
- return false;
- }
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,29 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.resource.adapter;
-
-import org.teiid.resource.cci.Execution;
-
-public abstract class BasicExecution implements Execution {
-
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,218 +0,0 @@
-package org.teiid.resource.adapter;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.Collection;
-import java.util.Properties;
-
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.core.TeiidException;
-import org.teiid.core.util.ReflectionHelper;
-import org.teiid.core.util.StringUtil;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.Execution;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ExecutionFactory;
-import org.teiid.resource.cci.ProcedureExecution;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.TypeFacility;
-import org.teiid.resource.cci.UpdateExecution;
-import org.teiid.resource.spi.BasicManagedConnectionFactory;
-
-
-public class BasicExecutionFactory implements ExecutionFactory {
-
- protected ConnectorCapabilities capabilities;
- private static final TypeFacility TYPE_FACILITY = new TypeFacility();
-
- private String capabilitiesClass;
- private boolean immutable = false;
- private boolean exceptionOnMaxRows = false;
- private int maxResultRows = -1;
- private boolean xaCapable;
- private String overrideCapabilitiesFile;
- private boolean sourceRequired = true;
-
- @Override
- public void start() throws ConnectorException {
- }
-
- public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
- return BasicConnectorCapabilities.class;
- }
-
- @Override
- public ConnectorCapabilities getCapabilities() throws ConnectorException {
- if (capabilities == null) {
- // create Capabilities
- capabilities = BasicManagedConnectionFactory.getInstance(ConnectorCapabilities.class, getCapabilitiesClass(), null, getDefaultCapabilities());
- }
-
- // capabilities overload
- Properties props = getOverrideCapabilities();
- if (this.capabilities != null && props != null) {
- this.capabilities = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(this.capabilities, props));
- }
- return capabilities;
- }
-
- @Override
- public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException {
- if (command instanceof QueryExpression) {
- return createResultSetExecution((QueryExpression)command, executionContext, metadata, connectionFactory);
- }
- if (command instanceof Call) {
- return createProcedureExecution((Call)command, executionContext, metadata, connectionFactory);
- }
- return createUpdateExecution(command, executionContext, metadata, connectionFactory);
- }
-
- public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
- throw new ConnectorException("Unsupported Execution"); //$NON-NLS-1$
- }
-
- public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
- throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
- }
-
- public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
- throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
- }
-
- // derived
- private Properties overrideCapabilities;
-
-
- @Override
- public LanguageFactory getLanguageFactory() {
- return LanguageFactory.INSTANCE;
- }
-
- @Override
- public TypeFacility getTypeFacility() {
- return TYPE_FACILITY;
- }
-
- @Override
- public Properties getOverrideCapabilities() throws ConnectorException {
- if (this.overrideCapabilities == null && getOverrideCapabilitiesFile() != null) {
- try {
- this.overrideCapabilities = new Properties();
- this.overrideCapabilities.loadFromXML(this.getClass().getResourceAsStream(getOverrideCapabilitiesFile()));
- } catch (IOException e) {
- throw new ConnectorException(e);
- }
- }
- return this.overrideCapabilities;
- }
-
- public static <T> T getInstance(Class<T> expectedType, String className, Collection ctorObjs, Class defaultClass) throws ConnectorException {
- try {
- if (className == null) {
- if (defaultClass == null) {
- throw new ConnectorException("Neither class name or default class specified to create an instance"); //$NON-NLS-1$
- }
- return expectedType.cast(defaultClass.newInstance());
- }
- return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
- } catch (TeiidException e) {
- throw new ConnectorException(e);
- } catch (IllegalAccessException e) {
- throw new ConnectorException(e);
- } catch(InstantiationException e) {
- throw new ConnectorException(e);
- }
- }
- /**
- * Overloads the connector capabilities with one defined in the connector binding properties
- */
- static final class CapabilitesOverloader implements InvocationHandler {
- ConnectorCapabilities caps;
- Properties properties;
-
- CapabilitesOverloader(ConnectorCapabilities caps, Properties properties){
- this.caps = caps;
- this.properties = properties;
- }
-
- @Override
- public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
- String value = this.properties.getProperty(method.getName());
- if (value == null || value.trim().length() == 0 || (args != null && args.length != 0)) {
- return method.invoke(this.caps, args);
- }
- return StringUtil.valueOf(value, method.getReturnType());
- }
- }
-
- @Override
- public String getCapabilitiesClass() {
- return capabilitiesClass;
- }
-
- public void setCapabilitiesClass(String arg0) {
- this.capabilitiesClass = arg0;
- }
-
- @Override
- public boolean isImmutable() {
- return immutable;
- }
-
- public void setImmutable(boolean arg0) {
- this.immutable = arg0;
- }
-
- @Override
- public boolean isExceptionOnMaxRows() {
- return exceptionOnMaxRows;
- }
-
- public void setExceptionOnMaxRows(boolean arg0) {
- this.exceptionOnMaxRows = arg0;
- }
-
- @Override
- public int getMaxResultRows() {
- return maxResultRows;
- }
-
- public void setMaxResultRows(int arg0) {
- this.maxResultRows = arg0;
- }
-
- @Override
- public boolean isXaCapable() {
- return xaCapable;
- }
-
- public void setXaCapable(boolean arg0) {
- this.xaCapable = arg0;
- }
-
- @Override
- public String getOverrideCapabilitiesFile() throws ConnectorException {
- return this.overrideCapabilitiesFile;
- }
-
-
- public void setOverrideCapabilitiesFile(String overrideCapabilitiesFile) {
- this.overrideCapabilitiesFile = overrideCapabilitiesFile;
- }
-
- @Override
- public boolean isSourceRequired() {
- return sourceRequired;
- }
-
- public void setSourceRequired(boolean value) {
- this.sourceRequired = value;
- }
-}
Deleted: trunk/connector-api/src/main/java/org/teiid/resource/adapter/FileConnection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/adapter/FileConnection.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/adapter/FileConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,32 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-package org.teiid.resource.adapter;
-
-import java.io.File;
-
-import javax.resource.cci.Connection;
-
-public interface FileConnection extends Connection {
-
- File[] getFiles(String path);
-
-}
Modified: trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -38,7 +38,7 @@
import javax.security.auth.Subject;
import javax.transaction.xa.XAResource;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public class BasicManagedConnection implements ManagedConnection {
protected PrintWriter log;
Modified: trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/resource/spi/BasicManagedConnectionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -38,7 +38,7 @@
import org.teiid.core.TeiidException;
import org.teiid.core.util.ReflectionHelper;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public abstract class BasicManagedConnectionFactory implements ManagedConnectionFactory, ResourceAdapterAssociation, ValidatingManagedConnectionFactory {
Copied: trunk/connector-api/src/main/java/org/teiid/translator (from rev 2118, trunk/connector-api/src/main/java/org/teiid/resource/cci)
Copied: trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicConnectorCapabilities.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/translator/BasicConnectorCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,379 @@
+/*
+ * 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;
+
+import java.util.List;
+
+
+
+/**
+ * This class is a base implementation of the ConnectorCapabilities interface.
+ * It is implemented to return false for all capabilities. Subclass this base
+ * class and override any methods necessary to specify capabilities the
+ * connector actually supports.
+ */
+public class BasicConnectorCapabilities implements ConnectorCapabilities {
+
+ /**
+ * Construct the basic capabilities class.
+ */
+ public BasicConnectorCapabilities() {
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelectDistinct()
+ */
+ public boolean supportsSelectDistinct() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAliasedGroup()
+ */
+ public boolean supportsAliasedGroup() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSelfJoins()
+ */
+ public boolean supportsSelfJoins() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOuterJoins()
+ */
+ public boolean supportsOuterJoins() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsFullOuterJoins()
+ */
+ public boolean supportsFullOuterJoins() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsBetweenCriteria()
+ */
+ public boolean supportsBetweenCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCompareCriteriaEquals()
+ */
+ public boolean supportsCompareCriteriaEquals() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteria()
+ */
+ public boolean supportsLikeCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsLikeCriteriaEscapeCharacter()
+ */
+ public boolean supportsLikeCriteriaEscapeCharacter() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteria()
+ */
+ public boolean supportsInCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsInCriteriaSubquery()
+ */
+ public boolean supportsInCriteriaSubquery() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsIsNullCriteria()
+ */
+ public boolean supportsIsNullCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrCriteria()
+ */
+ public boolean supportsOrCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsNotCriteria()
+ */
+ public boolean supportsNotCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsExistsCriteria()
+ */
+ public boolean supportsExistsCriteria() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
+ */
+ public boolean supportsQuantifiedCompareCriteriaSome() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsQuantifiedCompareCriteriaAll()
+ */
+ public boolean supportsQuantifiedCompareCriteriaAll() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsOrderBy()
+ */
+ public boolean supportsOrderBy() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesSum()
+ */
+ public boolean supportsAggregatesSum() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesAvg()
+ */
+ public boolean supportsAggregatesAvg() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMin()
+ */
+ public boolean supportsAggregatesMin() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesMax()
+ */
+ public boolean supportsAggregatesMax() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCount()
+ */
+ public boolean supportsAggregatesCount() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesCountStar()
+ */
+ public boolean supportsAggregatesCountStar() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsAggregatesDistinct()
+ */
+ public boolean supportsAggregatesDistinct() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsScalarSubqueries()
+ */
+ public boolean supportsScalarSubqueries() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCorrelatedSubqueries()
+ */
+ public boolean supportsCorrelatedSubqueries() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsCaseExpressions()
+ */
+ public boolean supportsCaseExpressions() {
+ return false;
+ }
+
+ /*
+ * @see com.metamatrix.data.api.ConnectorCapabilities#supportsSearchedCaseExpressions()
+ */
+ public boolean supportsSearchedCaseExpressions() {
+ return false;
+ }
+
+ /**
+ * Return null to indicate no functions are supported.
+ * @return null
+ * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
+ */
+ public List<String> getSupportedFunctions() {
+ return null;
+ }
+
+ public boolean supportsInlineViews() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
+ * @since 4.2
+ */
+ public boolean supportsUnions() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#getMaxInCriteriaSize()
+ * @since 4.2
+ */
+ public int getMaxInCriteriaSize() {
+ return -1;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @since 5.0
+ */
+ public boolean supportsFunctionsInGroupBy() {
+ return false;
+ }
+
+ public boolean supportsRowLimit() {
+ return false;
+ }
+
+ public boolean supportsRowOffset() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#getMaxFromGroups()
+ */
+ public int getMaxFromGroups() {
+ return -1; //-1 indicates no max
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsExcept()
+ */
+ public boolean supportsExcept() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsIntersect()
+ */
+ public boolean supportsIntersect() {
+ return false;
+ }
+
+ /**
+ * @see org.teiid.translator.ConnectorCapabilities#supportsSetQueryOrderBy()
+ */
+ public boolean supportsSetQueryOrderBy() {
+ return false;
+ }
+
+ @Override
+ public boolean useAnsiJoin() {
+ return false;
+ }
+
+ @Override
+ public boolean requiresCriteria() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBatchedUpdates() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsGroupBy() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsHaving() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInnerJoins() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsSelectExpression() {
+ return false;
+ }
+
+ @Override
+ public SupportedJoinCriteria getSupportedJoinCriteria() {
+ return SupportedJoinCriteria.ANY;
+ }
+
+ @Override
+ public boolean supportsCompareCriteriaOrdered() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsInsertWithQueryExpression() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsBulkUpdate() {
+ return false;
+ }
+
+ @Override
+ public boolean supportsOrderByUnrelated() {
+ return false;
+ }
+
+}
Copied: trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecution.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,28 @@
+/*
+ * 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;
+
+
+public abstract class BasicExecution implements Execution {
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/translator/BasicExecution.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/resource/adapter/BasicExecutionFactory.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/translator/BasicExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,209 @@
+package org.teiid.translator;
+
+import java.io.IOException;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Collection;
+import java.util.Properties;
+
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.ReflectionHelper;
+import org.teiid.core.util.StringUtil;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.resource.spi.BasicManagedConnectionFactory;
+
+
+public class BasicExecutionFactory implements ExecutionFactory {
+
+ protected ConnectorCapabilities capabilities;
+ private static final TypeFacility TYPE_FACILITY = new TypeFacility();
+
+ private String capabilitiesClass;
+ private boolean immutable = false;
+ private boolean exceptionOnMaxRows = false;
+ private int maxResultRows = -1;
+ private boolean xaCapable;
+ private String overrideCapabilitiesFile;
+ private boolean sourceRequired = true;
+
+ @Override
+ public void start() throws ConnectorException {
+ }
+
+ public Class<? extends ConnectorCapabilities> getDefaultCapabilities() {
+ return BasicConnectorCapabilities.class;
+ }
+
+ @Override
+ public ConnectorCapabilities getCapabilities() throws ConnectorException {
+ if (capabilities == null) {
+ // create Capabilities
+ capabilities = BasicManagedConnectionFactory.getInstance(ConnectorCapabilities.class, getCapabilitiesClass(), null, getDefaultCapabilities());
+ }
+
+ // capabilities overload
+ Properties props = getOverrideCapabilities();
+ if (this.capabilities != null && props != null) {
+ this.capabilities = (ConnectorCapabilities) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[] {ConnectorCapabilities.class}, new CapabilitesOverloader(this.capabilities, props));
+ }
+ return capabilities;
+ }
+
+ @Override
+ public Execution createExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException {
+ if (command instanceof QueryExpression) {
+ return createResultSetExecution((QueryExpression)command, executionContext, metadata, connectionFactory);
+ }
+ if (command instanceof Call) {
+ return createProcedureExecution((Call)command, executionContext, metadata, connectionFactory);
+ }
+ return createUpdateExecution(command, executionContext, metadata, connectionFactory);
+ }
+
+ public ResultSetExecution createResultSetExecution(QueryExpression command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
+ throw new ConnectorException("Unsupported Execution"); //$NON-NLS-1$
+ }
+
+ public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
+ throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
+ }
+
+ public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connection) throws ConnectorException {
+ throw new ConnectorException("Unsupported Execution");//$NON-NLS-1$
+ }
+
+ // derived
+ private Properties overrideCapabilities;
+
+
+ @Override
+ public LanguageFactory getLanguageFactory() {
+ return LanguageFactory.INSTANCE;
+ }
+
+ @Override
+ public TypeFacility getTypeFacility() {
+ return TYPE_FACILITY;
+ }
+
+ @Override
+ public Properties getOverrideCapabilities() throws ConnectorException {
+ if (this.overrideCapabilities == null && getOverrideCapabilitiesFile() != null) {
+ try {
+ this.overrideCapabilities = new Properties();
+ this.overrideCapabilities.loadFromXML(this.getClass().getResourceAsStream(getOverrideCapabilitiesFile()));
+ } catch (IOException e) {
+ throw new ConnectorException(e);
+ }
+ }
+ return this.overrideCapabilities;
+ }
+
+ public static <T> T getInstance(Class<T> expectedType, String className, Collection ctorObjs, Class defaultClass) throws ConnectorException {
+ try {
+ if (className == null) {
+ if (defaultClass == null) {
+ throw new ConnectorException("Neither class name or default class specified to create an instance"); //$NON-NLS-1$
+ }
+ return expectedType.cast(defaultClass.newInstance());
+ }
+ return expectedType.cast(ReflectionHelper.create(className, ctorObjs, Thread.currentThread().getContextClassLoader()));
+ } catch (TeiidException e) {
+ throw new ConnectorException(e);
+ } catch (IllegalAccessException e) {
+ throw new ConnectorException(e);
+ } catch(InstantiationException e) {
+ throw new ConnectorException(e);
+ }
+ }
+ /**
+ * Overloads the connector capabilities with one defined in the connector binding properties
+ */
+ static final class CapabilitesOverloader implements InvocationHandler {
+ ConnectorCapabilities caps;
+ Properties properties;
+
+ CapabilitesOverloader(ConnectorCapabilities caps, Properties properties){
+ this.caps = caps;
+ this.properties = properties;
+ }
+
+ @Override
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
+ String value = this.properties.getProperty(method.getName());
+ if (value == null || value.trim().length() == 0 || (args != null && args.length != 0)) {
+ return method.invoke(this.caps, args);
+ }
+ return StringUtil.valueOf(value, method.getReturnType());
+ }
+ }
+
+ @Override
+ public String getCapabilitiesClass() {
+ return capabilitiesClass;
+ }
+
+ public void setCapabilitiesClass(String arg0) {
+ this.capabilitiesClass = arg0;
+ }
+
+ @Override
+ public boolean isImmutable() {
+ return immutable;
+ }
+
+ public void setImmutable(boolean arg0) {
+ this.immutable = arg0;
+ }
+
+ @Override
+ public boolean isExceptionOnMaxRows() {
+ return exceptionOnMaxRows;
+ }
+
+ public void setExceptionOnMaxRows(boolean arg0) {
+ this.exceptionOnMaxRows = arg0;
+ }
+
+ @Override
+ public int getMaxResultRows() {
+ return maxResultRows;
+ }
+
+ public void setMaxResultRows(int arg0) {
+ this.maxResultRows = arg0;
+ }
+
+ @Override
+ public boolean isXaCapable() {
+ return xaCapable;
+ }
+
+ public void setXaCapable(boolean arg0) {
+ this.xaCapable = arg0;
+ }
+
+ @Override
+ public String getOverrideCapabilitiesFile() throws ConnectorException {
+ return this.overrideCapabilitiesFile;
+ }
+
+
+ public void setOverrideCapabilitiesFile(String overrideCapabilitiesFile) {
+ this.overrideCapabilitiesFile = overrideCapabilitiesFile;
+ }
+
+ @Override
+ public boolean isSourceRequired() {
+ return sourceRequired;
+ }
+
+ public void setSourceRequired(boolean value) {
+ this.sourceRequired = value;
+ }
+}
Modified: trunk/connector-api/src/main/java/org/teiid/translator/CacheScope.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/CacheScope.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/CacheScope.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.io.Serializable;
Modified: trunk/connector-api/src/main/java/org/teiid/translator/ConnectorCapabilities.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/ConnectorCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ConnectorCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,12 +20,12 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.util.List;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.SetQuery;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.SetQuery;
/**
Copied: trunk/connector-api/src/main/java/org/teiid/translator/ConnectorException.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/resource/ConnectorException.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/ConnectorException.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ConnectorException.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,79 @@
+/*
+ * 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;
+
+import javax.resource.ResourceException;
+
+/**
+ * An exception the connector writer can return in case of an
+ * error while using the connector.
+ */
+public class ConnectorException extends ResourceException{
+
+ private static final long serialVersionUID = -5980862789340592219L;
+
+ /**
+ * No-arg constructor required by Externalizable semantics.
+ */
+ public ConnectorException() {
+ super();
+ }
+
+ /**
+ * Construct an instance with the message specified.
+ *
+ * @param message A message describing the exception
+ */
+ public ConnectorException( String message ) {
+ super( message );
+ }
+
+ public ConnectorException( String errorCode, String message ) {
+ super( message, errorCode);
+ }
+
+ public ConnectorException( int errorCode, String message ) {
+ super(message, Integer.toString(errorCode));
+ }
+
+
+ /**
+ * Construct an instance from a message and an exception to chain to this one.
+ *
+ * @param code A code denoting the exception
+ * @param e An exception to nest within this one
+ */
+ public ConnectorException( Throwable e, String message ) {
+ super(message,e);
+ }
+
+ /**
+ * Construct an instance with a linked exception specified.
+ *
+ * @param e An exception to chain to this exception
+ */
+ public ConnectorException( Throwable e ) {
+ super( e );
+ }
+
+}
Property changes on: trunk/connector-api/src/main/java/org/teiid/translator/ConnectorException.java
___________________________________________________________________
Name: svn:mergeinfo
+
Modified: trunk/connector-api/src/main/java/org/teiid/translator/DataNotAvailableException.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/DataNotAvailableException.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/DataNotAvailableException.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import org.teiid.core.TeiidRuntimeException;
Modified: trunk/connector-api/src/main/java/org/teiid/translator/Execution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/Execution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/Execution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,9 +20,8 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
-import org.teiid.resource.ConnectorException;
/**
* An execution represents the state and lifecycle for a particular
Modified: trunk/connector-api/src/main/java/org/teiid/translator/ExecutionContext.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/ExecutionContext.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ExecutionContext.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.io.Serializable;
Modified: trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/ExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,14 +20,13 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.util.Properties;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
+import org.teiid.language.LanguageFactory;
+import org.teiid.metadata.RuntimeMetadata;
Copied: trunk/connector-api/src/main/java/org/teiid/translator/FileConnection.java (from rev 2118, trunk/connector-api/src/main/java/org/teiid/resource/adapter/FileConnection.java)
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/translator/FileConnection.java (rev 0)
+++ trunk/connector-api/src/main/java/org/teiid/translator/FileConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -0,0 +1,32 @@
+/*
+ * 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;
+
+import java.io.File;
+
+import javax.resource.cci.Connection;
+
+public interface FileConnection extends Connection {
+
+ File[] getFiles(String path);
+
+}
Modified: trunk/connector-api/src/main/java/org/teiid/translator/MetadataProvider.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/MetadataProvider.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/MetadataProvider.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,10 +20,9 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.resource.ConnectorException;
+import org.teiid.metadata.MetadataFactory;
public interface MetadataProvider {
Modified: trunk/connector-api/src/main/java/org/teiid/translator/ProcedureExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/ProcedureExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ProcedureExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,12 +20,11 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.util.List;
-import org.teiid.connector.language.Call;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Call;
/**
* The procedure execution represents the case where a connector can execute a
Modified: trunk/connector-api/src/main/java/org/teiid/translator/ResultSetExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/ResultSetExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/ResultSetExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,13 +20,12 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.util.List;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Call;
+import org.teiid.language.QueryExpression;
/**
* Defines an execution for {@link QueryExpression}s and {@link Call}s that
Modified: trunk/connector-api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/SourceSystemFunctions.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
/**
* Constants for all the possible standard system push down functions.
Modified: trunk/connector-api/src/main/java/org/teiid/translator/TranslatorProperty.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/TranslatorProperty.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/TranslatorProperty.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
Modified: trunk/connector-api/src/main/java/org/teiid/translator/TypeFacility.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/TypeFacility.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/TypeFacility.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
import java.util.Calendar;
import java.util.Date;
Modified: trunk/connector-api/src/main/java/org/teiid/translator/UpdateExecution.java
===================================================================
--- trunk/connector-api/src/main/java/org/teiid/resource/cci/UpdateExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/main/java/org/teiid/translator/UpdateExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,13 +20,12 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci;
+package org.teiid.translator;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.Update;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Delete;
+import org.teiid.language.Insert;
+import org.teiid.language.Update;
/**
Modified: trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java
===================================================================
--- trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connector-api/src/test/java/org/teiid/connector/TestBasicExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,9 +27,9 @@
import java.util.Properties;
import org.junit.Test;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionFactory;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ExecutionFactory;
public class TestBasicExecutionFactory {
Copied: trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap (from rev 2118, trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap)
Modified: trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPConnectionImpl.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPConnectionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPConnectionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.cci.ldap;
+package org.teiid.resource.adapter.ldap;
import java.util.Hashtable;
@@ -44,8 +44,8 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.spi.BasicConnection;
+import org.teiid.translator.ConnectorException;
Modified: trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPManagedConnectionFactory.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPManagedConnectionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPManagedConnectionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci.ldap;
+package org.teiid.resource.adapter.ldap;
import javax.resource.ResourceException;
Modified: trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java
===================================================================
--- trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/cci/ldap/LDAPPlugin.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/connector-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.cci.ldap;
+package org.teiid.resource.adapter.ldap;
import java.util.ResourceBundle;
@@ -31,7 +31,7 @@
*/
public class LDAPPlugin {
- public static final String PLUGIN_ID = "org.teiid.resource.cci.ldap" ; //$NON-NLS-1$
+ public static final String PLUGIN_ID = LDAPPlugin.class.getPackage().getName();
/**
* Provides access to the plugin's log and to it's resources.
Copied: trunk/connectors/connector-ldap/src/main/resources/org/teiid/resource/adapter (from rev 2118, trunk/connectors/connector-ldap/src/main/resources/org/teiid/resource/cci)
Modified: trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/ldap/TestLDAPConnection.java
===================================================================
--- trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/ldap/TestLDAPConnection.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/connector-ldap/src/test/java/org/teiid/resource/cci/ldap/TestLDAPConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,8 +30,8 @@
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.resource.cci.ldap.LDAPConnectionImpl;
-import org.teiid.resource.cci.ldap.LDAPManagedConnectionFactory;
+import org.teiid.resource.adapter.ldap.LDAPConnectionImpl;
+import org.teiid.resource.adapter.ldap.LDAPManagedConnectionFactory;
public class TestLDAPConnection {
Modified: trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesforceConnectionImpl.java
===================================================================
--- trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesforceConnectionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/connector-salesforce/src/main/java/org/teiid/resource/cci/salesforce/SalesforceConnectionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -32,7 +32,6 @@
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.salesforce.Messages;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
import org.teiid.resource.adapter.salesforce.execution.DataPayload;
@@ -40,6 +39,7 @@
import org.teiid.resource.adapter.salesforce.execution.DeletedResult;
import org.teiid.resource.adapter.salesforce.execution.UpdatedResult;
import org.teiid.resource.spi.BasicConnection;
+import org.teiid.translator.ConnectorException;
import com.sforce.soap.partner.CallOptions;
import com.sforce.soap.partner.DeleteResult;
Modified: trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java
===================================================================
--- trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/connector-text/src/main/java/org/teiid/resource/adapter/file/FileConnectionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,8 +27,8 @@
import javax.resource.ResourceException;
import org.teiid.core.util.FileUtils;
-import org.teiid.resource.adapter.FileConnection;
import org.teiid.resource.spi.BasicConnection;
+import org.teiid.translator.FileConnection;
/**
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/TickerCollectorVisitor.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/TickerCollectorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/TickerCollectorVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import java.util.*;
-import org.teiid.connector.language.*;
-import org.teiid.connector.visitor.framework.HierarchyVisitor;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.*;
+import org.teiid.language.visitor.HierarchyVisitor;
+import org.teiid.translator.ConnectorException;
/**
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooCapabilities.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.Collections;
import java.util.List;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
+import org.teiid.translator.BasicConnectorCapabilities;
/**
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecution.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -38,19 +38,19 @@
import java.util.Set;
import java.util.StringTokenizer;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Condition;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Condition;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.Select;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ResultSetExecution;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ResultSetExecution;
/**
Modified: trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecutionFactory.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/sandbox/translator-yahoo/src/main/java/org/teiid/resource/adapter/yahoo/YahooExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,14 +22,14 @@
package org.teiid.resource.adapter.yahoo;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ResultSetExecution;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
public class YahooExecutionFactory extends BasicExecutionFactory {
Modified: trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo/TestYahooTranslation.java
===================================================================
--- trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo/TestYahooTranslation.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/sandbox/translator-yahoo/src/test/java/org/teiid/resource/adapter/yahoo/TestYahooTranslation.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,8 +22,8 @@
package org.teiid.resource.adapter.yahoo;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Select;
+import org.teiid.language.Command;
+import org.teiid.language.Select;
import org.teiid.resource.adapter.yahoo.YahooExecution;
import junit.framework.TestCase;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCBaseExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCBaseExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCBaseExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,14 +30,14 @@
import java.sql.Statement;
import java.util.List;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
+import org.teiid.translator.BasicConnectorCapabilities;
/**
@@ -46,7 +46,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#getMaxInCriteriaSize()
+ * @see org.teiid.translator.BasicConnectorCapabilities#getMaxInCriteriaSize()
* @since 4.2
*/
public int getMaxInCriteriaSize() {
@@ -260,21 +260,21 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsInlineViews()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsInlineViews()
*/
public boolean supportsInlineViews() {
return false;
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsQuantifiedCompareCriteriaSome()
*/
public boolean supportsQuantifiedCompareCriteriaSome() {
return true;
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsSetQueryOrderBy()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsSetQueryOrderBy()
*/
@Override
public boolean supportsSetQueryOrderBy() {
@@ -282,7 +282,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsUnions()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
*/
public boolean supportsUnions() {
return true;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionException.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionException.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionException.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.sql.SQLException;
import java.util.Arrays;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.JDBCPlugin;
import org.teiid.translator.jdbc.TranslatedCommand;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,24 +27,24 @@
import javax.sql.DataSource;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.core.TeiidException;
import org.teiid.core.util.PropertiesUtils;
import org.teiid.core.util.ReflectionHelper;
import org.teiid.core.util.StringUtil;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.MetadataProvider;
-import org.teiid.resource.cci.ProcedureExecution;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.TranslatorProperty;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.UpdateExecution;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCMetdataProcessor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,18 +34,18 @@
import java.util.Set;
import java.util.TreeMap;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.BaseColumn;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
import org.teiid.core.util.StringUtil;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.BaseColumn;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.ProcedureParameter.Type;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.JDBCPlugin;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCProcedureExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCProcedureExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCProcedureExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,13 +28,13 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Command;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ProcedureExecution;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.jdbc.JDBCPlugin;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCQueryExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCQueryExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCQueryExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -32,12 +32,12 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ResultSetExecution;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
import org.teiid.translator.jdbc.JDBCPlugin;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCUpdateExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCUpdateExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/JDBCUpdateExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,13 +28,13 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Literal;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.UpdateExecution;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
@@ -75,7 +75,7 @@
}
/**
- * @see com.metamatrix.data.api.BatchedUpdatesExecution#execute(org.teiid.connector.language.Command[])
+ * @see com.metamatrix.data.api.BatchedUpdatesExecution#execute(org.teiid.language.Command[])
* @since 4.2
*/
public int[] execute(BatchedUpdates batchedCommand) throws ConnectorException {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/SimpleCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/SimpleCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/resource/adapter/jdbc/SimpleCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -248,7 +248,7 @@
/**
* Return null to indicate no functions are supported.
* @return null
- * @see org.teiid.resource.cci.ConnectorCapabilities#getSupportedFunctions()
+ * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
*/
public List getSupportedFunctions() {
return null;
@@ -259,7 +259,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsUnions()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsUnions()
* @since 4.2
*/
public boolean supportsUnions() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/AliasModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/AliasModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/AliasModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import java.util.List;
-import org.teiid.connector.language.*;
+import org.teiid.language.*;
public class AliasModifier extends FunctionModifier {
// The alias to use
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ConvertModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ConvertModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,12 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
/**
* Base class for handling the convert function.
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/EscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/EscapeSyntaxModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/EscapeSyntaxModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.Function;
+import org.teiid.language.Function;
/**
@@ -36,7 +36,7 @@
public class EscapeSyntaxModifier extends FunctionModifier {
/**
- * @see org.teiid.connector.jdbc.translator.BasicFunctionModifier#translate(org.teiid.connector.language.Function)
+ * @see org.teiid.connector.jdbc.translator.BasicFunctionModifier#translate(org.teiid.language.Function)
* @since 5.0
*/
public List<?> translate(Function function) {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ExtractFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ExtractFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ExtractFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,11 +27,11 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.connector.language.SQLReservedWords.Tokens;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords.Tokens;
+import org.teiid.translator.SourceSystemFunctions;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/FunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,9 +28,9 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.translator.TypeFacility;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/LocateFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,13 +25,13 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Comparison;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.translator.TypeFacility;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ModFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ModFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/ModFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,11 +29,11 @@
import java.util.List;
import java.util.Set;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
/**
* Adds mod (remainder) support for non-integral types
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/SQLConversionVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,28 +34,28 @@
import java.util.Map;
import java.util.Set;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.SortSpecification;
-import org.teiid.connector.language.Argument.Direction;
-import org.teiid.connector.language.SQLReservedWords.Tokens;
-import org.teiid.connector.language.SetQuery.Operation;
-import org.teiid.connector.language.SortSpecification.Ordering;
-import org.teiid.connector.visitor.util.SQLStringVisitor;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.Comparison;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SetClause;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.Argument.Direction;
+import org.teiid.language.SQLReservedWords.Tokens;
+import org.teiid.language.SetQuery.Operation;
+import org.teiid.language.SortSpecification.Ordering;
+import org.teiid.language.visitor.SQLStringVisitor;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.Translator.NullOrder;
@@ -197,7 +197,7 @@
}
/**
- * @see org.teiid.connector.visitor.util.SQLStringVisitor#visit(org.teiid.connector.language.Call)
+ * @see org.teiid.language.visitor.SQLStringVisitor#visit(org.teiid.language.Call)
*/
public void visit(Call obj) {
this.prepared = true;
@@ -209,7 +209,7 @@
}
/**
- * @see org.teiid.connector.visitor.util.SQLStringVisitor#visit(org.teiid.connector.language.Literal)
+ * @see org.teiid.language.visitor.SQLStringVisitor#visit(org.teiid.language.Literal)
*/
public void visit(Literal obj) {
if (this.prepared && (replaceWithBinding || TranslatedCommand.isBindEligible(obj) || obj.isBindValue())) {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/TranslatedCommand.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,12 +26,12 @@
import java.util.List;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.visitor.util.CollectorVisitor;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
+import org.teiid.language.visitor.CollectorVisitor;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TypeFacility;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/Translator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -41,27 +41,27 @@
import java.util.Map;
import java.util.TimeZone;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SetQuery;
-import org.teiid.connector.language.Argument.Direction;
import org.teiid.core.util.ReflectionHelper;
+import org.teiid.language.Argument;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.SetQuery;
+import org.teiid.language.Argument.Direction;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/access/AccessSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
*/
package org.teiid.translator.jdbc.access;
-import org.teiid.resource.cci.ConnectorCapabilities;
+import org.teiid.translator.ConnectorCapabilities;
import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2Capabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -112,7 +112,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
* @since 5.0
*/
public boolean supportsFunctionsInGroupBy() {
@@ -124,7 +124,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsExcept()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
*/
@Override
public boolean supportsExcept() {
@@ -132,7 +132,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsIntersect()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
*/
@Override
public boolean supportsIntersect() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2SQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,21 +25,21 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.connector.language.Join.JoinType;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.Join;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.Join.JoinType;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbyCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -143,7 +143,7 @@
/**
* Derby supports only SearchedCaseExpression, not CaseExpression.
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsCaseExpressions()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsCaseExpressions()
* @since 5.0
*/
public boolean supportsCaseExpressions() {
@@ -152,7 +152,7 @@
/**
* Derby supports only left and right outer joins.
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFullOuterJoins()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFullOuterJoins()
* @since 5.0
*/
public boolean supportsFullOuterJoins() {
@@ -161,7 +161,7 @@
/**
* Inline views (subqueries in the FROM clause) are supported.
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsInlineViews()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsInlineViews()
* @since 4.3
*/
public boolean supportsInlineViews() {
@@ -169,7 +169,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsExcept()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
*/
@Override
public boolean supportsExcept() {
@@ -177,7 +177,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsIntersect()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
*/
@Override
public boolean supportsIntersect() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/derby/DerbySQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,10 +22,10 @@
package org.teiid.translator.jdbc.derby;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
import org.teiid.translator.jdbc.oracle.LeftOrRightFunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Capabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,7 +26,7 @@
import java.util.List;
import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class H2Capabilities extends JDBCCapabilities {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/h2/H2Translator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,10 +26,10 @@
import java.sql.Time;
import java.sql.Timestamp;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/AddDiffModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/AddDiffModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/AddDiffModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,12 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.ExtractFunctionModifier;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,7 +26,7 @@
import java.util.List;
import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class HsqlCapabilities extends JDBCCapabilities {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/hsql/HsqlTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,10 +26,10 @@
import java.sql.Time;
import java.sql.Timestamp;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/informix/InformixSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,10 +24,10 @@
*/
package org.teiid.translator.jdbc.informix;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/BitFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/BitFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/BitFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,9 +25,9 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Capabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQL5Translator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,11 +25,11 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Function;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Function;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.FunctionModifier;
public class MySQL5Translator extends MySQLTranslator {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,7 +26,7 @@
import java.util.List;
import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/mysql/MySQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,14 +31,14 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Function;
+import org.teiid.language.Function;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.FunctionModifier;
import org.teiid.translator.jdbc.LocateFunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/ConcatFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/ConcatFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/ConcatFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,15 +26,15 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Condition;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SearchedWhenClause;
-import org.teiid.connector.language.AndOr.Operator;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Condition;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.AndOr.Operator;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/DayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/DayWeekQuarterFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/DayWeekQuarterFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Function;
+import org.teiid.language.Function;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/LeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/LeftOrRightFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/LeftOrRightFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,10 +25,10 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.cci.TypeFacility;
+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.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/Log10FunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/Log10FunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/Log10FunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,10 +24,10 @@
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.cci.TypeFacility;
+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.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/MonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/MonthOrDayNameFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/MonthOrDayNameFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,11 +25,11 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,7 +28,7 @@
import java.util.List;
import org.teiid.resource.adapter.jdbc.JDBCCapabilities;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
/**
@@ -122,7 +122,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
* @since 5.0
*/
public boolean supportsFunctionsInGroupBy() {
@@ -137,7 +137,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsExcept()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
*/
@Override
public boolean supportsExcept() {
@@ -145,7 +145,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsIntersect()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
*/
@Override
public boolean supportsIntersect() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -35,30 +35,30 @@
import java.util.Collection;
import java.util.List;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SQLReservedWords.Tokens;
-import org.teiid.connector.language.SetQuery.Operation;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.visitor.util.CollectorVisitor;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Function;
+import org.teiid.language.Insert;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.language.SQLReservedWords.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.resource.ConnectorException;
+import org.teiid.metadata.Column;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.ExtractFunctionModifier;
@@ -348,7 +348,7 @@
/**
* Don't fully qualify elements if table = DUAL or element = ROWNUM or special stuff is packed into name in source value.
*
- * @see org.teiid.connector.visitor.util.SQLStringVisitor#skipGroupInElement(java.lang.String, java.lang.String)
+ * @see org.teiid.language.visitor.SQLStringVisitor#skipGroupInElement(java.lang.String, java.lang.String)
* @since 5.0
*/
@Override
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/oracle/OracleSpatialFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,9 +25,9 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.Literal;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/LocateFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/LocateFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/LocateFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,11 +25,11 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.translator.TypeFacility;
public class LocateFunctionModifier extends org.teiid.translator.jdbc.LocateFunctionModifier {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -263,7 +263,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsExcept()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsExcept()
*/
@Override
public boolean supportsExcept() {
@@ -271,7 +271,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#supportsIntersect()
+ * @see org.teiid.translator.BasicConnectorCapabilities#supportsIntersect()
*/
@Override
public boolean supportsIntersect() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/postgresql/PostgreSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,19 +28,19 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
@@ -188,7 +188,7 @@
/**
* Postgres doesn't provide min/max(boolean), so this conversion writes a min(BooleanValue) as
* bool_and(BooleanValue)
- * @see org.teiid.connector.visitor.framework.LanguageObjectVisitor#visit(org.teiid.connector.language.AggregateFunction)
+ * @see org.teiid.language.visitor.LanguageObjectVisitor#visit(org.teiid.language.AggregateFunction)
* @since 4.3
*/
@Override
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -116,7 +116,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
* @since 5.0
*/
public boolean supportsFunctionsInGroupBy() {
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sqlserver/SQLServerSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,12 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
/**
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SubstringFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SubstringFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SubstringFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,11 +25,11 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.FunctionModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -117,7 +117,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
* @since 5.0
*/
public boolean supportsFunctionsInGroupBy() {
@@ -125,7 +125,7 @@
}
/**
- * @see org.teiid.resource.adapter.BasicConnectorCapabilities#getMaxFromGroups()
+ * @see org.teiid.translator.BasicConnectorCapabilities#getMaxFromGroups()
*/
public int getMaxFromGroups() {
return 50;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/sybase/SybaseSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,16 +28,16 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.SetQuery;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
+import org.teiid.language.Function;
+import org.teiid.language.Limit;
+import org.teiid.language.OrderBy;
+import org.teiid.language.SetQuery;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.AliasModifier;
import org.teiid.translator.jdbc.ConvertModifier;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/teiid/TeiidCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -36,7 +36,7 @@
public class TeiidCapabilities extends JDBCCapabilities {
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#getSupportedFunctions()
+ * @see org.teiid.translator.ConnectorCapabilities#getSupportedFunctions()
* @since 4.3
*/
public List<String> getSupportedFunctions() {
@@ -140,7 +140,7 @@
}
/**
- * @see org.teiid.resource.cci.ConnectorCapabilities#supportsFunctionsInGroupBy()
+ * @see org.teiid.translator.ConnectorCapabilities#supportsFunctionsInGroupBy()
* @since 5.0
*/
public boolean supportsFunctionsInGroupBy() {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeMetadataFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/FakeMetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,9 +26,9 @@
import junit.framework.Assert;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.language.Command;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCProcedureExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCProcedureExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCProcedureExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,10 +31,10 @@
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
+import org.teiid.language.Command;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.JDBCProcedureExecution;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.Translator;
public class TestJDBCProcedureExecution {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCUpdateExecution.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCUpdateExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TestJDBCUpdateExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,13 +28,13 @@
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Command;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Insert;
+import org.teiid.language.Literal;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.JDBCUpdateExecution;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.Translator;
public class TestJDBCUpdateExecution {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/resource/adapter/jdbc/TranslationHelper.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,12 +30,12 @@
import junit.framework.Assert;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
import org.teiid.core.TeiidRuntimeException;
+import org.teiid.language.Command;
import org.teiid.query.function.metadata.FunctionMetadataReader;
import org.teiid.query.function.metadata.FunctionMethod;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestEscapeSyntaxModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,9 +27,9 @@
import java.util.List;
import org.teiid.cdk.CommandBuilder;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.language.Function;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.jdbc.EscapeSyntaxModifier;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestExtractFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,16 +27,16 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.ExtractFunctionModifier;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestLocateFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,12 @@
import java.util.Arrays;
import org.junit.Test;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.LocateFunctionModifier;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestModFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,12 +28,12 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.ModFunctionModifier;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/TestSQLConversionVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,8 +26,6 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
import org.teiid.dqp.internal.datamgr.language.TestDeleteImpl;
import org.teiid.dqp.internal.datamgr.language.TestInsertImpl;
@@ -35,10 +33,12 @@
import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.LanguageObject;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.Translator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/access/TestAccessSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,10 +25,10 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.access.AccessSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2ConvertModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,12 +29,12 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,12 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
import org.teiid.core.util.UnitTestUtil;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.db2.DB2SQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/derby/TestDerbySQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,9 +25,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.derby.DerbySQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/h2/TestH2Translator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.h2.H2Translator;
public class TestH2Translator {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQL5Translator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.mysql.MySQL5Translator;
/**
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/mysql/TestMySQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,9 +25,9 @@
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.mysql.MySQLTranslator;
/**
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestDayWeekQuarterFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,12 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLeftOrRightFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,9 +26,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLog10FunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLog10FunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestLog10FunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,11 +27,11 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.visitor.util.SQLStringVisitor;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
+import org.teiid.language.visitor.SQLStringVisitor;
import org.teiid.translator.jdbc.oracle.Log10FunctionModifier;
/**
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestMonthOrDayNameFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,9 +27,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.translator.jdbc.SQLConversionVisitor;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleConvertModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,12 +31,12 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
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 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,24 +29,24 @@
import org.junit.Before;
import org.junit.Test;
import org.teiid.cdk.CommandBuilder;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
import org.teiid.dqp.internal.datamgr.impl.FakeExecutionContextImpl;
+import org.teiid.language.Command;
+import org.teiid.metadata.Column;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.Translator;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestSubstringFunctionModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,11 +26,11 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.TypeFacility;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.oracle.OracleSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/postgresql/TestPostgreSQLTranslator.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.postgresql.PostgreSQLTranslator;
public class TestPostgreSQLTranslator {
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,19 +26,19 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Command;
+import org.teiid.metadata.Column;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.sqlserver.SQLServerSQLTranslator;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseConvertModifier.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,14 +30,14 @@
import org.junit.BeforeClass;
import org.junit.Test;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageFactory;
-import org.teiid.connector.language.Literal;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.Literal;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
+import org.teiid.translator.ConnectorException;
import org.teiid.translator.jdbc.SQLConversionVisitor;
import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sybase/TestSybaseSQLConversionVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,11 +27,11 @@
import org.junit.BeforeClass;
import org.junit.Test;
import org.mockito.Mockito;
-import org.teiid.connector.language.Command;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
import org.teiid.resource.adapter.jdbc.JDBCExecutionFactory;
import org.teiid.resource.adapter.jdbc.TranslationHelper;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
import org.teiid.translator.jdbc.TranslatedCommand;
import org.teiid.translator.jdbc.sybase.SybaseSQLTranslator;
Copied: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap (from rev 2118, trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap)
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/IQueryToLdapSearchParser.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/IQueryToLdapSearchParser.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,7 +31,7 @@
*
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
@@ -47,34 +47,34 @@
import javax.naming.directory.SearchControls;
import javax.naming.ldap.SortKey;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Condition;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Exists;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Not;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.ScalarSubquery;
-import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SortSpecification;
-import org.teiid.connector.language.TableReference;
-import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.connector.language.SortSpecification.Ordering;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Exists;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.Like;
+import org.teiid.language.Limit;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.OrderBy;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.Select;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.TableReference;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.SortSpecification.Ordering;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.Table;
+import org.teiid.translator.ConnectorException;
@@ -537,7 +537,7 @@
return;
}
filterList.add("("); //$NON-NLS-1$
- filterList.add(parseCompoundCriteriaOp(org.teiid.connector.language.AndOr.Operator.OR));
+ filterList.add(parseCompoundCriteriaOp(org.teiid.language.AndOr.Operator.OR));
Iterator rhsItr = rhsList.iterator();
while(rhsItr.hasNext()) {
addCompareCriteriaToList(filterList, Operator.EQ, getExpressionString(lhs),
@@ -641,7 +641,7 @@
/**
* Helper method for getting runtime {@link org.teiid.connector.metadata.runtime.Element} from a
- * {@link org.teiid.connector.language.DerivedColumn}.
+ * {@link org.teiid.language.DerivedColumn}.
* @param symbol Input ISelectSymbol
* @return Element returned metadata runtime Element
*/
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPConnectorCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,9 +19,9 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
+import org.teiid.translator.BasicConnectorCapabilities;
/**
* This class extends the BasicConnectorCapabilities class, and establishes
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorConstants.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPConnectorConstants.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPConnectorConstants.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import javax.naming.directory.*;
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,23 +19,23 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import javax.naming.ldap.LdapContext;
import javax.resource.ResourceException;
import javax.resource.cci.ConnectionFactory;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.TranslatorProperty;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.UpdateExecution;
/**
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPPlugin.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPPlugin.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import java.util.ResourceBundle;
@@ -31,7 +31,7 @@
*/
public class LDAPPlugin {
- public static final String PLUGIN_ID = "org.teiid.resource.adapter.ldap" ; //$NON-NLS-1$
+ public static final String PLUGIN_ID = LDAPPlugin.class.getPackage().getName();
/**
* Provides access to the plugin's log and to it's resources.
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPSearchDetails.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSearchDetails.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import java.util.ArrayList;
import java.util.Iterator;
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPSyncQueryExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPSyncQueryExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -69,7 +69,7 @@
*
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import java.io.IOException;
import java.sql.Timestamp;
@@ -93,13 +93,13 @@
import javax.naming.ldap.SortControl;
import javax.naming.ldap.SortKey;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.language.Select;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.ResultSetExecution;
+import org.teiid.metadata.Column;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ResultSetExecution;
Modified: trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java
===================================================================
--- trunk/connectors/translator-ldap/src/main/java/org/teiid/resource/adapter/ldap/LDAPUpdateExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/main/java/org/teiid/translator/ldap/LDAPUpdateExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -19,7 +19,7 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package org.teiid.resource.adapter.ldap;
+package org.teiid.translator.ldap;
import java.util.List;
@@ -32,25 +32,25 @@
import javax.naming.directory.ModificationItem;
import javax.naming.ldap.LdapContext;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Condition;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.Update;
-import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.language.Delete;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Insert;
+import org.teiid.language.Literal;
+import org.teiid.language.SetClause;
+import org.teiid.language.Update;
+import org.teiid.language.Comparison.Operator;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.UpdateExecution;
Copied: trunk/connectors/translator-ldap/src/main/resources/org/teiid/translator (from rev 2118, trunk/connectors/translator-ldap/src/main/resources/org/teiid/resource/adapter)
Modified: trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java
===================================================================
--- trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-ldap/src/test/java/org/teiid/resource/adapter/ldap/TestIQueryToLdapSearchParser.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,24 +34,24 @@
import junit.framework.TestCase;
import org.teiid.cdk.CommandBuilder;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.language.Command;
+import org.teiid.language.Select;
+import org.teiid.metadata.Column;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.Column.SearchType;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.ldap.IQueryToLdapSearchParser;
-import org.teiid.resource.adapter.ldap.LDAPExecutionFactory;
-import org.teiid.resource.adapter.ldap.LDAPSearchDetails;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ldap.IQueryToLdapSearchParser;
+import org.teiid.translator.ldap.LDAPExecutionFactory;
+import org.teiid.translator.ldap.LDAPSearchDetails;
/**
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackCapabilities.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
+import org.teiid.translator.BasicConnectorCapabilities;
/**
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecution.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -33,20 +33,20 @@
import java.util.List;
import java.util.Random;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Argument.Direction;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Argument.Direction;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ProcedureExecution;
-import org.teiid.resource.cci.TypeFacility;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.UpdateExecution;
/**
Modified: trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecutionFactory.java
===================================================================
--- trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-loopback/src/main/java/org/teiid/resource/adapter/loopback/LoopbackExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,14 +22,14 @@
package org.teiid.resource.adapter.loopback;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.Execution;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.TranslatorProperty;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.TranslatorProperty;
/**
* Loopback connector.
Modified: trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback/TestLoopbackExecution.java
===================================================================
--- trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback/TestLoopbackExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-loopback/src/test/java/org/teiid/resource/adaptor/loopback/TestLoopbackExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,9 +28,9 @@
import junit.framework.TestCase;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.loopback.LoopbackExecution;
import org.teiid.resource.adapter.loopback.LoopbackExecutionFactory;
+import org.teiid.translator.ConnectorException;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/MetadataProcessor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -6,16 +6,16 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
+import org.teiid.translator.ConnectorException;
import com.sforce.soap.partner.ChildRelationship;
import com.sforce.soap.partner.DescribeGlobalResult;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/NameUtil.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/NameUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/NameUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -7,7 +7,7 @@
*/
package org.teiid.resource.adapter.salesforce;
-import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords;
public class NameUtil {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceExecutionFactory.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesForceExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,29 +22,29 @@
package org.teiid.resource.adapter.salesforce;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.execution.DeleteExecutionImpl;
import org.teiid.resource.adapter.salesforce.execution.InsertExecutionImpl;
import org.teiid.resource.adapter.salesforce.execution.ProcedureExecutionParentImpl;
import org.teiid.resource.adapter.salesforce.execution.QueryExecutionImpl;
import org.teiid.resource.adapter.salesforce.execution.UpdateExecutionImpl;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.MetadataProvider;
-import org.teiid.resource.cci.ProcedureExecution;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.TranslatorProperty;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.UpdateExecution;
-public class SalesForceExecutionFactory extends org.teiid.resource.adapter.BasicExecutionFactory implements MetadataProvider {
+public class SalesForceExecutionFactory extends org.teiid.translator.BasicExecutionFactory implements MetadataProvider {
private String connectorStateClass;
private boolean auditModelFields = false;
@@ -87,11 +87,11 @@
@Override
public UpdateExecution createUpdateExecution(Command command, ExecutionContext executionContext, RuntimeMetadata metadata, Object connectionFactory) throws ConnectorException {
UpdateExecution result = null;
- if(command instanceof org.teiid.connector.language.Delete) {
+ if(command instanceof org.teiid.language.Delete) {
result = new DeleteExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
- } else if (command instanceof org.teiid.connector.language.Insert) {
+ } else if (command instanceof org.teiid.language.Insert) {
result = new InsertExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
- } else if (command instanceof org.teiid.connector.language.Update) {
+ } else if (command instanceof org.teiid.language.Update) {
result = new UpdateExecutionImpl(command, (SalesforceConnection)connectionFactory, metadata, executionContext);
}
return result;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceCapabilities.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
+import org.teiid.translator.BasicConnectorCapabilities;
public class SalesforceCapabilities extends BasicConnectorCapabilities {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnection.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnection.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/SalesforceConnection.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,10 +25,10 @@
import javax.xml.datatype.XMLGregorianCalendar;
-import org.teiid.resource.ConnectorException;
import org.teiid.resource.adapter.salesforce.execution.DataPayload;
import org.teiid.resource.adapter.salesforce.execution.DeletedResult;
import org.teiid.resource.adapter.salesforce.execution.UpdatedResult;
+import org.teiid.translator.ConnectorException;
import com.sforce.soap.partner.DescribeGlobalResult;
import com.sforce.soap.partner.DescribeSObjectResult;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Util.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Util.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/Util.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import java.text.DateFormat;
import java.text.SimpleDateFormat;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public class Util {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/AbstractUpdateExecution.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/AbstractUpdateExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/AbstractUpdateExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,18 +23,18 @@
import java.util.ArrayList;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Condition;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
+import org.teiid.language.Command;
+import org.teiid.language.Comparison;
+import org.teiid.language.Condition;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
import org.teiid.resource.adapter.salesforce.Util;
import org.teiid.resource.adapter.salesforce.execution.visitors.IQueryProvidingVisitor;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.UpdateExecution;
import com.sforce.soap.partner.QueryResult;
import com.sforce.soap.partner.sobject.SObject;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeleteExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeleteExecutionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/DeleteExecutionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -21,13 +21,13 @@
*/
package org.teiid.resource.adapter.salesforce.execution;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
+import org.teiid.language.Delete;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
import org.teiid.resource.adapter.salesforce.execution.visitors.DeleteVisitor;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
public class DeleteExecutionImpl extends AbstractUpdateExecution {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetDeletedExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetDeletedExecutionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetDeletedExecutionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -9,9 +9,9 @@
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.translator.ConnectorException;
/**
*
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetUpdatedExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetUpdatedExecutionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/GetUpdatedExecutionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -10,9 +10,9 @@
import javax.xml.datatype.DatatypeFactory;
import javax.xml.datatype.XMLGregorianCalendar;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.translator.ConnectorException;
/**
*
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/InsertExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/InsertExecutionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/InsertExecutionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,13 +22,13 @@
package org.teiid.resource.adapter.salesforce.execution;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Command;
+import org.teiid.language.Insert;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
import org.teiid.resource.adapter.salesforce.execution.visitors.InsertVisitor;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
public class InsertExecutionImpl extends AbstractUpdateExecution {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParent.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParent.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParent.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,9 +1,9 @@
package org.teiid.resource.adapter.salesforce.execution;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ExecutionContext;
public interface ProcedureExecutionParent {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParentImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParentImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/ProcedureExecutionParentImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -2,13 +2,13 @@
import java.util.List;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Call;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ProcedureExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
public class ProcedureExecutionParentImpl implements ProcedureExecution, ProcedureExecutionParent {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/QueryExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/QueryExecutionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/QueryExecutionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -33,27 +33,27 @@
import javax.xml.namespace.QName;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.TableReference;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.Join;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
+import org.teiid.language.TableReference;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
import org.teiid.resource.adapter.salesforce.Messages;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
import org.teiid.resource.adapter.salesforce.Util;
import org.teiid.resource.adapter.salesforce.execution.visitors.JoinQueryVisitor;
import org.teiid.resource.adapter.salesforce.execution.visitors.SelectVisitor;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ResultSetExecution;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
import org.w3c.dom.Element;
import com.sforce.soap.partner.QueryResult;
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/SalesforceProcedureExecution.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/SalesforceProcedureExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/SalesforceProcedureExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -2,7 +2,7 @@
import java.util.List;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public interface SalesforceProcedureExecution {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/UpdateExecutionImpl.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/UpdateExecutionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/UpdateExecutionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,18 +27,18 @@
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SetClause;
-import org.teiid.connector.language.Update;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.Literal;
+import org.teiid.language.SetClause;
+import org.teiid.language.Update;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.resource.adapter.salesforce.SalesforceConnection;
import org.teiid.resource.adapter.salesforce.Util;
import org.teiid.resource.adapter.salesforce.execution.visitors.UpdateVisitor;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
public class UpdateExecutionImpl extends AbstractUpdateExecution {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/CriteriaVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/CriteriaVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/CriteriaVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,24 +29,24 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Not;
-import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.visitor.framework.HierarchyVisitor;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.AndOr;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.In;
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.visitor.HierarchyVisitor;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
import org.teiid.resource.adapter.salesforce.Messages;
import org.teiid.resource.adapter.salesforce.Util;
+import org.teiid.translator.ConnectorException;
/**
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/DeleteVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/DeleteVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/DeleteVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,9 +23,9 @@
import java.util.Iterator;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Delete;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
public class DeleteVisitor extends CriteriaVisitor implements IQueryProvidingVisitor {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/ICriteriaVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/ICriteriaVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/ICriteriaVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -21,7 +21,7 @@
*/
package org.teiid.resource.adapter.salesforce.execution.visitors;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public interface ICriteriaVisitor {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/IQueryProvidingVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/IQueryProvidingVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/IQueryProvidingVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -21,7 +21,7 @@
*/
package org.teiid.resource.adapter.salesforce.execution.visitors;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public interface IQueryProvidingVisitor extends ICriteriaVisitor {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/InsertVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/InsertVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/InsertVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,14 +27,14 @@
import javax.xml.bind.JAXBElement;
import javax.xml.namespace.QName;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Insert;
+import org.teiid.language.Literal;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
public class InsertVisitor extends CriteriaVisitor {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/JoinQueryVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/JoinQueryVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/JoinQueryVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -1,18 +1,18 @@
package org.teiid.resource.adapter.salesforce.execution.visitors;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.TableReference;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.Join;
+import org.teiid.language.NamedTable;
+import org.teiid.language.TableReference;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
import org.teiid.resource.adapter.salesforce.Util;
+import org.teiid.translator.ConnectorException;
/**
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/SelectVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/SelectVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/SelectVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,21 +27,21 @@
import java.util.List;
import java.util.Map;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Limit;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Expression;
+import org.teiid.language.Limit;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Select;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
import org.teiid.resource.adapter.salesforce.Constants;
import org.teiid.resource.adapter.salesforce.Messages;
import org.teiid.resource.adapter.salesforce.Util;
+import org.teiid.translator.ConnectorException;
public class SelectVisitor extends CriteriaVisitor implements IQueryProvidingVisitor {
Modified: trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/UpdateVisitor.java
===================================================================
--- trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/UpdateVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/main/java/org/teiid/resource/adapter/salesforce/execution/visitors/UpdateVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -21,9 +21,9 @@
*/
package org.teiid.resource.adapter.salesforce.execution.visitors;
-import org.teiid.connector.language.Update;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
+import org.teiid.language.Update;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.ConnectorException;
public class UpdateVisitor extends CriteriaVisitor implements IQueryProvidingVisitor {
Modified: trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java
===================================================================
--- trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-salesforce/src/test/java/org/teiid/resource/adapter/salesforce/execution/visitors/TestVisitors.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,15 +27,15 @@
import java.util.List;
import org.junit.Test;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.Select;
+import org.teiid.metadata.Column;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.Column.SearchType;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.resource.adapter.salesforce.execution.visitors.JoinQueryVisitor;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextCapabilities.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextCapabilities.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,7 +22,7 @@
package org.teiid.resource.adapter.text;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
+import org.teiid.translator.BasicConnectorCapabilities;
public class TextCapabilities extends BasicConnectorCapabilities {
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextConnectionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -41,8 +41,8 @@
import org.teiid.core.util.StringUtil;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.FileConnection;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.FileConnection;
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextExecutionFactory.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextExecutionFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextExecutionFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -37,22 +37,22 @@
import javax.resource.ResourceException;
import javax.resource.cci.ConnectionFactory;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.Select;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.adapter.FileConnection;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.MetadataProvider;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.TranslatorProperty;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.Table;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.FileConnection;
+import org.teiid.translator.MetadataProvider;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TranslatorProperty;
+import org.teiid.translator.TypeFacility;
/**
Modified: trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextSynchExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/main/java/org/teiid/resource/adapter/text/TextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,19 +31,19 @@
import java.util.List;
import java.util.Properties;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.Column;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Select;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.metadata.Column;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.TypeFacility;
/**
* The essential part that executes the query. It keeps all the execution
@@ -241,7 +241,7 @@
/**
* Helper method for getting runtime {@link org.teiid.connector.metadata.runtime.Element} from a
- * {@link org.teiid.connector.language.DerivedColumn}.
+ * {@link org.teiid.language.DerivedColumn}.
* @param symbol Input ISelectSymbol
* @return Element returned metadata runtime Element
*/
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestMultiFileTextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,7 +30,7 @@
import junit.framework.TestCase;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
import com.metamatrix.cdk.api.ConnectorHost;
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestRowHeaderTextSynchExecution.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestRowHeaderTextSynchExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestRowHeaderTextSynchExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/TestTextConnector.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,11 +29,11 @@
import java.util.Properties;
import org.junit.Test;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.types.DataTypeManager;
-import org.teiid.resource.cci.MetadataProvider;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Table;
+import org.teiid.translator.MetadataProvider;
/**
Modified: trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java
===================================================================
--- trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/connectors/translator-text/src/test/java/org/teiid/resource/adapter/text/Util.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -32,18 +32,18 @@
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.FileUtils;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.Column;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.unittest.RealMetadataFactory;
-import org.teiid.resource.adapter.FileConnection;
+import org.teiid.translator.FileConnection;
import com.metamatrix.cdk.api.ConnectorHost;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,7 +28,7 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
-import org.teiid.resource.cci.ConnectorCapabilities;
+import org.teiid.translator.ConnectorCapabilities;
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -36,9 +36,6 @@
import javax.naming.NamingException;
import org.teiid.common.buffer.BlockedException;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
-import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.core.util.Assertion;
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
@@ -52,19 +49,22 @@
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataStore;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Scope;
import org.teiid.query.sql.lang.Command;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ExecutionFactory;
-import org.teiid.resource.cci.MetadataProvider;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.MetadataProvider;
/**
- * The <code>ConnectorManager</code> manages a {@link org.teiid.resource.adapter.BasicExecutionFactory Connector}
+ * The <code>ConnectorManager</code> manages a {@link org.teiid.translator.BasicExecutionFactory Connector}
* and its associated workers' state.
*/
public class ConnectorManager {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.dqp.message.AtomicResultsMessage;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,9 +30,6 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleBuffer;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.TransformationException;
@@ -44,22 +41,25 @@
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.language.Call;
+import org.teiid.language.QueryExpression;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataAdapter;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.Execution;
-import org.teiid.resource.cci.ExecutionFactory;
-import org.teiid.resource.cci.ProcedureExecution;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.UpdateExecution;
public class ConnectorWorkItem implements ConnectorWork {
@@ -82,7 +82,7 @@
private ExecutionContextImpl securityContext;
private volatile ResultSetExecution execution;
private ProcedureBatchHandler procedureBatchHandler;
- private org.teiid.connector.language.Command translatedCommand;
+ private org.teiid.language.Command translatedCommand;
private Class<?>[] schema;
private List<Integer> convertToRuntimeType;
private boolean[] convertToDesiredRuntimeType;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -36,8 +36,8 @@
import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.process.DQPWorkContext;
-import org.teiid.resource.cci.CacheScope;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.CacheScope;
+import org.teiid.translator.ExecutionContext;
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -30,12 +30,12 @@
import java.util.Collections;
import java.util.List;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Argument.Direction;
import org.teiid.dqp.DQPPlugin;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ProcedureExecution;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Argument.Direction;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ProcedureExecution;
class ProcedureBatchHandler {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TranslatorRepository.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TranslatorRepository.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/TranslatorRepository.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,7 +26,7 @@
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-import org.teiid.resource.cci.ExecutionFactory;
+import org.teiid.translator.ExecutionFactory;
public class TranslatorRepository implements Serializable{
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,42 +28,42 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Condition;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.DerivedTable;
-import org.teiid.connector.language.Exists;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.In;
-import org.teiid.connector.language.InsertValueSource;
-import org.teiid.connector.language.IsNull;
-import org.teiid.connector.language.Join;
-import org.teiid.connector.language.Like;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Not;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.language.SearchedCase;
-import org.teiid.connector.language.SearchedWhenClause;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SortSpecification;
-import org.teiid.connector.language.SubqueryComparison;
-import org.teiid.connector.language.SubqueryIn;
-import org.teiid.connector.language.TableReference;
-import org.teiid.connector.language.Argument.Direction;
-import org.teiid.connector.language.Comparison.Operator;
-import org.teiid.connector.language.SortSpecification.Ordering;
-import org.teiid.connector.language.SubqueryComparison.Quantifier;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.AndOr;
+import org.teiid.language.Argument;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Condition;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.DerivedTable;
+import org.teiid.language.Exists;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.In;
+import org.teiid.language.InsertValueSource;
+import org.teiid.language.IsNull;
+import org.teiid.language.Join;
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Not;
+import org.teiid.language.QueryExpression;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Select;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryIn;
+import org.teiid.language.TableReference;
+import org.teiid.language.Argument.Direction;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.SortSpecification.Ordering;
+import org.teiid.language.SubqueryComparison.Quantifier;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
@@ -108,7 +108,7 @@
import org.teiid.query.sql.symbol.ScalarSubquery;
import org.teiid.query.sql.symbol.SearchedCaseExpression;
import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public class LanguageBridgeFactory {
@@ -120,7 +120,7 @@
}
}
- public org.teiid.connector.language.Command translate(Command command) {
+ public org.teiid.language.Command translate(Command command) {
if (command == null) return null;
if (command instanceof Query) {
return translate((Query)command);
@@ -147,18 +147,18 @@
return translate((SetQuery)command);
}
- org.teiid.connector.language.SetQuery translate(SetQuery union) {
- org.teiid.connector.language.SetQuery result = new org.teiid.connector.language.SetQuery();
+ org.teiid.language.SetQuery translate(SetQuery union) {
+ org.teiid.language.SetQuery result = new org.teiid.language.SetQuery();
result.setAll(union.isAll());
switch (union.getOperation()) {
case UNION:
- result.setOperation(org.teiid.connector.language.SetQuery.Operation.UNION);
+ result.setOperation(org.teiid.language.SetQuery.Operation.UNION);
break;
case INTERSECT:
- result.setOperation(org.teiid.connector.language.SetQuery.Operation.INTERSECT);
+ result.setOperation(org.teiid.language.SetQuery.Operation.INTERSECT);
break;
case EXCEPT:
- result.setOperation(org.teiid.connector.language.SetQuery.Operation.EXCEPT);
+ result.setOperation(org.teiid.language.SetQuery.Operation.EXCEPT);
break;
}
result.setLeftQuery(translate(union.getLeftQuery()));
@@ -180,7 +180,7 @@
symbol = ((AliasSymbol)symbol).getSymbol();
}
- org.teiid.connector.language.Expression iExp = null;
+ org.teiid.language.Expression iExp = null;
if(symbol instanceof ElementSymbol) {
iExp = translate((ElementSymbol)symbol);
} else if(symbol instanceof AggregateSymbol) {
@@ -280,7 +280,7 @@
throw new AssertionError();
}
- org.teiid.connector.language.Comparison translate(CompareCriteria criteria) {
+ org.teiid.language.Comparison translate(CompareCriteria criteria) {
Operator operator = Operator.EQ;
switch(criteria.getOperator()) {
case CompareCriteria.EQ:
@@ -304,7 +304,7 @@
}
- return new org.teiid.connector.language.Comparison(translate(criteria.getLeftExpression()),
+ return new org.teiid.language.Comparison(translate(criteria.getLeftExpression()),
translate(criteria.getRightExpression()), operator);
}
@@ -401,19 +401,19 @@
return new Not(translate(criteria.getCriteria()));
}
- public org.teiid.connector.language.GroupBy translate(GroupBy groupBy) {
+ public org.teiid.language.GroupBy translate(GroupBy groupBy) {
if(groupBy == null){
return null;
}
List items = groupBy.getSymbols();
- List<org.teiid.connector.language.Expression> translatedItems = new ArrayList<org.teiid.connector.language.Expression>();
+ List<org.teiid.language.Expression> translatedItems = new ArrayList<org.teiid.language.Expression>();
for (Iterator i = items.iterator(); i.hasNext();) {
translatedItems.add(translate((Expression)i.next()));
}
- return new org.teiid.connector.language.GroupBy(translatedItems);
+ return new org.teiid.language.GroupBy(translatedItems);
}
- public org.teiid.connector.language.OrderBy translate(OrderBy orderBy) {
+ public org.teiid.language.OrderBy translate(OrderBy orderBy) {
if(orderBy == null){
return null;
}
@@ -431,12 +431,12 @@
}
translatedItems.add(orderByItem);
}
- return new org.teiid.connector.language.OrderBy(translatedItems);
+ return new org.teiid.language.OrderBy(translatedItems);
}
/* Expressions */
- public org.teiid.connector.language.Expression translate(Expression expr) {
+ public org.teiid.language.Expression translate(Expression expr) {
if (expr == null) return null;
if (expr instanceof Constant) {
return translate((Constant)expr);
@@ -459,15 +459,15 @@
return result;
}
- org.teiid.connector.language.Function translate(Function function) {
+ org.teiid.language.Function translate(Function function) {
Expression [] args = function.getArgs();
- List<org.teiid.connector.language.Expression> params = new ArrayList<org.teiid.connector.language.Expression>(args.length);
+ List<org.teiid.language.Expression> params = new ArrayList<org.teiid.language.Expression>(args.length);
if (args != null) {
for (int i = 0; i < args.length; i++) {
params.add(translate(args[i]));
}
}
- return new org.teiid.connector.language.Function(function.getName(), params, function.getType());
+ return new org.teiid.language.Function(function.getName(), params, function.getType());
}
SearchedCase translate(SearchedCaseExpression expr) {
@@ -481,11 +481,11 @@
}
- org.teiid.connector.language.Expression translate(ScalarSubquery ss) {
- return new org.teiid.connector.language.ScalarSubquery(translate((QueryCommand)ss.getCommand()));
+ org.teiid.language.Expression translate(ScalarSubquery ss) {
+ return new org.teiid.language.ScalarSubquery(translate((QueryCommand)ss.getCommand()));
}
- org.teiid.connector.language.Expression translate(SingleElementSymbol symbol) {
+ org.teiid.language.Expression translate(SingleElementSymbol symbol) {
if (symbol == null) return null;
if (symbol instanceof ElementSymbol) {
return translate((ElementSymbol)symbol);
@@ -497,7 +497,7 @@
throw new AssertionError();
}
- org.teiid.connector.language.Expression translate(AliasSymbol symbol) {
+ org.teiid.language.Expression translate(AliasSymbol symbol) {
return translate(symbol.getSymbol());
}
@@ -522,13 +522,13 @@
symbol.getType());
}
- org.teiid.connector.language.Expression translate(ExpressionSymbol symbol) {
+ org.teiid.language.Expression translate(ExpressionSymbol symbol) {
return translate(symbol.getExpression());
}
/* Insert */
- org.teiid.connector.language.Insert translate(Insert insert) {
+ org.teiid.language.Insert translate(Insert insert) {
List elements = insert.getVariables();
List<ColumnReference> translatedElements = new ArrayList<ColumnReference>();
for (Iterator i = elements.iterator(); i.hasNext();) {
@@ -541,40 +541,40 @@
} else {
// This is for the simple one row insert.
List values = insert.getValues();
- List<org.teiid.connector.language.Expression> translatedValues = new ArrayList<org.teiid.connector.language.Expression>();
+ List<org.teiid.language.Expression> translatedValues = new ArrayList<org.teiid.language.Expression>();
for (Iterator i = values.iterator(); i.hasNext();) {
translatedValues.add(translate((Expression)i.next()));
}
valueSource = new ExpressionValueSource(translatedValues);
}
- return new org.teiid.connector.language.Insert(translate(insert.getGroup()),
+ return new org.teiid.language.Insert(translate(insert.getGroup()),
translatedElements,
valueSource);
}
/* Update */
- org.teiid.connector.language.Update translate(Update update) {
- return new org.teiid.connector.language.Update(translate(update.getGroup()),
+ org.teiid.language.Update translate(Update update) {
+ return new org.teiid.language.Update(translate(update.getGroup()),
translate(update.getChangeList()),
translate(update.getCriteria()));
}
- List<org.teiid.connector.language.SetClause> translate(SetClauseList setClauseList) {
- List<org.teiid.connector.language.SetClause> clauses = new ArrayList<org.teiid.connector.language.SetClause>(setClauseList.getClauses().size());
+ List<org.teiid.language.SetClause> translate(SetClauseList setClauseList) {
+ List<org.teiid.language.SetClause> clauses = new ArrayList<org.teiid.language.SetClause>(setClauseList.getClauses().size());
for (SetClause setClause : setClauseList.getClauses()) {
clauses.add(translate(setClause));
}
return clauses;
}
- org.teiid.connector.language.SetClause translate(SetClause setClause) {
- return new org.teiid.connector.language.SetClause(translate(setClause.getSymbol()), translate(setClause.getValue()));
+ org.teiid.language.SetClause translate(SetClause setClause) {
+ return new org.teiid.language.SetClause(translate(setClause.getSymbol()), translate(setClause.getValue()));
}
/* Delete */
- org.teiid.connector.language.Delete translate(Delete delete) {
- org.teiid.connector.language.Delete deleteImpl = new org.teiid.connector.language.Delete(translate(delete.getGroup()),
+ org.teiid.language.Delete translate(Delete delete) {
+ org.teiid.language.Delete deleteImpl = new org.teiid.language.Delete(translate(delete.getGroup()),
translate(delete.getCriteria()));
return deleteImpl;
}
@@ -659,14 +659,14 @@
/* Batched Updates */
BatchedUpdates translate(BatchedUpdateCommand command) {
List updates = command.getUpdateCommands();
- List<org.teiid.connector.language.Command> translatedUpdates = new ArrayList<org.teiid.connector.language.Command>(updates.size());
+ List<org.teiid.language.Command> translatedUpdates = new ArrayList<org.teiid.language.Command>(updates.size());
for (Iterator i = updates.iterator(); i.hasNext();) {
translatedUpdates.add(translate((Command)i.next()));
}
return new BatchedUpdates(translatedUpdates);
}
- org.teiid.connector.language.Limit translate(Limit limit) {
+ org.teiid.language.Limit translate(Limit limit) {
if (limit == null) {
return null;
}
@@ -677,6 +677,6 @@
}
Literal c2 = (Literal)translate(limit.getRowLimit());
int rowLimit = ((Integer)c2.getValue()).intValue();
- return new org.teiid.connector.language.Limit(rowOffset, rowLimit);
+ return new org.teiid.language.Limit(rowOffset, rowLimit);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,13 +25,13 @@
package org.teiid.dqp.internal.datamgr.metadata;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.metadata.runtime.*;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.util.ArgCheck;
+import org.teiid.metadata.*;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.StoredProcedureInfo;
import org.teiid.query.sql.lang.SPParameter;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -36,7 +36,7 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
/**
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 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -37,16 +37,6 @@
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleSource;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.ForeignKey;
-import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
@@ -65,7 +55,17 @@
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.BufferService;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.processor.CollectionTupleSource;
import org.teiid.query.processor.ProcessorDataManager;
@@ -77,7 +77,7 @@
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.util.CommandContext;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
public class DataTierManagerImpl implements ProcessorDataManager {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -33,7 +33,7 @@
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.AtomicResultsMessage;
-import org.teiid.resource.ConnectorException;
+import org.teiid.translator.ConnectorException;
/**
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -35,7 +35,6 @@
import org.teiid.client.metadata.MetadataResult;
import org.teiid.client.metadata.ResultsMetadataConstants;
import org.teiid.client.metadata.ResultsMetadataDefaults;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
@@ -44,6 +43,7 @@
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.dqp.message.RequestID;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.SupportConstants;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -66,7 +66,7 @@
import org.teiid.query.sql.lang.SPParameter;
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.resource.cci.DataNotAvailableException;
+import org.teiid.translator.DataNotAvailableException;
public class RequestWorkItem extends AbstractWorkItem {
Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,12 +28,12 @@
import java.util.List;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.Table.Type;
import org.teiid.core.TeiidComponentException;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.Table.Type;
/**
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -39,19 +39,6 @@
import org.jboss.virtual.VirtualFile;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.ColumnSet;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.ForeignKey;
-import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
-import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.BlobImpl;
import org.teiid.core.types.ClobImpl;
@@ -63,6 +50,19 @@
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.StringUtil;
import org.teiid.dqp.DQPPlugin;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnSet;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
+import org.teiid.metadata.ProcedureParameter.Type;
import org.teiid.query.QueryPlugin;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,9 +25,9 @@
import java.io.Serializable;
import java.util.*;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.HashCodeUtil;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.function.metadata.*;
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -38,10 +38,10 @@
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.api.exception.query.FunctionExecutionException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.TransformationException;
import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.QueryPlugin;
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.ErrorMessageKeys;
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,7 +34,7 @@
import org.teiid.query.function.metadata.FunctionCategoryConstants;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.metadata.FunctionParameter;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,9 +28,9 @@
import java.util.List;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
@@ -45,7 +45,7 @@
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
import org.teiid.query.sql.visitor.ElementCollectorVisitor;
-import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ConnectorCapabilities.SupportedJoinCriteria;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -52,7 +52,7 @@
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.Permutation;
-import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ConnectorCapabilities.SupportedJoinCriteria;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -38,9 +38,9 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.api.exception.query.QueryResolverException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.metadata.QueryMetadataInterface;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -54,7 +54,7 @@
import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.query.sql.util.SymbolMap;
import org.teiid.query.util.CommandContext;
-import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ConnectorCapabilities.SupportedJoinCriteria;
public final class RuleRaiseAccess implements OptimizerRule {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,9 +31,9 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.api.exception.query.QueryResolverException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.util.Assertion;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
Modified: trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,8 +25,8 @@
import java.io.StringReader;
import org.teiid.api.exception.query.QueryParserException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.Criteria;
Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,9 +26,9 @@
import java.util.LinkedList;
import java.util.List;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.StringUtil;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.lang.Command;
import org.teiid.query.sql.lang.FromClause;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -40,7 +40,7 @@
import org.teiid.query.execution.QueryExecPlugin;
import org.teiid.query.processor.BatchCollector.BatchProducer;
import org.teiid.query.util.CommandContext;
-import org.teiid.resource.cci.DataNotAvailableException;
+import org.teiid.translator.DataNotAvailableException;
public class QueryProcessor implements BatchProducer {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,11 +34,11 @@
import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.client.plan.PlanNode;
import org.teiid.common.buffer.BlockedException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.id.IDGenerator;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SQLReservedWords;
import org.teiid.logging.LogManager;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.execution.QueryExecPlugin;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -37,9 +37,9 @@
import org.teiid.common.buffer.TupleBatch;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.TupleSource;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.aggregate.AggregateFunction;
import org.teiid.query.function.aggregate.Avg;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -46,7 +46,6 @@
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.api.exception.query.QueryValidatorException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.TeiidException;
@@ -54,6 +53,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.execution.QueryExecPlugin;
import org.teiid.query.function.FunctionDescriptor;
@@ -147,7 +147,7 @@
import org.teiid.query.sql.visitor.EvaluatableVisitor.EvaluationLevel;
import org.teiid.query.util.CommandContext;
import org.teiid.query.util.ErrorMessageKeys;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,7 +26,7 @@
import java.util.HashSet;
import java.util.Set;
-import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords;
/**
* Special variable names in stored procedure language.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,9 +25,9 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.visitor.SQLStringVisitor;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,7 +22,7 @@
package org.teiid.query.sql.proc;
-import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,10 +27,10 @@
import java.util.Map;
import java.util.Set;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.EquivalenceUtil;
import org.teiid.core.util.HashCodeUtil;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.LanguageVisitor;
import org.teiid.query.util.ErrorMessageKeys;
@@ -110,7 +110,7 @@
/**
* Construct an aggregate symbol with all given data.
* @param name Name of the function
- * @param aggregateFunction Aggregate function type ({@link org.teiid.connector.language.SQLReservedWords#COUNT}, etc)
+ * @param aggregateFunction Aggregate function type ({@link org.teiid.language.SQLReservedWords#COUNT}, etc)
* @param isDistinct True if DISTINCT flag is set
* @param expression Contained expression
*/
@@ -125,11 +125,11 @@
* Set the aggregate function. If the aggregate function is an invalid value, an
* IllegalArgumentException is thrown.
* @param aggregateFunction Aggregate function type
- * @see org.teiid.connector.language.SQLReservedWords#COUNT
- * @see org.teiid.connector.language.SQLReservedWords#SUM
- * @see org.teiid.connector.language.SQLReservedWords#AVG
- * @see org.teiid.connector.language.SQLReservedWords#MIN
- * @see org.teiid.connector.language.SQLReservedWords#MAX
+ * @see org.teiid.language.SQLReservedWords#COUNT
+ * @see org.teiid.language.SQLReservedWords#SUM
+ * @see org.teiid.language.SQLReservedWords#AVG
+ * @see org.teiid.language.SQLReservedWords#MIN
+ * @see org.teiid.language.SQLReservedWords#MAX
*/
private void setAggregateFunction(String aggregateFunction) {
// Validate aggregate
@@ -143,11 +143,11 @@
* Get the aggregate function type - this will map to one of the reserved words
* for the aggregate functions.
* @return Aggregate function type
- * @see org.teiid.connector.language.SQLReservedWords#COUNT
- * @see org.teiid.connector.language.SQLReservedWords#SUM
- * @see org.teiid.connector.language.SQLReservedWords#AVG
- * @see org.teiid.connector.language.SQLReservedWords#MIN
- * @see org.teiid.connector.language.SQLReservedWords#MAX
+ * @see org.teiid.language.SQLReservedWords#COUNT
+ * @see org.teiid.language.SQLReservedWords#SUM
+ * @see org.teiid.language.SQLReservedWords#AVG
+ * @see org.teiid.language.SQLReservedWords#MIN
+ * @see org.teiid.language.SQLReservedWords#MAX
*/
public String getAggregateFunction() {
return this.aggregate;
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 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,10 +29,10 @@
import java.util.LinkedList;
import java.util.List;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.connector.language.SQLReservedWords.Tokens;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.util.StringUtil;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords.Tokens;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.LanguageVisitor;
@@ -113,7 +113,7 @@
import org.teiid.query.sql.symbol.XMLForest;
import org.teiid.query.sql.symbol.XMLNamespaces;
import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,8 +25,8 @@
import java.util.Collection;
import java.util.Set;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.QueryPlugin;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.navigator.PreOrderNavigator;
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -112,7 +112,7 @@
import org.teiid.query.sql.visitor.SQLStringVisitor;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
import org.teiid.query.util.ErrorMessageKeys;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class ValidationVisitor extends AbstractValidationVisitor {
Modified: trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,10 +26,10 @@
import java.util.Iterator;
import java.util.List;
-import org.teiid.connector.language.LanguageFactory;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import org.teiid.language.LanguageFactory;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.optimizer.relational.AliasGenerator;
import org.teiid.query.parser.QueryParser;
@@ -59,11 +59,11 @@
this.metadata = metadata;
}
- public org.teiid.connector.language.Command getCommand(String queryString) {
+ public org.teiid.language.Command getCommand(String queryString) {
return getCommand(queryString, false, false);
}
- public org.teiid.connector.language.Command getCommand(String queryString, boolean generateAliases, boolean supportsGroupAlias) {
+ public org.teiid.language.Command getCommand(String queryString, boolean generateAliases, boolean supportsGroupAlias) {
Command command = null;
try {
command = QueryParser.getQueryParser().parseCommand(queryString);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeConnector.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,19 +27,19 @@
import junit.framework.Assert;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.Execution;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.language.Command;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.translator.BasicConnectorCapabilities;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.UpdateExecution;
public class FakeConnector extends BasicExecutionFactory {
private static final int RESULT_SIZE = 5;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeExecutionContextImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import java.util.concurrent.atomic.AtomicInteger;
-import org.teiid.resource.cci.ExecutionContext;
+import org.teiid.translator.ExecutionContext;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeProcedureExecution.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,10 +26,10 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicExecution;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.ProcedureExecution;
+import org.teiid.translator.BasicExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.ProcedureExecution;
final class FakeProcedureExecution extends BasicExecution implements ProcedureExecution {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,7 +34,7 @@
import org.teiid.dqp.message.AtomicRequestID;
import org.teiid.dqp.message.AtomicRequestMessage;
import org.teiid.dqp.message.RequestID;
-import org.teiid.resource.cci.ExecutionFactory;
+import org.teiid.translator.ExecutionFactory;
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,7 +34,6 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.client.RequestMessage;
-import org.teiid.connector.language.Call;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.internal.process.DQPWorkContext;
@@ -42,6 +41,7 @@
import org.teiid.dqp.message.AtomicResultsMessage;
import org.teiid.dqp.message.RequestID;
import org.teiid.dqp.service.TransactionContext;
+import org.teiid.language.Call;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
@@ -49,8 +49,8 @@
import org.teiid.query.sql.lang.StoredProcedure;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.unittest.FakeMetadataFactory;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ProcedureExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ProcedureExecution;
public class TestConnectorWorkItem {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestTypeFacilityImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import java.sql.Clob;
-import org.teiid.resource.cci.TypeFacility;
+import org.teiid.translator.TypeFacility;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,10 +24,10 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.Constant;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,10 +25,10 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Delete;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.Update;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Delete;
+import org.teiid.language.Insert;
+import org.teiid.language.Update;
import org.teiid.query.sql.lang.BatchedUpdateCommand;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.Comparison.Operator;
+import org.teiid.language.Comparison;
+import org.teiid.language.Literal;
+import org.teiid.language.Comparison.Operator;
import org.teiid.query.sql.lang.AbstractCompareCriteria;
import org.teiid.query.sql.symbol.Constant;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.AndOr;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.AndOr.Operator;
+import org.teiid.language.AndOr;
+import org.teiid.language.Comparison;
+import org.teiid.language.AndOr.Operator;
import org.teiid.query.sql.lang.CompareCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Delete;
+import org.teiid.language.Delete;
import org.teiid.query.sql.lang.CompoundCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,8 +24,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.NamedTable;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.NamedTable;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.unittest.FakeMetadataObject;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.Exists;
+import org.teiid.language.Exists;
import org.teiid.query.sql.lang.ExistsCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,8 +26,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
import org.teiid.query.sql.symbol.Constant;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,8 +28,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.GroupBy;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.GroupBy;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.Function;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.NamedTable;
+import org.teiid.language.NamedTable;
import org.teiid.query.sql.symbol.GroupSymbol;
import org.teiid.query.unittest.FakeMetadataObject;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,9 +26,9 @@
import java.util.Iterator;
import java.util.List;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.In;
+import org.teiid.language.Expression;
+import org.teiid.language.In;
+import org.teiid.language.Literal;
import org.teiid.query.sql.lang.SetCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.DerivedTable;
+import org.teiid.language.DerivedTable;
import org.teiid.query.sql.lang.SubqueryFromClause;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,10 +27,10 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.ExpressionValueSource;
-import org.teiid.connector.language.Insert;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Expression;
+import org.teiid.language.ExpressionValueSource;
+import org.teiid.language.Insert;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.GroupSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.IsNull;
+import org.teiid.language.IsNull;
import org.teiid.query.sql.lang.IsNullCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,8 +26,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Join;
+import org.teiid.language.Comparison;
+import org.teiid.language.Join;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.JoinPredicate;
import org.teiid.query.sql.lang.JoinType;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -22,8 +22,8 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.Like;
+import org.teiid.language.Like;
+import org.teiid.language.Literal;
import org.teiid.query.sql.lang.MatchCriteria;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.Literal;
+import org.teiid.language.Literal;
import org.teiid.query.sql.symbol.Constant;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.Not;
+import org.teiid.language.Not;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.NotCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,8 +28,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.SortSpecification;
+import org.teiid.language.OrderBy;
+import org.teiid.language.SortSpecification;
public class TestOrderByImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestParameterImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Argument.Direction;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Argument.Direction;
public class TestParameterImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Call;
+import org.teiid.language.Call;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.lang.Command;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,9 +29,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Select;
import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Select;
import org.teiid.query.sql.lang.CompoundCriteria;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.UnaryFromClause;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,8 +24,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.language.ScalarSubquery;
+import org.teiid.language.Select;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.symbol.SingleElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.language.SearchedCase;
+import org.teiid.language.SearchedCase;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.DerivedColumn;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
public class TestSelectSymbolImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,15 +27,15 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.OrderBy;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.SetQuery;
-import org.teiid.connector.language.SortSpecification;
-import org.teiid.connector.language.SortSpecification.Ordering;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.NamedTable;
+import org.teiid.language.OrderBy;
+import org.teiid.language.Select;
+import org.teiid.language.SetQuery;
+import org.teiid.language.SortSpecification;
+import org.teiid.language.SortSpecification.Ordering;
import org.teiid.query.sql.lang.SetQuery.Operation;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,9 +24,9 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.SubqueryComparison;
-import org.teiid.connector.language.SubqueryComparison.Quantifier;
+import org.teiid.language.Comparison;
+import org.teiid.language.SubqueryComparison;
+import org.teiid.language.SubqueryComparison.Quantifier;
import org.teiid.query.sql.lang.AbstractCompareCriteria;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SubqueryCompareCriteria;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -23,7 +23,7 @@
package org.teiid.dqp.internal.datamgr.language;
-import org.teiid.connector.language.SubqueryIn;
+import org.teiid.language.SubqueryIn;
import org.teiid.query.sql.lang.Query;
import org.teiid.query.sql.lang.SubquerySetCriteria;
import org.teiid.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,7 +26,7 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Update;
+import org.teiid.language.Update;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.GroupSymbol;
Modified: trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -38,8 +38,8 @@
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.query.sql.symbol.SingleElementSymbol;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.DataNotAvailableException;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
/**
Modified: trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -36,9 +36,9 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.MetadataFactory;
import org.teiid.query.unittest.FakeMetadataFactory;
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -34,7 +34,7 @@
import org.junit.Test;
import org.teiid.api.exception.query.FunctionExecutionException;
-import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.function.FunctionMethods;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.unittest.TimestampUtil;
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -41,13 +41,13 @@
import org.junit.Test;
import org.teiid.api.exception.query.FunctionExecutionException;
import org.teiid.common.buffer.BufferManagerFactory;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.types.ClobType;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.NullType;
import org.teiid.core.types.XMLType;
import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.function.FunctionDescriptor;
import org.teiid.query.function.FunctionForm;
import org.teiid.query.function.FunctionLibrary;
@@ -58,7 +58,7 @@
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.CommandContext;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
@SuppressWarnings("nls")
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -49,7 +49,7 @@
import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.FakeMetadataObject;
import org.teiid.query.unittest.FakeMetadataStore;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class TestJoinOptimization {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,7 +27,7 @@
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.unittest.FakeMetadataFactory;
-import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
+import org.teiid.translator.ConnectorCapabilities.SupportedJoinCriteria;
public class TestJoinPushdownRestrictions {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -89,7 +89,7 @@
import org.teiid.query.util.CommandContext;
import org.teiid.query.validator.Validator;
import org.teiid.query.validator.ValidatorReport;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class TestOptimizer {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,7 +31,7 @@
import org.teiid.query.processor.ProcessorPlan;
import org.teiid.query.unittest.FakeMetadataFacade;
import org.teiid.query.unittest.FakeMetadataFactory;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class TestSubqueryPushdown {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,8 +26,8 @@
import java.util.List;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.TeiidComponentException;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,10 +29,10 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.Select;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Literal;
+import org.teiid.language.Select;
public class TestJDBCExecutionHelper extends TestCase{
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,8 +24,8 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.sql.symbol.AggregateSymbol;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,7 +31,7 @@
import java.util.Map;
import org.junit.Test;
-import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.Select;
@@ -46,7 +46,7 @@
import org.teiid.query.sql.symbol.TestCaseExpression;
import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,8 +28,8 @@
import java.util.List;
import org.teiid.client.metadata.ParameterInfo;
-import org.teiid.connector.language.SQLReservedWords;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.language.SQLReservedWords;
import org.teiid.query.parser.QueryParser;
import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.sql.LanguageObject;
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -35,10 +35,10 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.mapping.xml.MappingAttribute;
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,19 +29,19 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.metadata.ParameterInfo;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.ColumnSet;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
-import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnSet;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
+import org.teiid.metadata.ProcedureParameter.Type;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.sql.lang.SPParameter;
Modified: trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/jboss-integration/src/main/java/org/teiid/templates/connector/RaXmlPropertyConverter.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -46,7 +46,7 @@
import org.teiid.adminapi.jboss.ManagedUtil;
import org.teiid.deployers.ExtendedPropertyMetadata;
import org.teiid.deployers.ManagedPropertyUtil;
-import org.teiid.resource.cci.ExecutionFactory;
+import org.teiid.translator.ExecutionFactory;
public class RaXmlPropertyConverter {
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -43,17 +43,6 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.api.exception.query.QueryMetadataException;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.ColumnSet;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.ForeignKey;
-import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
@@ -62,6 +51,17 @@
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.StringUtil;
import org.teiid.internal.core.index.Index;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnSet;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.metadata.VdbConstants;
import org.teiid.metadata.TransformationMetadata.Resource;
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,25 +27,25 @@
import java.util.Iterator;
import java.util.List;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
-import org.teiid.connector.metadata.runtime.Column;
-import org.teiid.connector.metadata.runtime.ColumnSet;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.ForeignKey;
-import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.Procedure;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.Table;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
-import org.teiid.connector.metadata.runtime.Datatype.Variety;
import org.teiid.core.id.UUID;
import org.teiid.core.index.IEntryResult;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.StringUtil;
import org.teiid.internal.core.index.EntryResult;
import org.teiid.internal.core.index.IIndexConstants;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.ColumnSet;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.KeyRecord;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Schema;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
+import org.teiid.metadata.Datatype.Variety;
/**
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/TransformationRecordImpl.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,7 +24,7 @@
import java.util.List;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.metadata.AbstractMetadataRecord;
/**
* TransformationRecordImpl
Modified: trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java
===================================================================
--- trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/metadata/src/test/java/com/metamatrix/cdk/api/ConnectorHost.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,17 +26,17 @@
import java.util.Arrays;
import java.util.List;
-import org.teiid.connector.language.BatchedUpdates;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.language.BatchedUpdates;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.index.VDBMetadataFactory;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.DataNotAvailableException;
-import org.teiid.resource.cci.Execution;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ExecutionFactory;
-import org.teiid.resource.cci.ResultSetExecution;
-import org.teiid.resource.cci.UpdateExecution;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.DataNotAvailableException;
+import org.teiid.translator.Execution;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ResultSetExecution;
+import org.teiid.translator.UpdateExecution;
/**
* A simple test environment to execute commands on a connector.
Modified: trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java
===================================================================
--- trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,9 +27,9 @@
import java.util.Collection;
import org.teiid.cdk.CommandBuilder;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.language.Command;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.metadata.index.VDBMetadataFactory;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,13 +31,13 @@
import java.util.Arrays;
import java.util.Collection;
-import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.core.CoreConstants;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.util.FileUtils;
import org.teiid.core.util.LRUCache;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.query.function.metadata.FunctionMetadataReader;
import org.teiid.query.function.metadata.FunctionMethod;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -29,8 +29,8 @@
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.metadata.CompositeMetadataStore;
+import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.metadata.TransformationMetadata.Resource;
import org.teiid.query.function.metadata.FunctionMethod;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/ManagedPropertyUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,7 +31,7 @@
import org.jboss.metatype.api.types.SimpleMetaType;
import org.jboss.metatype.api.values.MetaValue;
import org.jboss.metatype.api.values.SimpleValueSupport;
-import org.teiid.resource.cci.TranslatorProperty;
+import org.teiid.translator.TranslatorProperty;
public class ManagedPropertyUtil {
private static final String TEIID_PROPERTY = "teiid-property"; //$NON-NLS-1$
Modified: trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/MetadataStoreGroup.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.ArrayList;
import java.util.List;
-import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.metadata.MetadataStore;
public class MetadataStoreGroup implements Serializable{
private static final long serialVersionUID = -3702321839716725121L;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -37,9 +37,9 @@
import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import org.teiid.resource.cci.ExecutionFactory;
-import org.teiid.resource.cci.TranslatorProperty;
import org.teiid.runtime.RuntimePlugin;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.TranslatorProperty;
/**
Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorPropertyUtil.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorPropertyUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorPropertyUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -25,7 +25,7 @@
import java.util.HashMap;
import java.util.Map;
-import org.teiid.resource.cci.TranslatorProperty;
+import org.teiid.translator.TranslatorProperty;
public class TranslatorPropertyUtil {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -35,7 +35,6 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.SourceMappingMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.core.CoreConstants;
import org.teiid.core.util.FileUtils;
import org.teiid.dqp.internal.cache.DQPContextCache;
@@ -44,11 +43,12 @@
import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.TransformationMetadata.Resource;
import org.teiid.metadata.index.IndexMetadataFactory;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.cci.ExecutionFactory;
import org.teiid.runtime.RuntimePlugin;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionFactory;
public class VDBDeployer extends AbstractSimpleRealDeployer<VDBMetaData> {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -35,9 +35,9 @@
import org.teiid.adminapi.AdminProcessingException;
import org.teiid.adminapi.VDB;
import org.teiid.adminapi.impl.VDBMetaData;
-import org.teiid.connector.metadata.runtime.Datatype;
-import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.Datatype;
+import org.teiid.metadata.MetadataStore;
import org.teiid.metadata.TransformationMetadata.Resource;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.vdb.runtime.VDBKey;
Modified: trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfo.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfo.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfo.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -28,7 +28,7 @@
import org.jboss.metatype.api.types.MapCompositeMetaType;
import org.jboss.metatype.api.types.SimpleMetaType;
import org.teiid.deployers.ManagedPropertyUtil;
-import org.teiid.resource.cci.TranslatorProperty;
+import org.teiid.translator.TranslatorProperty;
/**
* This class defines the template for all the translator classes. Each Translator's class
Modified: trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/runtime/src/main/java/org/teiid/templates/TranslatorTemplateInfoFactory.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,7 +31,7 @@
import org.jboss.managed.api.ManagedProperty;
import org.teiid.deployers.ManagedPropertyUtil;
import org.teiid.deployers.TranslatorPropertyUtil;
-import org.teiid.resource.cci.TranslatorProperty;
+import org.teiid.translator.TranslatorProperty;
public class TranslatorTemplateInfoFactory {
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -24,11 +24,11 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.Command;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Select;
+import org.teiid.metadata.AbstractMetadataRecord;
public class TestTranslationUtility extends TestCase {
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/language/TestLanguageUtil.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,6 +27,11 @@
import java.util.List;
import java.util.Set;
+import org.teiid.language.Condition;
+import org.teiid.language.LanguageFactory;
+import org.teiid.language.LanguageUtil;
+import org.teiid.language.Select;
+
import junit.framework.TestCase;
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/MockConnector.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -5,20 +5,23 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.QueryExpression;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
-import org.teiid.resource.ConnectorException;
-import org.teiid.resource.adapter.BasicConnectorCapabilities;
-import org.teiid.resource.adapter.BasicExecutionFactory;
-import org.teiid.resource.cci.ConnectorCapabilities;
-import org.teiid.resource.cci.ExecutionContext;
-import org.teiid.resource.cci.ProcedureExecution;
-import org.teiid.resource.cci.ResultSetExecution;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.NamedTable;
+import org.teiid.language.QueryExpression;
+import org.teiid.metadata.AbstractMetadataRecord;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
+import org.teiid.translator.BasicConnectorCapabilities;
+import org.teiid.translator.BasicExecutionFactory;
+import org.teiid.translator.ConnectorCapabilities;
+import org.teiid.translator.ConnectorException;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.ResultSetExecution;
public class MockConnector extends BasicExecutionFactory {
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,12 +27,13 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
-import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.Select;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.Column.SearchType;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,9 +27,10 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Select;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Select;
+import org.teiid.metadata.Table;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -26,12 +26,16 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.DerivedColumn;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Select;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.Call;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.DerivedColumn;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Select;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.Table;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,11 +27,12 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Argument;
-import org.teiid.connector.language.Call;
-import org.teiid.connector.language.Argument.Direction;
-import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Argument.Direction;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.BaseColumn.NullType;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -27,8 +27,11 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.Call;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.language.Call;
+import org.teiid.metadata.Column;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
import com.metamatrix.cdk.api.TranslationUtility;
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestCollectorVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -32,14 +32,15 @@
import junit.framework.TestCase;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Comparison;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.NamedTable;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.language.Comparison.Operator;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Comparison;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.NamedTable;
+import org.teiid.language.Select;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.language.visitor.CollectorVisitor;
/**
*/
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 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -31,17 +31,6 @@
import java.util.List;
import org.junit.Test;
-import org.teiid.connector.language.AggregateFunction;
-import org.teiid.connector.language.ColumnReference;
-import org.teiid.connector.language.Command;
-import org.teiid.connector.language.Expression;
-import org.teiid.connector.language.Function;
-import org.teiid.connector.language.Insert;
-import org.teiid.connector.language.LanguageObject;
-import org.teiid.connector.language.Literal;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.connector.language.Select;
-import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.language.TestAggregateImpl;
import org.teiid.dqp.internal.datamgr.language.TestCompareCriteriaImpl;
import org.teiid.dqp.internal.datamgr.language.TestDeleteImpl;
@@ -68,6 +57,18 @@
import org.teiid.dqp.internal.datamgr.language.TestSubqueryInCriteriaImpl;
import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
+import org.teiid.language.AggregateFunction;
+import org.teiid.language.ColumnReference;
+import org.teiid.language.Command;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.Insert;
+import org.teiid.language.LanguageObject;
+import org.teiid.language.Literal;
+import org.teiid.language.SQLReservedWords;
+import org.teiid.language.Select;
+import org.teiid.language.visitor.SQLStringVisitor;
+import org.teiid.metadata.RuntimeMetadata;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.JoinType;
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -41,7 +41,7 @@
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.processor.HardcodedDataManager;
import org.teiid.query.unittest.TimestampUtil;
-import org.teiid.resource.cci.SourceSystemFunctions;
+import org.teiid.translator.SourceSystemFunctions;
public class TestXMLTypeTranslations extends BaseQueryTest {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-05-11 22:15:35 UTC (rev 2118)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-05-12 15:27:10 UTC (rev 2119)
@@ -33,8 +33,6 @@
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
import org.teiid.common.queue.FakeWorkManager;
-import org.teiid.connector.metadata.runtime.MetadataStore;
-import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.deployers.MetadataStoreGroup;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
@@ -43,12 +41,14 @@
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.service.FakeBufferService;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Schema;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.metadata.index.VDBMetadataFactory;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
-import org.teiid.resource.ConnectorException;
import org.teiid.services.SessionServiceImpl;
+import org.teiid.translator.ConnectorException;
import org.teiid.transport.ClientServiceRegistry;
import org.teiid.transport.ClientServiceRegistryImpl;
import org.teiid.transport.LocalServerConnection;
15 years, 11 months
teiid SVN: r2118 - in trunk: engine/src/test/java/com/metamatrix/query/processor and 97 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-05-11 18:15:35 -0400 (Tue, 11 May 2010)
New Revision: 2118
Added:
trunk/engine/src/test/java/org/teiid/cache/
trunk/engine/src/test/java/org/teiid/cdk/
trunk/engine/src/test/java/org/teiid/common/
trunk/engine/src/test/java/org/teiid/common/buffer/
trunk/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java
trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBatch.java
trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
trunk/engine/src/test/java/org/teiid/common/buffer/impl/
trunk/engine/src/test/java/org/teiid/common/log/
trunk/engine/src/test/java/org/teiid/common/queue/
trunk/engine/src/test/java/org/teiid/dqp/message/
trunk/engine/src/test/java/org/teiid/dqp/service/
trunk/engine/src/test/java/org/teiid/internal/
trunk/engine/src/test/java/org/teiid/internal/core/
trunk/engine/src/test/java/org/teiid/internal/core/xml/
trunk/engine/src/test/java/org/teiid/query/
trunk/engine/src/test/java/org/teiid/query/analysis/
trunk/engine/src/test/java/org/teiid/query/function/
trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
trunk/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java
trunk/engine/src/test/java/org/teiid/query/function/metadata/
trunk/engine/src/test/java/org/teiid/query/function/source/
trunk/engine/src/test/java/org/teiid/query/mapping/
trunk/engine/src/test/java/org/teiid/query/mapping/xml/
trunk/engine/src/test/java/org/teiid/query/optimizer/
trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
trunk/engine/src/test/java/org/teiid/query/optimizer/InlineViewCase.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestComparableMetadataPushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinWithFunction.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java
trunk/engine/src/test/java/org/teiid/query/optimizer/batch/
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestRuleStack.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/plantree/
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/
trunk/engine/src/test/java/org/teiid/query/parser/
trunk/engine/src/test/java/org/teiid/query/processor/
trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java
trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java
trunk/engine/src/test/java/org/teiid/query/processor/FakeTupleSource.java
trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java
trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java
trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
trunk/engine/src/test/java/org/teiid/query/processor/TestCollectionTupleSource.java
trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java
trunk/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestQueryProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java
trunk/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/org/teiid/query/processor/batch/
trunk/engine/src/test/java/org/teiid/query/processor/dynamic/
trunk/engine/src/test/java/org/teiid/query/processor/eval/
trunk/engine/src/test/java/org/teiid/query/processor/proc/
trunk/engine/src/test/java/org/teiid/query/processor/relational/
trunk/engine/src/test/java/org/teiid/query/processor/xml/
trunk/engine/src/test/java/org/teiid/query/processor/xquery/
trunk/engine/src/test/java/org/teiid/query/resolver/
trunk/engine/src/test/java/org/teiid/query/rewriter/
trunk/engine/src/test/java/org/teiid/query/sql/
trunk/engine/src/test/java/org/teiid/query/sql/lang/
trunk/engine/src/test/java/org/teiid/query/sql/proc/
trunk/engine/src/test/java/org/teiid/query/sql/symbol/
trunk/engine/src/test/java/org/teiid/query/sql/util/
trunk/engine/src/test/java/org/teiid/query/sql/visitor/
trunk/engine/src/test/java/org/teiid/query/unittest/
trunk/engine/src/test/java/org/teiid/query/util/
trunk/engine/src/test/java/org/teiid/query/validator/
trunk/engine/src/test/java/org/teiid/query/xquery/
trunk/engine/src/test/java/org/teiid/vdb/
trunk/engine/src/test/java/org/teiid/vdb/runtime/
trunk/engine/src/test/resources/org/
trunk/engine/src/test/resources/org/teiid/
Removed:
trunk/engine/src/test/java/com/metamatrix/query/parser/
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataStore.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
trunk/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java
trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestBatchIterator.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestCollectionTupleSource.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestJoinWithFunction.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestSQLXMLProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestSetProcessing.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
trunk/engine/src/test/java/com/metamatrix/query/processor/batch/
trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/
trunk/engine/src/test/java/com/metamatrix/query/processor/eval/
trunk/engine/src/test/java/com/metamatrix/query/processor/proc/
trunk/engine/src/test/java/com/metamatrix/query/processor/relational/
trunk/engine/src/test/java/com/metamatrix/query/processor/xml/
trunk/engine/src/test/java/com/metamatrix/query/processor/xquery/
trunk/engine/src/test/java/com/metamatrix/query/resolver/
trunk/engine/src/test/java/com/metamatrix/query/rewriter/
trunk/engine/src/test/java/com/metamatrix/query/sql/lang/
trunk/engine/src/test/java/com/metamatrix/query/sql/proc/
trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/
trunk/engine/src/test/java/com/metamatrix/query/sql/util/
trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/
trunk/engine/src/test/java/com/metamatrix/query/unittest/
trunk/engine/src/test/java/com/metamatrix/query/util/
trunk/engine/src/test/java/com/metamatrix/query/validator/
trunk/engine/src/test/java/com/metamatrix/query/xquery/
trunk/engine/src/test/java/com/metamatrix/vdb/runtime/
trunk/engine/src/test/resources/com/
trunk/engine/src/test/resources/org/metamatrix/
trunk/engine/src/test/resources/org/teiid/query/mapping/xml/testExample.xml
Modified:
trunk/engine/src/test/java/org/teiid/cache/FakeCache.java
trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java
trunk/engine/src/test/java/org/teiid/common/queue/FakeWorkItem.java
trunk/engine/src/test/java/org/teiid/common/queue/FakeWorkManager.java
trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestByteLobChunkStream.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java
trunk/engine/src/test/java/org/teiid/dqp/message/TestRequestID.java
trunk/engine/src/test/java/org/teiid/dqp/message/TestResultsMessage.java
trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
trunk/engine/src/test/java/org/teiid/dqp/service/FakeBufferService.java
trunk/engine/src/test/java/org/teiid/internal/core/xml/TestJdomHelper.java
trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
trunk/engine/src/test/java/org/teiid/query/analysis/TestAnalysisRecord.java
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java
trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingAttribute.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingChoiceNode.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingDocument.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingLoader.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingRecursiveElement.java
trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestNamespace.java
trunk/engine/src/test/java/org/teiid/query/optimizer/batch/TestBatchedUpdatePlanner.java
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/FakeCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/TestBasicSourceCapabilities.java
trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/TestDefaultCapabilitiesFinder.java
trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/plantree/TestNodeEditor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCalculateCostUtil.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCriteriaCapabilityValidatorVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestFrameUtil.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestGroupRecontext.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestJoinRegion.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/TestRuleAssignOutputElements.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleChooseDependent.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePlaceAccess.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleValidateWhereAll.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/FakeXMLMetadata.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestContextReplacerVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestHandleNillableNode.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestMarkExcludeVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestNameInSourceResolverVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestRemoveExcludedVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestXMLNodeMappingVisitor.java
trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestXMLPlanner.java
trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java
trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
trunk/engine/src/test/java/org/teiid/query/parser/TestParserXQuery.java
trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java
trunk/engine/src/test/java/org/teiid/query/processor/batch/TestBatchedUpdatePlan.java
trunk/engine/src/test/java/org/teiid/query/processor/dynamic/SimpleQueryProcessorFactory.java
trunk/engine/src/test/java/org/teiid/query/processor/dynamic/TestSqlEval.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
trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/BlockingFakeRelationalNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/FakeRelationalNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/NodeTestUtil.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestDuplicateFilter.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestLimitNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalPlan.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/FakePlanExecutor.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/NoOpInstruction.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestElement.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestInstructions.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestProcessorEnvironment.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLContext.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLValueTranslator.java
trunk/engine/src/test/java/org/teiid/query/processor/xml/XMLProgramUtil.java
trunk/engine/src/test/java/org/teiid/query/processor/xquery/TestXQueryProcessor.java
trunk/engine/src/test/java/org/teiid/query/resolver/CheckNoTempMetadataIDsVisitor.java
trunk/engine/src/test/java/org/teiid/query/resolver/CheckSymbolsAreResolvedVisitor.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestAccessPattern.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestFunctionResolving.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java
trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestAliasSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestBetweenCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCompoundCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCreate.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDependentSetCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDrop.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDynamicCommand.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestExpressionSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestIsNullCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJoinPredicate.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestLimit.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestOption.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestQuery.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSelect.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSetCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSetQuery.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSubqueryFromClause.java
trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSubquerySetCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestAssignmentStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestBlock.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestBreakStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCommandStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestContinueStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCriteriaSelector.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestDeclareStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestHasCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestIfStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestLoopStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestRaiseErrorStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestTranslateCriteria.java
trunk/engine/src/test/java/org/teiid/query/sql/proc/TestWhileStatement.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestFunction.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java
trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java
trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java
trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestAggregateSymbolCollectorVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestEvaluatableVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestGroupCollectorVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java
trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataStore.java
trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
trunk/engine/src/test/java/org/teiid/query/util/TestPermutation.java
trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
trunk/engine/src/test/java/org/teiid/query/xquery/HardcodedSqlEval.java
trunk/engine/src/test/java/org/teiid/query/xquery/TestXQueryEngine.java
trunk/engine/src/test/java/org/teiid/vdb/runtime/TestVDBKey.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java
trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestManagedUtil.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java
trunk/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java
trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java
trunk/metadata/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java
trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/ExtendedPropertyMetadata.java
trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java
trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java
trunk/runtime/src/main/java/org/teiid/deployers/VirtualDatabaseException.java
trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ClientInstance.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/LocalServerConnection.java
trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java
trunk/runtime/src/main/java/org/teiid/transport/ObjectEncoder.java
trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java
trunk/runtime/src/test/java/org/teiid/deployers/TestObjectSerializer.java
trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java
trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/BaseQueryTest.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractMMQueryTestCase.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
trunk/test-integration/db/src/test/java/org/teiid/dynamicvdb/TestVDBLessExecution.java
Log:
TEIID-918 changing package to org.teiid and removing metamatrix from class names
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,402 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.teiid.logging.LogManager;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.TranslatableProcedureContainer;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
-
-public class FakeDataManager implements ProcessorDataManager {
- private Map tuples = new HashMap();
- private static final String LOG_CONTEXT = "FAKE_DATA_MANAGER"; //$NON-NLS-1$
-
- //used to test blocked exception. If true,
- //the first time nextTuple is called on FakeTupleSource,
- //it will throws BlockedExceptiom
- private boolean blockOnce;
-
- // ---- Cached code table stuff ----
-
- // upper table name + upper key col name + upper ret col name -> map of values
- private Map codeTableValues = new HashMap();
-
- // throw Blocked on first request
- private boolean throwBlocked = false;
-
- // upper table name + upper key col name + upper ret col name -> flag of whether this table has blocked yet
- private Map blockedState = new HashMap();
-
- // Track history to verify it later
- private List<String> queries = new ArrayList<String>();
- private boolean recordingCommands = true;
-
- /**
- * Return string form of all queries run against this FDM
- * @return List<String> recorded commands
- */
- public List<String> getQueries() {
- return this.queries;
- }
-
- /**
- * Clears the list of recorded commands and returns a copy
- * @return a copy of the recorded commands prior to clearing the list
- */
- public List<String> clearQueries() {
- List<String> rc = new ArrayList<String>(this.getQueries());
- this.queries.clear();
- return rc;
- }
-
- public void registerTuples(Object groupID, List elements, List[] data) {
- tuples.put(groupID, new Object[] { elements, data });
- }
-
- public void closeRequest(Object requestID) {
- // does nothing?
- }
-
- public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID)
- throws MetaMatrixComponentException {
-
- LogManager.logTrace(LOG_CONTEXT, new Object[]{"Register Request:", command, ",processorID:", processorID, ",model name:", modelName,",TupleSourceID nodeID:",new Integer(nodeID)}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- if (this.recordingCommands) {
- if (! (command instanceof BatchedUpdateCommand) ) {
- this.queries.add(command.toString());
- }
- }
-
- if (ReferenceCollectorVisitor.getReferences(command).size() > 0) {
- throw new IllegalArgumentException("Found references in the command registered with the DataManager."); //$NON-NLS-1$
- }
- // Get group ID from atomic command
- GroupSymbol group = null;
- if(command instanceof Query){
- group = getQueryGroup((Query)command);
- }else if(command instanceof SetQuery) {
- SetQuery union = (SetQuery) command;
- group = getQueryGroup(union.getProjectedQuery());
- } else if (command instanceof ProcedureContainer) {
- group = ((ProcedureContainer) command).getGroup();
- } else if ( command instanceof BatchedUpdateCommand ) {
- if ( command.getSubCommands().get(0) instanceof Update ) {
- group = ((Update)command.getSubCommands().get(0)).getGroup();
- }
- if (this.recordingCommands) {
- for ( Iterator<Command> it = ((BatchedUpdateCommand) command).getUpdateCommands().iterator(); it.hasNext(); ) {
- this.queries.add(it.next().toString());
- }
- }
- }
-
- Object groupID = group.getMetadataID();
-
- Object[] tupleInfo = (Object[]) tuples.get(groupID);
- List elements = (List) tupleInfo[0];
- List[] tuples = (List[]) tupleInfo[1];
-
- List projectedSymbols = command.getProjectedSymbols();
- int[] columnMap = getColumnMap(elements, projectedSymbols);
-
- /*
- * updateCommands is used to hold a list of commands that
- * either came from a BatchedUpdateCommand or a signle
- * command from an Update command.
- */
- List<Command> updateCommands = new ArrayList<Command>();
-
- // Apply query criteria to tuples
- if(command instanceof Query){
- Query query = (Query)command;
- if(query.getCriteria() != null) {
- // Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
- Map lookupMap = new HashMap();
- for(int i=0; i<elements.size(); i++) {
- Object element = elements.get(i);
- mapElementToIndex(lookupMap, element, new Integer(i), group);
- }
- for(int i=0; i<projectedSymbols.size(); i++) {
- Object element = projectedSymbols.get(i);
- mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
- }
-
- List filteredTuples = new ArrayList();
- for(int i=0; i<tuples.length; i++) {
- try {
- if(new Evaluator(lookupMap, null, null).evaluate(query.getCriteria(), tuples[i])) {
- filteredTuples.add(tuples[i]);
- }
- } catch(CriteriaEvaluationException e) {
- throw new MetaMatrixComponentException(e, e.getMessage());
- }
- }
-
- tuples = new List[filteredTuples.size()];
- filteredTuples.toArray(tuples);
- }
- } else if ( command instanceof Insert || command instanceof Update || command instanceof Delete) {
- // add single update command to a list to be executed
- updateCommands.add(command);
- } else if ( command instanceof BatchedUpdateCommand ) {
- // add all update commands to a list to be executed
- updateCommands.addAll(((BatchedUpdateCommand) command).getUpdateCommands());
- }
-
- // if we had update commands added to the list, execute them now
- if ( updateCommands.size() > 0 ) {
- List<List<Integer>> filteredTuples = new ArrayList<List<Integer>>();
- for ( int c = 0; c < updateCommands.size(); c++ ) {
- Command cmd = updateCommands.get(c);
- if (cmd instanceof TranslatableProcedureContainer) {
- TranslatableProcedureContainer update = (TranslatableProcedureContainer)cmd;
- if ( update.getCriteria() != null ) {
- // Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
- Map<Object, Integer> lookupMap = new HashMap<Object, Integer>();
- for(int i=0; i<elements.size(); i++) {
- Object element = elements.get(i);
- mapElementToIndex(lookupMap, element, new Integer(i), group);
- }
- for(int i=0; i<projectedSymbols.size(); i++) {
- Object element = projectedSymbols.get(i);
- mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
- }
-
- int updated = 0;
- for(int i=0; i<tuples.length; i++) {
- try {
- if(new Evaluator(lookupMap, null, null).evaluate(update.getCriteria(), tuples[i])) {
- updated++;
- }
- } catch(CriteriaEvaluationException e) {
- throw new MetaMatrixComponentException(e, e.getMessage());
- }
- }
- List<Integer> updateTuple = new ArrayList<Integer>(1);
- updateTuple.add( new Integer(updated) );
- filteredTuples.add(updateTuple);
- }
- } else {
- filteredTuples.add(Arrays.asList(1)); //TODO: check for bulk
- }
- }
- tuples = new List[filteredTuples.size()];
- filteredTuples.toArray(tuples);
- elements = new ArrayList<Object>(projectedSymbols);
- columnMap[0] = 0;
- }
-
- FakeTupleSource ts= new FakeTupleSource(elements, tuples, projectedSymbols, columnMap);
- if(this.blockOnce){
- ts.setBlockOnce();
- }
- return ts;
- }
-
- private GroupSymbol getQueryGroup(Query query) throws MetaMatrixComponentException {
- GroupSymbol group;
- From from = query.getFrom();
- List groups = from.getGroups();
- if(groups.size() != 1) {
- throw new MetaMatrixComponentException("Cannot build fake tuple source for command: " + query); //$NON-NLS-1$
- }
- group = (GroupSymbol) groups.get(0);
- Iterator projSymbols = query.getSelect().getProjectedSymbols().iterator();
- while (projSymbols.hasNext()) {
- Object symbol = projSymbols.next();
- if (symbol instanceof ElementSymbol){
- ElementSymbol elementSymbol = (ElementSymbol)symbol;
- GroupSymbol g = elementSymbol.getGroupSymbol();
- if (!g.equals(group)){
- throw new MetaMatrixComponentException("Illegal symbol " + elementSymbol + " in SELECT of command: " + query); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (elementSymbol.getMetadataID() == null){
- throw new MetaMatrixComponentException("Illegal null metadata ID in ElementSymbol " + elementSymbol + " in SELECT of command: " + query); //$NON-NLS-1$ //$NON-NLS-2$
- } else if (elementSymbol.getMetadataID() instanceof TempMetadataID){
- throw new MetaMatrixComponentException("Illegal TempMetadataID in ElementSymbol " + elementSymbol + " in SELECT of command: " + query); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- return group;
- }
-
- /**
- * @param lookupMap
- * @param element
- * @param integer
- * @param group
- */
- private void mapElementToIndex(Map lookupMap, Object element, Integer index, GroupSymbol group) {
- if (group.getDefinition() != null){
- String groupAlias = group.getCanonicalName();
- ElementSymbol elementSymbol = (ElementSymbol)SymbolMap.getExpression((SingleElementSymbol)element);
- String newName = groupAlias + "." + elementSymbol.getShortName(); //$NON-NLS-1$
- ElementSymbol aliasedElement = new ElementSymbol(newName, elementSymbol.getDisplayFullyQualified());
- aliasedElement.setGroupSymbol(elementSymbol.getGroupSymbol());
- aliasedElement.setMetadataID(elementSymbol.getMetadataID());
- aliasedElement.setType(elementSymbol.getType());
- lookupMap.put(aliasedElement, index);
- } else {
- lookupMap.put(element, index);
- }
- }
-
- // columnMap[expectedElementIndex] = allElementIndex
- private int[] getColumnMap(List allElements, List expectedElements) {
- int[] map = new int[expectedElements.size()];
-
- for(int i=0; i<expectedElements.size(); i++) {
- SingleElementSymbol symbol = (SingleElementSymbol) expectedElements.get(i);
-
- if (symbol instanceof AliasSymbol) {
- symbol = ((AliasSymbol)symbol).getSymbol();
- }
-
- String shortName = symbol.getShortName();
-
- // Find matching short name in all elements
- boolean foundMatch = false;
- for(int j=0; j<allElements.size(); j++) {
- SingleElementSymbol tupleSymbol = (SingleElementSymbol) allElements.get(j);
- if(tupleSymbol.getShortName().equalsIgnoreCase(shortName)) {
- map[i] = j;
- foundMatch = true;
- break;
- }
- }
-
- if(! foundMatch) {
- map[i] = -1;
- }
- }
-
- return map;
- }
-
-
- public void setThrowBlocked(boolean throwBlocked) {
- this.throwBlocked = throwBlocked;
- }
-
- public void defineCodeTable(String tableName, String keyCol, String retCol, Map values) {
- String key = tableName.toUpperCase() + keyCol.toUpperCase() + retCol.toUpperCase();
- this.codeTableValues.put(key, values);
- this.blockedState.put(key, Boolean.FALSE);
- }
-
- public Object lookupCodeValue(
- CommandContext context,
- String codeTableName,
- String returnElementName,
- String keyElementName,
- Object keyValue)
- throws BlockedException, MetaMatrixComponentException {
-
- String tableKey = codeTableName.toUpperCase() + keyElementName.toUpperCase() + returnElementName.toUpperCase();
- if(! codeTableValues.containsKey(tableKey)) {
- throw new MetaMatrixComponentException("Unknown code table: " + codeTableName); //$NON-NLS-1$
- }
-
- if(throwBlocked) {
- if(blockedState.get(tableKey).equals(Boolean.FALSE)) {
- blockedState.put(tableKey, Boolean.TRUE);
- throw BlockedException.INSTANCE;
- }
- }
-
- Map values = (Map) codeTableValues.get(tableKey);
- return values.get(keyValue);
- }
-
- public void setBlockOnce() {
- blockOnce = true;
- }
-
- @Override
- public void clearCodeTables() {/* does nothing */}
-
- /**
- * Are commands/queries that are registered with the data manager being
- * recorded?
- * <p>
- * Recorded commands can be retrieved by {@link #getQueries()}
- *
- * @return whether or not commands should be recorded
- */
- public boolean isRecordingCommands() {
- return recordingCommands;
- }
-
- /**
- * Indicate whether or not commands/queries registered with the data
- * manager are to be recorded in {@link #queries}.
- * <p>
- * Recorded commands can be retrieved by {@link #getQueries()}
- *
- * @param shouldRecord should commands be recorded?
- */
- public void setRecordingCommands(boolean shouldRecord) {
- this.recordingCommands = shouldRecord;
- }
-
- public void registerTuples(QueryMetadataInterface metadata, String groupName, List[] tuples) throws QueryResolverException, MetaMatrixComponentException {
- GroupSymbol group = new GroupSymbol(groupName);
- ResolverUtil.resolveGroup(group, metadata);
- List<ElementSymbol> elementSymbols = ResolverUtil.resolveElementsInGroup(group, metadata);
- this.registerTuples(group.getMetadataID(), elementSymbols, tuples);
- }
-
-
-}
\ No newline at end of file
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataStore.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataStore.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataStore.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,321 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.teiid.client.metadata.ParameterInfo;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-
-
-/**
- * This is sample data go along with FakeMetaDataFactory and FakeDataManager
- */
-public class FakeDataStore {
-
- // Helper to create a list of elements - used in creating sample data
- public static List createElements(List elementIDs) {
- List elements = new ArrayList();
- for(int i=0; i<elementIDs.size(); i++) {
- FakeMetadataObject elementID = (FakeMetadataObject) elementIDs.get(i);
- ElementSymbol element = new ElementSymbol(elementID.getName());
- elements.add(element);
- }
-
- return elements;
- }
-
- private static List getProcResultSetSymbols(List params){
- List result = new ArrayList();
- Iterator iter = params.iterator();
- while(iter.hasNext()){
- SPParameter param = (SPParameter)iter.next();
- if(param.getResultSetColumns() != null){
- result.addAll(param.getResultSetColumns());
- }
- }
- iter = params.iterator();
- while(iter.hasNext()){
- SPParameter param = (SPParameter)iter.next();
- if(param.getParameterType() == ParameterInfo.INOUT || param.getParameterType() == ParameterInfo.RETURN_VALUE) {
- result.add(param.getParameterSymbol());
- }
- }
- return result;
- }
-
- public static void sampleData1(FakeDataManager dataMgr) throws QueryMetadataException, MetaMatrixComponentException {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- // Group pm1.g2
- groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- // Group pm1.g3
- groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g3"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- // Group pm2.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- // Group pm2.g2
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g2"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- // Group pm2.g3
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g3"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- // Group tm1.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("tm1.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- } );
-
- //stored procedure pm1.sp1
- TempMetadataStore tempStore = new TempMetadataStore();
- StoredProcedureInfo procInfo = metadata.getStoredProcedureInfoForProcedure("pm1.sp1"); //$NON-NLS-1$
- elementSymbols = getProcResultSetSymbols(procInfo.getParameters());
- tempStore.addTempGroup("pm1.sp1", elementSymbols); //$NON-NLS-1$
- Object procID = tempStore.getTempGroupID("pm1.sp1"); //$NON-NLS-1$
- dataMgr.registerTuples(
- procID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1)}),
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- } );
- }
-
- public static void sampleData2(FakeDataManager dataMgr) throws QueryMetadataException, MetaMatrixComponentException {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata
- .getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(groupID, elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] {
- "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- });
-
- // Group pm1.g2
- groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(groupID, elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] {
- "a", new Integer(1), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(0), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(5), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(2), Boolean.FALSE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "d", new Integer(2), Boolean.FALSE, new Double(1.0) }), //$NON-NLS-1$
- });
-
- // Group pm2.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(groupID, elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] {
- "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- });
-
- // Group pm2.g2
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g2"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(groupID, elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] {
- "a", new Integer(1), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(0), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(5), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(2), Boolean.FALSE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "d", new Integer(2), Boolean.FALSE, new Double(1.0) }), //$NON-NLS-1$
- });
-
- // Group pm1.table1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm1.table1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = createElements(elementIDs);
-
- dataMgr.registerTuples(groupID, elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] {
- "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,142 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- */
-public class FakeProcessorPlan extends ProcessorPlan {
-
- private List outputElements;
- private List batches;
- int batchIndex = 0;
- private int nextBatchRow = 1;
- private boolean opened = false;
-
- /**
- * Constructor for FakeProcessorPlan.
- * @param batches List of things to return in response to nextBatch() - typically
- * this is TupleBatch, but it can also be BlockedException or a
- * MetaMatrixComponentException.
- */
- public FakeProcessorPlan(List outputElements, List batches) {
- this.outputElements = outputElements;
- this.batches = batches;
- }
-
- public FakeProcessorPlan(int counts) {
- List[] rows = new List[counts];
- for (int i = 0; i < counts; i++) {
- rows[i] = Arrays.asList(new Object[] {new Integer(1)});
- }
- TupleBatch batch = new TupleBatch(1, rows);
- batch.setTerminationFlag(true);
- this.batches = Arrays.asList(batch);
- this.outputElements = Command.getUpdateCommandSymbol();
- }
-
- public boolean isOpened() {
- return opened;
- }
-
- /**
- * @see java.lang.Object#clone()
- */
- public FakeProcessorPlan clone() {
- throw new UnsupportedOperationException();
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#initialize(com.metamatrix.query.processor.ProcessorDataManager, java.lang.Object, com.metamatrix.common.buffer.BufferManager, java.lang.String, int)
- */
- public void initialize(
- CommandContext context,
- ProcessorDataManager dataMgr,
- BufferManager bufferMgr) {
-
- // nothing
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
- */
- public List getOutputElements() {
- return this.outputElements;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#open()
- */
- public void open() throws MetaMatrixComponentException {
- assertFalse("ProcessorPlan.open() should not be called more than once", opened); //$NON-NLS-1$
- opened = true;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#nextBatch()
- */
- public TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException {
- if(this.batches == null || this.batches.size() == 0 || batchIndex >= this.batches.size()) {
- // Return empty terminator batch
- TupleBatch batch = new TupleBatch(nextBatchRow, Collections.EMPTY_LIST);
- batch.setTerminationFlag(true);
- return batch;
- }
- Object nextReturn = this.batches.get(batchIndex);
- batchIndex++;
-
- if(nextReturn instanceof TupleBatch) {
- TupleBatch batch = (TupleBatch) nextReturn;
- nextBatchRow = nextBatchRow + batch.getRowCount();
- return batch;
- }
- throw (MetaMatrixComponentException) nextReturn;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#close()
- */
- public void close() throws MetaMatrixComponentException {
- // nothing
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorPlan#getSchema()
- */
- public List getSchema() {
- return this.outputElements;
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.*;
-
-public class FakeTupleSource implements TupleSource {
-
- public static class FakeComponentException extends MetaMatrixComponentException {
-
- }
-
- private List elements;
- private List[] tuples;
- private int index = 0;
- private List expectedSymbols;
- private int[] columnMap;
-
- //used to test blocked exception. If true,
- //the first time nextTuple is called, it will throws BlockedExceptiom
- private boolean blockOnce;
-
- private boolean exceptionOnClose;
-
- public FakeTupleSource(List elements, List[] tuples) {
- this.elements = elements;
- this.tuples = tuples;
- }
-
- public FakeTupleSource(List elements, List[] tuples, List expectedSymbols, int[] columnMap) {
- this.elements = elements;
- this.tuples = tuples;
- this.expectedSymbols = expectedSymbols;
- this.columnMap = columnMap;
- }
-
- public List getSchema() {
- List theElements = null;
- if(expectedSymbols != null) {
- theElements = expectedSymbols;
- } else {
- theElements = elements;
- }
-
- return theElements;
- }
-
- public void openSource()
- throws MetaMatrixComponentException {
-
- index = 0;
- }
-
- public List nextTuple()
- throws MetaMatrixComponentException {
-
- if(this.blockOnce){
- this.blockOnce = false;
- throw BlockedException.INSTANCE;
- }
-
- if(index < tuples.length) {
- // Get full data tuple, with elements
- List tuple = tuples[index++];
-
- if(expectedSymbols == null) {
- return tuple;
- }
- // Build mapped data tuple, with expectedSymbols
- List mappedTuple = new ArrayList(expectedSymbols.size());
- for(int i=0; i<columnMap.length; i++) {
- int colIndex = columnMap[i];
- if(colIndex >= 0) {
- mappedTuple.add( tuple.get(colIndex) );
- } else {
- mappedTuple.add( null );
- }
- }
- return mappedTuple;
- }
- return null;
- }
-
- public void closeSource() {
- }
-
- public void setBlockOnce(){
- this.blockOnce = true;
- }
-
- public void setExceptionOnClose(boolean exceptionOnClose) {
- this.exceptionOnClose = exceptionOnClose;
- }
-
- @Override
- public int available() {
- return 0;
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
-
-
-/**
- * @since 4.2
- */
-public class HardcodedDataManager implements
- ProcessorDataManager {
-
- // sql string to data
- private Map data = new HashMap();
-
- // valid models - if null, any is assumed valid
- private Set validModels;
-
- private boolean mustRegisterCommands = true;
-
- private boolean blockOnce;
-
- // Collect all commands run against this class
- private Collection commandHistory = new ArrayList(); // Commands
-
- public HardcodedDataManager() {
- this(true);
- }
-
- public HardcodedDataManager(boolean mustRegisterCommands) {
- this.mustRegisterCommands = mustRegisterCommands;
- }
-
- public void addData(String sql, List[] rows) {
- data.put(sql, rows);
- }
-
- public void clearData() {
- this.data.clear();
- this.commandHistory.clear();
- }
-
- public void setBlockOnce(boolean blockOnce) {
- this.blockOnce = blockOnce;
- }
-
- /**
- * Set of model names that are valid. Invalid ones will throw an error.
- * @param models
- * @since 4.2
- */
- public void setValidModels(Set models) {
- this.validModels = models;
- }
-
- /**
- * Return collection of Command that has occurred on this data manager
- * @return
- * @since 4.2
- */
- public Collection getCommandHistory() {
- return this.commandHistory;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorDataManager#lookupCodeValue(com.metamatrix.query.util.CommandContext, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
- * @since 4.2
- */
- public Object lookupCodeValue(CommandContext context,
- String codeTableName,
- String returnElementName,
- String keyElementName,
- Object keyValue) throws BlockedException,
- MetaMatrixComponentException {
- return null;
- }
-
- /**
- * @see com.metamatrix.query.processor.ProcessorDataManager#registerRequest(java.lang.Object, com.metamatrix.query.sql.lang.Command, java.lang.String, String, int)
- * @since 4.2
- */
- public TupleSource registerRequest(Object processorID,
- Command command,
- String modelName,
- String connectorBindingId, int nodeID) throws MetaMatrixComponentException {
-
- if(modelName != null && validModels != null && ! validModels.contains(modelName)) {
- throw new MetaMatrixComponentException("Detected query against invalid model: " + modelName + ": " + command); //$NON-NLS-1$//$NON-NLS-2$
- }
- this.commandHistory.add(command);
-
- List projectedSymbols = command.getProjectedSymbols();
-
- List[] rows = (List[]) data.get(command.toString());
- if(rows == null) {
- if (mustRegisterCommands) {
- throw new MetaMatrixComponentException("Unknown command: " + command.toString()); //$NON-NLS-1$
- }
- // Create one row of nulls
- rows = new List[1];
- rows[0] = new ArrayList();
-
- for(int i=0; i<projectedSymbols.size(); i++) {
- rows[0].add(null);
- }
- }
-
- FakeTupleSource source = new FakeTupleSource(projectedSymbols, rows);
- if (blockOnce) {
- source.setBlockOnce();
- }
- return source;
- }
-
- public void setMustRegisterCommands(boolean mustRegisterCommands) {
- this.mustRegisterCommands = mustRegisterCommands;
- }
-
- public void clearCodeTables() {
-
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,285 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static com.metamatrix.query.processor.TestProcessor.*;
-
-import java.math.BigDecimal;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestAggregatePushdown;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestAggregateProcessing {
-
- static void sampleDataBQT3(FakeDataManager dataMgr) throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- // Group bqt1.smalla
-
- List[] tuples = new List[20];
- for (int i = 0; i < tuples.length; i++) {
- tuples[i] = new ArrayList(17);
- tuples[i].add(new Integer(i));
- tuples[i].add("" + i); //$NON-NLS-1$
- tuples[i].add(new Integer(i + 1));
- for (int j = 0; j < 14; j++) {
- tuples[i].add(null);
- }
- }
-
- dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
-
- tuples = new List[20];
- for (int i = 0; i < tuples.length; i++) {
- tuples[i] = new ArrayList(17);
- tuples[i].add(new Integer(i));
- for (int j = 0; j < 16; j++) {
- tuples[i].add(null);
- }
- }
-
- dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
- }
-
- private void sampleDataBQT_defect9842(FakeDataManager dataMgr) throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- List[] tuples = new List[5];
- for (int i = 0; i < tuples.length; i++) {
- int k = i + 10;
- tuples[i] = new ArrayList(17);
- if (i < 2) {
- tuples[i].add(new Integer(1)); // need duplicate values
- } else {
- tuples[i].add(new Integer(2)); // need duplicate values
- }
- tuples[i].add("" + k); //$NON-NLS-1$
- tuples[i].add(new Integer(k + 1));
- tuples[i].add("" + (k + 1)); //$NON-NLS-1$
- tuples[i].add(new Float(0.5));
- for (int j = 0; j < 8; j++) {
- tuples[i].add(null);
- }
- tuples[i].add(new Short((short) k));
- tuples[i].add(null);
- tuples[i].add(new BigDecimal("" + k)); //$NON-NLS-1$
- tuples[i].add(null);
- }
-
- dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
- }
-
- @Test public void testAggregateOnBQT() throws Exception {
- // Create query
- String sql = "SELECT IntKey, SUM(IntNum) FROM BQT1.SmallA GROUP BY IntKey, IntNum HAVING IntNum > 10 ORDER BY IntKey"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(10), new Long(11) }),
- Arrays.asList(new Object[] { new Integer(11), new Long(12) }),
- Arrays.asList(new Object[] { new Integer(12), new Long(13) }),
- Arrays.asList(new Object[] { new Integer(13), new Long(14) }),
- Arrays.asList(new Object[] { new Integer(14), new Long(15) }),
- Arrays.asList(new Object[] { new Integer(15), new Long(16) }),
- Arrays.asList(new Object[] { new Integer(16), new Long(17) }),
- Arrays.asList(new Object[] { new Integer(17), new Long(18) }),
- Arrays.asList(new Object[] { new Integer(18), new Long(19) }),
- Arrays.asList(new Object[] { new Integer(19), new Long(20) }) };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT3(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory
- .exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testAggregateOnBQT2() throws Exception {
- // Create query
- String sql = "SELECT IntNum, IsNotNull FROM (SELECT IntNum, LongNum, COUNT(IntNum) AS IsNotNull FROM BQT1.SmallA GROUP BY IntNum, LongNum HAVING LongNum IS NULL ) AS x ORDER BY IntNum, IsNotNull"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(4), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(5), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(6), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(7), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(8), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(9), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(10), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(11), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(12), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(13), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(14), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(15), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(16), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(17), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(18), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(19), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(20), new Integer(1) }) };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT3(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory
- .exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testAggregateOnBQT_defect9842() throws Exception {
- // Create query
- String sql = "SELECT IntKey, SUM((BigDecimalValue)*(ShortValue)-(BigDecimalValue)*(ShortValue)*(FloatNum)) " + //$NON-NLS-1$
- "AS MySum FROM BQT1.SmallA GROUP BY IntKey ORDER BY IntKey"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1),
- new BigDecimal("110.5") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2),
- new BigDecimal("254.5") }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT_defect9842(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory
- .exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCase186260() {
- /*
- * This case revealed that an expression like "COUNT( DISTINCT e1 )", where the type of e1 is
- * anything but integer, was not handled properly. We tried to use "integer" (the type of the
- * COUNT expression) to work with the e1 tuples.
- */
- // Create query
- String sql = "SELECT COUNT(DISTINCT pm1.g2.e1), COUNT(DISTINCT pm1.g3.e1) FROM pm1.g2, pm1.g3"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(3), new Integer(3) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @SuppressWarnings("unchecked")
- @Test public void testAggregatePushdown() {
- Command command = helpParse("select e1, count(e2), max(e2) from (select e1, e2, e3 from pm1.g1 union all select e1, e2, e3 from pm1.g2 union all select e1, e2, e3 from pm2.g1) z group by e1"); //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- capFinder.addCapabilities("pm1", TestAggregatePushdown.getAggregateCapabilities()); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT v_0.c_0, COUNT(v_0.c_1), MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0", //$NON-NLS-1$
- new List[] {
- Arrays.asList("a", Integer.valueOf(2), Integer.valueOf(1)), //$NON-NLS-1$
- });
- dataManager.addData("SELECT v_0.c_0, COUNT(v_0.c_1), MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g2 AS g_0) AS v_0 GROUP BY v_0.c_0", //$NON-NLS-1$
- new List[] {
- Arrays.asList("a", Integer.valueOf(3), Integer.valueOf(2)), //$NON-NLS-1$
- });
- dataManager.addData("SELECT g_0.e1, g_0.e2 FROM pm2.g1 AS g_0", //$NON-NLS-1$
- new List[] {
- Arrays.asList("a", Integer.valueOf(3)), //$NON-NLS-1$
- Arrays.asList("xyz", Integer.valueOf(4)), //$NON-NLS-1$
- Arrays.asList(null, Integer.valueOf(5)),
- });
-
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(null, Integer.valueOf(1), Integer.valueOf(5)),
- Arrays.asList("a", Integer.valueOf(6), Integer.valueOf(3)), //$NON-NLS-1$
- Arrays.asList("xyz", Integer.valueOf(1), Integer.valueOf(4)) //$NON-NLS-1$
- };
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testUnionAggregatePushdown() {
- Command command = helpParse("select count(*), max(e3) from (select e1, e2, e3 from pm1.g1 union all (select convert(e2, string) as a, e2, e3 from pm2.g2 order by a limit 10)) x group by e1, e2"); //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- capFinder.addCapabilities("pm1", TestAggregatePushdown.getAggregateCapabilities()); //$NON-NLS-1$
- BasicSourceCapabilities bac = TestAggregatePushdown.getAggregateCapabilities();
- bac.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", bac); //$NON-NLS-1$
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT v_0.c_1, v_0.c_0, COUNT(*), MAX(v_0.c_2) FROM (SELECT g_0.e2 AS c_0, g_0.e1 AS c_1, g_0.e3 AS c_2 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0, v_0.c_1", //$NON-NLS-1$
- new List[] {
- Arrays.asList("2", Integer.valueOf(2), Integer.valueOf(2), Boolean.FALSE), //$NON-NLS-1$
- Arrays.asList("1", Integer.valueOf(1), Integer.valueOf(3), Boolean.TRUE), //$NON-NLS-1$
- });
- dataManager.addData("SELECT v_0.c_1, v_0.c_0, COUNT(*), MAX(v_0.c_2) FROM (SELECT g_0.e2 AS c_0, convert(g_0.e2, string) AS c_1, g_0.e3 AS c_2 FROM pm2.g2 AS g_0 ORDER BY c_1 LIMIT 10) AS v_0 GROUP BY v_0.c_0, v_0.c_1", //$NON-NLS-1$
- new List[] {
- Arrays.asList("1", Integer.valueOf(1), Integer.valueOf(4), Boolean.FALSE), //$NON-NLS-1$
- });
-
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(Integer.valueOf(7), Boolean.TRUE),
- Arrays.asList(Integer.valueOf(2), Boolean.FALSE),
- };
-
- helpProcess(plan, dataManager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,48 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Collections;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixException;
-
-public class TestBaseProcessorPlan extends TestCase {
-
- public TestBaseProcessorPlan(String name) {
- super(name);
- }
-
- public void testGetAndClearWarnings() {
- FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(), Collections.emptyList());
- MetaMatrixException warning = new MetaMatrixException("test"); //$NON-NLS-1$
- plan.addWarning(warning);
-
- List warnings = plan.getAndClearWarnings();
- assertEquals("Did not get expected number of warnings", 1, warnings.size()); //$NON-NLS-1$
- assertEquals("Did not get expected warning", warning, warnings.get(0)); //$NON-NLS-1$
- assertNull("Did not clear warnings from plan", plan.getAndClearWarnings()); //$NON-NLS-1$
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestBatchIterator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestBatchIterator.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestBatchIterator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.processor.relational.FakeRelationalNode;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-
-@SuppressWarnings("nls")
-public class TestBatchIterator {
-
- @Test public void testReset() throws Exception {
- BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
- Arrays.asList(1),
- Arrays.asList(1),
- Arrays.asList(1)
- }, 1));
- BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
- bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")), "test", TupleSourceType.PROCESSOR), true); //$NON-NLS-1$
- bi.mark();
- bi.nextTuple();
- bi.nextTuple();
- bi.reset();
- bi.nextTuple();
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestCollectionTupleSource.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestCollectionTupleSource.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestCollectionTupleSource.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-/**
- */
-public class TestCollectionTupleSource {
-
- @Test public void testNullSource() {
- List<SingleElementSymbol> elements = new ArrayList<SingleElementSymbol>();
- elements.add(new ElementSymbol("x")); //$NON-NLS-1$
- elements.add(new ElementSymbol("y")); //$NON-NLS-1$
- CollectionTupleSource nts = CollectionTupleSource.createNullTupleSource(elements);
-
- // Check schema
- assertEquals("Didn't get expected schema", elements, nts.getSchema()); //$NON-NLS-1$
-
- // Walk it and get no data
- List tuple = nts.nextTuple();
- nts.closeSource();
-
- assertEquals("Didn't get termination tuple for first tuple", null, tuple); //$NON-NLS-1$
- }
-
- @Test public void testUpdateCountSource() {
- CollectionTupleSource nts = CollectionTupleSource.createUpdateCountTupleSource(5);
-
- // Check schema
- assertEquals("Didn't get expected schema", Command.getUpdateCommandSymbol(), nts.getSchema()); //$NON-NLS-1$
-
- // Walk it and get no data
- List tuple = nts.nextTuple();
- nts.closeSource();
-
- assertEquals("Didn't get termination tuple for first tuple", Arrays.asList(5), tuple); //$NON-NLS-1$
- }
-
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,783 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.relational.JoinNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-
-
-public class TestDependentJoins extends TestCase {
-
- /**
- * @param sql
- * @return
- */
- static ProcessorPlan helpGetPlan(String sql) {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(2));
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false); //fake data manager doesn't support order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(TestProcessor.helpParse(sql),
- FakeMetadataFactory.example1Cached(),
- capFinder);
- return plan;
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1=pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin1() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1=pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin2() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(sql);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin3() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin4() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND concat(pm1.g1.e1, 'a') = concat(pm2.g1.e1, 'a') AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin5() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE concat(pm1.g1.e1, 'a') = concat(pm2.g1.e1, 'a') AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- public void testMultiCritDepJoin5a() {
- // Create query
- String sql = "SELECT X.e1 FROM pm1.g1 as X, pm2.g1 WHERE concat(X.e1, 'a') = concat(pm2.g1.e1, 'a') AND X.e2=pm2.g1.e2 order by x.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- public void testMultiCritDepJoin5b() {
- //Create query
- String sql = "SELECT X.e1, X.e2 FROM pm1.g1 as X, pm2.g1 WHERE concat(X.e1, convert(X.e4, string)) = concat(pm2.g1.e1, convert(pm2.g1.e4, string)) AND X.e2=pm2.g1.e2 order by x.e1 option makedep x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = concat(pm2.g1.e1, '') AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin6() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = concat(pm2.g1.e1, '') AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE concat(pm1.g1.e1, '') = pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
- public void testMultiCritDepJoin7() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE concat(pm1.g1.e1, '') = pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = pm2.g1.e1 AND pm1.g1.e2 <> pm2.g1.e2 */
- public void testMultiCritDepJoin8() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = pm2.g1.e1 AND pm1.g1.e2 <> pm2.g1.e2 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 <> pm2.g1.e2 */
- public void testMultiCritDepJoin9() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 <> pm2.g1.e2 option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e3=pm2.g1.e3 AND pm1.g1.e2=pm2.g1.e2 AND pm2.g1.e1 = 'a' */
- public void testMultiCritDepJoin10() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e3=pm2.g1.e3 AND pm1.g1.e2=pm2.g1.e2 AND pm2.g1.e1 = 'a' option makedep pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- public void testLargeSetInDepJoinWAccessPatternCausingSortNodeInsertCanHandleAlias() {
- helpTestDepAccessCausingSortNodeInsert(true);
- }
-
- public void testLargeSetInDepJoinWAccessPatternCausingSortNodeInsertCannotHandleAlias() {
- helpTestDepAccessCausingSortNodeInsert(false);
- }
-
- public void helpTestDepAccessCausingSortNodeInsert(boolean accessNodeHandlesAliases) {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a INNER JOIN pm1.g1 b ON a.e2=b.e2 AND a.e1 = b.e1 OPTION MAKEDEP a"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "aa ", "aa ", new Integer(0)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "bb ", "bb ", new Integer(1)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "cc ", "cc ", new Integer(2)}) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData2b(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
- depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
- depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- if(accessNodeHandlesAliases) {
- depcaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- }
-
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
-
- capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Slightly modify metadata to set max set size to just a few rows - this
- // will allow us to test the dependent overflow case
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
-
- //Verify a dependent join (not merge join) was used
- assertTrue(plan instanceof RelationalPlan);
- RelationalPlan relationalPlan = (RelationalPlan)plan;
- RelationalNode project = relationalPlan.getRootNode();
- RelationalNode join = project.getChildren()[0];
- assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- public void testCase5130() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "select a.intkey from bqt1.smalla a, bqt1.smallb b where concat(a.stringkey, 't') = b.stringkey option makedep a"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder, new String[] {"SELECT a.stringkey, a.intkey FROM bqt1.smalla AS a", "SELECT b.stringkey FROM bqt1.smallb AS b"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.stringkey FROM bqt1.smallb AS g_0", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1t" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2" })}); //$NON-NLS-1$
- dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1", new Integer(1) })}); //$NON-NLS-1$
-
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- };
-
- TestProcessor.helpProcess(plan, dataManager, expected);
-
- assertFalse(dataManager.getCommandHistory().contains("SELECT a.stringkey, a.intkey FROM bqt1.smalla AS a WHERE concat(a.stringkey, 't') IN ('1', '2')")); //$NON-NLS-1$
- }
-
- public void testCase5130a() throws Exception {
- HardcodedDataManager dataManager = helpTestDependentJoin(false);
-
- assertFalse(dataManager.getCommandHistory().contains("SELECT a.stringkey, a.intkey FROM bqt2.smalla AS a WHERE (concat(a.stringkey, 't') IN ('1t', '2')) AND (a.intkey IN (1))")); //$NON-NLS-1$
- }
-
- public void testUnlimitedIn() throws Exception {
- helpTestDependentJoin(true);
- }
-
- private HardcodedDataManager helpTestDependentJoin(boolean unlimitIn)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- if (unlimitIn) {
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, -1);
- }
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- String sql = "select a.intkey from bqt1.smalla a, bqt2.smallb b where concat(a.stringkey, 't') = b.stringkey and a.intkey = b.intkey option makedep a"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0 WHERE g_0.intkey IN (<dependent values>)", "SELECT g_0.stringkey, g_0.intkey FROM bqt2.smallb AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- unlimitIn?2:1, // Access
- unlimitIn?0:1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM bqt2.smallb AS g_0", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1t", new Integer(1) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2t", new Integer(2) })}); //$NON-NLS-1$
- dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0 WHERE g_0.intkey IN (1, 2)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1", new Integer(1) })}); //$NON-NLS-1$
-
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- };
-
- TestProcessor.helpProcess(plan, dataManager, expected);
- return dataManager;
- }
-
- static void sampleData4(FakeDataManager dataMgr) throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
- // Group pm6.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm6.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "b", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "e", new Integer(1) }), //$NON-NLS-1$
- } );
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm6.g1 WHERE pm1.g1.e1=pm6.g1.e1 OPTION MAKEDEP pm6.g1 */
- public void testLargeSetInDepAccess() throws Exception {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm6.g1 WHERE pm1.g1.e1=pm6.g1.e1 OPTION MAKEDEP pm6.g1"; //$NON-NLS-1$
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData4(dataManager);
-
- // Slightly modify metadata to set max set size to just a few rows - this
- // will allow us to test the dependent overflow case
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
- depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
- depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
-
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm6", depcaps); //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] {
- new String("b")})}; //$NON-NLS-1$
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- public void testLargeSetInDepAccessMultiJoinCriteria() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1=pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by e1 OPTION MAKEDEP pm2.g1"; //$NON-NLS-1$
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Slightly modify metadata to set max set size to just a few rows - this
- // will allow us to test the dependent overflow case
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
- depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
-
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", depcaps); //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] {
- new String("a")}), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- new String("a")}), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- new String("a")}), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- new String("a")}), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- new String("a")}), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- new String("b")}), //$NON-NLS-1$
- Arrays.asList(new Object[] {
- new String("c")})}; //$NON-NLS-1$
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
-
- }
-
- public void testLargeSetInDepAccessWithAccessPattern() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a INNER JOIN pm1.g1 b ON a.e1=b.e1 AND a.e2 = b.e2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] {
- "aa ", "aa ", new Integer(0)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] {
- "bb ", "bb ", new Integer(1)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] {
- "cc ", "cc ", new Integer(2)}) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData2b(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
- depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
- depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
-
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
-
- capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
-
- //Verify a dependent join (not merge join) was used
- assertTrue(plan instanceof RelationalPlan);
- RelationalPlan relationalPlan = (RelationalPlan)plan;
- RelationalNode project = relationalPlan.getRootNode();
- RelationalNode join = project.getChildren()[0];
- assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g1.e2 = -100 OPTION MAKEDEP pm1.g2 */
- public void testDependentNoRows() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g1.e2 = -100 OPTION MAKEDEP pm1.g2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE (pm1.g1.e2+1)=pm2.g1.e2 OPTION MAKEDEP pm1.g2 */
- public void testExpressionInDepJoin() {
- // Create query
- String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE (pm1.g1.e2+1)=pm2.g1.e2 OPTION MAKEDEP pm2.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(3) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,406 +0,0 @@
-package com.metamatrix.query.processor;
-
-import static com.metamatrix.query.processor.TestProcessor.*;
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-
-public class TestInsertProcessing {
-
- @Test public void testSelectIntoWithTypeConversion() {
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.BATCHED_UPDATES, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
- new String[] { "e1", "e2", "e3" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.FLOAT});
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(pm1g1);
- store.addObjects(pm1g1e);
-
- FakeMetadataFacade metadata = new FakeMetadataFacade(store);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("BatchedUpdate{I}", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1) })});
-
- String sql = "SELECT 1, convert(1, float), convert(1, float) INTO pm1.g1"; //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- };
-
- helpProcess(plan, dataManager, expected);
-
- BatchedUpdateCommand buc = (BatchedUpdateCommand)dataManager.getCommandHistory().iterator().next();
- Insert insert = (Insert)buc.getUpdateCommands().get(0);
-
- Constant value0 = (Constant)insert.getValues().get(0);
- Constant value1 = (Constant)insert.getValues().get(1);
-
- assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, value0.getValue().getClass());
- assertEquals(DataTypeManager.DefaultDataClasses.FLOAT, value1.getValue().getClass());
- }
-
-
- @Test public void testSelectInto_Case5569a_BATCH_NO_BULK_NO() {
- boolean doBatching = false;
- boolean doBulkInsert = false;
- helpSelectInto_Case5569Processor( doBatching, doBulkInsert );
- }
-
- @Test public void testSelectInto_Case5569b_BATCH_YES_BULK_NO() {
- boolean doBatching = true;
- boolean doBulkInsert = false;
- helpSelectInto_Case5569Processor( doBatching, doBulkInsert );
- }
-
- @Test public void testSelectInto_Case5569c_BATCH_NO_BULK_YES() {
- boolean doBatching = false;
- boolean doBulkInsert = true;
- helpSelectInto_Case5569Processor( doBatching, doBulkInsert );
- }
-
- public void helpSelectInto_Case5569Processor( boolean doBatching, boolean doBulkInsert ) {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
-
- caps.setCapabilitySupport(Capability.BATCHED_UPDATES, doBatching);
- caps.setCapabilitySupport(Capability.BULK_UPDATE, doBulkInsert);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1", new Integer(1), Boolean.FALSE, new Double(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2", new Integer(2), Boolean.TRUE, new Double(2) })}); //$NON-NLS-1$
-
- if (doBulkInsert) {
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (?, ?, ?, ?)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- }
- else
- if (doBatching) {
- dataManager.addData("BatchedUpdate{I,I}", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- } else {
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1)})});
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1)})});
- }
-
- String sql = "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 INTO pm1.g2 from pm1.g1"; //$NON-NLS-1$
-
- Command command = helpParse(sql);
-
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(2) }),
- };
-
- helpProcess(plan, dataManager, expected);
-
- // if not doBulkInsert and is doBatching,
- // check the command hist to ensure it contains the expected commands
- if ( !doBulkInsert && doBatching ) {
- BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(1);
- assertEquals(2, bu.getUpdateCommands().size());
- assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
- assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
- }
- }
-
-
- @Test public void testSelectInto_Case5412a() {
-
- // test setting BULK_INSERT capability to true
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
-
- caps.setCapabilitySupport(Capability.BULK_UPDATE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
- new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.FLOAT});
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(pm1g1);
- store.addObjects(pm1g1e);
-
- FakeMetadataFacade metadata = new FakeMetadataFacade(store);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (?, ?)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1) })});
-
- String sql = "SELECT 1, convert(1, float) INTO pm1.g1"; //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- };
-
- helpProcess(plan, dataManager, expected);
- }
-
-
- @Test public void testSelectInto_Case5412b() {
-
- // test setting BULK_INSERT capability to false
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
-
- caps.setCapabilitySupport(Capability.BULK_UPDATE, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
- new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.FLOAT});
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(pm1g1);
- store.addObjects(pm1g1e);
-
- FakeMetadataFacade metadata = new FakeMetadataFacade(store);
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (1, 1.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1) })});
-
- String sql = "SELECT 1, convert(1, float) INTO pm1.g1"; //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- };
-
- helpProcess(plan, dataManager, expected);
-
- Insert insert = (Insert)dataManager.getCommandHistory().iterator().next();
-
- Constant value0 = (Constant)insert.getValues().get(0);
- Constant value1 = (Constant)insert.getValues().get(1);
-
- assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, value0.getValue().getClass());
- assertEquals(DataTypeManager.DefaultDataClasses.FLOAT, value1.getValue().getClass());
- }
-
- @Test public void testInsertIntoWithSubquery_None() {
- helpInsertIntoWithSubquery( null );
- }
-
- @Test public void testInsertIntoWithSubquery_Batch() {
- helpInsertIntoWithSubquery( Capability.BATCHED_UPDATES );
- }
-
- @Test public void testInsertIntoWithSubquery_Bulk() {
- helpInsertIntoWithSubquery( Capability.BULK_UPDATE );
- }
-
- @Test public void testInsertIntoWithSubquery_Pushdown() {
- helpInsertIntoWithSubquery( Capability.INSERT_WITH_QUERYEXPRESSION );
- }
-
- public void helpInsertIntoWithSubquery( Capability cap ) {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
-
- caps.setCapabilitySupport(cap, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1", new Integer(1), Boolean.FALSE, new Double(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2", new Integer(2), Boolean.TRUE, new Double(2) })}); //$NON-NLS-1$
-
- if (cap != null) {
- switch (cap) {
- case BULK_UPDATE:
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (?, ?, ?, ?)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- break;
- case BATCHED_UPDATES:
- dataManager.addData("BatchedUpdate{I,I}", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- break;
- case INSERT_WITH_QUERYEXPRESSION:
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- break;
- }
- } else {
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1)})});
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1)})});
- }
-
- String sql = "INSERT INTO pm1.g2 SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 from pm1.g1"; //$NON-NLS-1$
-
- Command command = helpParse(sql);
-
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(2) }),
- };
-
- helpProcess(plan, dataManager, expected);
-
- // if not doBulkInsert and is doBatching,
- // check the command hist to ensure it contains the expected commands
- if ( cap == Capability.BATCHED_UPDATES ) {
- BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(1);
- assertEquals(2, bu.getUpdateCommands().size());
- assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
- assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
- }
- }
-
- @Test public void testInsertIntoWithSubquery2_BATCH_NO_BULK_NO() {
- boolean doBatching = false;
- boolean doBulkInsert = false;
- helpInsertIntoWithSubquery2( doBatching, doBulkInsert );
- }
-
- @Test public void testInsertIntoWithSubquery2_BATCH_YES_BULK_NO() {
- boolean doBatching = true;
- boolean doBulkInsert = false;
- helpInsertIntoWithSubquery2( doBatching, doBulkInsert );
- }
-
- @Test public void testInsertIntoWithSubquery2_BATCH_NO_BULK_YES() {
- boolean doBatching = false;
- boolean doBulkInsert = true;
- helpInsertIntoWithSubquery2( doBatching, doBulkInsert );
- }
-
- public void helpInsertIntoWithSubquery2( boolean doBatching, boolean doBulkInsert ) {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
-
- caps.setCapabilitySupport(Capability.BATCHED_UPDATES, doBatching);
- caps.setCapabilitySupport(Capability.BULK_UPDATE, doBulkInsert);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { "1", new Integer(1), Boolean.FALSE, new Double(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2", new Integer(2), Boolean.TRUE, new Double(2) })}); //$NON-NLS-1$
-
- if (doBulkInsert) {
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (?, ?, ?, ?)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- }
- else
- if (doBatching) {
- dataManager.addData("BatchedUpdate{I,I}", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(2)})});
- } else {
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1)})});
- dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1)})});
- }
-
- String sql = "INSERT INTO pm1.g2 SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 from pm1.g1 UNION ALL SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 from pm1.g1"; //$NON-NLS-1$
-// String sql = "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 INTO pm1.g2 from pm1.g1"; //$NON-NLS-1$
-
- Command command = helpParse(sql);
-
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(4) }),
- };
-
- helpProcess(plan, dataManager, expected);
-
- // if not doBulkInsert and is doBatching,
- // check the command hist to ensure it contains the expected commands
- if ( !doBulkInsert && doBatching ) {
- BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(2);
- assertEquals(2, bu.getUpdateCommands().size());
- assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
- assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
- }
- }
-
- @Test public void testInsertIntoVirtualWithQueryExpression() {
- String sql = "insert into vm1.g1 (e1, e2, e3, e4) select * from pm1.g1"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(6),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestJoinWithFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestJoinWithFunction.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestJoinWithFunction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,437 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2009 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * 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 com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-/**
- * <p><code>TestCase</code> to cover processing of JOINs which use a scalar
- * function as a symbol or as part of the JOIN criteria.</p>
- *
- * <p>All tests should verify and validate that the scalar function's result
- * is being used appropriately from the pre-JOIN and post-JOIN aspect. Most
- * specifically, the results returned from the JOIN should match the expected
- * results defined in each test method.</p>
- * @since 6.0
- */
-public class TestJoinWithFunction extends TestCase {
-
- /**
- * <p>Test the use of a non-deterministic function on a user command that
- * performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed on the result returned from the JOIN and
- * is expected to be executed for each row of the final result set.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryMetadataException
- */
- public void testNonDeterministicPostJoin() throws QueryMetadataException, MetaMatrixComponentException {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. RandomTop is the use of RAND() on
- * the user command and should result in unique random numbers for each
- * row in the JOINed output.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, RAND() AS RandomTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- /*
- * Populate a List with our expected results. We can predict the return value
- * for RAND() because the TestProcessor.helpProcess() method seeds the random
- * number generator.
- */
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(0.24053641567148587) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(0.0), new Double(0.6374174253501083) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(0.5504370051176339) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
- new Boolean(false), null, new Double(0.5975452777972018) }), };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- FakeDataStore.sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * <p>Test the use of a non-deterministic function on a source command of a JOIN
- * defined by a user command that performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed on the result that will be used for one side
- * of the JOIN. The function should only be executed for each row of the the result
- * set returned from the left-side of the JOIN which should result in the same return
- * value for multiple rows of the final result set after the JOIN is completed. For
- * example, if the left-side query is expected to return one row and the right-side
- * query will return three rows which match the JOIN criteria for the one row on the
- * left-side then the expected result should be that the function be executed once to
- * represent the one row from the left-side and the function's return value will be
- * repeated for each of the three post-JOINed results.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryMetadataException
- */
- public void testNonDeterministicPreJoin() throws QueryMetadataException, MetaMatrixComponentException {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. TopRandom is the use of RAND() on
- * the user command while RandomLeft is the use of RAND() within a
- * source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- /*
- * Populate a List with our expected results. We can predict the return value
- * for RAND() because the TestProcessor.helpProcess() method seeds the random
- * number generator.
- */
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(0.24053641567148587) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(0.0), new Double(0.6374174253501083) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(0.6374174253501083) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
- new Boolean(false), null, new Double(0.6374174253501083) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- FakeDataStore.sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * <p>Test the use of a non-deterministic function on the sub-command of a user
- * command and the user command itself, which performs a JOIN of two sources.</p>
- *
- * <p>This test combines the PostJoin and PreJoin test cases.</p>
- * @see #testNonDeterministicPostJoin
- * @see #testNonDeterministicPreJoin
- * @throws MetaMatrixComponentException
- * @throws QueryMetadataException
- */
- public void testNonDeterministicPrePostJoin() throws MetaMatrixComponentException, QueryMetadataException {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. TopRandom is the use of RAND() on
- * the user command while RandomLeft is the use of RAND() within a
- * source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft, RAND() AS RandomTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- /*
- * Populate a List with our expected results. We can predict the return value
- * for RAND() because the TestProcessor.helpProcess() method seeds the random
- * number generator.
- */
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(0.24053641567148587), new Double(0.5975452777972018) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(0.0), new Double(0.6374174253501083), new Double(0.3332183994766498) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(0.6374174253501083), new Double(0.3851891847407185) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
- new Boolean(false), null, new Double(0.6374174253501083), new Double(0.984841540199809) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- FakeDataStore.sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * <p>Test the use of a deterministic function on the user command which
- * performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed prior to the JOIN being executed and should
- * result in the projected symbol becoming a constant.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryMetadataException
- */
- public void testDeterministicPostJoin() throws MetaMatrixComponentException, QueryMetadataException {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
- * the user command and should result in 10 for each row in the JOINed
- * output.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- /*
- * Populate a List with our expected results.
- */
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(10) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(0.0), new Double(10) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(10) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
- new Boolean(false), null, new Double(10) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- FakeDataStore.sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * <p>The function should be executed prior to the JOIN being executed and should
- * result in the projected symbol becoming a constant.</p>
-
- * <p>Test the use of a deterministic function on the source command of a JOIN
- * defined by a user command which performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed prior to the commands from either side of the
- * JOIN being executed and merged into user command prior to the JOIN actually being
- * executed.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryMetadataException
- */
- public void testDeterministicPreJoin() throws QueryMetadataException, MetaMatrixComponentException {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. SqrtLeft is the use of SQRT()
- * within a source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- /*
- * Populate a List with our expected results.
- */
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(10) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(0.0), new Double(10) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(10) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
- new Boolean(false), null, new Double(10) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- FakeDataStore.sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * <p>Test the use of a deterministic function on the sub-command of a user
- * command and the user command itself, which performs a JOIN of two sources.</p>
- *
- * <p>This test combines the PostJoin and PreJoin test cases.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryMetadataException
- * @see #testDeterministicPostJoin
- * @see #testDeterministicPreJoin
- */
- public void testDeterministicPrePostJoin() throws QueryMetadataException, MetaMatrixComponentException {
- // sub-query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // sub-query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
- * the user command while SqrtLeft is the use of SQRT() within a
- * source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- /*
- * Populate a List with our expected results.
- */
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(10.0), new Double(10.0) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
- new Boolean(false), new Double(0.0), new Double(10.0), new Double(10.0) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
- new Boolean(true), new Double(2.0), new Double(10.0), new Double(10.0) }),
- Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
- new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
- new Boolean(false), null, new Double(10.0), new Double(10.0) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- FakeDataStore.sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,491 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestOptionalJoins {
-
- @Test public void testOptionalJoinNode1() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2 where pm1.g1.e1 = 'a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode2() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2, pm1.g3 where pm1.g1.e1 = 'a' and pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode3() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode4() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode5() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode6() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode7() {
- // Create query
- String sql = "SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode8() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ (select * from pm1.g2) as X on pm1.g1.e1 = x.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode9() {
- // Create query
- String sql = "SELECT pm1.g2.e1 FROM pm1.g2, /* optional */ vm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode10() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM /* optional */ vm1.g1, pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode11() {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ vm1.g2 on pm1.g1.e1 = vm1.g2.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode12() {
- // Create query
- String sql = "SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN vm1.g1 on pm1.g1.e1 = vm1.g1.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode13() {
- // Create query
- String sql = "SELECT count(pm1.g1.e1) FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode15() {
- // Create query
- String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode16() {
- // Create query
- String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x order by x.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode17() {
- // Create query
- String sql = "SELECT length(z) FROM /* optional */ pm1.g1, (select distinct e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY y, z) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(5) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode18() {
- // Create query
- String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOptionalJoinNode19() {
- // Create query
- String sql = "SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(6) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,763 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-import org.teiid.client.metadata.ParameterInfo;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.processor.proc.CreateCursorResultSetInstruction;
-import com.metamatrix.query.processor.proc.ProcedurePlan;
-import com.metamatrix.query.processor.proc.TestProcedureProcessor;
-import com.metamatrix.query.processor.relational.DependentProcedureExecutionNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-
-public class TestProcedureRelational {
-
- @Test public void testProcInExistsSubquery() throws Exception {
- String sql = "select pm1.g1.e1 from pm1.g1 where exists (select * from (EXEC pm1.vsp9(pm1.g1.e2 + 1)) x where x.e1 = pm1.g1.e1)"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcInSelectScalarSubquery() throws Exception {
- String sql = "select (EXEC pm1.vsp36(pm1.g1.e2)) from pm1.g1 where pm1.g1.e1 = 'a'"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(0) }),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsTable(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- //virtual group with procedure in transformation
- @Test public void testAliasedProcAsTable(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 as x where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testAliasedJoin(){
- String sql = "select x.param1, x.param2, y.param1, y.param2, x.e1 from pm1.vsp26 as x, pm1.vsp26 as y where x.param1=1 and x.param2='a' and y.param1 = 2 and y.param2 = 'b'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "a", new Integer(2), "b", "a"}), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
-
- @Test public void testAliasedJoin1(){
- String sql = "select x.param1, x.param2, y.param1, y.param2, x.e1 from pm1.vsp26 as x, pm1.vsp26 as y where x.param1=1 and x.param2='a' and y.param1 = x.param1 and y.param2 = x.param2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "a", new Integer(1), "a", "a"}), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Will fail due to access pattern validation (missing param2 assignment)
- */
- @Test public void testProcAsTable1(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=1"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
- }
-
- /**
- * Will fail since less than does not constitue an input
- */
- @Test public void testProcAsTable2(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1<1 and param2='a'"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
- }
-
- @Test public void testProcAsTable3(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1 in (1,2,3) and param2 in ('a', 'b') order by param1, param2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Integer(1), "b", "b", new Integer(2)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Integer(2), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Integer(2), "b", "b", new Integer(2)}), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Integer(3), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Will fail missing param2 assignment
- */
- @Test public void testProcAsTable4(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=1 and not(param2 = 'a')"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
- }
-
- /**
- * Will fail missing param2 assignment
- */
- @Test public void testProcAsTable5(){
- String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=e2 and param2 = 'a'"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
- }
-
- @Test public void testProcAsTableInJoin(){
- String sql = "select param1, param2, pm1.vsp26.e2 from pm1.vsp26, pm1.g1 where param1 = pm1.g1.e2 and param2 = pm1.g1.e1 order by param1, param2, e2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(1), "c", new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "b", new Integer(2)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(3), "a", new Integer(3)}), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsTableInSubquery(){
- String sql = "select param1, param2, pm1.vsp26.e2, (select count(e1) from pm1.vsp26 where param1 = 1 and param2 = 'a') x from pm1.vsp26, pm1.g1 where param1 = pm1.g1.e2 and param2 = pm1.g1.e1 order by param1, param2, e2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(1), "c", new Integer(1), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "b", new Integer(2), new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(3), "a", new Integer(3), new Integer(1)}), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- private void helpTestProcRelational(String userQuery,
- String inputCriteria,
- String atomicQuery) {
- ProcessorPlan plan = TestOptimizer.helpPlan(userQuery, FakeMetadataFactory.example1Cached(),
- new String[] {} );
-
- RelationalPlan rplan = (RelationalPlan)plan;
-
- RelationalNode root = rplan.getRootNode();
-
- while (root.getChildren() != null) {
- root = root.getChildren()[0];
-
- if (root instanceof DependentProcedureExecutionNode) {
- break;
- }
- }
-
- DependentProcedureExecutionNode dep = (DependentProcedureExecutionNode)root;
-
- assertEquals(inputCriteria, dep.getInputCriteria().toString());
-
- ProcedurePlan pp = (ProcedurePlan)dep.getProcessorPlan();
-
- CreateCursorResultSetInstruction ccrsi = (CreateCursorResultSetInstruction)pp.getOriginalProgram().getInstructionAt(0);
-
- plan = ccrsi.getCommand();
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- TestOptimizer.checkAtomicQueries(new String[] {atomicQuery}, plan);
- }
-
- //virtual group with procedure in transaformation
- @Test public void testProcInVirtualGroup1() {
-
- String userQuery = "select e1 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
- String inputCriteria = "(pm1.vsp26.param1 = 1) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
- String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
-
- helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
- }
-
- //virtual group with procedure in transformation
- @Test public void testCase3403() {
- String userQuery = "select e1 from pm1.vsp26 where param1=2 and param2='a' and 'x'='x'"; //$NON-NLS-1$
- String inputCriteria = "(pm1.vsp26.param1 = 2) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
- String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
-
- helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
- }
-
- @Test public void testCase3448() {
- String userQuery = "select e1 from pm1.vsp26 where (param1=1 and e2=2) and param2='a'"; //$NON-NLS-1$
- String inputCriteria = "(pm1.vsp26.param1 = 1) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
- String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
-
- helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
- }
-
- @Test public void testProcAsVirtualGroup2(){
- String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup3(){
- String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup4(){
- String sql = "SELECT P.e1 as ve3 FROM pm1.vsp26 as P, pm1.g2 where P.e1=g2.e1 and param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}) //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup5(){
- String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2='a' and e1='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup6(){
- String sql = "SELECT P.e1 as ve3 FROM pm1.vsp26 as P, vm1.g1 where P.e1=g1.e1 and param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}) //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup7(){
- String sql = "SELECT e1 FROM (SELECT p.e1, param1, param2 FROM pm1.vsp26 as P, vm1.g1 where P.e1=g1.e1) x where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}) //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup10_Defect20164(){
- String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where (param1=1 and param2='a') and e1='c'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testProcAsVirtualGroup8(){
- String sql = "SELECT P.e1 as ve3, P.e2 as ve4 FROM pm1.vsp26 as P where param1=1 and param2='a' and e2=3"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(3)}), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- //virtual group with procedure in transformation
- @Test public void testProcAsVirtualGroup9(){
- String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "FOO" }), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Relies upon a default value of null for param1
- *
- * This is marked as defered since it is not desirable to support this behavior for a single default value
- */
- public void defer_testProcAsVirtualGroup9a(){
- String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(2112), "a" }), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Relies upon a default value of null for both parameters
- *
- * This is marked as defered since it is not desirable to support this behavior for a single default value
- */
- public void defer_testProcAsVirtualGroup9b(){
- String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(2112), null })
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * test for defect 22376
- */
- @Test public void testParameterPassing() throws Exception {
- FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
-
- FakeMetadataObject rs1 = FakeMetadataFactory.createResultSet("v1.rs1", v1, new String[] {"e1"}, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs1p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
-
- QueryNode n1 = new QueryNode("v1.vp1", "CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x = '1'; SELECT e1 FROM v1.vp2 where v1.vp2.in = VARIABLES.x; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vt1 = FakeMetadataFactory.createVirtualProcedure("v1.vp1", v1, Arrays.asList(new FakeMetadataObject[] { rs1p1 }), n1); //$NON-NLS-1$
-
- FakeMetadataObject p1 = FakeMetadataFactory.createParameter("v1.vp2.in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
- QueryNode n2 = new QueryNode("v1.vp2", "CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x; declare string VARIABLES.y; VARIABLES.x = '2'; VARIABLES.y = v1.vp2.in; select VARIABLES.y; end"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vt2 = FakeMetadataFactory.createVirtualProcedure("v1.vp2", v1, Arrays.asList(new FakeMetadataObject[] { rs1p1, p1 }), n2); //$NON-NLS-1$
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(v1);
- store.addObject(rs1);
- store.addObject(vt1);
- store.addObject(vt2);
- store.addObject(vt2);
-
- String sql = "select * from (exec v1.vp1()) foo"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- };
-
- FakeMetadataFacade metadata = new FakeMetadataFacade(store);
-
- // Construct data manager with data
- // Plan query
- ProcessorPlan plan = TestProcedureProcessor.getProcedurePlan(sql, metadata);
- // Run query
- TestProcedureProcessor.helpTestProcess(plan, expected, new FakeDataManager());
-
- }
-
- //virtual group with procedure in transformation
- @Test public void testCase6395ProcAsVirtualGroup9(){
- String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param1=1 and param2='a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "FOO" }), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Case 6395 - This test case will now raise a QueryPlannerException. param2 is required
- * and not nullable. This case is expected to fail because of 'param2 is null'
- */
- @Test public void testProcAsVirtualGroup2WithNull() throws Exception {
- String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2 is null"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- try {
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.doProcess(plan, dataManager, expected, TestProcessor.createCommandContext());
- fail("QueryPlannerException was expected."); //$NON-NLS-1$
- } catch (QueryValidatorException e) {
- assertEquals("The procedure parameter is not nullable, but is set to null: pm1.vsp26.param2",e.getMessage()); //$NON-NLS-1$
- }
- }
-
- /**
- * Case 6395 - This case is expected to succeed. param1 and param2 are both required, but nulls
- * are acceptable for both.
- */
- @Test public void testProcAsVirtualGroup2WithNull2() throws Exception {
- String sql = "select * from pm1.vsp47 where param1 is null and param2 is null"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, new Integer(2112), null, null })
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Case 6395 - This will not throw an exception and the proc will not be invoked.
- */
- @Test public void testProcAsVirtualGroup2WithNull3() throws Exception {
- String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2 = commandpayload()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- /*
- * The following are tests that were removed from the validator. We are no longer trying to validate a priori whether
- * procedure input criteria is valid. This can be addressed later more generally when we do up front validation of
- * access patterns and access patterns have a wider range of semantics.
- *
- @Test public void testProcInVirtualGroupDefect14609_1() throws Exception{
- helpValidate("select ve3 from vm1.vgvp1 where ve1=1.1 and ve2='a'", new String[] {"ve1 = 1.1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testProcInVirtualGroupDefect14609_2() throws Exception{
- helpValidate("select ve3 from vm1.vgvp1 where convert(ve1, integer)=1 and ve2='a'", new String[] {"convert(ve1, integer) = 1" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testProcInVirtualGroupDefect14609_3() throws Exception{
- helpValidate("select ve3 from vm1.vgvp1 where 1.1=ve1 and ve2='a'", new String[] {"1.1 = ve1" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testProcInVirtualGroupDefect14609_4() throws Exception{
- helpValidate("select ve3 from vm1.vgvp1 where 1=convert(ve1, integer) and ve2='a'", new String[] {"1 = convert(ve1, integer)" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testDefect15861() throws Exception{
- helpValidate("select ve3 from vm1.vgvp1 where (ve1=1 or ve1=2) and ve2='a'", new String[] {"(ve1 = 1) OR (ve1 = 2)", "ve1 = 2"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testProcInVirtualGroup1_Defect20164() {
- helpFailProcedure("select ve3 from vm1.vgvp2 where (ve1=1 and ve2='a') or ve3='c'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testProcInVirtualGroup2_Defect20164() {
- helpFailProcedure("select ve3 from vm1.vgvp2 where ve1=1 or ve2='a'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testProcInVirtualGroup3_Defect20164() {
- helpFailProcedure("select ve3 from vm1.vgvp2, pm1.g1 where ve1=pm1.g1.e2 and ve2='a'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testProcInVirtualGroup4_Defect20164() {
- helpValidate("select ve3 from vm1.vgvp2 where (ve1=1 and ve2='a') and (ve3='a' OR ve3='c')", new String[0], FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testProcInVirtualGroup5_Defect20164() {
- helpFailProcedure("select ve3 from vm1.vgvp2 where ve1=1 and NOT(ve2='a')", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testProcInVirtualGroup6_Defect20164() {
- helpValidate("select ve3 from vm1.vgvp2 where ve1=1 and ve2 is null", new String[0], FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }
-
- @Test public void testProcInVirtualGroup7_Defect20164() {
- helpFailProcedure("select ve3 from vm1.vgvp2 where ve1=1 and ve2 is not null", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
- }*/
-
- /**
- * Ensures that dependent procedures are processed 1 at a time so that projected input values
- * are set correctly.
- */
- @Test public void testIssue119() throws Exception {
- FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
-
- FakeMetadataObject in = FakeMetadataFactory.createParameter("v1.vp1.in1", 2, SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs1 = FakeMetadataFactory.createResultSet("v1.vp1.rs1", v1, new String[] {"e1", "e2", "e3", "e4", "e5"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- FakeMetadataObject rs1p1 = FakeMetadataFactory.createParameter("ret", 1, SPParameter.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
-
- QueryNode n1 = new QueryNode("v1.vp1", "CREATE VIRTUAL PROCEDURE BEGIN SELECT vp1.in1 e1, x.in1 e2, x.e1 e3, y.in1 e4, y.e1 e5 FROM pm1.sp119 x, pm1.sp119 y where x.in1 = vp1.in1 and y.in1 = x.e1; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vt1 = FakeMetadataFactory.createVirtualProcedure("v1.vp1", v1, Arrays.asList(new FakeMetadataObject[] { rs1p1, in }), n1); //$NON-NLS-1$
-
- FakeMetadataObject in1 = FakeMetadataFactory.createParameter("pm1.sp119.in1", 2, SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
- FakeMetadataObject rs3 = FakeMetadataFactory.createResultSet("pm1.sp119.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs3p1 = FakeMetadataFactory.createParameter("ret", 1, SPParameter.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3); //$NON-NLS-1$
- FakeMetadataObject sp1 = FakeMetadataFactory.createStoredProcedure("pm1.sp119", pm1, Arrays.asList(new FakeMetadataObject[] { rs3p1, in1 }), "pm1.sp119"); //$NON-NLS-1$ //$NON-NLS-2$
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(v1);
- store.addObject(rs1);
- store.addObject(vt1);
- store.addObject(sp1);
-
- String sql = "select * from (exec v1.vp1(1)) foo order by e4, e5"; //$NON-NLS-1$
-
- List<?>[] expected = new List[] {
- Arrays.asList(1, 1, 3, 3, 5),
- Arrays.asList(1, 1, 3, 3, 8),
- Arrays.asList(1, 1, 6, 6, 8),
- Arrays.asList(1, 1, 6, 6, 11),
- };
-
- FakeMetadataFacade metadata = new FakeMetadataFacade(store);
-
- // Construct data manager with data
- // Plan query
- ProcessorPlan plan = TestProcedureProcessor.getProcedurePlan(sql, metadata);
- // Run query
- HardcodedDataManager dataManager = new HardcodedDataManager() {
- @Override
- public TupleSource registerRequest(Object processorID,
- Command command, String modelName,
- String connectorBindingId, int nodeID)
- throws MetaMatrixComponentException {
- if (command instanceof StoredProcedure) {
- StoredProcedure proc = (StoredProcedure)command;
- List<SPParameter> params = proc.getInputParameters();
- assertEquals(1, params.size());
- int value = (Integer)((Constant)params.get(0).getExpression()).getValue();
- return new FakeTupleSource(command.getProjectedSymbols(), new List[] {
- Arrays.asList(value+2), Arrays.asList(value+5)
- });
- }
- return super.registerRequest(processorID, command, modelName,
- connectorBindingId, nodeID);
- }
- };
-
- TestProcedureProcessor.helpTestProcess(plan, expected, dataManager);
-
- }
-
- @Test public void testProcRelationalWithNoInputs() {
- String sql = "select e1 from pm1.vsp2 order by e1 desc limit 1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList("c") //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,7487 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.SQLException;
-import java.sql.Timestamp;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Calendar;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Set;
-
-import org.junit.Test;
-import org.teiid.client.metadata.ParameterInfo;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionTree;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.function.UDFSource;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.FakeFunctionMetadataSource;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.TestRuleRaiseNull;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.rules.RuleChooseDependent;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.relational.JoinNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.BindVariableVisitor;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.unittest.TimestampUtil;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorReport;
-
-public class TestProcessor {
-
- // ################################## TEST HELPERS ################################
-
- static Command helpParse(String sql) {
- // parse
- try {
- return QueryParser.getQueryParser().parseCommand(sql);
- } catch(MetaMatrixException e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- public static ProcessorPlan helpGetPlan(String sql, QueryMetadataInterface metadata) {
- return helpGetPlan(sql, metadata, null);
- }
-
- public static ProcessorPlan helpGetPlan(String sql, QueryMetadataInterface metadata, String[] bindings) {
- if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
-
- Command command = helpParse(sql);
-
- // attach bindings
- if(bindings != null) {
- try {
- BindVariableVisitor.bindReferences(command, Arrays.asList(bindings), metadata);
- } catch(Throwable e) {
- throw new MetaMatrixRuntimeException(e);
- }
- }
-
- ProcessorPlan process = helpGetPlan(command, metadata);
-
- return process;
- }
-
- static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata) {
- return helpGetPlan(command, metadata, new DefaultCapabilitiesFinder());
- }
-
- static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) {
- CommandContext context = new CommandContext();
- context.setProcessorBatchSize(2000);
- context.setConnectorBatchSize(2000);
- return helpGetPlan(command, metadata, capFinder, context);
- }
-
- static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) {
- if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
- AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
- try {
- QueryResolver.resolveCommand(command, metadata);
-
- ValidatorReport repo = Validator.validate(command, metadata);
- Collection failures = new ArrayList();
- repo.collectInvalidObjects(failures);
- if (failures.size() > 0){
- fail("Exception during validation (" + repo); //$NON-NLS-1$
- }
- command = QueryRewriter.rewrite(command, metadata, createCommandContext());
- ProcessorPlan process = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, context);
- if(DEBUG) System.out.println("\n" + process); //$NON-NLS-1$
- //per defect 10022, clone this plan before processing, just to make sure
- //a cloned plan with correlated subquery references (or any cloned plan) can be processed
- process = process.clone();
-
- assertNotNull("Output elements of process plan are null", process.getOutputElements()); //$NON-NLS-1$
-
- return process;
- } catch (MetaMatrixComponentException e) {
- throw new RuntimeException(e);
- } catch (MetaMatrixProcessingException e) {
- throw new RuntimeException(e);
- } finally {
- if(DEBUG) {
- System.out.println(analysisRecord.getDebugLog());
- }
- }
- }
-
- public static void helpProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults) {
- CommandContext context = createCommandContext();
- helpProcess(plan, context, dataManager, expectedResults);
- }
-
- public static void helpProcess(ProcessorPlan plan, CommandContext context, ProcessorDataManager dataManager, List[] expectedResults) {
- try {
- ProcessorPlan clonePlan = plan.clone();
-
- // Process twice to test reset and clone
- doProcess(plan, dataManager, expectedResults, context);
- plan.reset();
- doProcess(plan, dataManager, expectedResults, context);
-
- // Execute cloned of original plan
- doProcess(clonePlan, dataManager, expectedResults, context);
- } catch (Exception ex) {
- throw new RuntimeException(ex);
- }
- }
-
- private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager) {
- helpProcessException(plan, dataManager, null);
- }
-
- private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager, String expectedErrorMessage) {
- TupleBuffer tsId = null;
- BufferManager bufferMgr = null;
- try {
- bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- CommandContext context = new CommandContext("0", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- processor.setNonBlocking(true);
- BatchCollector collector = processor.createBatchCollector();
- tsId = collector.collectTuples();
- fail("Expected error during processing, but got none."); //$NON-NLS-1$
- } catch(MetaMatrixCoreException e) {
- // ignore - this is expected
- if(expectedErrorMessage != null) {
- assertEquals(expectedErrorMessage, e.getMessage());
- }
- } finally {
- if (tsId != null) {
- tsId.remove();
- }
- }
- }
-
- public static void doProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults, CommandContext context) throws Exception {
- BufferManagerImpl bufferMgr = (BufferManagerImpl)BufferManagerFactory.getStandaloneBufferManager();
- bufferMgr.setProcessorBatchSize(context.getProcessorBatchSize());
- bufferMgr.setConnectorBatchSize(context.getProcessorBatchSize());
- context.getNextRand(0);
- TupleBuffer id = null;
- try {
- QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- processor.setNonBlocking(true);
- BatchCollector collector = processor.createBatchCollector();
- id = collector.collectTuples();
- if ( expectedResults != null ) {
- examineResults(expectedResults, bufferMgr, id);
- }
- } finally {
- if (id != null) {
- id.remove();
- }
- }
- }
-
- /**
- * @param expectedResults
- * @param bufferMgr
- * @param tsID
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
- * @since 4.3
- */
- static void examineResults(List[] expectedResults,BufferManager bufferMgr,TupleBuffer tsID)
- throws MetaMatrixComponentException,SQLException, MetaMatrixProcessingException {
-
- // Create QueryResults from TupleSource
- TupleSource ts = tsID.createIndexedTupleSource();
- int count = tsID.getRowCount();
-
- if(DEBUG) {
- System.out.println("\nResults:\n" + tsID.getSchema()); //$NON-NLS-1$
- TupleSource ts2 = tsID.createIndexedTupleSource();
- for(int j=0; j<count; j++) {
- System.out.println("" + j + ": " + ts2.nextTuple()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- ts2.closeSource();
- }
-
- // Compare actual to expected row count
- assertEquals("Did not get expected row count: ", expectedResults.length, count); //$NON-NLS-1$
-
- // Walk results and compare
- for(int i=0; i<count; i++) {
- List record = ts.nextTuple();
-
- //handle xml
- if(record.size() == 1){
- Object cellValue = record.get(0);
- if(cellValue instanceof XMLType){
- XMLType id = (XMLType)cellValue;
- String actualDoc = id.getString();
- record = new ArrayList(record);
- record.set(0, actualDoc);
- }
- if (expectedResults[i].size() == 1) {
- assertEquals("Row " + i + " does not match expected: ", expectedResults[i].get(0), record.get(0)); //$NON-NLS-1$ //$NON-NLS-2$
- continue;
- }
- }
-
- assertEquals("Row " + i + " does not match expected: ", expectedResults[i], record); //$NON-NLS-1$ //$NON-NLS-2$
- }
- ts.closeSource();
- }
-
- public static CommandContext createCommandContext() {
- Properties props = new Properties();
- props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
- props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
- CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- context.setProcessorBatchSize(2000);
- context.setConnectorBatchSize(2000);
- context.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
- return context;
- }
-
- public static void sampleData1(FakeDataManager dataMgr) {
- try {
- FakeDataStore.sampleData1(dataMgr);
- } catch(Throwable e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleData2(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- try {
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
- // Group pm1.g2
- groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(1), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(5), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", new Integer(2), Boolean.FALSE, new Double(1.0) }), //$NON-NLS-1$
- } );
-
- // Group pm2.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- } );
-
- // Group pm1.table1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm1.table1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleData2a(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- try {
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
- // Group pm2.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(7), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- } );
-
- // Group pm4.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm4.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "aa", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bb", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cc", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- public static void sampleData2b(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- try {
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "aa ", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bb ", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cc ", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
- // Group pm2.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- } );
-
- // Group pm4.g1
- groupID = (FakeMetadataObject) metadata.getGroupID("pm4.g1"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { "aa ", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bb ", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cc ", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleData3(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- try {
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementSymbols = new ArrayList(1);
- ElementSymbol count = new ElementSymbol("Count"); //$NON-NLS-1$
- count.setType(Integer.class);
- elementSymbols.add(count);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- } );
- }catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleDataStringTimestamps(FakeDataManager dataMgr) {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- try {
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
- new List[] {
- Arrays.asList(new Object[] { "Jan 01 2004 12:00:00", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "Dec 31 2004 12:00:00", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "Aug 01 2004 12:00:00", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- } );
-
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleDataBQT1(FakeDataManager dataMgr) {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- try {
- // Group bqt1.smalla
-
- List[] tuples = new List[20];
- for(int i=0; i<tuples.length; i++) {
- tuples[i] = new ArrayList(17);
- tuples[i].add(new Integer(i));
- for(int j=0; j<16; j++) {
- tuples[i].add(null);
- }
- }
-
- dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
-
- // Group bqt2.mediumb
- tuples = new List[20];
- for(int i=0; i<tuples.length; i++) {
- tuples[i] = new ArrayList(17);
- tuples[i].add(new Integer(i));
- for(int j=0; j<16; j++) {
- tuples[i].add(null);
- }
- }
-
- dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleDataBQT2(FakeDataManager dataMgr) {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- try {
- for(int i=0; i<groups.length; i++) {
- String groupName = groups[i];
-
- List[] tuples = new List[30];
- for(int row=0; row<tuples.length; row++) {
- tuples[row] = new ArrayList(17);
- tuples[row].add(new Integer(row));
- for(int col=0; col<16; col++) {
- tuples[row].add(null);
- }
- }
-
- dataMgr.registerTuples(metadata, groupName, tuples);
- }
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Just want to register two rows of all the integral types to test AVG
- * @param dataMgr
- * @since 4.2
- */
- private void sampleDataBQT_defect11682(FakeDataManager dataMgr) {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- try {
- List[] tuples = new List[2];
- for(int i=1; i<=tuples.length; i++) {
- int index=i-1;
- tuples[index] = new ArrayList(17);
- tuples[index].add(new Integer(i)); //IntKey
- tuples[index].add(null);
- tuples[index].add(new Integer(i));
- tuples[index].add(null);
- tuples[index].add(new Float(i));
- tuples[index].add(new Long(i));
- tuples[index].add(new Double(i));
- tuples[index].add(new Byte((byte)i));
- tuples[index].add(null);
- tuples[index].add(null);
- tuples[index].add(null);
- tuples[index].add(null);
- tuples[index].add(null);
- tuples[index].add(new Short((short)i));
- tuples[index].add(new BigInteger(i+"")); //$NON-NLS-1$
- tuples[index].add(new BigDecimal(i+".0")); //$NON-NLS-1$
- tuples[index].add(null);
- }
-
- dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private void sampleDataBQTSmall(FakeDataManager dataMgr) {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- try {
- List[] tuples = new List[1];
- for(int i=0; i<tuples.length; i++) {
- tuples[i] = new ArrayList(17);
- tuples[i].add(new Integer(i));
- for(int j=0; j<16; j++) {
- tuples[i].add(null);
- }
- }
-
- dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
-
- } catch(MetaMatrixException e) {
- throw new RuntimeException(e);
- }
- }
-
- private List createRowWithTimestamp(String tsStr) {
- Timestamp ts = Timestamp.valueOf(tsStr);
- return Arrays.asList(new Object[] {
- new Integer(0), "a", new Integer(1), "a", //$NON-NLS-1$ //$NON-NLS-2$
- null, null, null, null, null, null, ts, null, null, null, null, null, null
- });
- }
-
- private void sampleDataBQT_case1566(FakeDataManager dataMgr) throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- dataMgr.registerTuples(metadata, "bqt1.smalla", new List[] { //$NON-NLS-1$
- createRowWithTimestamp("2002-01-01 10:00:00"), //$NON-NLS-1$
- createRowWithTimestamp("2002-01-01 14:00:00"), //$NON-NLS-1$
- createRowWithTimestamp("2002-01-02 10:00:00"), //$NON-NLS-1$
- createRowWithTimestamp("2002-01-02 14:00:00"), //$NON-NLS-1$
- createRowWithTimestamp("2002-01-02 19:00:00.01"), //$NON-NLS-1$
- } );
- }
-
- static List getProcResultSetSymbols(List params){
- List result = new ArrayList();
- Iterator iter = params.iterator();
- while(iter.hasNext()){
- SPParameter param = (SPParameter)iter.next();
- if(param.getResultSetColumns() != null){
- result.addAll(param.getResultSetColumns());
- }
- }
- iter = params.iterator();
- while(iter.hasNext()){
- SPParameter param = (SPParameter)iter.next();
- if(param.getParameterType() == ParameterInfo.INOUT || param.getParameterType() == ParameterInfo.RETURN_VALUE) {
- result.add(param.getParameterSymbol());
- }
- }
- return result;
- }
-
- @Test public void test1() {
- // Create query
- String sql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test2() {
- // Create query
- String sql = "SELECT COUNT(*) FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(6) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test3() {
- // Create query
- String sql = "SELECT COUNT(*), COUNT(e1), COUNT(distinct e1), COUNT(distinct e2), COUNT(distinct e3), COUNT(distinct e4) FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(6), new Integer(5), new Integer(3), new Integer(4), new Integer(2), new Integer(4) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** see also integer average defect 11682 */
- @Test public void test4() {
- // Create query
- String sql = "SELECT MIN(e2), MAX(e2), SUM(e2), AVG(e2), SUM(distinct e2), AVG(distinct e2) FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), new Integer(3), new Long(7), new Double(1.1666666666666667), new Long(6), new Double(1.5) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test5() {
- // Create query
- String sql = "SELECT MIN(e4), MAX(e4), SUM(e4), AVG(e4), SUM(distinct e4), AVG(distinct e4) FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Double(0.0), new Double(7.0), new Double(12.0), new Double(2.4), new Double(10.0), new Double(2.5) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test7() {
- // Create query
- String sql = "SELECT * FROM vm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test8() {
- // Create query
- String sql = "SELECT * FROM vm1.g2 order by 1, 2, 3"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test9() {
- // Create query
- String sql = "SELECT * FROM vm1.g4 order by e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "3" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void test10() {
- // Create query
- String sql = "SELECT e1 FROM vm1.g4 where e1 = 'a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testBooleanComparisonGT() {
- // Create query
- String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 > {b'false'}"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.TRUE }),
- Arrays.asList(new Object[] { Boolean.TRUE })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testBooleanComparisonGE() {
- // Create query
- String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 >= {b'false'}"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.TRUE }),
- Arrays.asList(new Object[] { Boolean.TRUE }),
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testBooleanComparisonLT() {
- // Create query
- String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 < {b'true'}"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testBooleanComparisonLE() {
- // Create query
- String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 <= {b'true'}"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.TRUE }),
- Arrays.asList(new Object[] { Boolean.TRUE }),
- Arrays.asList(new Object[] { Boolean.FALSE }),
- Arrays.asList(new Object[] { Boolean.FALSE })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testConcatOperator() {
- // Create query
- String sql = "SELECT pm1.g1.e1 || e2 AS x FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a3" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a0" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Duplicates defect #4841: SELECT e1 a, e1 b FROM pm1.g1 order by a */
- @Test public void testDefect4841_1() {
- // Create query
- String sql = "SELECT e1 a, e1 b FROM pm1.g1 order by a"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Duplicates defect #4841: SELECT e1 a, e1 b FROM pm1.g1 order by a, b desc */
- @Test public void testDefect4841_2() {
- // Create query
- String sql = "SELECT e1 a, e1 b FROM pm1.g1 order by a"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Duplicates defect #5292: SELECT DISTINCT e1, e1 a FROM pm1.g1 */
- @Test public void testDefect5292_1() {
- // Create query
- String sql = "SELECT DISTINCT e1, e1 a FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Duplicates defect #5292: SELECT DISTINCT e1, e1 a FROM pm1.g1 ORDER BY a */
- @Test public void testDefect5292_2() {
- // Create query
- String sql = "SELECT DISTINCT e1, e1 a FROM pm1.g1 ORDER BY a"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Duplicates defect #5004: SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx' */
- @Test public void testDefect5004() {
- // Create query
- String sql = "SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Test to ensure that multiple empty batches are handled by the grouping node as well
- */
- @Test public void testDefect5004a() {
- // Create query
- String sql = "SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- CommandContext context = createCommandContext();
- context.setProcessorBatchSize(2);
- context.setConnectorBatchSize(2);
- context.setMetadata(FakeMetadataFactory.example1Cached());
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
-
- // Run query
- helpProcess(plan, context, dataManager, expected);
- }
-
- /** SELECT COUNT(e2), MIN(e2), MAX(e2), SUM(e2), AVG(e2) FROM pm1.g1 WHERE e2=-999999 */
- @Test public void test13() {
- // Create query
- String sql = "SELECT COUNT(e2), MIN(e2), MAX(e2), SUM(e2), AVG(e2) FROM pm1.g1 WHERE e2=-999999"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] {new Integer(0), null, null, null, null})
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * This test uncovered a bug in the FakeDataManager; the element
- * symbol in the atomic query criteria has a canonical name
- * of "Y.e4", but the FakeDataManager sends a Map of ElementSymbols
- * having the unaliased names. The first symbol cannot be found
- * in the Map due to the implementation of Symbol.equals() being
- * based entirely on the canonical name, which causes a NPE.
- * (Alex says this wasn't previously a problem because aliased groups
- * did not previously get pushed down to the source.)
- */
- @Test public void testCriteriaAliasedGroup() {
- String sql = "select e1, e2 FROM pm2.g1 Y WHERE 2.0 = e4"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b", new Integer(0) }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT e1 FROM pm1.g1 WHERE 'abc' = 'xyz' */
- @Test public void testCriteriaComparesUnequalConstants() {
- // Create query
- String sql = "SELECT e1 FROM pm1.g1 WHERE 'abc' = 'xyz'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
- @Test public void testRightOuterJoin1() {
- // Create query
- String sql = "SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { null, "d" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, "e" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 LEFT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
- @Test public void testLeftOuterJoin1() {
- // Create query
- String sql = "SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 LEFT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 FULL OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
- @Test public void testFullOuterJoin1() throws Exception {
- // Create query
- String sql = "SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 FULL OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, "d" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, "e" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testFullOuterJoin2() throws Exception {
- // Create query
- String sql = "SELECT a.e4 c0, b.e4 c1 FROM pm1.g1 a FULL OUTER JOIN pm1.g1 b ON a.e4=b.e4 order by c0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { new Double(0), new Double(0) }),
- Arrays.asList(new Object[] { new Double(2), new Double(2) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testFullOuterJoin3() throws Exception {
- // Create query
- String sql = "SELECT a.e4 c0, b.e4 c1 FROM pm1.g1 b FULL OUTER JOIN (select e4, 1 x from pm1.g1 union all select e4, 2 from pm1.g1) a ON a.e4=b.e4 and a.x = 2 order by c0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { new Double(0), new Double(0) }),
- Arrays.asList(new Object[] { new Double(0), null }),
- Arrays.asList(new Object[] { new Double(2), new Double(2) }),
- Arrays.asList(new Object[] { new Double(2), null }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT x.e1, pm2.g1.e1 FROM (SELECT e1 FROM pm1.g1) AS x LEFT OUTER JOIN pm2.g1 ON x.e1=pm2.g1.e1 */
- @Test public void testLeftOuterJoinWithInlineView() {
- // Create query
- String sql = "SELECT x.e1, pm2.g1.e1 FROM (SELECT e1 FROM pm1.g1) AS x LEFT OUTER JOIN pm2.g1 ON x.e1=pm2.g1.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT * FROM vm1.g5 ORDER BY expr */
- @Test public void testDefect5273_1() {
- // Create query
- String sql = "SELECT expr FROM vm1.g5 ORDER BY expr"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT expr AS e FROM vm1.g5 ORDER BY e */
- @Test public void testDefect5273_2() {
- // Create query
- String sql = "SELECT expr AS e FROM vm1.g5 ORDER BY e"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT e2 AS e FROM vm1.g5 ORDER BY e */
- @Test public void testDefect5273_3() {
- // Create query
- String sql = "SELECT e2 AS e FROM vm1.g5 ORDER BY e"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(3) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT e AS f FROM vm1.g6 ORDER BY f */
- @Test public void testDefect5273_4() {
- // Create query
- String sql = "SELECT e AS f FROM vm1.g6 ORDER BY f"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT e AS f FROM vm1.g7 ORDER BY f */
- @Test public void testDefect5273_5() {
- // Create query
- String sql = "SELECT e AS f FROM vm1.g7 ORDER BY f"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a3" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c1" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT e AS f FROM vm1.g7 ORDER BY f */
- @Test public void testDefect5273_6() {
- // Create query
- String sql = "SELECT e AS f FROM vm1.g8 ORDER BY f"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testFalseCriteria1() {
- // Create query
- String sql = "SELECT 5 FROM pm1.g1 WHERE 0=1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testFalseCriteria2() {
- // Create query
- String sql = "SELECT count(*) FROM pm1.g1 WHERE 0=1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testTempGroup() {
- // Create query
- String sql = "SELECT e1 FROM tm1.g1 WHERE e1 = 'a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSubquery1() {
- // Create query
- String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSubquerySimple() {
- // Create query
- String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCritInSubquery() {
- // Create query
- String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1 WHERE e1 = 'a') AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCritAboveSubquery() {
- // Create query
- String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x WHERE e1 = 'a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSubqueryInJoinPredicate() {
- // Create query
- String sql = "SELECT x.e1 FROM (SELECT e1 FROM pm1.g1) AS x JOIN (SELECT e1 FROM pm1.g1) y ON x.e1=y.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSubqueryWithRenaming() {
- // Create query
- String sql = "SELECT x.a FROM (SELECT e1 AS a FROM pm1.g1) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNestedSubquery() {
- // Create query
- String sql = "SELECT x.a FROM (SELECT e1 AS a FROM (SELECT e1 FROM pm1.g1) AS y) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null }),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery IN clause criteria
- */
- @Test public void testSubqueryINClause() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery IN clause criteria with nulls
- * in sample data
- */
- @Test public void testSubqueryINClauseWithNulls() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e4 IN (SELECT e4 FROM pm2.g1)"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery IN clause criteria with nulls
- * in sample data
- */
- @Test public void testSubqueryINClauseWithNulls2() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e4 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a compound criteria of two subqueries in IN clauses
- */
- @Test public void testSubqueryINClauses() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1) AND e1 IN (SELECT e1 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a compound criteria of a subquery in IN clause and another type of
- * criteria
- */
- @Test public void testSubqueryINClauseMixedCriteria() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1) AND e1 IN ('b')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a compound criteria of a subquery in IN clause and another type of
- * criteria
- */
- @Test public void testSubqueryINClauseMixedCriteria2() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1) AND NOT (e1 = 'a')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests nesting of Subquery IN clause criteria
- */
- @Test public void testNestedSubqueryINClauses() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1 WHERE e1 IN (SELECT e1 FROM pm1.g1))"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSubqueryXML() {
- // Create query
- String sql = "SELECT * FROM (SELECT * FROM xmltest.doc1) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] {
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
- "<root><node1><node2><node3/></node2></node1></root>" //$NON-NLS-1$
- })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery EXISTS predicate criteria
- */
- @Test public void testSubqueryExistsPredicate() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE EXISTS (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery EXISTS predicate criteria
- * where the subquery returns no rows
- */
- @Test public void testSubqueryExistsPredicate2() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE EXISTS (SELECT e2 FROM pm2.g1 WHERE e1 = 'ZZTop')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicate() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 = ANY (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicate2() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 = SOME (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicate3() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 = ALL (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicate4() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 <= ALL (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicate5() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 < SOME (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicate5a() {
- String sql = "SELECT e1 FROM pm2.g1 WHERE e2 < SOME (SELECT e2 FROM pm1.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "e" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- * without predicate quantifier
- */
- @Test public void testSubqueryComparePredicate6() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 < (SELECT e2 FROM pm2.g1 WHERE e1 = 'e')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a single Subquery in compare predicate criteria
- */
- @Test public void testSubqueryComparePredicateNested() {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 < SOME (SELECT e2 FROM pm2.g1 WHERE EXISTS (SELECT e2 FROM pm2.g1))"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", new List[] { Arrays.asList(new Object[] { new Integer(0), "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Integer(1), "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "c" }), //$NON-NLS-1$
- });
-
- dataManager.addData("SELECT pm2.g1.e2 FROM pm2.g1", new List[] { //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- });
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a scalar subquery in the SELECT clause
- */
- @Test public void testSubqueryScalar() {
- String sql = "SELECT e1, (SELECT e2 FROM pm2.g1 WHERE e1 = 'b') FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a scalar subquery which returns no rows in the SELECT clause
- */
- @Test public void testSubqueryScalar2() {
- String sql = "SELECT e1, (SELECT e2 FROM pm2.g1 WHERE e1 = 'a') FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Tests a scalar subquery which returns more than one rows
- * causes the expected Exception
- */
- @Test public void testSubqueryScalarException() throws Exception {
- String sql = "SELECT e1, (SELECT e2 FROM pm2.g1) FROM pm1.g1"; //$NON-NLS-1$
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcessException(plan, dataManager);
- }
-
- @Test public void testSubqueryScalarInTransformation() {
- String sql = "select * from vm1.g25"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), new Double(0.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSubqueryScalarInTransformation2() {
- String sql = "select * from vm1.g25 where e5 = 0.0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), new Double(0.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery_CASE2022() {
- String sql = "select * from BQT2_V WHERE BQT2_V.IntKey < 50"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT1(dataManager);
- sampleDataBQT2(dataManager);
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- // Plan query
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
- @Test public void testCorrelatedSubquery1() {
- String sql = "Select e1, e2, e4 from pm1.g1 where e2 in (select e2 FROM pm2.g1 WHERE pm1.g1.e4 = pm2.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- /**
- * There is a bug when the second query in a UNION ALL has a correlated subquery, and both
- * the outer and inner query are selecting from the same virtual group, and aliasing them
- * differently to distinguish between them. The generated atomic query has screwed up
- * aliasing.
- */
- @Test public void testCorrelatedSubqueryCase3667() {
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- // Plan query
- String sql = "Select e1, e2, e4 from pm2.g1 where 1=2 " + //$NON-NLS-1$
- "UNION ALL Select e1, e2, e4 from vm1.g1 outg1 where outg1.e2 in (select ing1.e2 FROM vm1.g1 ing1 WHERE outg1.e4 = ing1.e4)";//$NON-NLS-1$
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "aString", new Integer(22), new Double(22.0) }), //$NON-NLS-1$
- };
-
- dataManager.addData("SELECT g_0.e1, g_0.e2, g_0.e4 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (SELECT g_1.e2 FROM pm1.g1 AS g_1 WHERE g_1.e4 = g_0.e4)", //$NON-NLS-1$
- expected);
-
- helpProcess(plan, dataManager, expected);
- }
-
- /** control query, this test passes */
- @Test public void testCorrelatedSubqueryCase3667a() {
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Plan query
- String sql = "Select e1, e2, e4 from vm1.g1 outg1 where outg1.e2 in (select ing1.e2 FROM vm1.g1 ing1 WHERE outg1.e4 = ing1.e4)";//$NON-NLS-1$
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "aString", new Integer(22), new Double(22.0) }), //$NON-NLS-1$
- };
-
- dataManager.addData("SELECT g_0.e1, g_0.e2, g_0.e4 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (SELECT g_1.e2 FROM pm1.g1 AS g_1 WHERE g_1.e4 = g_0.e4)", //$NON-NLS-1$
- expected);
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery2() {
- String sql = "Select e1, e2 from pm1.g1 where e2 in (select e2 FROM pm2.g1 WHERE pm1.g1.e4 = pm2.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testCorrelatedSubquery3() {
- String sql = "Select e1, (select e2 FROM pm2.g1 WHERE pm1.g1.e4 = pm2.g1.e4) from pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery3a() {
- String sql = "Select e1, (select e2 FROM pm2.g1 WHERE X.e4 = e4) from pm1.g1 X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery3b() {
- String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = e4) from pm1.g1 X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery3c() {
- String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from pm1.g1 X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery4() {
- String sql = "Select e1, e2 from pm1.g1 X where e2 in (select e2 FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery4a() {
- String sql = "Select e1, e2 from pm1.g1 X where e2 = some (select e2 FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery_defect9968() {
- String sql = "Select e1, e2 from pm1.g1 X where e2 in (select max(X.e2) FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery_defect9968a() {
- String sql = "Select e1, e2 from pm1.g1 X where e2 in (select ((X.e2)/2) as e FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery_defect9968b() {
- String sql = "Select e1, e2 from pm1.g1 X where e2 in (select (select e2 as e FROM pm2.g1 WHERE X.e4 = pm2.g1.e4) as e FROM pm2.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubquery_defect10021() {
- String sql = "Select e1, e2 from table1 X where e4 in (select max(Y.e4) FROM table1 Y WHERE X.e4 = Y.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(2) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Note the subquery has a multi-column result - conceptually this is
- * legal for the EXISTS predicate
- */
- @Test public void testCorrelatedSubquery5() {
- String sql = "Select * from pm1.g1 where exists (select * FROM pm2.g1 WHERE pm1.g1.e1 = e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Count the # of parent rows for which no child rows exist
- */
- @Test public void testCorrelatedSubquery6() {
- String sql = "Select count(*) from pm1.g1 where not (exists (select * FROM pm2.g1 WHERE pm1.g1.e1 = e1))"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { new Integer(2) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Select e2, e4, and the avg of e4 for each group of e1
- */
- @Test public void testCorrelatedSubquery7() {
- String sql = "select e2, e4, (select avg(e4) FROM pm1.g1 Y WHERE X.e1 = e1) from pm1.g1 X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) }),
- Arrays.asList(new Object[] { new Integer(1), new Double(1.0), null }),
- Arrays.asList(new Object[] { new Integer(3), new Double(7.0), new Double(3.6666666666666665) }),
- Arrays.asList(new Object[] { new Integer(1), null , null }),
- Arrays.asList(new Object[] { new Integer(2), new Double(0.0), new Double(0.0) }),
- Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Select e2, e4, and the avg of e4 for each group of e1
- */
- @Test public void testCorrelatedSubquery8() {
- String sql = "select X.e2, X.e4, (select avg(Y.e4) FROM pm1.g1 Y WHERE X.e1 = Y.e1) from pm1.g1 X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) }),
- Arrays.asList(new Object[] { new Integer(1), new Double(1.0), null }),
- Arrays.asList(new Object[] { new Integer(3), new Double(7.0), new Double(3.6666666666666665) }),
- Arrays.asList(new Object[] { new Integer(1), null , null }),
- Arrays.asList(new Object[] { new Integer(2), new Double(0.0), new Double(0.0) }),
- Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer1() {
- String sql = "Select e1, e2 from vm1.g1 X where e2 in (select e2 FROM vm1.g1 Y WHERE X.e4 = Y.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1) }),
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer2() {
- String sql = "Select e1, e2 from vm1.g2 where e2 in (select e2 FROM vm1.g1 WHERE vm1.g2.e4 = vm1.g1.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer3() {
- String sql = "Select e2 from vm1.g6 where e2 in (select e2 FROM vm1.g1 WHERE vm1.g6.e = e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer4() {
- String sql = "Select e2 from vm1.g7 where e2 in (select e2 FROM vm1.g1 WHERE vm1.g7.e = e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer5() {
- String sql = "Select e1 from vm1.g4 where not (e1 in (select e1 FROM vm1.g1 WHERE vm1.g4.e1 = e1)) order by e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "3" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer6() {
- String sql = "Select e2 from vm1.g1 X where e2 in (select X.e2 FROM vm1.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer6a() {
- String sql = "Select e2 from vm1.g1 where e2 in (select vm1.g1.e2 FROM vm1.g5)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer6b() {
- String sql = "Select e2 from vm1.g1 where e2 in (select vm1.g1.e2 FROM vm1.g2)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer6c() {
- String sql = "Select e2 from vm1.g7 where e2 in (select vm1.g7.e FROM vm1.g1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer6e() {
- String sql = "Select e2 from vm1.g1 where e2 in (select vm1.g1.e2 FROM vm1.g2a)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer7() {
- String sql = "Select e2 from vm1.g7 where e2 in (select vm1.g7.e FROM vm1.g1 WHERE vm1.g7.e = e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[0];
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation() {
- String sql = "Select * from vm1.g21"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation2() {
- String sql = "Select * from vm1.g20"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation3() {
- String sql = "Select * from vm1.g19 order by e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "3" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * User correlated subquery, and one of the virtual group transformations
- * also has a correlated subquery
- */
- @Test public void testCorrelatedSubqueryInTransformation4() {
- String sql = "Select * from vm1.g20 where exists (Select * from vm1.g19 where convert(vm1.g20.e2, string) = vm1.g19.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * User correlated subquery, and one of the virtual group transformations
- * also has a correlated subquery
- */
- @Test public void testCorrelatedSubqueryInTransformation5() {
- String sql = "Select * from vm1.g19 where exists (Select e2 from vm1.g20 where convert(e2, string) = vm1.g19.e1) order by e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "3" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation6() {
- String sql = "Select * from vm1.g21 where e2 = some (Select e2 from pm1.g1 where e1 = vm1.g21.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation7() {
- String sql = "Select * from vm1.g21 where exists (Select e2 from pm1.g2 where e4 = convert(vm1.g21.e2, double))"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation8() {
- String sql = "Select * from vm1.g21 where exists (Select e2 from pm1.g1 where e4 = convert(vm1.g21.e2, double))"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation9() {
- String sql = "Select * from vm1.g22"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
-
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation10() {
- String sql = "Select * from vm1.g23"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation11() {
- String sql = "Select * from vm1.g24"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
-// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }),
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation12() {
- String sql = "Select * from vm1.g24 X where exists (Select * from vm1.g24 Y where X.e2 = Y.e2)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
-// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }),
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation13() {
- String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g25 where pm1.g1.e4 = e5 and e4=0.0) as e5 from pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation14() {
- String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g26 where pm1.g1.e4 = e5 and e4=0.0) as e5 from pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation15() {
- String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g23 where vm1.g22.e4 = e5) as e5 from vm1.g22 where e1 = 'a'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Test selecting a virtual element (e5) which is defined by a scalar subquery in the virtual transformation */
- @Test public void testCorrelatedSubqueryInTransformation15a() {
- String sql = "Select e1, e2, e3, e4 from pm1.g1 where exists (select * from vm1.g26 where pm1.g1.e3 = e3)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueryInTransformation15b() {
- String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g23 where vm1.g22.e4 = e5) as e5 from vm1.g22 where e1 = 'a' and exists (select * from vm1.g23 where vm1.g22.e3 = e3)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Test selecting a virtual element (e5) which is defined by a scalar subquery in the virtual transformation */
- @Test public void testCorrelatedSubqueryInTransformation15c() {
- String sql = "Select e1, e2, e3, e4 from pm1.g1 where exists (select e1, e2, e3, e4, e5 as e from vm1.g26 where pm1.g1.e3 = e3)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** Test selecting a virtual element (e5) which is defined by a scalar subquery in the virtual transformation */
- @Test public void testCorrelatedSubqueryInTransformation15d() {
- String sql = "Select e1, e2, e3, e4 from pm1.g1 where exists (select e1, e2, e3, e4, ((e4 + e5)/(e4 + 1)) as e from vm1.g26 where pm1.g1.e3 = e3)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
-// Here is select * from vm1.g26
-// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }),
-// Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
-// Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }),
-// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }),
-// Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }),
-// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null })
-
-
- @Test public void testCorrelatedSubqueryInTransformation16() {
-// String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g23 where vm1.g22.e4 = e5) as e5 from vm1.g22 where e1 = 'a'"/* and exists (select * from vm1.g23 where vm1.g22.e3 = e3)"*/;
- String sql = "select * from vm1.g26 where e5 = 0.0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[]{
-// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }),
-// Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
-// Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }),
-// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }),
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
-// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCorrelatedSubqueriesNested() {
- String sql =
- "Select e1, e2, e4 from pm1.g1 where e2 < all (" + //$NON-NLS-1$
- "select e2 from pm1.g2 where pm1.g1.e1 = e1 and exists("+ //$NON-NLS-1$
- "select e2 from pm2.g1 where pm1.g2.e4 = pm2.g1.e4))"; //$NON-NLS-1$
- Command query = helpParse(sql);
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), new Double(2.0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(2), new Double(0.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(query, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** defect 15124 */
- @Test public void testCorrelatedSubqueryAndInlineView() {
- String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from (select * from pm1.g1) as X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** defect 15124 */
- @Test public void testCorrelatedSubqueryAndInlineView2() {
- String sql = "Select e1 from (select * from pm1.g1) as X WHERE e2 IN (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** defect 15124 */
- @Test public void testCorrelatedSubqueryAndInlineView3() {
- String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from (select * from pm1.g1 UNION ALL select * from pm1.g1) as X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** defect 15124 */
- @Test public void testCorrelatedSubqueryAndInlineView4() {
- String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from (select pm1.g1.e1, (select pm1.g1.e2 from pm1.g1 Z where pm1.g1.e1 = Z.e1), pm1.g1.e3, pm1.g1.e4 from pm1.g1) as X"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", null }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXMLUnion_defect8373() {
- // Create query
- String sql = "SELECT * FROM xmltest.doc5"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] {
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
- "<root><node1><node2>a</node2></node1><node1><node2/></node1><node1><node2>a</node2></node1><node1><node2>c</node2></node1><node1><node2>b</node2></node1><node1><node2>a</node2></node1><node1><node2>a</node2></node1><node1><node2/></node1><node1><node2>a</node2></node1><node1><node2>c</node2></node1><node1><node2>b</node2></node1><node1><node2>a</node2></node1></root>" //$NON-NLS-1$
- })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery1() {
- // Create query
- String sql = "EXEC pm1.sq1()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1) }),
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery2() {
- // Create query
- String sql = "EXEC pm1.sq2(\'a\')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery3() {
- // Create query
- String sql = "select x.e1 from (EXEC pm1.sq1()) as x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { null}),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery4() {
- // Create query
- String sql = "EXEC pm1.sq5('a')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery5() {
- // Create query
- String sql = "EXEC pm1.sp1()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, new Integer(1)}),
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery6() {
- // Create query
- String sql = "EXEC pm1.sqsp1()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { null}),
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testStoredQuery7() {
- // Create query
- String sql = "EXEC pm1.sq17()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] {
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
- "<root><node1><node2><node3/></node2></node1></root>" //$NON-NLS-1$
- })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- // implict type conversion of parameter
- @Test public void testStoredQuery8() {
- // Create query
- String sql = "EXEC pm1.sq5(5)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- // function for parameter
- @Test public void testStoredQuery9() {
- // Create query
- String sql = "EXEC pm1.sq5(concat('a', ''))"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** named parameters */
- @Test public void testStoredQuery10() {
- // Create query
- String sql = "EXEC pm1.sq3b(\"in\" = 'a', in3 = 'something')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testInsert() {
- // Create query
- String sql = "Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1)})
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData3(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA FULL OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20) */
- @Test public void testDefect7770_FullOuter() {
- // Create query
- String sql = "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA FULL OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6), new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(7), new Integer(7) }),
- Arrays.asList(new Object[] { new Integer(8), new Integer(8) }),
- Arrays.asList(new Object[] { new Integer(9), new Integer(9) }),
- Arrays.asList(new Object[] { new Integer(10), new Integer(10) }),
- Arrays.asList(new Object[] { new Integer(11), new Integer(11) }),
- Arrays.asList(new Object[] { new Integer(12), new Integer(12) }),
- Arrays.asList(new Object[] { new Integer(13), new Integer(13) }),
- Arrays.asList(new Object[] { new Integer(14), new Integer(14) }),
- Arrays.asList(new Object[] { new Integer(15), new Integer(15) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20) */
- @Test public void testDefect7770_RightOuter() {
- // Create query
- String sql = "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6), new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(7), new Integer(7) }),
- Arrays.asList(new Object[] { new Integer(8), new Integer(8) }),
- Arrays.asList(new Object[] { new Integer(9), new Integer(9) }),
- Arrays.asList(new Object[] { new Integer(10), new Integer(10) }),
- Arrays.asList(new Object[] { new Integer(11), new Integer(11) }),
- Arrays.asList(new Object[] { new Integer(12), new Integer(12) }),
- Arrays.asList(new Object[] { new Integer(13), new Integer(13) }),
- Arrays.asList(new Object[] { new Integer(14), new Integer(14) }),
- Arrays.asList(new Object[] { new Integer(15), new Integer(15) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20) */
- @Test public void testDefect7770_LeftOuter() {
- // Create query
- String sql = "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6), new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(7), new Integer(7) }),
- Arrays.asList(new Object[] { new Integer(8), new Integer(8) }),
- Arrays.asList(new Object[] { new Integer(9), new Integer(9) }),
- Arrays.asList(new Object[] { new Integer(10), new Integer(10) }),
- Arrays.asList(new Object[] { new Integer(11), new Integer(11) }),
- Arrays.asList(new Object[] { new Integer(12), new Integer(12) }),
- Arrays.asList(new Object[] { new Integer(13), new Integer(13) }),
- Arrays.asList(new Object[] { new Integer(14), new Integer(14) }),
- Arrays.asList(new Object[] { new Integer(15), new Integer(15) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testReorder1() {
- // Create query
- String sql = "SELECT e1 AS x, {b'false'}, e2+e4, e3 FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", Boolean.FALSE, new Double(2.0), Boolean.FALSE }), //$NON-NLS-1$
- Arrays.asList(new Object[] { null, Boolean.FALSE, new Double(2.0), Boolean.FALSE }),
- Arrays.asList(new Object[] { "a", Boolean.FALSE, new Double(10.0), Boolean.TRUE }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", Boolean.FALSE, null, Boolean.TRUE }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", Boolean.FALSE, new Double(2.0), Boolean.FALSE }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", Boolean.FALSE, new Double(2.0), Boolean.FALSE }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testTwoFullOuterJoins1() {
- // Create query
- String sql = "SELECT A.IntKey AS A_IntKey, B.IntKey AS B_IntKey, C.IntKey AS C_IntKey " + //$NON-NLS-1$
- "FROM (BQT1.SmallA AS A FULL OUTER JOIN BQT2.SmallA AS B ON A.IntKey = B.IntKey) FULL OUTER JOIN BQT3.SmallA AS C ON B.IntKey = C.IntKey " + //$NON-NLS-1$
- "WHERE (A.IntKey >= 0) AND (A.IntKey <= 15) " + //$NON-NLS-1$
- "AND (B.IntKey >= 5) AND (B.IntKey <= 20) " + //$NON-NLS-1$
- "AND (C.IntKey >= 10) AND (C.IntKey <= 30)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(10), new Integer(10), new Integer(10) }),
- Arrays.asList(new Object[] { new Integer(11), new Integer(11), new Integer(11) }),
- Arrays.asList(new Object[] { new Integer(12), new Integer(12), new Integer(12) }),
- Arrays.asList(new Object[] { new Integer(13), new Integer(13), new Integer(13) }),
- Arrays.asList(new Object[] { new Integer(14), new Integer(14), new Integer(14) }),
- Arrays.asList(new Object[] { new Integer(15), new Integer(15), new Integer(15) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSelectDistinctOnBQT() {
- // Create query
- String sql = "SELECT DISTINCT IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(4) }),
- Arrays.asList(new Object[] { new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(7) }),
- Arrays.asList(new Object[] { new Integer(8) }),
- Arrays.asList(new Object[] { new Integer(9) }),
- Arrays.asList(new Object[] { new Integer(10) }),
- Arrays.asList(new Object[] { new Integer(11) }),
- Arrays.asList(new Object[] { new Integer(12) }),
- Arrays.asList(new Object[] { new Integer(13) }),
- Arrays.asList(new Object[] { new Integer(14) }),
- Arrays.asList(new Object[] { new Integer(15) }),
- Arrays.asList(new Object[] { new Integer(16) }),
- Arrays.asList(new Object[] { new Integer(17) }),
- Arrays.asList(new Object[] { new Integer(18) }),
- Arrays.asList(new Object[] { new Integer(19) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSelectWithNoFrom() {
- // Create query
- String sql = "SELECT 5"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testBetween() {
- // Create query
- String sql = "SELECT * FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
- Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Test <code>QueryProcessor</code>'s ability to process a query containing
- * a <code>CASE</code> expression in which a <code>BETWEEN</code>
- * comparison is used in the queries <code>SELECT</code> statement.
- * <p>
- * For example:
- * <p>
- * SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
- */
- @Test public void testBetweenInCase() {
- // Create query
- final String sql = "SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(-1) }),
- Arrays.asList(new Object[] { new Integer(-1) }),
- Arrays.asList(new Object[] { new Integer(3) }),
- Arrays.asList(new Object[] { new Integer(-1) }),
- Arrays.asList(new Object[] { new Integer(-1) }),
- Arrays.asList(new Object[] { new Integer(-1) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Test <code>QueryProcessor</code>'s ability to process a query containing
- * an aggregate SUM with a <code>CASE</code> expression in which a
- * <code>BETWEEN</code> comparison is used in the queries <code>SELECT</code>
- * statement.
- * <p>
- * For example:
- * <p>
- * SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1
- */
- @Test public void testBetweenInCaseInSum() {
- // Create query
- final String sql = "SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(-2) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Test <code>QueryProcessor</code>'s ability to process a query containing
- * an aggregate SUM with a <code>CASE</code> expression in which a
- * <code>BETWEEN</code> comparison is used in the queries <code>SELECT</code>
- * statement and a GROUP BY is specified.
- * <p>
- * For example:
- * <p>
- * SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END)
- * FROM pm1.g1 GROUP BY e1 ORDER BY e1
- */
- @Test public void testBetweenInCaseInSumWithGroupBy() {
- // Create query
- final String sql = "SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1 GROUP BY e1 ORDER BY e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, new Long(-1) }),
- Arrays.asList(new Object[] { "a", new Long(1) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Long(-1) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c", new Long(-1) }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Test <code>QueryProcessor</code>'s ability to process a query containing
- * an aggregate COUNT with a <code>CASE</code> expression in which a
- * <code>BETWEEN</code> comparison is used in the queries <code>SELECT</code>
- * statement.
- * <p>
- * For example:
- * <p>
- * SELECT COUNT(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 END) FROM pm1.g1
- */
- @Test public void testBetweenInCaseInCount() {
- // Create query
- final String sql = "SELECT COUNT(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 END) FROM pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCase() {
- // Create query
- String sql = "SELECT e2, CASE e2 WHEN 1 THEN 2 ELSE 3 END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(3) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSelectNoFrom1() {
- // Create query
- String sql = "SELECT 1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSelectNoFrom2() {
- // Create query
- String sql = "SELECT 1, {b'true'}, 2.0 AS x, {d'2003-11-04'}"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), Boolean.TRUE, new Double(2.0), TimestampUtil.createDate(103, 10, 4) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCase1566() throws Exception {
- // Create query
- String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM bqt1.smalla) as y GROUP BY x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { java.sql.Date.valueOf("2002-01-01"), new Integer(2) }),
- Arrays.asList(new Object[] { java.sql.Date.valueOf("2002-01-02"), new Integer(3) }) };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT_case1566(dataManager);
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Parse query
- Command command = QueryParser.getQueryParser().parseCommand(sql);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.exampleBQTCached(), capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect10976(){
- String sql = "SELECT * FROM vm1.g28"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "A", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "B", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "C", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect10976_2(){
- String sql = "SELECT * FROM vm1.g29"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "A", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "B", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "C", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect10976_3(){
- String sql = "SELECT * FROM vm1.g30"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect10976_4(){
- String sql = "SELECT * FROM vm1.g31 order by x"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect10976_5(){
- String sql = "SELECT * FROM vm1.g32"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect11236_MergeJoinWithFunctions() {
- // Create query
- String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 = (pm2.g1.e2+1)"; //$NON-NLS-1$
- boolean pushDown = false;
- boolean dependent = false;
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3), new Integer(2) })
- };
-
- helpTestMergeJoinWithExpression(sql, pushDown, dependent, expected);
- }
-
- @Test public void testMergeJoinWithFunctionsPushDown() {
- // Create query
- String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 = (pm2.g1.e2+1)"; //$NON-NLS-1$
- boolean pushDown = true;
- boolean dependent = false;
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3), new Integer(2) })
- };
-
- helpTestMergeJoinWithExpression(sql, pushDown, dependent, expected);
- }
-
- @Test public void testMergeJoinWithFunctionsPushDownDependent() {
- // Create query
- String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 = (pm2.g1.e2+1) option makedep pm1.g1"; //$NON-NLS-1$
- boolean pushDown = true;
- boolean dependent = true;
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(3), new Integer(2) })
- };
-
- helpTestMergeJoinWithExpression(sql, pushDown, dependent, expected);
- }
-
-
- /**
- * @param sql
- * @param pushDown
- * @param expected
- */
- private void helpTestMergeJoinWithExpression(String sql,
- boolean pushDown,
- boolean dependent,
- List[] expected) {
- // Construct data manager with data
- ProcessorDataManager dataManager = null;
- if (!pushDown) {
- FakeDataManager fakeDataManager = new FakeDataManager();
- sampleData1(fakeDataManager);
- dataManager = fakeDataManager;
- } else {
- HardcodedDataManager hardCoded = new HardcodedDataManager();
- List[] results = new List[] {
- Arrays.asList(new Object[] {new Integer(0), new Integer(1)}),
- Arrays.asList(new Object[] {new Integer(0), new Integer(1)}),
- Arrays.asList(new Object[] {new Integer(1), new Integer(2)}),
- Arrays.asList(new Object[] {new Integer(1), new Integer(2)}),
- Arrays.asList(new Object[] {new Integer(2), new Integer(3)}),
- Arrays.asList(new Object[] {new Integer(3), new Integer(4)}),
- };
- hardCoded.addData("SELECT g_0.e2 AS c_0, (g_0.e2 + 1) AS c_1 FROM pm2.g1 AS g_0 ORDER BY c_1", results); //$NON-NLS-1$
- if (!dependent) {
- results = new List[] {
- Arrays.asList(new Object[] {new Integer(0),}),
- Arrays.asList(new Object[] {new Integer(0),}),
- Arrays.asList(new Object[] {new Integer(1),}),
- Arrays.asList(new Object[] {new Integer(1),}),
- Arrays.asList(new Object[] {new Integer(2),}),
- Arrays.asList(new Object[] {new Integer(3),}),
- };
- hardCoded.addData("SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", results); //$NON-NLS-1$
- } else {
- results = new List[] {
- Arrays.asList(new Object[] {new Integer(1),}),
- Arrays.asList(new Object[] {new Integer(2),}),
- Arrays.asList(new Object[] {new Integer(1),}),
- };
- hardCoded.addData("SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (1, 2)", results); //$NON-NLS-1$
- results = new List[] {
- Arrays.asList(new Object[] {new Integer(3),}),
- };
- hardCoded.addData("SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (3, 4)", results); //$NON-NLS-1$
- }
- dataManager = hardCoded;
- }
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, pushDown);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, pushDown);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(2));
- caps.setFunctionSupport("+", pushDown); //$NON-NLS-1$
- finder.addCapabilities("pm1", caps); //$NON-NLS-1$
- finder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, finder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCase2() {
- // Create query
- String sql = "SELECT e2, CASE e2 WHEN 1 THEN 2 END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(2), null })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCase3() {
- // Create query
- String sql = "SELECT e2, CASE e2 WHEN 1 THEN 2 ELSE null END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(2), null })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** nested scalar subquery */
- @Test public void testCase4() {
- // Create query
- String nestedExpression = "(SELECT e1 FROM pm1.g2 WHERE e2 = 3)"; //$NON-NLS-1$
- String sql = "SELECT e2, CASE e2 WHEN 1 THEN " + nestedExpression + " ELSE null END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$ //$NON-NLS-2$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(1), "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), null })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** nested correlated scalar subquery */
- @Test public void testCase5() {
- // Create query
- String nestedExpression = "(SELECT e2 FROM pm1.g2 WHERE pm1.g1.e2 = (e4 + 2))"; //$NON-NLS-1$
- String sql = "SELECT e2, CASE e2 WHEN " + nestedExpression + " THEN 1 ELSE null END FROM pm1.g1"; //$NON-NLS-1$ //$NON-NLS-2$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), null }),
- Arrays.asList(new Object[] { new Integer(1), null }),
- Arrays.asList(new Object[] { new Integer(3), null }),
- Arrays.asList(new Object[] { new Integer(1), null }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(0), null })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * NOTE: this test depends on the ProcessorPlan being executed
- * twice and reset in between, which currently is done in the
- * helpProcess method
- */
- @Test public void testDefect12135(){
- String sql = "SELECT pm1.g1.e1, pm1.g2.e1 FROM pm1.g1 LEFT OUTER JOIN pm1.g2 ON pm1.g1.e1=pm1.g2.e1"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect12081(){
- String sql = "SELECT DISTINCT vm1.g1.e1, upper(vm1.g1.e1) as Nuge, pm1.g1.e1, upper(pm1.g1.e1) as Nuge FROM vm1.g1, pm1.g1"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "A", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "a", "A", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "a", "A", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "c", "C" }) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect12081_2(){
- String sql = "SELECT DISTINCT vm1.g1b.e1, vm1.g1b.e1Upper, pm1.g1.e1, upper(pm1.g1.e1) as e1Upper FROM vm1.g1b, pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "A", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "a", "A", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "a", "A", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "c", "C" }) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect12081_3(){
- String sql = "SELECT DISTINCT vm1.g1b.e1, vm1.g1b.e1Upper, pm1.g1.e1, vm1.g1b.e1Upper FROM vm1.g1b, pm1.g1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "A", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "a", "A", "b", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "a", "A", "c", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "a", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "b", "B", "c", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "a", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "b", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { "c", "C", "c", "C" }) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Basically the same as above, but with a limit node between the dup removal and the project
- */
- @Test public void testDefect12081_4(){
- String sql = "SELECT DISTINCT e1, e1 FROM pm1.g1 where e1 = 'a' LIMIT 1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "a"}), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect12719(){
- String sql = "SELECT e1_, e2_, e2 FROM vm1.g34, pm1.g2 WHERE vm1.g34.e1_ = pm1.g2.e1 order by e1_, e2_"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0), new Integer(1) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0), new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0), new Integer(5) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0), new Integer(2) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), new Integer(0) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), new Integer(5) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1), new Integer(2) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", new Integer(3), new Integer(2) }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect13034() {
- String sql = "SELECT CONCAT('http://', CONCAT(CASE WHEN (HOST IS NULL) OR (HOST = '') THEN 'soap_host' ELSE HOST END, CASE WHEN (PORT IS NULL) OR (PORT = '') THEN '/metamatrix-soap/services/DataService' ELSE CONCAT(':', CONCAT(PORT, '/metamatrix-soap/services/DataService')) END)) AS location " + //$NON-NLS-1$
- "FROM (SELECT env('soap_host') AS HOST, env('soap_port') AS PORT) AS props"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "http://my.host.com:12345/metamatrix-soap/services/DataService" }), //$NON-NLS-1$
- };
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, new FakeDataManager(), expected);
-
- }
-
- /** see also integer average defect 11682 */
- @Test public void testIntAvgDefect11682() {
- // Create query
- String sql = "SELECT AVG(IntKey), AVG(IntNum), AVG(FloatNum), AVG(LongNum), AVG(DoubleNum), AVG(ByteNum), AVG(ShortValue), AVG(BigIntegerValue), AVG(BigDecimalValue) FROM BQT1.SmallA"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new BigDecimal("1.500000000"), new BigDecimal("1.500000000") }), //$NON-NLS-1$//$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT_defect11682(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonJoinCriteriaInFrom() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm2.g1 b ON a.e1=b.e1 AND b.e2 = 0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null, null }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonJoinCriteriaInWhere() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm2.g1 b ON a.e1=b.e1 WHERE b.e2 = 0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonJoinCriteriaInWhere2() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm1.g2 b ON a.e1=b.e1 WHERE (a.e2 + b.e2 = 1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "a", new Integer(1) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonJoinCriteriaInWhere3() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm1.g2 b ON a.e1=b.e1 WHERE (a.e2 = 0) OR (b.e2 = 0)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "a", new Integer(1) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonJoinCriteriaInFromNestedInVirtual() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN (SELECT c.e1, d.e2 FROM pm2.g1 c JOIN pm2.g1 d ON c.e1=d.e1 AND d.e2 >= 0) b ON a.e1=b.e1 AND b.e2 = 0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null, null }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonJoinCriteriaInFromUsingDependentJoin() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm2.g1 b ON a.e1=b.e1 AND b.e2 = 0"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null, null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", null, null }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect13700() {
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(10) }),
- };
-
- // Plan query
- ProcessorPlan plan = helpGetPlan("EXEC pm1.vsp36(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
-
- // Run query
- helpProcess(plan, new FakeDataManager(), expected);
-
- }
-
- @Test public void testDefect13920() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, false);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- Command command = helpParse("SELECT e5, e2, e3, e4 FROM vm1.g1c WHERE e5 >= {ts'2004-08-01 00:00:00.0'}"); //$NON-NLS-1$
- ProcessorPlan plan = helpGetPlan(command,
- FakeMetadataFactory.example1Cached(), capFinder);
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataStringTimestamps(dataManager);
-
- Calendar cal = Calendar.getInstance();
- cal.set(2004, Calendar.DECEMBER, 31, 0, 0, 0);
- cal.set(Calendar.MILLISECOND, 0);
- Timestamp t1 = new Timestamp(cal.getTime().getTime());
- cal.clear();
- cal.set(2004, Calendar.AUGUST, 1, 0, 0, 0);
- cal.set(Calendar.MILLISECOND, 0);
- Timestamp t2 = new Timestamp(cal.getTime().getTime());
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { t1, new Integer(1), Boolean.TRUE, null }),
- Arrays.asList(new Object[] { t2, new Integer(2), Boolean.FALSE, new Double(0.0) }),
- };
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- /** RLM Case 2077 */
- @Test public void testComplexJoinExpressionsUsingDependentJoin() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a, pm2.g1 b where rtrim(a.e1)=(b.e1 || b.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "bb ", "b", new Integer(0) }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2b(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
- caps.setFunctionSupport("rtrim", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
-
- Command command = helpParse(sql);
- CommandContext context = createCommandContext();
- context.setMetadata(metadata);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder,context);
-
- //Verify a dependent join (not merge join) was used
- assertTrue(plan instanceof RelationalPlan);
- RelationalPlan relationalPlan = (RelationalPlan)plan;
- RelationalNode project = relationalPlan.getRootNode();
- RelationalNode join = project.getChildren()[0];
- assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
-
- // Run query
- helpProcess(plan, context, dataManager, expected);
- }
-
- /** RLM Case 2077 */
- @Test public void testComplexJoinExpressionsUsingDependentJoinWithAccessPattern() {
- String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a, pm2.g1 b where rtrim(a.e1)=(b.e1 || b.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "bb ", "b", new Integer(0) }) //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2b(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
- caps.setFunctionSupport("rtrim", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm4.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
-
- Command command = helpParse(sql);
- CommandContext context = createCommandContext();
- context.setMetadata(metadata);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
-
- //Verify a dependent join (not merge join) was used
- assertTrue(plan instanceof RelationalPlan);
- RelationalPlan relationalPlan = (RelationalPlan)plan;
- RelationalNode project = relationalPlan.getRootNode();
- RelationalNode join = project.getChildren()[0];
- assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
-
- // Run query
- helpProcess(plan, context, dataManager, expected);
- }
-
- @Test public void testPushingCriteriaUnderJoinButNotToSource() {
- // Create query
- String sql = "SELECT A.IntKey AS A_IntKey, B.IntKey AS B_IntKey, C.IntKey AS C_IntKey " + //$NON-NLS-1$
- "FROM (BQT1.SmallA AS A FULL OUTER JOIN BQT2.SmallA AS B ON A.IntKey = B.IntKey) LEFT OUTER JOIN BQT3.SmallA AS C ON B.IntKey = C.IntKey " + //$NON-NLS-1$
- "WHERE (sin(A.IntKey) >= 0) " + //$NON-NLS-1$
- "AND (C.IntKey >= 10)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(13), new Integer(13), new Integer(13) }),
- Arrays.asList(new Object[] { new Integer(14), new Integer(14), new Integer(14) }),
- Arrays.asList(new Object[] { new Integer(15), new Integer(15), new Integer(15) }),
- Arrays.asList(new Object[] { new Integer(19), new Integer(19), new Integer(19) }),
- Arrays.asList(new Object[] { new Integer(20), new Integer(20), new Integer(20) }),
- Arrays.asList(new Object[] { new Integer(21), new Integer(21), new Integer(21) }),
- Arrays.asList(new Object[] { new Integer(26), new Integer(26), new Integer(26) }),
- Arrays.asList(new Object[] { new Integer(27), new Integer(27), new Integer(27) }),
- Arrays.asList(new Object[] { new Integer(28), new Integer(28), new Integer(28) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testPushdownLiteralInSelectUnderAggregate() {
- String sql = "SELECT COUNT(*) FROM (SELECT '' AS y, a.IntKey FROM BQT1.SmallA a union all select '', b.intkey from bqt1.smallb b) AS x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(30) })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testPushdownLiteralInSelectWithOrderBy() {
- String sql = "SELECT 1, concat('a', 'b' ) AS X FROM BQT1.SmallA where intkey = 0 " + //$NON-NLS-1$
- "UNION ALL " + //$NON-NLS-1$
- "select 2, 'Hello2' from BQT1.SmallA where intkey = 1 order by X desc"; //$NON-NLS-1$
-
-
- // Create expected results - would expect these to be:
- // 1, "ab"
- // 2, "Hello2"
- // but our fake tuple source is too dumb to return anything reasonable, so instead get:
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null, null }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQTSmall(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /** defect 15348*/
- @Test public void testPreparedStatementDefect15348(){
- String sql = "SELECT e1 from pm1.g1 where myrtrim(?)=e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
- FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
-
-
- Command command = helpParse(sql);
- CommandContext context = createCommandContext();
- context.setMetadata(metadata);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
-
- // Collect reference, set value
- Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
- VariableContext vc = new VariableContext();
- vc.setGlobalValue(ref.getContextSymbol(), "a "); //$NON-NLS-1$
- context.setVariableContext(vc);
- // Run query
- helpProcess(plan, context, dataManager, expected);
-
- }
-
- /** defect 15348*/
- @Test public void testPreparedStatementDefect15348b(){
- String sql = "SELECT e1 from pm4.g1 where myrtrim(concat(?, 'a '))=e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "aa" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
-
- FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
- FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
-
-
- Command command = helpParse(sql);
- CommandContext context = createCommandContext();
- context.setMetadata(metadata);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
-
- // Collect reference, set value
- Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
- VariableContext vc = new VariableContext();
- vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
- context.setVariableContext(vc);
-
- // Run query
- helpProcess(plan, context, dataManager, expected);
-
- }
-
- @Test public void testSourceDoesntSupportGroupAlias() {
- String sql = "SELECT a.IntKey, b.IntKey FROM BQT1.SmallA a, BQT1.SmallB b WHERE a.IntKey = 5 AND A.IntKey = b.IntKey"; //$NON-NLS-1$
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set atomicQueries = TestOptimizer.getAtomicQueries(plan);
- assertEquals("Expected one query to get pushed down", 1, atomicQueries.size()); //$NON-NLS-1$
- String atomicSql = atomicQueries.iterator().next().toString();
- String expectedSql = "SELECT BQT1.SmallA.IntKey, BQT1.SmallB.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) AND (BQT1.SmallA.IntKey = 5) AND (BQT1.SmallB.IntKey = 5)"; //$NON-NLS-1$
- assertEquals(expectedSql, atomicSql);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(5)}),
- };
-
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, expected);
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testSourceDoesntSupportGroupAliasOrCriteria() {
- String sql = "SELECT a.IntKey, b.IntKey FROM BQT1.SmallA a, BQT1.SmallB b WHERE a.StringKey = '5' AND A.IntKey = b.IntKey"; //$NON-NLS-1$
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set atomicQueries = TestOptimizer.getAtomicQueries(plan);
- assertEquals("Expected 2 queries to get pushed down", 2, atomicQueries.size()); //$NON-NLS-1$
-
- String expectedSql = "SELECT BQT1.SmallA.StringKey, BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
- String expectedSql2 = "SELECT BQT1.SmallB.IntKey FROM BQT1.SmallB"; //$NON-NLS-1$
- Set expectedQueries = new HashSet();
- expectedQueries.add(expectedSql);
- expectedQueries.add(expectedSql2);
- assertEquals(expectedQueries, atomicQueries);
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { "5", new Integer(5)}), //$NON-NLS-1$
- };
- List[] input2 = new List[] {Arrays.asList(new Object[] {new Integer(5)}),
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
- dataManager.addData(expectedSql2, input2);
-
- List[] expected = new List[] {Arrays.asList(new Object[] {new Integer(5), new Integer(5)}),
- };
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Same as testSourceDoesntSupportGroupAlias, but query is in an inline view and only
- * the first column is selected.
- *
- * @since 4.2
- */
- @Test public void testSourceDoesntSupportGroupAliasInVirtual() {
- String sql = "SELECT x FROM (SELECT a.IntKey as x, b.IntKey as y FROM BQT1.SmallA a, BQT1.SmallB b WHERE a.IntKey = 5 AND A.IntKey = b.IntKey) AS z, BQT2.SmallA WHERE y = IntKey"; //$NON-NLS-1$
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set atomicQueries = TestOptimizer.getAtomicQueries(plan);
- assertEquals("Expected 2 queries to get pushed down", 2, atomicQueries.size()); //$NON-NLS-1$
-
- String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) AND (BQT1.SmallA.IntKey = 5) AND (BQT1.SmallB.IntKey = 5)"; //$NON-NLS-1$
- String expectedSql2 = "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA WHERE BQT2.SmallA.IntKey = 5"; //$NON-NLS-1$
-
- Set expectedQueries = new HashSet();
- expectedQueries.add(expectedSql);
- expectedQueries.add(expectedSql2);
- assertEquals(expectedQueries, atomicQueries);
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(5)}),
- };
- List[] input2 = new List[] {
- Arrays.asList(new Object[] { new Integer(5)}),
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
- dataManager.addData(expectedSql2, input2);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5)}),
- };
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCaseInGroupBy() {
- String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set actualQueries = TestOptimizer.getAtomicQueries(plan);
- String expectedSql = "SELECT SUM(X_1.c_1), X_1.c_0 FROM (SELECT CASE WHEN BQT1.SmallA.IntKey >= 5000 THEN '5000 +' ELSE '0-999' END AS c_0, BQT1.SmallA.IntKey AS c_1 FROM BQT1.SmallA) AS v_0 GROUP BY X_1.c_0"; //$NON-NLS-1$
- assertEquals(1, actualQueries.size());
- assertEquals(expectedSql, actualQueries.iterator().next().toString());
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(10)}),
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(5), new Integer(10)}),
- };
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCaseInGroupByAndHavingCantPush() {
- String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "HAVING case when IntKey>=5000 then '5000 +' else '0-999' end = '5000 +'"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false); // Can't push GROUP BY
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set actualQueries = TestOptimizer.getAtomicQueries(plan);
- String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
- assertEquals(1, actualQueries.size());
- assertEquals(expectedSql, actualQueries.iterator().next().toString());
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { new Integer(2)}),
- Arrays.asList(new Object[] { new Integer(4)}),
- Arrays.asList(new Object[] { new Integer(10000)}),
- Arrays.asList(new Object[] { new Integer(10002)}),
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(20002), "5000 +"}), //$NON-NLS-1$
- };
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCaseInGroupByAndHavingCantPush2() {
- String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end || 'x' " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "HAVING length(case when IntKey>=5000 then '5000 +' else '0-999' end) > 5"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false); // Can't push GROUP BY
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set actualQueries = TestOptimizer.getAtomicQueries(plan);
- String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
- assertEquals(1, actualQueries.size());
- assertEquals(expectedSql, actualQueries.iterator().next().toString());
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { new Integer(2)}),
- Arrays.asList(new Object[] { new Integer(4)}),
- Arrays.asList(new Object[] { new Integer(10000)}),
- Arrays.asList(new Object[] { new Integer(10002)}),
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(20002), "5000 +x"}), //$NON-NLS-1$
- };
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testCaseInGroupByAndHavingCantPush3() {
- String sql = "SELECT s, c FROM (" + //$NON-NLS-1$
- "SELECT sum (IntKey) s, case when IntKey>=5000 then '5000 +' else '0-999' end || 'x' c " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- ") AS x WHERE length(c) > 5 AND s = 20002"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false); // Can't push GROUP BY
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set actualQueries = TestOptimizer.getAtomicQueries(plan);
- String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
- assertEquals(1, actualQueries.size());
- assertEquals(expectedSql, actualQueries.iterator().next().toString());
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { new Integer(2)}),
- Arrays.asList(new Object[] { new Integer(4)}),
- Arrays.asList(new Object[] { new Integer(10000)}),
- Arrays.asList(new Object[] { new Integer(10002)}),
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(20002), "5000 +x"}), //$NON-NLS-1$
- };
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testFunctionOfAggregateCantPush() {
- String sql = "SELECT StringKey || 'x', SUM(length(StringKey || 'x')) + 1 AS x FROM BQT1.SmallA GROUP BY StringKey || 'x' HAVING space(MAX(length((StringKey || 'x') || 'y'))) = ' '"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set actualQueries = TestOptimizer.getAtomicQueries(plan);
- String expectedSql = "SELECT BQT1.SmallA.StringKey FROM BQT1.SmallA"; //$NON-NLS-1$
- assertEquals(1, actualQueries.size());
- assertEquals(expectedSql, actualQueries.iterator().next().toString());
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { "0"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "10"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "11"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "100"}), //$NON-NLS-1$
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "0x", new Long(3)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "1x", new Long(3)}), //$NON-NLS-1$
- };
- helpProcess(plan, dataManager, expected);
- }
-
-
- @Test public void testCase2634() {
-
- String sql = "SELECT x, IntKey FROM (SELECT IntKey, 'a' AS x FROM BQT1.SmallA UNION ALL SELECT IntKey, 'b' AS x FROM BQT1.SmallB) as Z"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Set actualQueries = TestOptimizer.getAtomicQueries(plan);
- String expectedSql = "SELECT 'a' AS c_0, BQT1.SmallA.IntKey AS c_1 FROM BQT1.SmallA UNION ALL SELECT 'b' AS c_0, BQT1.SmallB.IntKey AS c_1 FROM BQT1.SmallB"; //$NON-NLS-1$
- assertEquals(1, actualQueries.size());
- assertEquals(expectedSql, actualQueries.iterator().next().toString());
-
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1)}), //$NON-NLS-1$
- };
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData(expectedSql, input1);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(1)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(0)}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", new Integer(1)}), //$NON-NLS-1$
- };
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testQueryWithoutFromWithOrderBy() {
-
- String sql = "select 'three' as x ORDER BY x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "three"} ), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testQueryWithoutFromWithOrderBy2() {
-
- String sql = "select concat('three', ' sixteen') as x ORDER BY x"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "three sixteen"} ), //$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testQueryWithoutFromWithOrderBy3() {
-
- String sql = "SELECT CONCAT('yy', 'z') as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
- "CONCAT('21', '12') AS EXPR ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "yyz", "2112"} ), //$NON-NLS-1$ //$NON-NLS-2$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testCase2507_3(){
-
- String sql = "SELECT CONCAT('yy', 'z') AS c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
- "CONCAT('21', '12') AS EXPR ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, capFinder,
- new String[0] ,
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- // TEST PROCESSING
-
- List[] expectedResults = new List[] {
- Arrays.asList(new Object[] { "yyz", "2112"}), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT1(dataManager);
-
- // Run query
- helpProcess(plan, dataManager, expectedResults);
-
- }
-
- @Test public void testMultiGroupJoinCriteria() {
-
- String sql = "SELECT X.NEWFIELD FROM " + //$NON-NLS-1$
- "(SELECT SMALLA.STRINGNUM, " + //$NON-NLS-1$
- "CASE WHEN SMALLA.STRINGNUM LIKE '1%' THEN SMALLA.INTKEY " + //$NON-NLS-1$
- "WHEN SMALLA.STRINGNUM LIKE '2%' THEN SMALLB.INTNUM " + //$NON-NLS-1$
- "WHEN SMALLA.STRINGNUM LIKE '3%' THEN MEDIUMA.INTKEY " + //$NON-NLS-1$
- "END AS NEWFIELD " + //$NON-NLS-1$
- "FROM BQT1.SMALLA, BQT1.SMALLB, BQT1.MEDIUMA " + //$NON-NLS-1$
- "WHERE SMALLA.INTKEY = SMALLB.INTKEY AND SMALLA.INTKEY = MEDIUMA.INTKEY) AS X " + //$NON-NLS-1$
- "WHERE X.NEWFIELD = -3"; //$NON-NLS-1$
-
- String expectedAtomic1 = "SELECT BQT1.SMALLB.INTKEY, BQT1.SMALLB.INTNUM FROM BQT1.SMALLB"; //$NON-NLS-1$
- String expectedAtomic2 = "SELECT BQT1.MEDIUMA.INTKEY FROM BQT1.MEDIUMA"; //$NON-NLS-1$
- String expectedAtomic3 = "SELECT BQT1.SMALLA.INTKEY, BQT1.SMALLA.STRINGNUM FROM BQT1.SMALLA"; //$NON-NLS-1$
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {expectedAtomic1, expectedAtomic2, expectedAtomic3} ,
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 2, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- // TEST PROCESSING
-
- List[] expectedResults = new List[] {
- Arrays.asList(new Object[] { new Integer(-3) }),
- };
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- List[] input1 = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(-4)}),
- Arrays.asList(new Object[] { new Integer(2), new Integer(-3)}),
- Arrays.asList(new Object[] { new Integer(3), new Integer(-2)}),
- };
- dataManager.addData(expectedAtomic1, input1);
- List[] input2 = new List[] {
- Arrays.asList(new Object[] { new Integer(1)}),
- Arrays.asList(new Object[] { new Integer(2)}),
- Arrays.asList(new Object[] { new Integer(3)}),
- };
- dataManager.addData(expectedAtomic2, input2);
- List[] input3 = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new String("1")}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), new String("2")}), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(3), new String("3")}), //$NON-NLS-1$
- };
- dataManager.addData(expectedAtomic3, input3);
-
- // Run query
- helpProcess(plan, dataManager, expectedResults);
-
- }
-
- /**
- * Cross-source join with group by on top but no aggregate functions - running some special cases
- * where there are no "aggregate groups" (the groups of the aggregate expressions) because there
- * are no aggregate expressions. In this case, need to switch the aggregate groups to be all the grouping
- * columns because they are all being "grouped on".
- *
- * @since 4.3
- */
- @Test public void testDefect18360(){
-
- String sql = "SELECT a.intkey, a.intnum FROM bqt1.smalla a join bqt2.mediumb b on a.stringkey = b.stringkey " + //$NON-NLS-1$
- "group by a.intkey, a.intnum"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- capFinder.addCapabilities("BQT1", new BasicSourceCapabilities()); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.exampleBQTCached(), capFinder);
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- List[] data1 = new List[] {
- Arrays.asList(new Object[] { "1", new Integer(1), new Integer(5) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2", new Integer(2), new Integer(6) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "3", new Integer(3), new Integer(7) }), //$NON-NLS-1$
- };
- dataManager.addData("SELECT bqt1.smalla.stringkey, bqt1.smalla.intkey, bqt1.smalla.intnum FROM bqt1.smalla", data1); //$NON-NLS-1$
-
- List[] data2 = new List[] {
- Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "3" }), //$NON-NLS-1$
- };
- dataManager.addData("SELECT bqt2.mediumb.stringkey FROM bqt2.mediumb", data2); //$NON-NLS-1$
-
- // Run query
- List[] expectedResults = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(6) }),
- Arrays.asList(new Object[] { new Integer(3), new Integer(7) }),
- };
- helpProcess(plan, dataManager, expectedResults);
-
- }
-
- @Test public void testDefect17407(){
- String sql = "select pm1.g1.e1 from pm1.g1, g7 MAKEDEP WHERE pm1.g1.e2=g7.e2 order by e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null}),
- Arrays.asList(new Object[] { null}),
- Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
- Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b"}),//$NON-NLS-1$
- Arrays.asList(new Object[] { "c"}),//$NON-NLS-1$
- Arrays.asList(new Object[] { "c"}),//$NON-NLS-1$
- };
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDecodeAsCriteria() {
- // Create query
- String sql = "SELECT x.foo, e2 FROM (select decodestring(e1, 'a,q,b,w') as foo, e2 from vm1.g1) as x where x.foo = 'w'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "w", new Integer(2) }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testInputParamInNestedExecParam() {
- // Create query
- String sql = "EXEC pm1.vsp48('a')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testVariableInExecParam() {
- // Create query
- String sql = "EXEC pm1.vsp49()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testVariableInNestedExecParam() {
- // Create query
- String sql = "EXEC pm1.vsp50()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testVariableInNestedExecParamInLoop() {
- // Create query
- String sql = "EXEC pm1.vsp51()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "bb" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testVariableInNestedExecParamInAssignment() {
- // Create query
- String sql = "EXEC pm1.vsp52()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testInputParamInNestedExecParamInLoop() {
- // Create query
- String sql = "EXEC pm1.vsp53('b')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "bb" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testInputParamInNestedExecParamInAssignment() {
- // Create query
- String sql = "EXEC pm1.vsp54('c')"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testBitwiseAggregateProc() {
- // Create query
- String sql = "EXEC virt.agg()"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(19) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(1), "b", new Integer(4) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "c", new Integer(3) }), //$NON-NLS-1$
- };
-
- // Plan query
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBitwise();
- ProcessorPlan plan = helpGetPlan(sql, metadata);
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBitwise(dataManager, metadata);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- private void sampleDataBitwise(FakeDataManager dataMgr, FakeMetadataFacade metadata) {
- try {
- // Group pm1.g1
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("phys.t"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(1) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "a", new Integer(16) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(1), "b", new Integer(4) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "c", new Integer(2) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "c", new Integer(1) }), //$NON-NLS-1$
- } );
-
- } catch(Throwable e) {
- e.printStackTrace();
- fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- @Test public void testFunctionGroupByInJoinCriteria() {
- // Create query
- String sql = "SELECT lower(vm1.g1.e1) from vm1.g1, vm1.g2a where vm1.g1.e1 = vm1.g2a.e1 group by lower(vm1.g1.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- private FakeMetadataFacade createProjectErrorMetadata() {
- FakeMetadataObject p1 = FakeMetadataFactory.createPhysicalModel("p1"); //$NON-NLS-1$
- FakeMetadataObject t1 = FakeMetadataFactory.createPhysicalGroup("p1.t", p1); //$NON-NLS-1$
- List e1 = FakeMetadataFactory.createElements(t1, new String[] {"a", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
- QueryNode n1 = new QueryNode("v1.t1", "SELECT convert(a, integer) as c, b FROM p1.t"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vt1 = FakeMetadataFactory.createVirtualGroup("v1.t1", v1, n1); //$NON-NLS-1$
- List vte1 = FakeMetadataFactory.createElements(vt1, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- QueryNode n2 = new QueryNode("v1.t2", "SELECT convert(a, integer) as c, b FROM p1.t"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vt2 = FakeMetadataFactory.createVirtualGroup("v1.t2", v1, n2); //$NON-NLS-1$
- List vte2 = FakeMetadataFactory.createElements(vt2, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- QueryNode n3 = new QueryNode("v1.u1", "SELECT c, b FROM v1.t1 UNION ALL SELECT c, b FROM v1.t1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vu1 = FakeMetadataFactory.createVirtualGroup("v1.u1", v1, n3); //$NON-NLS-1$
- List vtu1 = FakeMetadataFactory.createElements(vu1, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(p1);
- store.addObject(t1);
- store.addObjects(e1);
- store.addObject(v1);
- store.addObject(vt1);
- store.addObjects(vte1);
- store.addObject(vt2);
- store.addObjects(vte2);
- store.addObject(vu1);
- store.addObjects(vtu1);
- return new FakeMetadataFacade(store);
- }
-
- @Test public void testProjectionErrorOverUnionWithConvert() {
- // Create query
- FakeMetadataFacade metadata = createProjectErrorMetadata();
- String sql = "SELECT COUNT(*) FROM v1.u1"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("p1", caps); //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(2) }),
- };
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.a FROM p1.t AS g_0", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1) })});
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testUpdatesInLoop() {
- String sql = "update vm1.g39 set e2=3"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(3) } )});
- dataManager.addData("UPDATE pm1.g1 SET e2 = 3 WHERE pm1.g1.e2 = 3", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1) } )});
-
- // Create expected results
- List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1)})};
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testRand() {
- // Create query
- String sql = "SELECT RAND(E2) FROM pm1.g1 where pm1.g1.e2=3"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] {new Double(0.731057369148862)}),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /*
- * Prior to case 3994 testInsertTempTableCreation1 worked, but testInsertTempTableCreation did not.
- * Now they should both pass
- *
- */
- @Test public void testInsertTempTableCreation() {
- FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
- QueryNode n1 = new QueryNode("v1.vp", "CREATE VIRTUAL PROCEDURE BEGIN insert into #temp (var1) values (1); select #temp.var1 from #temp; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs = FakeMetadataFactory.createResultSet("rs", v1, new String[] { "var1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject paramRS = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs); //$NON-NLS-1$
- FakeMetadataObject vp = FakeMetadataFactory.createVirtualProcedure("v1.vp", v1, Arrays.asList(new Object[] {paramRS}), n1); //$NON-NLS-1$
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(v1);
- store.addObject(vp);
-
- ProcessorPlan plan = helpGetPlan("exec v1.vp()", new FakeMetadataFacade(store)); //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) })
- };
- helpProcess(plan, new FakeDataManager(), expected);
- }
-
- @Test public void testInsertTempTableCreation1() {
- FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
- QueryNode n1 = new QueryNode("v1.vp", "CREATE VIRTUAL PROCEDURE BEGIN insert into #temp (var1) values (1); select 2 as var1 into #temp; select #temp.var1 from #temp; END"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject rs = FakeMetadataFactory.createResultSet("rs", v1, new String[] { "var1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject paramRS = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs); //$NON-NLS-1$
- FakeMetadataObject vp = FakeMetadataFactory.createVirtualProcedure("v1.vp", v1, Arrays.asList(new Object[] {paramRS}), n1); //$NON-NLS-1$
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(v1);
- store.addObject(vp);
-
- ProcessorPlan plan = helpGetPlan("exec v1.vp()", new FakeMetadataFacade(store)); //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(2) })
- };
- helpProcess(plan, new FakeDataManager(), expected);
- }
-
- @Test public void testCase4531() {
- String sql = "select intkey, intnum from (select intnum as intkey, 1 as intnum from bqt1.smalla union all select intkey, intnum from bqt1.smalla union all select intkey, intnum from bqt2.smalla) x"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.exampleBQTCached(), capFinder);
-
- // Run query
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
- };
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT g_0.intkey, g_0.intnum FROM bqt2.smalla AS g_0", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) })});
- dataManager.addData("SELECT g_1.intnum AS c_0, 1 AS c_1 FROM bqt1.smalla AS g_1 UNION ALL SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM bqt1.smalla AS g_0", //$NON-NLS-1$
- new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
- Arrays.asList(new Object[] { new Integer(1), new Integer(1) })});
- helpProcess(plan, dataManager, expected);
- }
-
- private void sampleDataBQT2a(FakeDataManager dataMgr) throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- for(int groupIndex=0; groupIndex<groups.length; groupIndex++) {
- String groupName = groups[groupIndex];
-
- List[] tuples = new List[3];
- for(int row=0; row<tuples.length; row++) {
- tuples[row] = new ArrayList(17);
- tuples[row].add(new Integer(row)); //IntKey
- tuples[row].add(String.valueOf(row)); //StringKey
- tuples[row].add(new Integer(row)); //IntNum
- tuples[row].add(String.valueOf(row)); //StringNum
- for(int col=0; col<10; col++) { //FloatNum, LongNum, DoubleNum, ByteNum, DateValue, TimeValue, TimestampValue, BooleanValue, CharValue, ShortValue
- tuples[row].add(null);
- }
- tuples[row].add(new BigInteger(String.valueOf(row))); //BigIntegerValue
- tuples[row].add(new BigDecimal(row)); //BigDecimalValue
- tuples[row].add(null); //ObjectValue
- }
- dataMgr.registerTuples(metadata, groupName, tuples);
- }
- }
-
- @Test public void testDefect15355() throws Exception {
-
- String sql = "SELECT e1, e1 FROM pm1.g1 " //$NON-NLS-1$
- +"UNION ALL " //$NON-NLS-1$
- +"SELECT e1, (SELECT e1 FROM pm2.g1 WHERE pm2.g1.e2 = pm1.g2.e2) FROM pm1.g2"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "c", "c" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "a", "e" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d", null }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testDefect15355b() throws Exception {
-
- String sql = "SELECT StringKey, BigIntegerValue FROM BQT1.SmallA " //$NON-NLS-1$
- +"UNION ALL " //$NON-NLS-1$
- +"SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"; //$NON-NLS-1$
-
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "1", new BigInteger("1") }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "2", new BigInteger("2") }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "1", new BigInteger("1") }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "2", new BigInteger("2") }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355c() throws Exception {
-
- String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355d() throws Exception {
-
- String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355a WHERE StringKey = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355e() throws Exception {
-
- String sql = "SELECT BigIntegerValue, StringKey FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0"), "0" }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355f() throws Exception {
-
- String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355f2() throws Exception {
-
- String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE StringKey LIKE '%0' AND StringKey LIKE '0%'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355g() throws Exception {
-
- String sql = "SELECT BigIntegerValue AS a, BigIntegerValue AS b FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0"), new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355h() throws Exception {
-
- String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE BigIntegerValue = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testDefect15355i() throws Exception {
-
- String sql = "SELECT BigIntegerValue FROM VQT.Defect15355b WHERE BigIntegerValue = '0'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2a(dataManager);
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- /**
- * The inner most A.e1 was mistakenly getting transformed into pm1.g3.e1
- */
- @Test public void testInnerCorrelatedReference() throws Exception {
-
- String sql = "SELECT DISTINCT A.e1 FROM pm1.g3 AS A WHERE (A.e1 IN (SELECT A.e1 FROM pm1.g3))"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.addData("SELECT DISTINCT g_0.e1 FROM pm1.g3 AS g_0 WHERE g_0.e1 IN (SELECT g_0.e1 FROM pm1.g3 AS g_1)", expected); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- Command command = helpParse(sql);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- // Run query
- helpProcess(plan, dataManager, expected);
-
- }
-
- @Test public void testCase5413() {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Plan query
- String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) = e1";//$NON-NLS-1$
- QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
- Command command = TestProcessor.helpParse(sql);
- CommandContext context = createCommandContext();
- context.setMetadata(metadata);
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
-
- // Run query
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
- Map valueMap = new HashMap();
- valueMap.put(1, "b"); //$NON-NLS-1$ //$NON-NLS-2$
- dataManager.defineCodeTable("pm1.g1", "e2", "e1", valueMap); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- dataManager.setThrowBlocked(true);
-
- helpProcess(plan, context, dataManager, expected);
- }
-
- @Test public void testRaiseNullWithSelectInto() {
- String sql = "select pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 into pm1.g2 from pm1.g1 where (1=0)"; //$NON-NLS-1$
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 1, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0)}),
- };
-
- helpProcess(plan, new FakeDataManager(), expected);
-
- }
-
- /*
- * Test for Case6219
- */
- @Test public void testCase6219() {
- String sql = "SELECT e1 FROM pm1.g1, (SELECT 'ACT' AS StateCode,'A' AS StateAbbrv UNION ALL SELECT 'NSW' AS StateCode, 'N' AS StateAbbrv) AS StateNames_Abbrvs WHERE (pm1.g1.e1 = StateCode) AND ((StateNames_Abbrvs.StateAbbrv || pm1.g1.e1) = 'VVIC')"; //$NON-NLS-1$
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 0, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 3, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
-
- List[] expected = new List[] {
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
-
- }
-
- @Test public void testSortWithLimit() {
- String sql = "select e1 from (select pm1.g1.e1, pm1.g1.e2 from pm1.g1 order by pm1.g1.e1, pm1.g1.e2 limit 1) x"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { null}),
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testSortWithLimit1() {
- String sql = "select c from (select pm1.g1.e1 a, pm1.g1.e2 b, pm1.g1.e3 c from pm1.g1 order by b limit 1) x"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata);
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.FALSE}),
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- //note that the e1 column is not used in the source query
- assertEquals("SELECT pm1.g1.e3, pm1.g1.e2 FROM pm1.g1", (String)manager.getQueries().iterator().next()); //$NON-NLS-1$
- }
-
- @Test public void testSortWithLimit2() {
- String sql = "select a from (select max(e2) a from pm1.g1 group by e2 order by a limit 1) x where a = 0"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- /**
- * A more direct test of 1, where the nested order by is unrelated
- */
- @Test public void testSortWithLimit3() {
- String sql = "select c from (select pm1.g1.e3 c from pm1.g1 order by pm1.g1.e2 limit 1) x"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.FALSE }),
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testSortWithLimit4() {
- String sql = "select c from (select pm1.g1.e1 a, pm1.g1.e2 b, pm1.g1.e3 c from pm1.g1 order by b limit 1) x"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, false);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(caps));
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { Boolean.FALSE }),
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- assertEquals("SELECT g_0.e3 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_1", manager.getQueries().iterator().next()); //$NON-NLS-1$
- }
-
- @Test public void testCountWithHaving() {
- String sql = "select e1, count(*) from pm1.g1 group by e1 having count(*) > 1"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" , new Integer(3)}), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testLimitZero() {
- String sql = "select e1 from pm1.g1 limit 0"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- TestOptimizer.checkNodeTypes(plan, TestRuleRaiseNull.FULLY_NULL);
-
- List[] expected = new List[] {
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testLimitZero1() {
- String sql = "select distinct vm1.g1.e1, y.e1 from vm1.g1 left outer join (select 1 x, e1 from vm1.g2 limit 0) y on vm1.g1.e1 = y.e1 where vm1.g1.e1 = 'a'"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testLimitZero2() {
- String sql = "select vm1.g1.e1 from vm1.g1 union select e1 from pm1.g2 limit 0"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testLimitZero3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select e1 from pm1.g2 limit 0"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, capFinder);
-
- List[] expected = new List[] {
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testUnionWithTypeConversion() {
- String sql = "select pm1.g1.e1, pm1.g1.e2 from pm1.g1 where e1 = 'b' union select e2, e1 from pm1.g2 where e1 = 'b' order by e1, e2"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "2", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { "b", "2" }), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- /**
- * Tests non-deterministic evaluation in the select clause.
- *
- * The evaluation of the rand function is delayed until processing time (which actually has predictable
- * values since the test initializes the command context with the same seed)
- *
- * If this function were deterministic, it would be evaluated during rewrite to a single value.
- */
- @Test public void testNonDeterministicEvaluation() throws Exception {
- String sql = "select e1, convert(rand()*1000, integer) as x from pm1.g1 where e1 = 'a'"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(240) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(637) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(550) }), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- /**
- * here the rand function is deterministic and should yield a single value
- */
- @Test public void testDeterministicEvaluation() throws Exception {
- String sql = "select e1, convert(rand(0)*1000, integer) as x from pm1.g1 where e1 = 'a'"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a", new Integer(730) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(730) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "a", new Integer(730) }), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testEmptyAggregate() throws Exception {
- String sql = "select count(e1) from pm1.g1 where 1 = 0"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) })
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testNullAggregate() throws Exception {
- String sql = "select count(*), count(e1), sum(convert(e1, integer)) from pm1.g1 where e1 is null"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), new Integer(0), null })
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- /**
- * here the presence of a group by causes no rows to be returned
- */
- @Test public void testNullAggregate1() throws Exception {
- String sql = "select e1 from pm1.g1 where 1 = 0 group by e1"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testReferenceReplacementWithExpression() throws Exception {
- String sql = "select e1, e2 from (select e1, convert(e2, string) e2 from pm1.g1) x where exists (select e3 from pm1.g2 where x.e2 = e1)"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {};
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- /**
- * Here a merge join will be used since there is at least one equi join predicate.
- * TODO: this can be optimized further
- */
- @Test public void testCase6193_1() throws Exception {
- // Create query
- String sql = "select a.INTKEY, b.intkey from bqt1.smalla a LEFT OUTER JOIN bqt2.SMALLA b on a.intkey=b.intkey and a.intkey=5 where a.intkey <10 "; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT2", caps);
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), null }),
- Arrays.asList(new Object[] { new Integer(1), null }),
- Arrays.asList(new Object[] { new Integer(2), null }),
- Arrays.asList(new Object[] { new Integer(3), null }),
- Arrays.asList(new Object[] { new Integer(4), null }),
- Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
- Arrays.asList(new Object[] { new Integer(6), null }),
- Arrays.asList(new Object[] { new Integer(7), null }),
- Arrays.asList(new Object[] { new Integer(8), null }),
- Arrays.asList(new Object[] { new Integer(9), null })
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataBQT2(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {"SELECT b.intkey FROM bqt2.SMALLA AS b", "SELECT a.intkey FROM bqt1.smalla AS a"}, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Here a merge join will be used since there is at least one equi join predicate.
- */
- @Test public void testCase6193_2() throws Exception {
- // Create query
- String sql = "select a.e2, b.e2 from pm1.g1 a LEFT OUTER JOIN pm1.g2 b on a.e4=b.e4 and (a.e2+b.e2)=4 order by a.e2"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0), null }),
- Arrays.asList(new Object[] { new Integer(0), null }),
- Arrays.asList(new Object[] { new Integer(1), null }),
- Arrays.asList(new Object[] { new Integer(1), null }),
- Arrays.asList(new Object[] { new Integer(2), new Integer(2) }),
- Arrays.asList(new Object[] { new Integer(3), null }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT a.e4, a.e2 FROM pm1.g1 AS a", "SELECT b.e4, b.e2 FROM pm1.g2 AS b"}, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- });
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Here a merge join will be used since there is at least one equi join predicate.
- * The inner merge join is also a dependent join
- */
- @Test public void testCase6193_3() throws Exception {
- // Create query
- String sql = "select a.x, b.y from (select 4 x union select 1) a LEFT OUTER JOIN (select (a.e2 + b.e2) y from pm1.g1 a LEFT OUTER JOIN pm1.g2 b on a.e4=b.e4) b on (a.x = b.y)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(1), null }),
- Arrays.asList(new Object[] { new Integer(4), new Integer(4) }),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT a.e4, a.e2 FROM pm1.g1 AS a", "SELECT b.e4, b.e2 FROM pm1.g2 AS b"}, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 4, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
-
- TestOptimizer.checkDependentJoinCount(plan, 1);
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * A control test to ensure that y will still exist for sorting
- */
- @Test public void testOrderByWithDuplicateExpressions() throws Exception {
- String sql = "select e1 as x, e1 as y from pm1.g1 order by y ASC"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata);
-
- List[] expected = new List[] {
- Arrays.asList(null, null),
- Arrays.asList("a", "a"), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList("a", "a"), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList("a", "a"), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList("b", "b"), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList("c", "c"), //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- /**
- * This is a control test. It should work regardless of whether the reference is aliased
- * since accessnodes are now fully positional
- */
- @Test public void testPushdownNonAliasedSelectLiteral() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- Command command = helpParse("select ?, e1 from pm1.g1"); //$NON-NLS-1$
- ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
-
- Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
- VariableContext vc = new VariableContext();
- vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
- CommandContext context = createCommandContext();
- context.setVariableContext(vc);
-
- List[] expected = new List[] {
- Arrays.asList("a", "b"), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList("a", "c") //$NON-NLS-1$ //$NON-NLS-2$
- };
-
- HardcodedDataManager manager = new HardcodedDataManager();
- manager.addData("SELECT 'a', pm1.g1.e1 FROM pm1.g1", expected); //$NON-NLS-1$
-
- helpProcess(plan, context, manager, expected);
- }
-
- @Test public void testCase6486() {
- // Create query
- String sql = "select pm2.g1.e1 from pm1.g2, pm2.g1 where pm1.g2.e1=pm2.g1.e1 group by pm2.g1.e1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "d"}) //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonPushedOffset() throws Exception {
- String sql = "SELECT e1 FROM pm1.g1 LIMIT 1, 5"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c"}), //$NON-NLS-1$
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData2(dataManager);
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testNonCorrelatedSubQueryExecution() throws Exception {
- String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
- dataManager.setBlockOnce(true);
- dataManager.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", new List[] { //$NON-NLS-1$
- Arrays.asList(Integer.valueOf(1), "a"), //$NON-NLS-1$
- Arrays.asList(Integer.valueOf(2), "b") //$NON-NLS-1$
- });
- dataManager.addData("SELECT pm2.g1.e2 FROM pm2.g1", new List[] { //$NON-NLS-1$
- Arrays.asList(Integer.valueOf(2))
- });
-
- ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
- };
-
- doProcess(plan, dataManager, expected, createCommandContext());
-
- //we expect 2 queries, 1 for the outer and 1 for the subquery
- assertEquals(2, dataManager.getCommandHistory().size());
- }
-
- @Test public void testOrderByOutsideOfSelect() {
- // Create query
- String sql = "SELECT e1 FROM (select e1, e2 || e3 as e2 from pm1.g2) x order by e2"; //$NON-NLS-1$
-
- //a, a, null, c, b, a
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList("a"),
- Arrays.asList("a"),
- Arrays.asList(new String[] {null}),
- Arrays.asList("c"),
- Arrays.asList("b"),
- Arrays.asList("a"),
- };
-
- // Construct data manager with data
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
-
- // Run query
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testOrderByUnrelatedExpression() {
- String sql = "SELECT e1, e2 + 1 from pm1.g2 order by e3 || e2 limit 1"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("a", 1),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
-
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Test a query that uses ambiguous alias names in the top level query and
- * its sub-query and uses columns belonging to the alias as a parameter to a
- * function.
- * <p>
- * For example, <code>SELECT CONVERT(A.e2, biginteger) AS e2 FROM (SELECT
- * CONVERT(e2, long) AS e2 FROM pm1.g1 AS A) AS A</code>
- * <p>
- * The test is to ensure that A.e2 from the top level is not confused with
- * e2 in the second level.
- * <p>
- * Related Defects: JBEDSP-1137
- */
- @Test public void testAliasReuseInFunctionInSubQuery() throws Exception {
- // Create query
- String sql = "SELECT CONVERT(A.e2, biginteger) AS e2 FROM (" + //$NON-NLS-1$
- " SELECT CONVERT(e2, long) AS e2 FROM pm1.g1 AS A WHERE e1 = 'a'" + //$NON-NLS-1$
- ") AS A"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
-
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new BigInteger("3") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- sampleData1(manager);
- helpProcess(plan, manager, expected);
- }
-
- @Test public void testOrderByDescAll() {
- String sql = "SELECT distinct e1 from pm1.g2 order by e1 desc limit 1"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("c"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testImplicitAggregateWithInlineView() {
- String sql = "SELECT * FROM (SELECT b.count, enterprise_id FROM (SELECT COUNT(*), 2 AS enterprise_id FROM (SELECT 'A Name' AS Name, 1 AS enterprise_id) c ) b ) a WHERE enterprise_id = 1"; //$NON-NLS-1$
-
- List[] expected = new List[] {};
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- private static final boolean DEBUG = false;
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,139 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- */
-public class TestQueryProcessor extends TestCase {
-
- /**
- * Constructor for TestQueryProcessor.
- * @param name
- */
- public TestQueryProcessor(String name) {
- super(name);
- }
-
- public void helpTestProcessor(FakeProcessorPlan plan, long timeslice, List[] expectedResults) throws MetaMatrixCoreException {
- BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
- FakeDataManager dataManager = new FakeDataManager();
-
- CommandContext context = new CommandContext("pid", "group", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
- QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- BatchCollector collector = processor.createBatchCollector();
- TupleBuffer tsID = null;
- while(true) {
- try {
- tsID = collector.collectTuples();
- break;
- } catch(BlockedException e) {
- }
- }
-
- // Compare # of rows in actual and expected
- assertEquals("Did not get expected # of rows", expectedResults.length, tsID.getRowCount()); //$NON-NLS-1$
-
- // Compare actual with expected results
- TupleSource actual = tsID.createIndexedTupleSource();
- if(expectedResults.length > 0) {
- for(int i=0; i<expectedResults.length; i++) {
- List actRecord = actual.nextTuple();
- List expRecord = expectedResults[i];
- assertEquals("Did not match row at row index " + i, expRecord, actRecord); //$NON-NLS-1$
- }
- }
- tsID.remove();
- }
-
- public void testNoResults() throws Exception {
- List elements = new ArrayList();
- elements.add(new ElementSymbol("a")); //$NON-NLS-1$
- FakeProcessorPlan plan = new FakeProcessorPlan(elements, null);
- helpTestProcessor(plan, 1000, new List[0]);
- }
-
- public void testBlockNoResults() throws Exception {
- List elements = new ArrayList();
- elements.add(new ElementSymbol("a")); //$NON-NLS-1$
-
- List batches = new ArrayList();
- batches.add(BlockedException.INSTANCE);
- TupleBatch batch = new TupleBatch(1, new List[0]);
- batch.setTerminationFlag(true);
- batches.add(batch);
-
- FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
- helpTestProcessor(plan, 1000, new List[0]);
- }
-
- public void testProcessWithOccasionalBlocks() throws Exception {
- List elements = new ArrayList();
- elements.add(new ElementSymbol("a")); //$NON-NLS-1$
-
- HashSet blocked = new HashSet(Arrays.asList(new Integer[] { new Integer(0), new Integer(2), new Integer(7) }));
- int numBatches = 10;
- int batchRow = 1;
- int rowsPerBatch = 50;
- List[] expectedResults = new List[rowsPerBatch*(numBatches-blocked.size())];
- List batches = new ArrayList();
- for(int b=0; b<numBatches; b++) {
- if(blocked.contains(new Integer(b))) {
- batches.add(BlockedException.INSTANCE);
- } else {
- List[] rows = new List[rowsPerBatch];
- for(int i=0; i<rowsPerBatch; i++) {
- rows[i] = new ArrayList();
- rows[i].add(new Integer(batchRow));
- expectedResults[batchRow-1] = rows[i];
- batchRow++;
- }
-
- TupleBatch batch = new TupleBatch(batchRow-rows.length, rows);
- if(b == numBatches-1) {
- batch.setTerminationFlag(true);
- }
- batches.add(batch);
- }
- }
-
- FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
- helpTestProcessor(plan, 1000, expectedResults);
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestSQLXMLProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestSQLXMLProcessing.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestSQLXMLProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,174 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static com.metamatrix.query.processor.TestProcessor.*;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-@SuppressWarnings("nls")
-public class TestSQLXMLProcessing {
-
- @Test public void testXmlElementTextContent() throws Exception {
- String sql = "SELECT xmlelement(foo, '<bar>', convert('<bar1/>', xml))"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<foo><bar><bar1/></foo>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- /**
- * Repeat of the above test, but with a document declaration. Because of the way we do event filtering, we end
- * up with a slightly different, but equivalent answer.
- */
- @Test public void testXmlElementTextContent1() throws Exception {
- String sql = "SELECT xmlelement(foo, '<bar>', convert('<?xml version=\"1.0\" encoding=\"UTF-8\"?><bar1/>', xml))"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<foo><bar><bar1></bar1></foo>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXmlElement() {
- String sql = "SELECT xmlelement(e1, e2) from pm1.g1 order by e1, e2"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<e1>1</e1>"),
- Arrays.asList("<e1>0</e1>"),
- Arrays.asList("<e1>0</e1>"),
- Arrays.asList("<e1>3</e1>"),
- Arrays.asList("<e1>2</e1>"),
- Arrays.asList("<e1>1</e1>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXmlElementWithConcat() {
- String sql = "SELECT xmlelement(e1, e2, xmlconcat(xmlelement(x), xmlelement(y, e3))) from pm1.g1 order by e1, e2"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<e1>1<x></x><y>false</y></e1>"),
- Arrays.asList("<e1>0<x></x><y>false</y></e1>"),
- Arrays.asList("<e1>0<x></x><y>false</y></e1>"),
- Arrays.asList("<e1>3<x></x><y>true</y></e1>"),
- Arrays.asList("<e1>2<x></x><y>false</y></e1>"),
- Arrays.asList("<e1>1<x></x><y>true</y></e1>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXmlElementWithForest() {
- String sql = "SELECT xmlelement(x, xmlforest(e1, e2, '1' as val)) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<x><e2>1</e2><val>1</val></x>"), //note e1 is not present, because it's null
- Arrays.asList("<x><e1>a</e1><e2>0</e2><val>1</val></x>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXmlElementWithAttributes() {
- String sql = "SELECT xmlelement(x, xmlattributes(e1, e2, '1' as val)) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<x e2=\"1\" val=\"1\"></x>"), //note e1 is not present, because it's null
- Arrays.asList("<x e1=\"a\" e2=\"0\" val=\"1\"></x>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXmlElementWithPi() {
- String sql = "SELECT xmlelement(x, xmlpi(name e1, ' 1'))"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<x><?e1 1?></x>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
- @Test public void testXmlElementWithNamespaces() {
- String sql = "SELECT xmlelement(x, xmlnamespaces(no default, 'http://foo' as x, 'http://foo1' as y), xmlattributes(e1), e2) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
-
- List[] expected = new List[] {
- Arrays.asList("<x xmlns=\"\" xmlns:x=\"http://foo\" xmlns:y=\"http://foo1\">1</x>"), //note e1 is not present, because it's null
- Arrays.asList("<x xmlns=\"\" xmlns:x=\"http://foo\" xmlns:y=\"http://foo1\" e1=\"a\">0</x>"),
- };
-
- FakeDataManager dataManager = new FakeDataManager();
- sampleData1(dataManager);
-
- ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
-
- helpProcess(plan, dataManager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
-
-public class TestSecurityFunctions extends TestCase {
-
- /**
- * hasRole should be true without a service
- */
- public void testHasRoleWithoutService() throws Exception {
-
- String sql = "select pm1.g1.e2 from pm1.g1 where true = hasRole('data', pm1.g1.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Integer(0) }),
- };
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List[] { //$NON-NLS-1$
- Arrays.asList(new Object[] { "fooRole", new Integer(0) }), //$NON-NLS-1$
- });
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached());
-
- // Run query
- TestProcessor.helpProcess(plan, dataManager, expected);
- }
-
- public void testHasRoleWithService() throws Exception {
-
- String sql = "select pm1.g1.e2 from pm1.g1 where true = hasRole('data', pm1.g1.e1)"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] { };
-
- // Construct data manager with data
- HardcodedDataManager dataManager = new HardcodedDataManager();
-
- dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List[] { //$NON-NLS-1$
- Arrays.asList(new Object[] { "fooRole", new Integer(0) }), //$NON-NLS-1$
- });
-
- CommandContext context = new CommandContext();
- context.setSecurityFunctionEvaluator(new SecurityFunctionEvaluator() {
- public boolean hasRole(String roleType,
- String roleName) throws MetaMatrixComponentException {
- return false;
- }});
-
- Command command = TestProcessor.helpParse(sql);
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
-
- // Run query
- TestProcessor.helpProcess(plan, context, dataManager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestSetProcessing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestSetProcessing.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestSetProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,86 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestSetProcessing {
-
- @Test public void testExcept() throws Exception {
- String sql = "select e1, e2 from pm1.g2 except select e1, 1 from pm1.g2"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] {"SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] {"a", 0}), //$NON-NLS-1$
- Arrays.asList(new Object[] {"a", 3}), //$NON-NLS-1$
- Arrays.asList(new Object[] {"b", 2}), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- TestProcessor.sampleData1(manager);
- TestProcessor.helpProcess(plan, manager, expected);
- }
-
- @Test public void testIntersect() throws Exception {
- String sql = "select e1, e2 from pm1.g2 intersect select e1, 1 from pm1.g2"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] {"SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] {null, 1}),
- Arrays.asList(new Object[] {"c", 1}), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- TestProcessor.sampleData1(manager);
- TestProcessor.helpProcess(plan, manager, expected);
- }
-
- @Test public void testIntersectExcept() {
- String sql = "select e1, e2 from pm1.g2 except select e1, 1 from pm1.g2 intersect select 'a', e2 from pm1.g2"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1, 1 FROM pm1.g2 AS g_0", "SELECT g_0.e1, g_0.e2 FROM pm1.g2 AS g_0", "SELECT 'a', g_0.e2 FROM pm1.g2 AS g_0"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- List<?>[] expected = new List[] {
- Arrays.asList(new Object[] {null, 1}),
- Arrays.asList(new Object[] {"a", 0}), //$NON-NLS-1$
- Arrays.asList(new Object[] {"a", 3}), //$NON-NLS-1$
- Arrays.asList(new Object[] {"b", 2}), //$NON-NLS-1$
- Arrays.asList(new Object[] {"c", 1}), //$NON-NLS-1$
- };
-
- FakeDataManager manager = new FakeDataManager();
- TestProcessor.sampleData1(manager);
- TestProcessor.helpProcess(plan, manager, expected);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,93 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Before;
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestTempTables {
-
- private TempMetadataAdapter metadata;
- private TempTableDataManager dataManager;
-
- private void execute(String sql, List[] expectedResults) throws Exception {
- TestProcessor.doProcess(TestProcessor.helpGetPlan(sql, metadata), dataManager, expectedResults, TestProcessor.createCommandContext());
- }
-
- @Before public void setUp() throws MetaMatrixComponentException {
- TempTableStoreImpl tempStore = new TempTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), "1", null); //$NON-NLS-1$
- metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), tempStore.getMetadataStore());
- FakeDataManager fdm = new FakeDataManager();
- TestProcessor.sampleData1(fdm);
- dataManager = new TempTableDataManager(fdm, tempStore);
- }
-
- @Test public void testInsertWithQueryExpression() throws Exception {
- execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
- execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
- execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
- }
-
- @Test public void testOutofOrderInsert() throws Exception {
- execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
- execute("insert into x (e2, e1) values (1, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
- execute("select e1, e2 from x", new List[] {Arrays.asList("one", 1)}); //$NON-NLS-1$
- }
-
- @Test public void testUpdate() throws Exception {
- execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
- execute("insert into x (e2, e1) values (1, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
- execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
- execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
- execute("select e1 from x where e2 > 0 order by e1", new List[] { //$NON-NLS-1$
- Arrays.asList((String)null),
- Arrays.asList("2"), //$NON-NLS-1$
- Arrays.asList("3"), //$NON-NLS-1$
- Arrays.asList("c"), //$NON-NLS-1$
- Arrays.asList("one")}); //$NON-NLS-1$
- }
-
- @Test public void testDelete() throws Exception {
- execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
- execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
- execute("delete from x where ascii(e1) > e2", new List[] {Arrays.asList(5)}); //$NON-NLS-1$
- execute("select e1 from x order by e1", new List[] {Arrays.asList((String)null)}); //$NON-NLS-1$
- }
-
- @Test public void testDelete1() throws Exception {
- execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
- execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
- execute("delete from x", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
- execute("select e1 from x order by e1", new List[] {}); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,771 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.processor;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Properties;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.buffer.impl.MemoryStorageManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.unittest.TimestampUtil;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.validator.TestValidator;
-
-public class TestVirtualDepJoin {
-
- /**
- * @param usAcctsElem
- * @param is
- * @param is2
- * @param object
- * @param object2
- * @since 4.3
- */
- private static void setStats(List elementObjects,
- int[] ndvs,
- int[] nnvs,
- String[] mins,
- String[] maxs) {
-
- Iterator iter = elementObjects.iterator();
- for(int i=0; iter.hasNext(); i++) {
- FakeMetadataObject obj = (FakeMetadataObject) iter.next();
- if(ndvs != null) {
- obj.putProperty(FakeMetadataObject.Props.DISTINCT_VALUES, new Integer(ndvs[i]));
- }
- if(nnvs != null) {
- obj.putProperty(FakeMetadataObject.Props.NULL_VALUES, new Integer(nnvs[i]));
- }
- if(mins != null) {
- obj.putProperty(FakeMetadataObject.Props.MIN_VALUE, mins[i]);
- }
- if(maxs != null) {
- obj.putProperty(FakeMetadataObject.Props.MAX_VALUE, maxs[i]);
- }
-
- }
- }
-
- public static FakeMetadataFacade exampleVirtualDepJoin() {
- FakeMetadataObject us = FakeMetadataFactory.createPhysicalModel("US"); //$NON-NLS-1$
- us.putProperty(FakeMetadataObject.Props.MAX_SET_SIZE, new Integer(0));
- FakeMetadataObject usAccts = FakeMetadataFactory.createPhysicalGroup("US.Accounts", us); //$NON-NLS-1$
- usAccts.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1000000));
- List usAcctsElem = FakeMetadataFactory.createElements(usAccts,
- new String[] { "customer", "account", "txn", "txnid", "pennies" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER });
- setStats(usAcctsElem,
- new int[] { 1000, 1250, 4, 1000000, 800000}, // NDV per column
- new int[] { 0, 0, 0, 0, 0}, // NNV per column
- new String[] {"0", null, null, null, "-10"}, // min per column - use defaults //$NON-NLS-1$ //$NON-NLS-2$
- new String[] {"1000", null, null, null, "-5"} // max per column - use defaults //$NON-NLS-1$ //$NON-NLS-2$
- );
-
- FakeMetadataObject europe = FakeMetadataFactory.createPhysicalModel("Europe"); //$NON-NLS-1$
- europe.putProperty(FakeMetadataObject.Props.MAX_SET_SIZE, new Integer(0));
- FakeMetadataObject euAccts = FakeMetadataFactory.createPhysicalGroup("Europe.CustAccts", europe); //$NON-NLS-1$
- euAccts.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1000000));
- List euAcctsElem = FakeMetadataFactory.createElements(euAccts,
- new String[] { "id", "accid", "type", "amount" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.SHORT, DataTypeManager.DefaultDataTypes.BIG_DECIMAL });
- setStats(euAcctsElem,
- new int[] { 10000, 1000000, 4, 1000000, 750000}, // NDV per column
- new int[] { 0, 0, 0, 0, 0}, // NNV per column
- null, // min per column - use defaults
- null // max per column - use defaults
- );
-
- FakeMetadataObject cust = FakeMetadataFactory.createPhysicalModel("CustomerMaster"); //$NON-NLS-1$
- cust.putProperty(FakeMetadataObject.Props.MAX_SET_SIZE, new Integer(0));
- FakeMetadataObject customers = FakeMetadataFactory.createPhysicalGroup("CustomerMaster.Customers", cust); //$NON-NLS-1$
- customers.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1000));
- List customersElem = FakeMetadataFactory.createElements(customers,
- new String[] { "id", "first", "last", "birthday" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.DATE });
- setStats(customersElem,
- new int[] { 1000, 800, 800, 365}, // NDV per column
- new int[] { 0, 0, 0, 0}, // NNV per column
- null, // min per column - use defaults
- null // max per column - use defaults
- );
- FakeMetadataObject locations = FakeMetadataFactory.createPhysicalGroup("CustomerMaster.Locations", cust); //$NON-NLS-1$
- locations.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1200));
- List locationsElem = FakeMetadataFactory.createElements(locations,
- new String[] { "id", "location" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.STRING });
- setStats(locationsElem,
- new int[] { 1000, 2}, // NDV per column
- new int[] { 0, 0, 0, 0}, // NNV per column
- null, // min per column - use defaults
- null // max per column - use defaults
- );
-
- FakeMetadataObject vAccts = FakeMetadataFactory.createVirtualModel("Accounts"); //$NON-NLS-1$
- QueryNode accountsPlan = new QueryNode("Accounts.Accounts", //$NON-NLS-1$
- "SELECT customer as customer_id, convert(account, long) as account_id, convert(txnid, long) as transaction_id, case txn when 'DEP' then 1 when 'TFR' then 2 when 'WD' then 3 else -1 end as txn_type, (pennies + convert('0.00', bigdecimal)) / 100 as amount, 'US' as source FROM US.Accounts where txn != 'X'" + //$NON-NLS-1$
- "UNION ALL " + //$NON-NLS-1$
- "SELECT id, convert(accid / 10000, long), mod(accid, 10000), convert(type, integer), amount, 'EU' from Europe.CustAccts"); //$NON-NLS-1$
- FakeMetadataObject accounts = FakeMetadataFactory.createVirtualGroup("Accounts.Accounts", vAccts, accountsPlan); //$NON-NLS-1$
- List accountsElem = FakeMetadataFactory.createElements(accounts,
- new String[] { "customer_id", "account_id", "transaction_id", "txn_type", "amount", "source" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
- new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.DefaultDataTypes.STRING });
-
- FakeMetadataObject master = FakeMetadataFactory.createVirtualModel("Master"); //$NON-NLS-1$
- QueryNode masterPlan = new QueryNode("Master.Transactions", //$NON-NLS-1$
- "select id as CustomerID, First, Last, a.account_id as AccountID, transaction_id as TransactionID, txn_type AS TxnCode, Amount from CustomerMaster.Customers c, Accounts.Accounts a where c.id=a.customer_id"); //$NON-NLS-1$
- FakeMetadataObject transactions = FakeMetadataFactory.createVirtualGroup("Master.Transactions", master, masterPlan); //$NON-NLS-1$
- List transactionsElem = FakeMetadataFactory.createElements(transactions,
- new String[] { "CustomerID", "First", "Last", "AccountID", "TransactionID", "TxnCode", "Amount" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
- new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL });
-
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(us);
- store.addObject(usAccts);
- store.addObjects(usAcctsElem);
-
- store.addObject(europe);
- store.addObject(euAccts);
- store.addObjects(euAcctsElem);
-
- store.addObject(cust);
- store.addObject(customers);
- store.addObjects(customersElem);
- store.addObject(locations);
- store.addObjects(locationsElem);
-
- store.addObject(vAccts);
- store.addObject(accounts);
- store.addObjects(accountsElem);
-
- store.addObject(master);
- store.addObject(transactions);
- store.addObjects(transactionsElem);
-
- return new FakeMetadataFacade(store);
- }
-
- @Test public void testVirtualDepJoinNoValues() throws Exception {
- // Create query
- String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first=-9999 group by c.id, first, last"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
-
- // Plan query
- CommandContext context = TestProcessor.createCommandContext();
-
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- finder.addCapabilities("Europe", caps);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
-
- TestOptimizer.checkDependentJoinCount(plan, 1);
- // Run query
- TestProcessor.helpProcess(plan, context, dataManager, expected);
-
- // Second query *will not be run* as no values were passed and dependent side has always false criteria
- // So, the list should contain only the first query
- assertEquals(3, dataManager.getQueries().size());
- }
-
- public void helpTestVirtualDepJoinSourceSelection(boolean setPushdown) throws Exception {
- // Create query
- String sql = "select c.id as CustomerID, First, Last, a.account_id as AccountID, transaction_id as TransactionID, txn_type AS TxnCode, Amount, source from (CustomerMaster.Customers c join CustomerMaster.Locations l on c.id=l.id) join Accounts.Accounts a on c.id=a.customer_id and l.location=a.source where c.first='Miles' option makenotdep c, l"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20"), "EU" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00"), "EU" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
-
- // Plan query
- CommandContext context = TestProcessor.createCommandContext();
-
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, setPushdown);
- finder.addCapabilities("US", caps); //$NON-NLS-1$
- finder.addCapabilities("Europe", caps);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
-
- // Check plan contents
- int selectCount = !setPushdown ? 2 : 0;
- int accessCount = setPushdown ? 2 : 4;
- int depAccessCount = 4 - accessCount;
- TestOptimizer.checkNodeTypes(plan, new int[] {
- accessCount, // Access
- depAccessCount, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 3, // Project
- selectCount, // Select
- 0, // Sort
- 1 // UnionAll
- });
-
- // Run query
- TestProcessor.helpProcess(plan, context, dataManager, expected);
- }
-
- @Test public void testVirtualDepJoinSourceSelectionPushdown() throws Exception {
- helpTestVirtualDepJoinSourceSelection(true);
- }
-
- @Test public void testVirtualDepJoinSourceSelectionNoPushdown() throws Exception {
- helpTestVirtualDepJoinSourceSelection(false);
- }
-
- @Test public void testVirtualDepJoinPartialPushdown() throws Exception {
- // Create query
- String sql = "SELECT * from Master.Transactions where last = 'Davis'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
-
- // Plan query
- CommandContext context = TestProcessor.createCommandContext();
-
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
- BasicSourceCapabilities caps2 = TestOptimizer.getTypicalCapabilities();
- caps2.setCapabilitySupport(Capability.CRITERIA_IN, false);
- finder.addCapabilities("US", caps1); //$NON-NLS-1$
- finder.addCapabilities("Europe", caps2);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps1);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 3, // Project
- 1, // Select
- 0, // Sort
- 1 // UnionAll
- });
-
- TestOptimizer.checkDependentJoinCount(plan, 1);
- // Run query
- TestProcessor.helpProcess(plan, context, dataManager, expected);
- }
-
- @Test public void testVirtualDepJoinOverAggregates() throws Exception {
- // Create query
- String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "Miles", "Davis", new BigDecimal("1007.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
-
- // Plan query
- CommandContext context = TestProcessor.createCommandContext();
-
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- finder.addCapabilities("Europe", caps);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 3, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- TestOptimizer.checkDependentJoinCount(plan, 1);
- // Run query
- TestProcessor.helpProcess(plan, context, dataManager, expected);
-
- List<String> expectedQueries = new ArrayList<String>(6);
- for (int i = 0; i < 3; i++) {
- expectedQueries.add("SELECT DISTINCT g_0.id AS c_0, g_0.first AS c_1, g_0.last AS c_2 FROM CustomerMaster.Customers AS g_0 WHERE g_0.first = 'Miles' ORDER BY c_0"); //$NON-NLS-1$
- expectedQueries.add("SELECT DISTINCT g_0.id AS c_0, g_0.amount AS c_1 FROM Europe.CustAccts AS g_0 WHERE g_0.id = 100 ORDER BY c_0"); //$NON-NLS-1$
- }
-
- assertEquals(expectedQueries, dataManager.getQueries());
- }
-
- @Test public void testVirtualDepJoinSelects() throws Exception {
- helpTestVirtualDepJoin(false);
- }
-
- @Test public void testVirtualDepJoinPushdown() throws Exception {
- helpTestVirtualDepJoin(true);
- }
-
- @Test public void testVirtualDepMultipleDependentBatches() throws Exception {
- helpTestMultipleBatches(true);
- }
-
- @Test public void testVirtualDepMultipleDependentBatchesNonUnique() throws Exception {
- helpTestMultipleBatches(false);
- }
-
- private void helpTestMultipleBatches(boolean unique) throws Exception,
- MetaMatrixComponentException,
- MetaMatrixException,
- SQLException {
- // Create query
- String sql = "SELECT * from Master.Transactions where last = 'Davis' order by CustomerID, TransactionID"; //$NON-NLS-1$
-
- List expected = new LinkedList();
-
-
- // Create expected results
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- if (!unique) {
- expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(16000), new Long(207), new Integer(3), new BigDecimal("12.34") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(16000), new Long(299), new Integer(3), new BigDecimal("950.34") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(550), new Long(1004), new Integer(3), new BigDecimal("542.20") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(550), new Long(1005), new Integer(1), new BigDecimal("99.99") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(620), new Long(1006), new Integer(1), new BigDecimal("10000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(620), new Long(1007), new Integer(2), new BigDecimal("0.75") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(630), new Long(1008), new Integer(2), new BigDecimal("62.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
- overrideVirtualDepJoinData(dataManager, metadata, unique);
-
- // Plan query
- CommandContext context = TestProcessor.createCommandContext();
-
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
- finder.addCapabilities("US", caps); //$NON-NLS-1$
- finder.addCapabilities("Europe", caps);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
-
- // Run query
- BufferManager bufferMgr = createCustomBufferMgr(2);
- QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
- processor.setNonBlocking(true);
- BatchCollector collector = processor.createBatchCollector();
- TupleBuffer id = collector.collectTuples();
-
- TestProcessor.examineResults((List[])expected.toArray(new List[expected.size()]), bufferMgr, id);
- }
-
- private BufferManager createCustomBufferMgr(int batchSize) throws MetaMatrixComponentException {
- BufferManagerImpl bufferMgr = new BufferManagerImpl();
- bufferMgr.setConnectorBatchSize(batchSize);
- bufferMgr.setProcessorBatchSize(batchSize);
- bufferMgr.initialize();
-
- // Add unmanaged memory storage manager
- bufferMgr.setStorageManager(new MemoryStorageManager());
-
- return bufferMgr;
- }
-
- public void helpTestVirtualDepJoin(boolean pushCriteria) throws Exception {
- // Create query
- String sql = "SELECT * from Master.Transactions where last = 'Davis'"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
-
- // Plan query
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, pushCriteria);
- finder.addCapabilities("US", caps); //$NON-NLS-1$
- finder.addCapabilities("Europe", caps);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder);
-
- // Run query
- CommandContext context = TestProcessor.createCommandContext();
- TestProcessor.helpProcess(plan, context, dataManager, expected);
- }
-
- private void sampleDataVirtualDepJoin(FakeDataManager dataMgr, FakeMetadataFacade metadata) throws Exception {
- dataMgr.setBlockOnce();
- // Group US.Accounts
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("US.Accounts"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { new Long(100), new Integer(15000), "DEP", new Integer(123), new Integer(10000) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(100), new Integer(15000), "TFR", new Integer(127), new Integer(25000) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(100), new Integer(15000), "WD", new Integer(128), new Integer(100000) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(100), new Integer(15001), "DEP", new Integer(134), new Integer(1000) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(100), new Integer(15001), "DEP", new Integer(201), new Integer(1000) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), new Integer(16000), "WD", new Integer(207), new Integer(1234) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), new Integer(16000), "WD", new Integer(299), new Integer(95034) }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), new Integer(16000), "X", new Integer(301), new Integer(5000) }), //$NON-NLS-1$
- } );
-
- // Group Europe.CustAccts
- groupID = (FakeMetadataObject) metadata.getGroupID("Europe.CustAccts"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols,
-
- new List[] {
- Arrays.asList(new Object[] { new Long(100), new Long(5401002), new Short((short)1), new BigDecimal("7.20") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(100), new Long(5401003), new Short((short)2), new BigDecimal("1000.00") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), new Long(5501004), new Short((short)3), new BigDecimal("542.20") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), new Long(5501005), new Short((short)1), new BigDecimal("99.99") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(300), new Long(6201006), new Short((short)1), new BigDecimal("10000.00") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(300), new Long(6201007), new Short((short)2), new BigDecimal("0.75") }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(300), new Long(6301008), new Short((short)2), new BigDecimal("62.00") }), //$NON-NLS-1$
- } );
-
- // Group CustomerMaster.Customers
- groupID = (FakeMetadataObject) metadata.getGroupID("CustomerMaster.Customers"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- TimestampUtil ts = new TimestampUtil();
- dataMgr.registerTuples(groupID, elementSymbols,
- new List[] {
- Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", ts.createDate(1926, 4, 25) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Long(200), "John", "Coltrane", ts.createDate(1926, 8, 23) }), //$NON-NLS-1$ //$NON-NLS-2$
- Arrays.asList(new Object[] { new Long(300), "Thelonious", "Monk", ts.createDate(1917, 9, 10) }), //$NON-NLS-1$ //$NON-NLS-2$
- } );
-
- // Group CustomerMaster.Locations
- groupID = (FakeMetadataObject) metadata.getGroupID("CustomerMaster.Locations"); //$NON-NLS-1$
- elementIDs = metadata.getElementIDsInGroupID(groupID);
- elementSymbols = FakeDataStore.createElements(elementIDs);
-
- dataMgr.registerTuples(groupID, elementSymbols,
- new List[] {
- Arrays.asList(new Object[] { new Long(100), "US" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(100), "EU" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), "US" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(200), "EU" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Long(300), "EU" }), //$NON-NLS-1$
- } );
- }
-
- private void overrideVirtualDepJoinData(FakeDataManager dataMgr, FakeMetadataFacade metadata, boolean unique) throws Exception {
- // Group CustomerMaster.Customers
- FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("CustomerMaster.Customers"); //$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(groupID);
- List elementSymbols = FakeDataStore.createElements(elementIDs);
-
- TimestampUtil ts = new TimestampUtil();
-
- List data = new LinkedList();
-
- data.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", ts.createDate(1926, 4, 25) })); //$NON-NLS-1$ //$NON-NLS-2$
- if (!unique) {
- data.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", ts.createDate(1926, 4, 25) })); //$NON-NLS-1$ //$NON-NLS-2$
- }
- data.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", ts.createDate(1926, 4, 26) })); //$NON-NLS-1$ //$NON-NLS-2$
- data.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", ts.createDate(1926, 4, 27) })); //$NON-NLS-1$ //$NON-NLS-2$
- data.add(Arrays.asList(new Object[] { new Long(400), "CloneC", "Davis", ts.createDate(1926, 4, 28) })); //$NON-NLS-1$ //$NON-NLS-2$
-
- dataMgr.registerTuples(
- groupID,
- elementSymbols, (List[])data.toArray(new List[data.size()]));
- }
-
- @Test public void testVirtualAccessVirtualDep() throws Exception {
- String sql = "SELECT a.e0, b.e2 FROM vTest.vGroup a inner join vTest.vGroup b on (a.e0 = b.e2 and a.e1 = b.e2) where b.e0=1 and b.e1='2'"; //$NON-NLS-1$
-
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("test", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, finder,
- new String[] {"SELECT g_0.e2 AS c_0 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2') ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e0 AS c_0, g_0.e1 AS c_1, g_0.e0 AS c_2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 IN (<dependent values>)) AND (g_0.e1 IN (<dependent values>)) ORDER BY c_2, c_1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Here the virtual makenotdep hint causes us to throw an exception
- *
- */
- @Test public void testVirtualAccessVirtualDep2() {
- String sql = "SELECT a.e0, b.e2 FROM vTest.vGroup a makenotdep inner join vTest.vGroup b on (a.e0 = b.e2 and a.e1 = b.e2) where b.e0=1 and b.e1='2'"; //$NON-NLS-1$
-
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- finder.addCapabilities("test", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, finder,
- new String[] {}, TestOptimizer.SHOULD_FAIL);
-
- }
-
- /**
- * same as testVirtualDepJoinOverAggregate, but the makenotdep hint prevents the
- * dependent join from happening
- */
- @Test public void testVirtualDepJoinOverAggregates2() throws Exception {
- // Create query
- String sql = "select first, last, sum(amount) from Europe.CustAccts e makenotdep join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "Miles", "Davis", new BigDecimal("1007.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = exampleVirtualDepJoin();
- FakeDataManager dataManager = new FakeDataManager();
- sampleDataVirtualDepJoin(dataManager, metadata);
-
- // Plan query
- CommandContext context = TestProcessor.createCommandContext();
-
- Command command = TestProcessor.helpParse(sql);
- FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- finder.addCapabilities("Europe", caps);//$NON-NLS-1$
- finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
- ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 3, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- TestOptimizer.checkDependentJoinCount(plan, 0);
- // Run query
- TestProcessor.helpProcess(plan, context, dataManager, expected);
- }
-
-
- @Test public void testVirtualMakeDepHint() throws Exception {
- // Create query
- String sql = "select distinct pm1.g1.e1 from (pm1.g1 inner join pm1.g2 on g1.e1 = g2.e1) makedep inner join pm2.g1 on pm2.g1.e1 = pm1.g1.e1 where pm2.g1.e3 = 1"; //$NON-NLS-1$
-
- // Create expected results
- List[] expected = new List[] {
- Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
- };
-
- // Construct data manager with data
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
- FakeDataManager dataManager = new FakeDataManager();
- TestProcessor.sampleData1(dataManager);
-
- // Plan query
- ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 2, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- TestOptimizer.checkDependentJoinCount(plan, 1);
- // Run query
- TestProcessor.helpProcess(plan, new CommandContext(), dataManager, expected);
- }
-
-
-}
Copied: trunk/engine/src/test/java/org/teiid/cache (from rev 2112, trunk/engine/src/test/java/com/metamatrix/cache)
Modified: trunk/engine/src/test/java/org/teiid/cache/FakeCache.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/cache/FakeCache.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/cache/FakeCache.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.cache;
+package org.teiid.cache;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,6 +29,11 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.cache.Cache;
+import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.CacheFactory;
+import org.teiid.cache.CacheListener;
+
public class FakeCache<K, V> implements Cache<K, V> {
public static class FakeCacheFactory implements CacheFactory{
Copied: trunk/engine/src/test/java/org/teiid/cdk (from rev 2112, trunk/engine/src/test/java/com/metamatrix/cdk)
Modified: trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/cdk/CommandBuilder.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/cdk/CommandBuilder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,26 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.cdk;
+package org.teiid.cdk;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.teiid.connector.language.LanguageFactory;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.AliasGenerator;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.AllSymbol;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.AliasGenerator;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.AllSymbol;
/**
* Convert a query string into a SQL language parse tree.
@@ -74,8 +74,8 @@
command.acceptVisitor(new AliasGenerator(supportsGroupAlias));
}
return new LanguageBridgeFactory(metadata).translate(command);
- } catch (MetaMatrixException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch (TeiidException e) {
+ throw new TeiidRuntimeException(e);
}
}
Copied: trunk/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/BufferManagerFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,73 @@
+/*
+ * 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.common.buffer;
+
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.common.buffer.impl.MemoryStorageManager;
+import org.teiid.core.TeiidComponentException;
+
+
+/**
+ * <p>Factory for BufferManager instances. One method will get
+ * a server buffer manager, as it should be instantiated in a running
+ * MetaMatrix server. That BufferManager is configured mostly by the
+ * passed in properties.</p>
+ *
+ * <p>The other method returns a stand-alone, in-memory buffer manager. This
+ * is typically used for either in-memory testing or any time the
+ * query processor component is not expected to run out of memory, such as
+ * within the modeler.</p>
+ */
+public class BufferManagerFactory {
+
+ private static BufferManager INSTANCE;
+
+ /**
+ * Helper to get a buffer manager all set up for unmanaged standalone use. This is
+ * typically used for testing or when memory is not an issue.
+ * @return BufferManager ready for use
+ */
+ public static BufferManager getStandaloneBufferManager() {
+ if (INSTANCE == null) {
+ BufferManagerImpl bufferMgr = createBufferManager();
+ INSTANCE = bufferMgr;
+ }
+
+ return INSTANCE;
+ }
+
+ public static BufferManagerImpl createBufferManager() {
+ BufferManagerImpl bufferMgr = new BufferManagerImpl();
+ try {
+ bufferMgr.initialize();
+ } catch (TeiidComponentException e) {
+ throw new RuntimeException(e);
+ }
+
+ // Add unmanaged memory storage manager
+ bufferMgr.setStorageManager(new MemoryStorageManager());
+ return bufferMgr;
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBatch.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBatch.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBatch.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBatch.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,58 @@
+/*
+ * 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.common.buffer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.common.buffer.TupleBatch;
+
+import junit.framework.TestCase;
+
+
+public class TestTupleBatch extends TestCase {
+
+ public TestTupleBatch(String name) {
+ super(name);
+ }
+
+ public TupleBatch exampleBatch(int rowBegin, int numRows, int numColumns) {
+ List rows = new ArrayList();
+ for(int i=0; i<numRows; i++) {
+ List row = new ArrayList();
+ for(int j=0; j<numColumns; j++) {
+ row.add("data-" + (rowBegin + i) + "-" + j); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ rows.add(row);
+ }
+ return new TupleBatch(rowBegin, rows);
+ }
+
+ /*
+ * Test for void TupleBatch(int, List)
+ */
+ public void testTupleBatch() {
+ exampleBatch(0, 10, 2);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,88 @@
+/*
+ * 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.common.buffer;
+
+import static org.junit.Assert.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.common.buffer.BatchManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+
+public class TestTupleBuffer {
+
+ @Test public void testForwardOnly() throws Exception {
+ ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
+ x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ List<ElementSymbol> schema = Arrays.asList(x);
+ TupleBuffer tb = new TupleBuffer(new BatchManager() {
+
+ @Override
+ public void remove() {
+
+ }
+
+ @Override
+ public ManagedBatch createManagedBatch(final TupleBatch batch)
+ throws TeiidComponentException {
+ return new ManagedBatch() {
+
+ @Override
+ public void remove() {
+
+ }
+
+ @Override
+ public TupleBatch getBatch(boolean cache, String[] types)
+ throws TeiidComponentException {
+ return batch;
+ }
+ };
+ }
+ }, "x", schema, 32); //$NON-NLS-1$
+ tb.setForwardOnly(true);
+ tb.addTuple(Arrays.asList(1));
+ TupleBatch batch = tb.getBatch(1);
+ assertTrue(!batch.getTerminationFlag());
+ assertEquals(1, batch.getBeginRow());
+ try {
+ tb.getBatch(1);
+ fail("expected exception"); //$NON-NLS-1$
+ } catch (AssertionError e) {
+
+ }
+ tb.addTuple(Arrays.asList(1));
+ tb.close();
+ batch = tb.getBatch(2);
+ assertTrue(batch.getTerminationFlag());
+ assertEquals(2, batch.getBeginRow());
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/common/buffer/TestTupleBuffer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/common/buffer/impl (from rev 2112, trunk/engine/src/test/java/com/metamatrix/common/buffer/impl)
Modified: trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/TestFileStorageManager.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/common/buffer/impl/TestFileStorageManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.buffer.impl;
+package org.teiid.common.buffer.impl;
import static org.junit.Assert.*;
@@ -31,15 +31,16 @@
import java.util.Random;
import org.junit.Test;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.common.buffer.impl.FileStorageManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestFileStorageManager {
- public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws MetaMatrixComponentException {
+ public FileStorageManager getStorageManager(Integer maxFileSize, Integer openFiles, String dir) throws TeiidComponentException {
FileStorageManager sm = new FileStorageManager();
sm.setStorageDirectory(UnitTestUtil.getTestScratchPath() + (dir != null ? File.separator + dir : "")); //$NON-NLS-1$
if (maxFileSize != null) {
@@ -84,7 +85,7 @@
static Random r = new Random();
private void writeBytes(FileStore store)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
byte[] bytes = new byte[2048];
r.nextBytes(bytes);
long start = store.write(bytes, 0, bytes.length);
Copied: trunk/engine/src/test/java/org/teiid/common/log (from rev 2112, trunk/engine/src/test/java/com/metamatrix/common/log)
Copied: trunk/engine/src/test/java/org/teiid/common/queue (from rev 2112, trunk/engine/src/test/java/com/metamatrix/common/queue)
Modified: trunk/engine/src/test/java/org/teiid/common/queue/FakeWorkItem.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkItem.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/common/queue/FakeWorkItem.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.queue;
+package org.teiid.common.queue;
import java.sql.Timestamp;
Modified: trunk/engine/src/test/java/org/teiid/common/queue/FakeWorkManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/FakeWorkManager.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/common/queue/FakeWorkManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,4 +1,4 @@
-package com.metamatrix.common.queue;
+package org.teiid.common.queue;
import javax.resource.spi.work.ExecutionContext;
import javax.resource.spi.work.Work;
Modified: trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/queue/TestStatsCapturingWorkManager.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/common/queue/TestStatsCapturingWorkManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.queue;
+package org.teiid.common.queue;
import static org.junit.Assert.*;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/cache/TestDQPContextCache.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -23,10 +23,10 @@
import junit.framework.TestCase;
+import org.teiid.cache.Cache;
+import org.teiid.cache.FakeCache.FakeCacheFactory;
import org.teiid.dqp.internal.process.DQPWorkContext;
-import com.metamatrix.cache.Cache;
-import com.metamatrix.cache.FakeCache.FakeCacheFactory;
public class TestDQPContextCache extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/FakeTransactionService.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,10 +25,10 @@
import javax.resource.spi.XATerminator;
import javax.transaction.TransactionManager;
+import org.teiid.common.queue.FakeWorkManager;
+import org.teiid.core.util.SimpleMock;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.core.util.SimpleMock;
public class FakeTransactionService extends TransactionServerImpl {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,13 +29,13 @@
import junit.framework.TestCase;
import org.mockito.Mockito;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.dqp.internal.process.AbstractWorkItem;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
import org.teiid.resource.cci.ExecutionFactory;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
/**
* JUnit test for TestConnectorStateManager
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestConnectorWorkItem.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -38,20 +38,20 @@
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.process.AbstractWorkItem;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.resource.ConnectorException;
import org.teiid.resource.cci.ProcedureExecution;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestConnectorWorkItem {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/impl/TestExecutionContextImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,9 +22,9 @@
package org.teiid.dqp.internal.datamgr.impl;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.impl.ExecutionContextImpl;
-import com.metamatrix.core.util.UnitTestUtil;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestAggregateImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,10 +27,10 @@
import org.teiid.connector.language.AggregateFunction;
import org.teiid.connector.language.Literal;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
public class TestAggregateImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestBatchedUpdatesImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,10 +29,10 @@
import org.teiid.connector.language.Delete;
import org.teiid.connector.language.Insert;
import org.teiid.connector.language.Update;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompareCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,9 +27,9 @@
import org.teiid.connector.language.Comparison;
import org.teiid.connector.language.Literal;
import org.teiid.connector.language.Comparison.Operator;
+import org.teiid.query.sql.lang.AbstractCompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
public class TestCompareCriteriaImpl extends TestCase {
@@ -41,10 +41,10 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.CompareCriteria helpExample(int operator, int leftVal, int rightVal) {
+ public static org.teiid.query.sql.lang.CompareCriteria helpExample(int operator, int leftVal, int rightVal) {
Constant left = new Constant(new Integer(leftVal));
Constant right = new Constant(new Integer(rightVal));
- return new com.metamatrix.query.sql.lang.CompareCriteria(left, operator, right);
+ return new org.teiid.query.sql.lang.CompareCriteria(left, operator, right);
}
public static Comparison example(int operator, int leftVal, int rightVal) throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestCompoundCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,8 +27,8 @@
import org.teiid.connector.language.AndOr;
import org.teiid.connector.language.Comparison;
import org.teiid.connector.language.AndOr.Operator;
+import org.teiid.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
public class TestCompoundCriteriaImpl extends TestCase {
@@ -40,10 +40,10 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.CompoundCriteria helpExample(int operator) {
+ public static org.teiid.query.sql.lang.CompoundCriteria helpExample(int operator) {
CompareCriteria c1 = TestCompareCriteriaImpl.helpExample(CompareCriteria.GE, 100, 200);
CompareCriteria c2 = TestCompareCriteriaImpl.helpExample(CompareCriteria.LT, 500, 600);
- return new com.metamatrix.query.sql.lang.CompoundCriteria(operator, c1, c2);
+ return new org.teiid.query.sql.lang.CompoundCriteria(operator, c1, c2);
}
public static AndOr example(int operator) throws Exception {
@@ -51,12 +51,12 @@
}
public void testGetOperator() throws Exception {
- assertEquals(Operator.AND, example(com.metamatrix.query.sql.lang.CompoundCriteria.AND).getOperator());
- assertEquals(Operator.OR, example(com.metamatrix.query.sql.lang.CompoundCriteria.OR).getOperator());
+ assertEquals(Operator.AND, example(org.teiid.query.sql.lang.CompoundCriteria.AND).getOperator());
+ assertEquals(Operator.OR, example(org.teiid.query.sql.lang.CompoundCriteria.OR).getOperator());
}
public void testGetCriteria() throws Exception {
- AndOr cc = example(com.metamatrix.query.sql.lang.CompoundCriteria.AND);
+ AndOr cc = example(org.teiid.query.sql.lang.CompoundCriteria.AND);
assertTrue(cc.getLeftCondition() instanceof Comparison);
assertTrue(cc.getRightCondition() instanceof Comparison);
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestDeleteImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,8 +26,8 @@
import junit.framework.TestCase;
import org.teiid.connector.language.Delete;
+import org.teiid.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
public class TestDeleteImpl extends TestCase {
@@ -39,8 +39,8 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.Delete helpExample() {
- return new com.metamatrix.query.sql.lang.Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
+ public static org.teiid.query.sql.lang.Delete helpExample() {
+ return new org.teiid.query.sql.lang.Delete(TestGroupImpl.helpExample("vm1.g1"), //$NON-NLS-1$
TestCompoundCriteriaImpl.helpExample(CompoundCriteria.AND));
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestElementImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,9 +26,9 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.NamedTable;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataObject;
public class TestElementImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestExistsCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,8 +24,8 @@
import org.teiid.connector.language.Exists;
+import org.teiid.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestFunctionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,8 +28,8 @@
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.Function;
+import org.teiid.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Constant;
public class TestFunctionImpl extends TestCase {
@@ -41,10 +41,10 @@
super(name);
}
- public static com.metamatrix.query.sql.symbol.Function helpExample(String name) {
+ public static org.teiid.query.sql.symbol.Function helpExample(String name) {
Constant c1 = new Constant(new Integer(100));
Constant c2 = new Constant(new Integer(200));
- com.metamatrix.query.sql.symbol.Function f = new com.metamatrix.query.sql.symbol.Function(name, new com.metamatrix.query.sql.symbol.Expression[] {c1, c2});
+ org.teiid.query.sql.symbol.Function f = new org.teiid.query.sql.symbol.Function(name, new org.teiid.query.sql.symbol.Expression[] {c1, c2});
f.setType(Integer.class);
return f;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupByImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,10 +30,10 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.GroupBy;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
public class TestGroupByImpl extends TestCase {
@@ -45,16 +45,16 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.GroupBy helpExample() {
+ public static org.teiid.query.sql.lang.GroupBy helpExample() {
List<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
- return new com.metamatrix.query.sql.lang.GroupBy(symbols);
+ return new org.teiid.query.sql.lang.GroupBy(symbols);
}
- public static com.metamatrix.query.sql.lang.GroupBy helpExampleWithFunctions() {
+ public static org.teiid.query.sql.lang.GroupBy helpExampleWithFunctions() {
List<Expression> symbols = new ArrayList<Expression>();
ElementSymbol e1 = TestElementImpl.helpExample("vm1.g1", "e1");//$NON-NLS-1$ //$NON-NLS-2$
@@ -62,7 +62,7 @@
symbols.add(e1);
symbols.add(f);
- return new com.metamatrix.query.sql.lang.GroupBy(symbols);
+ return new org.teiid.query.sql.lang.GroupBy(symbols);
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestGroupImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,11 +24,11 @@
import org.teiid.connector.language.NamedTable;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataObject;
import junit.framework.TestCase;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataObject;
public class TestGroupImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,8 +29,8 @@
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.Literal;
import org.teiid.connector.language.In;
+import org.teiid.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetCriteria;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInlineViewImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,8 +24,8 @@
import org.teiid.connector.language.DerivedTable;
+import org.teiid.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestInsertImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,10 +31,10 @@
import org.teiid.connector.language.Expression;
import org.teiid.connector.language.ExpressionValueSource;
import org.teiid.connector.language.Insert;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestInsertImpl extends TestCase {
@@ -46,7 +46,7 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.Insert helpExample(String groupName) {
+ public static org.teiid.query.sql.lang.Insert helpExample(String groupName) {
GroupSymbol group = TestGroupImpl.helpExample(groupName);
ArrayList<ElementSymbol> elements = new ArrayList<ElementSymbol>();
elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
@@ -60,12 +60,12 @@
values.add(TestLiteralImpl.helpExample(3));
values.add(TestLiteralImpl.helpExample(4));
- return new com.metamatrix.query.sql.lang.Insert(group,
+ return new org.teiid.query.sql.lang.Insert(group,
elements,
values);
}
- public static com.metamatrix.query.sql.lang.Insert helpExample2(String groupName) {
+ public static org.teiid.query.sql.lang.Insert helpExample2(String groupName) {
GroupSymbol group = TestGroupImpl.helpExample(groupName);
ArrayList elements = new ArrayList();
elements.add(TestElementImpl.helpExample(groupName, "e1")); //$NON-NLS-1$
@@ -73,7 +73,7 @@
ArrayList values = new ArrayList();
values.add(TestSearchedCaseExpressionImpl.helpExample());
- return new com.metamatrix.query.sql.lang.Insert(group,
+ return new org.teiid.query.sql.lang.Insert(group,
elements,
values);
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestIsNullCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,8 +24,8 @@
import org.teiid.connector.language.IsNull;
+import org.teiid.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestJoinImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,12 +28,12 @@
import org.teiid.connector.language.Comparison;
import org.teiid.connector.language.Join;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
public class TestJoinImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLikeCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,10 +24,10 @@
import org.teiid.connector.language.Literal;
import org.teiid.connector.language.Like;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestLiteralImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,8 +24,8 @@
import org.teiid.connector.language.Literal;
+import org.teiid.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Constant;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestNotCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,9 +24,9 @@
import org.teiid.connector.language.Not;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestOrderByImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -41,7 +41,7 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.OrderBy helpExample() {
+ public static org.teiid.query.sql.lang.OrderBy helpExample() {
ArrayList elements = new ArrayList();
elements.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
elements.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
@@ -53,7 +53,7 @@
types.add(Boolean.FALSE);
types.add(Boolean.TRUE);
types.add(Boolean.FALSE);
- return new com.metamatrix.query.sql.lang.OrderBy(elements, types);
+ return new org.teiid.query.sql.lang.OrderBy(elements, types);
}
public static OrderBy example() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestProcedureImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,11 +25,11 @@
import junit.framework.TestCase;
import org.teiid.connector.language.Call;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.StoredProcedure;
public class TestProcedureImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestQueryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,12 +31,12 @@
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Select;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
public class TestQueryImpl extends TestCase {
@@ -48,13 +48,13 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.Select helpExampleSelect(boolean distinct) {
+ public static org.teiid.query.sql.lang.Select helpExampleSelect(boolean distinct) {
ArrayList<ElementSymbol> symbols = new ArrayList<ElementSymbol>();
symbols.add(TestElementImpl.helpExample("vm1.g1", "e1")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e2")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e3")); //$NON-NLS-1$ //$NON-NLS-2$
symbols.add(TestElementImpl.helpExample("vm1.g1", "e4")); //$NON-NLS-1$ //$NON-NLS-2$
- com.metamatrix.query.sql.lang.Select sel = new com.metamatrix.query.sql.lang.Select(symbols);
+ org.teiid.query.sql.lang.Select sel = new org.teiid.query.sql.lang.Select(symbols);
sel.setDistinct(distinct);
return sel;
}
@@ -109,13 +109,13 @@
assertTrue(EquivalenceUtil.areEquivalent(expected, types));
}
- public static com.metamatrix.query.sql.lang.From helpExampleFrom() {
+ public static org.teiid.query.sql.lang.From helpExampleFrom() {
List<UnaryFromClause> clauses = new ArrayList<UnaryFromClause>();
clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g1"))); //$NON-NLS-1$
clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("myAlias", "vm1.g2"))); //$NON-NLS-1$ //$NON-NLS-2$
clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g3"))); //$NON-NLS-1$
clauses.add(new UnaryFromClause(TestGroupImpl.helpExample("vm1.g4"))); //$NON-NLS-1$
- return new com.metamatrix.query.sql.lang.From(clauses);
+ return new org.teiid.query.sql.lang.From(clauses);
}
public void testGetSelectSymbols() throws Exception {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestScalarSubqueryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,9 +26,9 @@
import org.teiid.connector.language.Select;
import org.teiid.connector.language.ScalarSubquery;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
/**
*/
@@ -42,9 +42,9 @@
super(name);
}
- public static com.metamatrix.query.sql.symbol.ScalarSubquery helpExample() {
+ public static org.teiid.query.sql.symbol.ScalarSubquery helpExample() {
Query query = TestQueryImpl.helpExample(true);
- com.metamatrix.query.sql.symbol.ScalarSubquery ss = new com.metamatrix.query.sql.symbol.ScalarSubquery(query);
+ org.teiid.query.sql.symbol.ScalarSubquery ss = new org.teiid.query.sql.symbol.ScalarSubquery(query);
ss.setType(((SingleElementSymbol)query.getProjectedSymbols().get(0)).getType());
return ss;
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSearchedCaseExpressionImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,13 +26,13 @@
import java.util.List;
import org.teiid.connector.language.SearchedCase;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.TestCaseExpression;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.TestCaseExpression;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSelectSymbolImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,8 +26,8 @@
import org.teiid.connector.language.ColumnReference;
import org.teiid.connector.language.DerivedColumn;
+import org.teiid.core.types.DataTypeManager;
-import com.metamatrix.common.types.DataTypeManager;
public class TestSelectSymbolImpl extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSetQueryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -35,9 +35,9 @@
import org.teiid.connector.language.SetQuery;
import org.teiid.connector.language.SortSpecification;
import org.teiid.connector.language.SortSpecification.Ordering;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
/**
@@ -45,8 +45,8 @@
*/
public class TestSetQueryImpl extends TestCase {
- public static com.metamatrix.query.sql.lang.SetQuery helpExampleSetQuery() {
- com.metamatrix.query.sql.lang.SetQuery setQuery = new com.metamatrix.query.sql.lang.SetQuery(Operation.UNION);
+ public static org.teiid.query.sql.lang.SetQuery helpExampleSetQuery() {
+ org.teiid.query.sql.lang.SetQuery setQuery = new org.teiid.query.sql.lang.SetQuery(Operation.UNION);
setQuery.setAll(false);
setQuery.setLeftQuery(TestQueryImpl.helpExample(true));
setQuery.setRightQuery(TestQueryImpl.helpExample(true));
@@ -101,7 +101,7 @@
}
public void testNestedSetQuery() throws Exception {
- com.metamatrix.query.sql.lang.SetQuery query = new com.metamatrix.query.sql.lang.SetQuery(com.metamatrix.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleSetQuery(), helpExampleSetQuery());
+ org.teiid.query.sql.lang.SetQuery query = new org.teiid.query.sql.lang.SetQuery(org.teiid.query.sql.lang.SetQuery.Operation.EXCEPT, true, helpExampleSetQuery(), helpExampleSetQuery());
SetQuery setQuery = TstLanguageBridgeFactory.factory.translate(query);
assertTrue(setQuery.getLeftQuery() instanceof SetQuery);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryCompareCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,11 +27,11 @@
import org.teiid.connector.language.Comparison;
import org.teiid.connector.language.SubqueryComparison;
import org.teiid.connector.language.SubqueryComparison.Quantifier;
+import org.teiid.query.sql.lang.AbstractCompareCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestSubqueryInCriteriaImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,12 +24,12 @@
import org.teiid.connector.language.SubqueryIn;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TestUpdateImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,10 +27,10 @@
import junit.framework.TestCase;
import org.teiid.connector.language.Update;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestUpdateImpl extends TestCase {
@@ -42,9 +42,9 @@
super(name);
}
- public static com.metamatrix.query.sql.lang.Update helpExample() {
+ public static org.teiid.query.sql.lang.Update helpExample() {
GroupSymbol group = TestGroupImpl.helpExample("vm1.g1"); //$NON-NLS-1$
- com.metamatrix.query.sql.lang.Update result = new com.metamatrix.query.sql.lang.Update();
+ org.teiid.query.sql.lang.Update result = new org.teiid.query.sql.lang.Update();
result.setGroup(group);
result.addChange(TestElementImpl.helpExample("vm1.g1", "e1"), new Constant(new Integer(1)));
result.addChange(TestElementImpl.helpExample("vm1.g1", "e2"), new Constant(new Integer(1)));
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/language/TstLanguageBridgeFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -23,9 +23,9 @@
package org.teiid.dqp.internal.datamgr.language;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TstLanguageBridgeFactory {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/datamgr/metadata/TestMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,13 +26,14 @@
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
public class TestMetadataFactory extends TestCase {
private RuntimeMetadataImpl metadataFactory;
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestByteLobChunkStream.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestByteLobChunkStream.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestByteLobChunkStream.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,10 +26,10 @@
import java.util.Arrays;
import org.teiid.client.lob.LobChunkInputStream;
+import org.teiid.core.util.ObjectConverterUtil;
import junit.framework.TestCase;
-import com.metamatrix.core.util.ObjectConverterUtil;
public class TestByteLobChunkStream extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCallableStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,11 +27,12 @@
import java.util.Collections;
import java.util.List;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.query.processor.HardcodedDataManager;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.processor.HardcodedDataManager;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestCallableStatement extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestCodeTableCache.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,15 +25,15 @@
import java.util.Arrays;
import java.util.List;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.CodeTableCache;
import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
import org.teiid.dqp.internal.process.CodeTableCache.CacheState;
+import org.teiid.query.util.CommandContext;
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -70,7 +70,7 @@
try {
ctc.loadTable(nodeId, results);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new RuntimeException(e);
}
ctc.markCacheDone(nodeId, setDone);
@@ -91,7 +91,7 @@
try {
ctc.loadTable(nodeId, results);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new RuntimeException(e);
}
ctc.markCacheDone(nodeId, true);
@@ -179,7 +179,7 @@
try {
ctc.lookupValue("countrycode", "code", "country", "US", TEST_CONTEXT); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
fail("Expected exception during lookup"); //$NON-NLS-1$
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
// expected this
}
}
@@ -205,7 +205,7 @@
try {
ctc.loadTable(nodeId, results);
fail("expected exception"); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
assertEquals("Duplicate code table 'table' key 'value' value '1'", e.getMessage()); //$NON-NLS-1$
}
}
@@ -223,7 +223,7 @@
try {
ctc.loadTable(nodeId, results);
fail("expected exception"); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
assertEquals("Error Code:ERR.018.005.0100 Message:Unable to load code table for because result sizes exceeds the allowed parameter - maxCodeTableRecords.", e.getMessage()); //$NON-NLS-1$
}
}
@@ -241,7 +241,7 @@
try {
ctc.loadTable(nodeId, results);
fail("expected exception"); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
assertEquals("Error Code:ERR.018.005.0100 Message:Unable to load code table for because result sizes exceeds the allowed parameter - maxCodeTables.", e.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestConnectorCapabilitiesFinder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,9 +31,9 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCore.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -33,16 +33,16 @@
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.RequestMessage;
import org.teiid.client.ResultsMessage;
+import org.teiid.common.queue.FakeWorkManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.service.AutoGenDataService;
+import org.teiid.dqp.service.FakeBufferService;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestDQPCore {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPCoreRequestHandling.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,13 +32,13 @@
import org.teiid.client.RequestMessage;
import org.teiid.client.SourceWarning;
import org.teiid.client.security.SessionToken;
+import org.teiid.core.TeiidException;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
import org.teiid.dqp.internal.process.DQPCore.ClientState;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.query.sql.lang.Command;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.query.sql.lang.Command;
/**
*/
@@ -107,7 +107,7 @@
}
private SourceWarning getSourceFailures(String model, String binding, String message) {
- return new SourceWarning(model, binding, new MetaMatrixException(message), true);
+ return new SourceWarning(model, binding, new TeiidException(message), true);
}
public void testAddRequest() {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDQPWorkContext.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,9 +22,10 @@
package org.teiid.dqp.internal.process;
+import org.teiid.core.util.UnitTestUtil;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestDQPWorkContext extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestDataTierManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,22 +26,22 @@
import org.mockito.Mockito;
import org.teiid.client.RequestMessage;
+import org.teiid.core.TeiidException;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.AutoGenDataService;
+import org.teiid.dqp.service.FakeBufferService;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.dynamic.SimpleQueryProcessorFactory;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.dynamic.SimpleQueryProcessorFactory;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
public class TestDataTierManager extends TestCase {
@@ -125,7 +125,7 @@
try {
dtm.lookupCodeValue(context, "BQT1.SmallA", "IntKey", "StringKey", "49"); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
fail("processor should have failed"); //$NON-NLS-1$
- } catch (MetaMatrixException e) {
+ } catch (TeiidException e) {
assertEquals("Connector Exception", e.getMessage()); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestMetaDataProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -33,16 +33,16 @@
import org.teiid.client.RequestMessage;
import org.teiid.client.metadata.MetadataResult;
import org.teiid.client.metadata.ResultsMetadataConstants;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedPlanCache.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,15 +28,15 @@
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryParserException;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.parser.ParseInfo;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.lang.Command;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.lang.Command;
public class TestPreparedPlanCache {
private static final String EXAMPLE_QUERY = "SELECT * FROM table"; //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,31 +31,31 @@
import org.junit.Test;
import org.mockito.Mockito;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.RequestMessage;
import org.teiid.client.RequestMessage.StatementType;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.service.AutoGenDataService;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestPreparedStatement {
@@ -207,13 +207,13 @@
}
static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values, SessionAwareCache<PreparedPlan> prepPlanCache)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
return helpGetProcessorPlan(preparedSql, values, new DefaultCapabilitiesFinder(), FakeMetadataFactory.example1Cached(), prepPlanCache, SESSION_ID, false, false, FakeMetadataFactory.example1VDB());
}
static public PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
SessionAwareCache<PreparedPlan> prepPlanCache, int conn)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
return helpGetProcessorPlan(preparedSql, values,
new DefaultCapabilitiesFinder(), FakeMetadataFactory
.example1Cached(), prepPlanCache, conn, false, false, FakeMetadataFactory.example1VDB());
@@ -221,7 +221,7 @@
static PreparedStatementRequest helpGetProcessorPlan(String preparedSql, List values,
CapabilitiesFinder capFinder, QueryMetadataInterface metadata, SessionAwareCache<PreparedPlan> prepPlanCache, int conn, boolean callableStatement, boolean limitResults, VDBMetaData vdb)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
//Create Request
RequestMessage request = new RequestMessage(preparedSql);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestPreparedStatementBatchedUpdate.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,16 +29,16 @@
import java.util.List;
import org.junit.Test;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.HardcodedDataManager;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.HardcodedDataManager;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
/**
* JUnit TestCase to test planning and caching of <code>PreparedStatement</code>
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/TestRequest.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,21 +30,21 @@
import org.mockito.Mockito;
import org.teiid.client.RequestMessage;
import org.teiid.client.RequestMessage.StatementType;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
+import org.teiid.dqp.service.AutoGenDataService;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.ContextProperties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.dqp.service.AutoGenDataService;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.ContextProperties;
/**
@@ -125,8 +125,8 @@
assertEquals("1", request.context.getEnvironmentProperties().get(ContextProperties.SESSION_ID)); //$NON-NLS-1$
}
- private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ private Request helpProcessMessage(RequestMessage message, SessionAwareCache<PreparedPlan> cache, DQPWorkContext workContext) throws TeiidComponentException,
+ TeiidProcessingException {
Request request = null;
if (cache != null) {
request = new PreparedStatementRequest(cache);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceCapabilitiesFinder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,13 +26,13 @@
import java.util.List;
import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.AllCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import junit.framework.TestCase;
-import com.metamatrix.query.optimizer.capabilities.AllCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceElementReplacementVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,14 +25,15 @@
import java.util.HashSet;
import java.util.Set;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.TestCase;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.navigator.DeepPostOrderNavigator;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourceMetadataWrapper.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,10 +26,11 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
/**
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -34,29 +34,29 @@
import org.junit.Test;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.id.IntegerIDFactory;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.processor.HardcodedDataManager;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.resolver.TestResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.processor.HardcodedDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.resolver.TestResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
/**
@@ -73,7 +73,7 @@
setMustRegisterCommands(false);
}
- public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID) throws com.metamatrix.api.exception.MetaMatrixComponentException {
+ public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID) throws org.teiid.core.TeiidComponentException {
assertNotNull(connectorBindingId);
Collection elements = ElementCollectorVisitor.getElements(command, true, true);
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/process/validator/TestAuthorizationValidationVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -35,21 +35,21 @@
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.adminapi.impl.DataPolicyMetadata.PermissionMetaData;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
import org.teiid.dqp.internal.process.Request;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorFailure;
+import org.teiid.query.validator.ValidatorReport;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.Symbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorFailure;
-import com.metamatrix.query.validator.ValidatorReport;
public class TestAuthorizationValidationVisitor extends TestCase {
@@ -153,7 +153,7 @@
return svc;
}
- private void helpTest(DataPolicyMetadata policy, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ private void helpTest(DataPolicyMetadata policy, String sql, QueryMetadataInterface metadata, String[] expectedInaccesible, VDBMetaData vdb) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = QueryParser.getQueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -279,7 +279,7 @@
helpTest(exampleAuthSvc1(), "select * from xmltest.doc1", FakeMetadataFactory.example1Cached(), new String[] {"xmltest.doc1"}, FakeMetadataFactory.example1VDB()); //$NON-NLS-1$ //$NON-NLS-2$
}
- private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, MetaMatrixComponentException {
+ private void helpTestLookupVisibility(boolean visible) throws QueryParserException, QueryValidatorException, TeiidComponentException {
VDBMetaData vdb = FakeMetadataFactory.example1VDB();
vdb.getModel("pm1").setVisible(visible); //$NON-NLS-1$
AuthorizationValidationVisitor mvvv = new AuthorizationValidationVisitor(vdb, false, new HashMap<String, DataPolicy>(), "test"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/dqp/internal/transaction/TestTransactionServer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -34,9 +34,9 @@
import org.teiid.adminapi.Transaction;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
+import org.teiid.common.queue.FakeWorkManager;
+import org.teiid.dqp.service.TransactionContext;
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.service.TransactionContext;
public class TestTransactionServer {
private TransactionServerImpl server;
Copied: trunk/engine/src/test/java/org/teiid/dqp/message (from rev 2112, trunk/engine/src/test/java/com/metamatrix/dqp/message)
Modified: trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestAtomicRequestMessage.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/dqp/message/TestAtomicRequestMessage.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
import junit.framework.TestCase;
import org.teiid.client.RequestMessage;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.language.TestQueryImpl;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestAtomicRequestMessage extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/dqp/message/TestRequestID.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestRequestID.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/dqp/message/TestRequestID.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.dqp.message.RequestID;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/dqp/message/TestResultsMessage.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/message/TestResultsMessage.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/dqp/message/TestResultsMessage.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
import java.math.BigInteger;
import java.util.ArrayList;
@@ -31,9 +31,9 @@
import org.teiid.client.ResultsMessage;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestResultsMessage extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/dqp/service (from rev 2112, trunk/engine/src/test/java/com/metamatrix/dqp/service)
Modified: trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/AutoGenDataService.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/AutoGenDataService.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -28,19 +28,19 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem;
import org.teiid.dqp.internal.process.AbstractWorkItem;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.AtomicResultsMessage;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.resource.ConnectorException;
import org.teiid.resource.cci.DataNotAvailableException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
/**
* This data service will automatically generate results when called with a query - basically
Modified: trunk/engine/src/test/java/org/teiid/dqp/service/FakeBufferService.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/dqp/service/FakeBufferService.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/dqp/service/FakeBufferService.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
+import org.teiid.cache.CacheFactory;
+import org.teiid.cache.FakeCache.FakeCacheFactory;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.service.BufferService;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.cache.FakeCache.FakeCacheFactory;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
/**
*/
Copied: trunk/engine/src/test/java/org/teiid/internal/core/xml (from rev 2112, trunk/engine/src/test/java/com/metamatrix/internal/core/xml)
Modified: trunk/engine/src/test/java/org/teiid/internal/core/xml/TestJdomHelper.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/internal/core/xml/TestJdomHelper.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/internal/core/xml/TestJdomHelper.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.internal.core.xml;
+package org.teiid.internal.core.xml;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
@@ -31,8 +31,9 @@
import org.jdom.Document;
import org.jdom.Element;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.internal.core.xml.JdomHelper;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* This class tests the functionality in the JdomHelper class
Modified: trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/engine/src/test/java/org/teiid/metadata/TestTransformationMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -35,12 +35,12 @@
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestTransformationMetadata {
Copied: trunk/engine/src/test/java/org/teiid/query/analysis (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/analysis)
Modified: trunk/engine/src/test/java/org/teiid/query/analysis/TestAnalysisRecord.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/analysis/TestAnalysisRecord.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/analysis/TestAnalysisRecord.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.analysis;
+package org.teiid.query.analysis;
import java.util.Collection;
@@ -28,8 +28,9 @@
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.Annotation.Priority;
+import org.teiid.core.util.StringUtil;
+import org.teiid.query.analysis.AnalysisRecord;
-import com.metamatrix.core.util.StringUtil;
/**
*/
Copied: trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,1176 @@
+/*
+ * 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.function;
+
+import static org.junit.Assert.*;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.query.function.FunctionMethods;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.query.util.CommandContext;
+
+
+public class TestFunction {
+
+ private void helpConcat(String s1, String s2, Object expected) {
+ Object actual = FunctionMethods.concat(s1, s2);
+ assertEquals("concat(" + s1 + ", " + s2 + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpTrim(String str, boolean left, Object expected) {
+ Object actual = null;
+ if (left) {
+ actual = FunctionMethods.leftTrim(str);
+ assertEquals("ltrim(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ actual = FunctionMethods.rightTrim(str);
+ assertEquals("rtrim(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ public static void helpLeft(String str, int count, Object expected) throws FunctionExecutionException {
+ Object actual = FunctionMethods.left(str, new Integer(count));
+ assertEquals("left(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static void helpRight(String str, int count, Object expected) throws FunctionExecutionException {
+ Object actual = FunctionMethods.right(str, new Integer(count));
+ assertEquals("right(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static void helpReplace(String str, String sub, String replace, Object expected) {
+ Object actual = FunctionMethods.replace(str, sub, replace);
+ assertEquals("replace(" + str + "," + sub + "," + replace + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ public static void helpSubstring(String str, Integer start, Integer length, Object expected) {
+ Object actual = FunctionMethods.substring(str, start, length);
+ assertEquals("substring(" + str + "," + start + "," + length + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ public static void helpSubstring(String str, Integer start, Object expected) {
+ Object actual = FunctionMethods.substring(str, start);
+ assertEquals("substring(" + str + "," + start + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpConvert(Object src, String tgtType, Object expected) throws FunctionExecutionException {
+ Object actual = FunctionMethods.convert(src, tgtType);
+ assertEquals("convert(" + src + "," + tgtType + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpConvertFail(Object src, String tgtType) {
+ try {
+ FunctionMethods.convert(src, tgtType);
+ fail("Expected convert(" + src + "," + tgtType + ") to throw FunctionExecutionException, but it did not."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ } catch (FunctionExecutionException e) {
+ }
+ }
+
+ public static void helpTestInitCap(String input, String expected) {
+ String actual = (String) FunctionMethods.initCap(input);
+ assertEquals("Didn't get expected result from initCap", expected, actual); //$NON-NLS-1$
+ }
+
+ public static void helpTestLpad(String input, int length, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.lpad(input, new Integer(length));
+ assertEquals("Didn't get expected result from lpad", expected, actual); //$NON-NLS-1$
+ }
+
+ public static void helpTestLpad(String input, int length, String pad, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.lpad(input, new Integer(length), pad);
+ assertEquals("Didn't get expected result from lpad", expected, actual); //$NON-NLS-1$
+ }
+
+ public static void helpTestRpad(String input, int length, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.rpad(input, new Integer(length));
+ assertEquals("Didn't get expected result from rpad", expected, actual); //$NON-NLS-1$
+ }
+
+ public static void helpTestRpad(String input, int length, String c, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.rpad(input, new Integer(length), c);
+ assertEquals("Didn't get expected result from rpad", expected, actual); //$NON-NLS-1$
+ }
+
+ public static void helpTestTranslate(String input, String src, String dest, String expected) throws FunctionExecutionException {
+ String actual = (String) FunctionMethods.translate(input, src, dest);
+ assertEquals("Didn't get expected result from translate", expected, actual); //$NON-NLS-1$
+ }
+
+ public static void helpTestLocate(String locateString, String input, int expectedLocation) {
+ Integer location = (Integer) FunctionMethods.locate(locateString, input);
+ int actualLocation = location.intValue();
+ assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
+ }
+
+ public static void helpTestLocate(String locateString, String input, Integer start, int expectedLocation) {
+ Integer location = (Integer) FunctionMethods.locate(locateString, input, start);
+ int actualLocation = location.intValue();
+ assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
+ }
+
+ public static void helpTestRound(Integer number, Integer places, Object expected) {
+ Object actual = FunctionMethods.round(number, places);
+ assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpTestRound(Float number, Integer places, Object expected) {
+ Object actual = FunctionMethods.round(number, places);
+ assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpTestRound(Double number, Integer places, Object expected) {
+ Object actual = FunctionMethods.round(number, places);
+ assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpTestRound(BigDecimal number, Integer places, Object expected) {
+ Object actual = FunctionMethods.round(number, places);
+ assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ public static void helpTestHour1(String timeStr, int expected) {
+ Time t = Time.valueOf(timeStr);
+ Object actual = FunctionMethods.hour(t);
+ assertEquals("hour(" + t + ") failed", new Integer(expected), actual); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static void helpTestHour2(String timestampStr, int expected) {
+ Timestamp ts = Timestamp.valueOf(timestampStr);
+ Object actual = FunctionMethods.hour(ts);
+ assertEquals("hour(" + ts + ") failed", new Integer(expected), actual); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ public static void helpTestTimestampCreate(java.sql.Date date, Time time, String expected) {
+ Object actual = FunctionMethods.timestampCreate(date, time);
+ assertEquals("timestampCreate(" + date + ", " + time + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected, actual.toString());
+ }
+
+ public static void helpTestTimestampDiff(String intervalType, Timestamp timeStamp1, Timestamp timeStamp2, Long expected) {
+ Object actual = FunctionMethods.timestampDiff(intervalType, timeStamp1, timeStamp2);
+ assertEquals("timestampDiff(" + intervalType + ", " + timeStamp1 + ", " + timeStamp2 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ expected, actual);
+
+ // test reverse - should be
+ Long expected2 = new Long(0 - expected.longValue());
+ Object actual2 = FunctionMethods.timestampDiff(intervalType, timeStamp2, timeStamp1);
+ assertEquals("timestampDiff(" + intervalType + ", " + timeStamp2 + ", " + timeStamp1 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ expected2, actual2);
+ }
+
+ public static void helpTestParseTimestamp(String tsStr, String format, String expected) throws FunctionExecutionException {
+ Object actual = FunctionMethods.parseTimestamp(tsStr, format);
+ assertEquals("parseTimestamp(" + tsStr + ", " + format + ") failed", expected.toString(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new Constant(actual).toString());
+ }
+
+ // ################################## ACTUAL TESTS ################################
+
+ // ------------------------------ CONCAT ------------------------------
+
+ @Test public void testConcat1() throws Exception {
+ helpConcat("x", "y", "xy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testConcat5() throws Exception {
+ helpConcat("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // ------------------------------ TRIM ------------------------------
+
+ @Test public void testTrim3() throws Exception {
+ helpTrim("", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim4() throws Exception {
+ helpTrim("", false, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim5() throws Exception {
+ helpTrim("x", true, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim6() throws Exception {
+ helpTrim("x", false, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim7() throws Exception {
+ helpTrim(" x", true, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim8() throws Exception {
+ helpTrim(" x ", true, "x "); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim9() throws Exception {
+ helpTrim("x ", false, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim10() throws Exception {
+ helpTrim(" x x ", false, " x x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim11() throws Exception {
+ helpTrim(" ", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testTrim12() throws Exception {
+ helpTrim(" ", false, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // ------------------------------ LEFT ------------------------------
+
+ @Test public void testLeft1() throws Exception {
+ helpLeft("abcd", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLeft2() throws Exception {
+ helpLeft("abcd", 3, "abc"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLeft4() throws Exception {
+ helpLeft("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLeft5() throws Exception {
+ helpLeft("", 2, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLeft6() throws Exception {
+ helpLeft("abcd", 5, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLeft7() throws Exception {
+ helpLeft("abcd", 4, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // ------------------------------ RIGHT ------------------------------
+
+ @Test public void testRight1() throws Exception {
+ helpRight("abcd", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRight2() throws Exception {
+ helpRight("abcd", 3, "bcd"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRight4() throws Exception {
+ helpRight("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRight5() throws Exception {
+ helpRight("", 2, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRight6() throws Exception {
+ helpRight("abcd", 5, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRight7() throws Exception {
+ helpRight("abcd", 4, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // ------------------------------ SUBSTRING ------------------------------
+
+ @Test public void testSubstring1() throws Exception {
+ helpSubstring("abc", new Integer(1), new Integer(1), "a"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring2() throws Exception {
+ helpSubstring("abc", new Integer(2), new Integer(2), "bc"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring3() throws Exception {
+ helpSubstring("abc", new Integer(3), new Integer(3), "c"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring4() throws Exception {
+ helpSubstring("abc", new Integer(3), new Integer(0), ""); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring6() throws Exception {
+ helpSubstring("abc", new Integer(3), "c"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring7() throws Exception {
+ helpSubstring("abc", new Integer(1), "abc"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring8() throws Exception {
+ helpSubstring("abc", new Integer(-1), "c"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring9() throws Exception {
+ helpSubstring("abc", new Integer(-3), "abc"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring10() throws Exception {
+ helpSubstring("abc", new Integer(-4), null); //$NON-NLS-1$
+ }
+
+ @Test public void testSubstring11() throws Exception {
+ helpSubstring("abc", new Integer(-1), new Integer(2), "c"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring12() throws Exception {
+ helpSubstring("abc", new Integer(-3), new Integer(2), "ab"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testSubstring13() throws Exception {
+ helpSubstring("abc", new Integer(0), new Integer(2), "ab"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+
+ // ------------------------------ REPLACE ------------------------------
+
+ @Test public void testReplace1() throws Exception {
+ helpReplace("", "x", "y", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace2() throws Exception {
+ helpReplace("", "", "z", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace3() throws Exception {
+ helpReplace("x", "x", "y", "y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace4() throws Exception {
+ helpReplace("xx", "x", "y", "yy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace5() throws Exception {
+ helpReplace("x x", "x", "y", "y y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace6() throws Exception {
+ helpReplace("x x", "x", "", " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace7() throws Exception {
+ helpReplace("x x", "x", "yz", "yz yz"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testReplace8() throws Exception {
+ helpReplace("xx xx", "xx", "y", "y y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ // ------------------------------ CONVERT ------------------------------
+
+ @Test public void testConvertStringBoolean1() throws Exception {
+ helpConvert("true", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringBoolean2() throws Exception {
+ helpConvert("false", "boolean", Boolean.FALSE); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringBoolean3() throws Exception {
+ helpConvert("x", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringBoolean4() throws Exception {
+ helpConvert("TrUe", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringBoolean5() throws Exception {
+ helpConvert("FAlsE", "boolean", Boolean.FALSE); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringChar1() throws Exception {
+ helpConvert("a", "char", new Character('a')); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringChar2() throws Exception {
+ helpConvert("xx", "char", new Character('x')); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringByte1() throws Exception {
+ helpConvert("5", "byte", new Byte((byte) 5)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringShort1() throws Exception {
+ helpConvert("5", "short", new Short((short) 5)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringInteger1() throws Exception {
+ helpConvert("5", "integer", new Integer(5)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // Integer > Integer.MAX_VALUE - should fail
+ @Test public void testConvertStringInteger2() throws Exception {
+ helpConvertFail("" + Integer.MAX_VALUE + "1", "integer"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testConvertStringInteger3() throws Exception {
+ helpConvertFail("5.99", "integer"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringLong1() throws Exception {
+ helpConvert("5", "long", new Long(5)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringBigInteger1() throws Exception {
+ helpConvert("5", "biginteger", new BigInteger("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testConvertStringBigInteger2() throws Exception {
+ String bigInt = "" + Integer.MAX_VALUE + "111"; //$NON-NLS-1$ //$NON-NLS-2$
+ helpConvert(bigInt, "biginteger", new BigInteger(bigInt)); //$NON-NLS-1$
+ }
+
+ @Test public void testConvertStringFloat1() throws Exception {
+ helpConvert("5.2", "float", new Float(5.2f)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringDouble1() throws Exception {
+ helpConvert("5.2", "double", new Double(5.2d)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertStringBigDecimal1() throws Exception {
+ helpConvert("5.2", "bigdecimal", new BigDecimal("5.2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testConvertDoubleBigInteger() throws Exception {
+ helpConvert(new Double(1.0d), "biginteger", new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertFloatBigInteger() throws Exception {
+ helpConvert(new Float(1.0), "biginteger", new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertBigDecimalBigInteger() throws Exception {
+ helpConvert(new BigDecimal("1.0"), "biginteger", new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testConvertDoubleLong() throws Exception {
+ helpConvert(new Double(1.0d), "long", new Long("1")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testConvertTimestampString() throws Exception {
+ Timestamp ts = TimestampUtil.createTimestamp(103, 7, 22, 22, 43, 53, 3333333);
+ helpConvert(ts, "string", "2003-08-22 22:43:53.003333333"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testAscii2() throws Exception {
+ Integer code = FunctionMethods.ascii(" "); //$NON-NLS-1$
+ assertEquals("Didn't get expected code", 32, code.intValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testAscii4() throws Exception {
+ assertNull(FunctionMethods.ascii("")); //$NON-NLS-1$
+ }
+
+ @Test public void testAscii5() throws Exception {
+ Integer code = FunctionMethods.ascii("abc"); //$NON-NLS-1$
+ assertEquals("Didn't get expected code", 97, code.intValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testChr1() throws Exception {
+ Character chr = (Character) FunctionMethods.chr(new Integer(32));
+ assertEquals("Didn't get expected character", ' ', chr.charValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testNvl1() throws Exception {
+ String ret = (String) FunctionMethods.ifnull("x", "y"); //$NON-NLS-1$ //$NON-NLS-2$
+ assertEquals("Didn't get expected value", "x", ret); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testNvl2() throws Exception {
+ String ret = (String) FunctionMethods.ifnull(null, "y"); //$NON-NLS-1$
+ assertEquals("Didn't get expected value", "y", ret); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testNvl3() throws Exception {
+ String ret = (String) FunctionMethods.ifnull(null, null);
+ assertEquals("Didn't get expected value", null, ret); //$NON-NLS-1$
+ }
+
+ @Test public void testInitCap2() throws Exception {
+ helpTestInitCap("abc", "Abc"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInitCap3() throws Exception {
+ helpTestInitCap(" test some\tweird\rspaces\nhere", " Test Some\tWeird\rSpaces\nHere"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInitCap4() throws Exception {
+ helpTestInitCap("x y ", "X Y "); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInitCap5() throws Exception {
+ helpTestInitCap("cows are FUN", "Cows Are Fun"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLpad1() throws Exception {
+ helpTestLpad("x", 4, " x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLpad3() throws Exception {
+ helpTestLpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLpad4() throws Exception {
+ helpTestLpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLpad5() throws Exception {
+ helpTestLpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testLpad6() throws Exception {
+ helpTestLpad("10", 6, "0", "000010"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testLpad7() throws Exception {
+ helpTestLpad("x", 4, "yq", "qyqx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testRpad1() throws Exception {
+ helpTestRpad("x", 4, "x "); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRpad3() throws Exception {
+ helpTestRpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRpad4() throws Exception {
+ helpTestRpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRpad5() throws Exception {
+ helpTestRpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testRpad6() throws Exception {
+ helpTestRpad("10", 6, "0", "100000"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testTranslate1() throws Exception {
+ helpTestTranslate("This is my test", "ty", "yt", "This is mt yesy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testTranslate2() throws Exception {
+ helpTestTranslate("", "ty", "yt", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testTranslate3() throws Exception {
+ try {
+ FunctionMethods.translate("test", "x", "yz"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ fail("Did not get expected exception on differing src and dest lengths"); //$NON-NLS-1$
+ } catch (FunctionExecutionException e) {
+ }
+ }
+
+ @Test public void testTranslate4() throws Exception {
+ helpTestTranslate("test", "xy", "ab", "test"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testLocate1() throws Exception {
+ helpTestLocate(",", "Metamatrix, John Quincy", 11); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate2() throws Exception {
+ helpTestLocate(" ", "Metamatrix, John Quincy", 12); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate3() throws Exception {
+ helpTestLocate("x", "xx", 1); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate4() throws Exception {
+ helpTestLocate("y", "xx", 0); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate5() throws Exception {
+ helpTestLocate("b", "abab", 3, 4); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate6() throws Exception {
+ helpTestLocate("z", "abab", 0, 0); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate7() throws Exception {
+ helpTestLocate("z", "abab", null, 0); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testLocate8() throws Exception {
+ helpTestLocate("z", "abab", -1, 0); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testBitand() throws Exception {
+ // Both values are integers
+ Integer result = (Integer) FunctionMethods.bitand(new Integer(0xFFF), new Integer(0x0F0));
+ assertNotNull("Result should not be null", result); //$NON-NLS-1$
+ assertEquals("result should be 0x0F0", 0x0F0, result.intValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testBitor() throws Exception {
+ // Both values are integers
+ Integer result = (Integer) FunctionMethods.bitor(new Integer(0xFFF), new Integer(0x0F0));
+ assertNotNull("Result should not be null", result); //$NON-NLS-1$
+ assertEquals("result should be 0xFFF", 0xFFF, result.intValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testBitxor() throws Exception {
+ // Both values are integers
+ Integer result = (Integer) FunctionMethods.bitxor(new Integer(0xFFF), new Integer(0x0F0));
+ assertNotNull("Result should not be null", result); //$NON-NLS-1$
+ assertEquals("result should be 0xF0F", 0xF0F, result.intValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testBitnot() throws Exception {
+ // Both values are integers
+ Integer result = FunctionMethods.bitnot(0xF0F);
+ assertNotNull("Result should not be null", result); //$NON-NLS-1$
+ assertEquals("result should be 0xFFFFF0F0", 0xFFFFF0F0, result.intValue()); //$NON-NLS-1$
+ }
+
+ @Test public void testRoundInteger1() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(0), new Integer(1928));
+ }
+
+ @Test public void testRoundInteger2() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(-1), new Integer(1930));
+ }
+
+ @Test public void testRoundInteger3() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(-2), new Integer(1900));
+ }
+
+ @Test public void testRoundInteger4() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(-3), new Integer(2000));
+ }
+
+ @Test public void testRoundInteger5() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(-4), new Integer(0));
+ }
+
+ @Test public void testRoundInteger6() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(-5), new Integer(0));
+ }
+
+ @Test public void testRoundInteger7() throws Exception {
+ helpTestRound(new Integer(1928), new Integer(1), new Integer(1928));
+ }
+
+ @Test public void testRoundFloat1() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(4), new Float(123.456F));
+ }
+
+ @Test public void testRoundFloat2() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(3), new Float(123.456F));
+ }
+
+ @Test public void testRoundFloat3() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(2), new Float(123.46F));
+ }
+
+ @Test public void testRoundFloat4() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(1), new Float(123.5F));
+ }
+
+ @Test public void testRoundFloat5() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(0), new Float(123F));
+ }
+
+ @Test public void testRoundFloat6() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(-1), new Float(120F));
+ }
+
+ @Test public void testRoundFloat7() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(-2), new Float(100F));
+ }
+
+ @Test public void testRoundFloat8() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(-3), new Float(0F));
+ }
+
+ @Test public void testRoundFloat9() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(-4), new Float(0F));
+ }
+
+ @Test public void testRoundFloat10() throws Exception {
+ helpTestRound(new Float(123.456F), new Integer(4000), new Float(123.456F));
+ }
+
+ @Test public void testRoundDouble1() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(4), new Double(123.456));
+ }
+
+ @Test public void testRoundDouble2() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(3), new Double(123.456));
+ }
+
+ @Test public void testRoundDouble3() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(2), new Double(123.46));
+ }
+
+ @Test public void testRoundDouble4() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(1), new Double(123.5));
+ }
+
+ @Test public void testRoundDouble5() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(0), new Double(123));
+ }
+
+ @Test public void testRoundDouble6() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(-1), new Double(120));
+ }
+
+ @Test public void testRoundDouble7() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(-2), new Double(100));
+ }
+
+ @Test public void testRoundDouble8() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(-3), new Double(0));
+ }
+
+ @Test public void testRoundDouble9() throws Exception {
+ helpTestRound(new Double(123.456), new Integer(-4), new Double(0));
+ }
+
+ @Test public void testRoundDouble10() throws Exception {
+ helpTestRound(new Double(-3.5), new Integer(0), new Double(-4));
+ }
+
+ @Test public void testRoundBigDecimal1() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(4), new BigDecimal("123.456")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal2() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(3), new BigDecimal("123.456")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal3() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(2), new BigDecimal("123.460")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal4() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(1), new BigDecimal("123.500")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal5() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(0), new BigDecimal("123.000")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal6() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(-1), new BigDecimal("120.000")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal7() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(-2), new BigDecimal("100.000")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal8() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(-3), new BigDecimal("0.000")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testRoundBigDecimal9() throws Exception {
+ helpTestRound(new BigDecimal("123.456"), new Integer(-4), new BigDecimal("0.000")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testHour1() throws Exception {
+ helpTestHour1("00:00:00", 0); //$NON-NLS-1$
+ }
+
+ @Test public void testHour2() throws Exception {
+ helpTestHour1("11:00:00", 11); //$NON-NLS-1$
+ }
+
+ @Test public void testHour3() throws Exception {
+ helpTestHour1("12:00:00", 12); //$NON-NLS-1$
+ }
+
+ @Test public void testHour4() throws Exception {
+ helpTestHour1("13:00:00", 13); //$NON-NLS-1$
+ }
+
+ @Test public void testHour5() throws Exception {
+ helpTestHour1("23:59:59", 23); //$NON-NLS-1$
+ }
+
+ @Test public void testHour6() throws Exception {
+ helpTestHour2("2002-01-01 00:00:00", 0); //$NON-NLS-1$
+ }
+
+ @Test public void testHour7() throws Exception {
+ helpTestHour2("2002-01-01 11:00:00", 11); //$NON-NLS-1$
+ }
+
+ @Test public void testHour8() throws Exception {
+ helpTestHour2("2002-01-01 12:00:00", 12); //$NON-NLS-1$
+ }
+
+ @Test public void testHour9() throws Exception {
+ helpTestHour2("2002-01-01 13:00:00", 13); //$NON-NLS-1$
+ }
+
+ @Test public void testHour10() throws Exception {
+ helpTestHour2("2002-01-01 23:59:59", 23); //$NON-NLS-1$
+ }
+
+ @Test public void testTimestampCreate1() throws Exception {
+ helpTestTimestampCreate(TimestampUtil.createDate(103, 11, 1), TimestampUtil.createTime(23, 59, 59), "2003-12-01 23:59:59.0"); //$NON-NLS-1$
+ }
+
+ @Test public void testTimestampAdd2() throws Exception {
+ assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(SQLReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 1),
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100000000),
+ new Long(99999999));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_2() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ // 1 day (8.64 x 10^10 nanos) and 1 nano
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 2),
+ TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 3),
+ new Long(86400000000001L));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_3() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ // 1 day (8.64 x 10^10 nanos) less 1 nano
+ TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 2),
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 3),
+ new Long(-86399999999999L));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_4() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 1),
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 3),
+ new Long(00000002));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_5() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 1),
+ TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 10),
+ new Long(9));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_6() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 2),
+ TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 3),
+ new Long(1));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_7() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ // 1 nano diff
+ TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
+ TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
+ new Long(1));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_FracSec_8() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
+ // 1 nano diff
+ TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
+ TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
+ new Long(-1));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Min_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
+ TimestampUtil.createTimestamp(0, 0, 0, 2, 34, 12, 0),
+ TimestampUtil.createTimestamp(0, 0, 0, 12, 0, 0, 0),
+ new Long(565));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Min_2() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
+ TimestampUtil.createTimestamp((2001-1900), 0, 0, 2, 0, 0, 0),
+ TimestampUtil.createTimestamp((2001-1900), 0, 0, 0, 33, 12, 0),
+ new Long(-86));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Min_3() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
+ TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 65497),
+ TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 483219),
+ new Long(4277));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Min_4() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
+ TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 0),
+ TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 0),
+ new Long(4277));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Min_5() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
+ TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 1),
+ TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 0),
+ new Long(0));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Hour_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR,
+ TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 0, 0, 0),
+ TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 59, 59, 999999999),
+ new Long(0));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Week_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_WEEK,
+ TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100),
+ TimestampUtil.createTimestamp((2001-1900), 4, 2, 5, 19, 35, 500),
+ new Long(-7));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Month_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
+ TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 0),
+ TimestampUtil.createTimestamp((2004-1900), 11, 20, 12, 0, 0, 0),
+ new Long(7));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Month_2() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
+ TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0, 1000000),
+ TimestampUtil.createTimestamp((2004-1900), 11, 1, 12, 0, 0, 1),
+ new Long(6));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Month_3() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
+ TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 1),
+ TimestampUtil.createTimestamp((2004-1900), 11, 18, 12, 0, 0, 1000000),
+ new Long(7));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Month_4() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
+ TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 0, 1000000),
+ TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
+ new Long(7));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Month_5() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
+ TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
+ TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
+ new Long(7));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Month_6() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
+ TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
+ TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 2, 0),
+ new Long(7));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Day_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
+ TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
+ TimestampUtil.createTimestamp((2004-1900), 3, 1, 0, 0, 0, 0),
+ new Long(31));
+ }
+
+ @Test public void testTimestampDiffTimeStamp_Day_2() throws Exception {
+ // Leap year
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
+ TimestampUtil.createTimestamp((2004-1900), 1, 1, 0, 0, 0, 0),
+ TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
+ new Long(29));
+ }
+
+ @Test public void testTimestampDiffTime_Hour_1() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
+ TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(
+ TimestampUtil.createTime(5, 5, 36).getTime()), new Long(2));
+ }
+
+ @Test public void testTimestampDiffTime_Hour_2() throws Exception {
+ helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
+ TimestampUtil.createTime(5, 0, 30).getTime()), new Timestamp(
+ TimestampUtil.createTime(3, 0, 31).getTime()), new Long(-1));
+ }
+
+ @Test public void testParseTimestamp1() throws Exception {
+ helpTestParseTimestamp("1993-04-24 3:59:59 PM", "yyyy-MM-dd hh:mm:ss aa", "{ts'1993-04-24 15:59:59.0'}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ }
+
+ public void helpTestModifyTimeZone(String tsStr, String tzStart, String tzEnd, String expectedStr) throws Exception {
+ Timestamp ts = tsStr != null ? Timestamp.valueOf(tsStr) : null;
+ Timestamp actual = null;
+
+ if(tzStart == null) {
+ actual = (Timestamp) FunctionMethods.modifyTimeZone(new CommandContext(), ts, tzEnd);
+ } else {
+ actual = (Timestamp) FunctionMethods.modifyTimeZone(ts, tzStart, tzEnd);
+ }
+
+ String actualStr = null;
+ if(actual != null) {
+ actualStr = actual.toString();
+ }
+ assertEquals("Did not get expected output timestamp", expectedStr, actualStr); //$NON-NLS-1$
+ }
+
+ /*
+ * The following test results may look odd, but it is due to the parsing of the initial date, which is done
+ * against the system default timezone (not the startTz shown below). The fianl date value is also being read
+ * against the default timezone and not the endTz shown.
+ */
+ @Test public void testModifyTimeZoneGMT() throws Exception {
+ helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "GMT+00:00", "GMT-01:00", "2004-10-03 16:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testModifyTimeZoneGMTPartialHour() throws Exception {
+ helpTestModifyTimeZone("2004-10-03 15:30:59.123456789", "GMT+00:00", "GMT-01:45", "2004-10-03 17:15:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testModifyTimeZoneNamedTZ() throws Exception {
+ helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "America/New_York", "America/Chicago", "2004-10-03 16:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testModifyTimeZoneNamedTZ2() throws Exception {
+ helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "America/Chicago", "America/New_York", "2004-10-03 14:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testModifyTimeZoneStartLocal() throws Exception {
+ helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "America/Chicago", "America/Los_Angeles", "2004-10-03 17:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ // case 2458
+ @Test public void testCurrentDate() throws Exception {
+
+ Date curDate = (Date)FunctionMethods.currentDate();
+
+ Calendar cal1 = Calendar.getInstance();
+ cal1.setTime(curDate);
+
+ assertEquals(cal1.get(Calendar.HOUR_OF_DAY), 0);
+ assertEquals(cal1.get(Calendar.MINUTE), 0);
+ assertEquals(cal1.get(Calendar.SECOND), 0);
+ assertEquals(cal1.get(Calendar.MILLISECOND), 0);
+
+ }
+
+ // case 2458
+ @Test public void testCurrentTime() throws Exception {
+
+ Time curDate = (Time)FunctionMethods.currentTime();
+
+ Calendar cal1 = Calendar.getInstance();
+ cal1.setTime(curDate);
+
+ // can not test the current time without making a copy of current "time"
+ // so check the normalization of the date to unix epoch
+ assertEquals(cal1.get(Calendar.YEAR), 1970);
+ assertEquals(cal1.get(Calendar.MONTH), Calendar.JANUARY);
+ assertEquals(cal1.get(Calendar.DATE), 1);
+
+ }
+
+ @Test public void testRand() throws Exception {
+ Double d = (Double)FunctionMethods.rand(new CommandContext(), new Integer(100));
+ assertEquals(new Double(0.7220096548596434), d);
+
+ try {
+ FunctionMethods.rand(new CommandContext(), new Double(34.5));
+ fail("should have failed to take a double"); //$NON-NLS-1$
+ } catch (FunctionExecutionException e) {
+ }
+
+ FunctionMethods.rand(new CommandContext());
+ }
+
+ @Test public void testEnv() throws Exception {
+ Properties p = new Properties();
+ String envProperty = "EnvProperty"; //$NON-NLS-1$
+ String systemProperty = "SystemProperty"; //$NON-NLS-1$
+ p.setProperty(envProperty.toLowerCase(), envProperty);
+
+ // set an environment property
+ CommandContext context = new CommandContext();
+ context.setEnvironmentProperties(p);
+
+ // set the system property
+ System.setProperty(systemProperty, systemProperty);
+ System.setProperty(systemProperty.toLowerCase(), systemProperty+"_lowercase"); //$NON-NLS-1$
+
+ assertEquals(envProperty, FunctionMethods.env(context, envProperty));
+ assertEquals(systemProperty, FunctionMethods.env(context, systemProperty));
+ assertEquals(systemProperty+"_lowercase", FunctionMethods.env(context, systemProperty.toUpperCase())); //$NON-NLS-1$
+ }
+
+ @Test(expected=FunctionExecutionException.class) public void testParseIntStrictness() throws Exception {
+ FunctionMethods.parseInteger("a 1 a", "#"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testParseDateStrictness() throws Exception {
+ assertEquals(TimestampUtil.createTimestamp(108, 0, 1, 0, 0, 0, 0), FunctionMethods.parseTimestamp(" 2007-13-01", "yyyy-MM")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testParseTimeWhitespace() throws Exception {
+ assertEquals(TimestampUtil.createTime(15, 0, 0), FunctionMethods.parseTimestamp(" 15:00:00 ", "HH:mm:ss")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testMod() {
+ assertEquals(new BigDecimal("-1.1"), FunctionMethods.mod(new BigDecimal("-3.1"), new BigDecimal("2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testMod1() {
+ assertEquals(new BigDecimal("-1.1"), FunctionMethods.mod(new BigDecimal("-3.1"), new BigDecimal("-2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testMod2() {
+ assertEquals(-40, FunctionMethods.mod(-340, 60), 0);
+ }
+
+ @Test public void testMod3() {
+ assertEquals(-40, FunctionMethods.mod(-340, -60), 0);
+ }
+
+ @Test public void testMod4() {
+ assertEquals(new BigInteger("-1"), FunctionMethods.mod(new BigInteger("-3"), new BigInteger("2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testMod5() {
+ assertEquals(new BigInteger("-1"), FunctionMethods.mod(new BigInteger("-3"), new BigInteger("-2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionDescriptorImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,120 @@
+/*
+ * 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.function;
+
+import java.lang.reflect.Method;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.metadata.FunctionMethod;
+
+import junit.framework.TestCase;
+
+
+public class TestFunctionDescriptorImpl extends TestCase {
+
+ /**
+ * Constructor for TestFunctionDescriptorImpl.
+ * @param name
+ */
+ public TestFunctionDescriptorImpl(String name) {
+ super(name);
+ }
+
+ /**
+ * Find the invocation method for a function.
+ * @param source The function metadata source, which knows how to obtain the invocation class
+ * @param invocationClass The class to invoke for this function
+ * @param invocationMethod The method to invoke for this function
+ * @param numArgs Number of arguments in method
+ * @throws NoSuchMethodException
+ * @throws SecurityException
+ */
+ private Method lookupMethod(String invocationClass, String invocationMethod, int numArgs) throws SecurityException, NoSuchMethodException {
+ // Build signature
+ Class[] objectSignature = new Class[numArgs];
+ for(int i=0; i<numArgs; i++) {
+ objectSignature[i] = Integer.TYPE;
+ }
+
+ // Find Method
+ Method method = null;
+ try {
+ Class methodClass = Class.forName(invocationClass);
+ method = methodClass.getMethod(invocationMethod, objectSignature);
+ } catch(ClassNotFoundException e) {
+ // Failed to load class, so can't load method - this will fail at invocation time.
+ // We don't fail here because this situation can occur in the modeler, which does
+ // not have the function jar files. The modeler never invokes, so this isn't a
+ // problem.
+ return null;
+ }
+
+ // Validate method
+ if(! FunctionTree.isValidMethod(method)) {
+ return null;
+ }
+ return method;
+ }
+
+ public void test1() throws Exception {
+ FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN, //$NON-NLS-1$
+ new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
+ DataTypeManager.DefaultDataClasses.INTEGER,
+ lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2) , false, true, FunctionMethod.DETERMINISTIC); //$NON-NLS-1$ //$NON-NLS-2$
+
+ UnitTestUtil.helpTestEquivalence(0, f1, f1);
+ }
+
+ public void test2() throws Exception {
+ FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+ new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
+ DataTypeManager.DefaultDataClasses.INTEGER,
+ lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ FunctionDescriptor f2 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+ new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
+ DataTypeManager.DefaultDataClasses.INTEGER,
+ lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ UnitTestUtil.helpTestEquivalence(0, f1, f2);
+ }
+
+ public void test3() throws Exception {
+ FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+ new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
+ DataTypeManager.DefaultDataClasses.INTEGER,
+ lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, false, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ FunctionDescriptor f2 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
+ new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
+ DataTypeManager.DefaultDataClasses.INTEGER,
+ lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ assertNotSame("objects should not be equal", f1, f2); //$NON-NLS-1$
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,1381 @@
+/*
+ * 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.function;
+
+import static org.junit.Assert.*;
+
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Date;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.types.ClobType;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.NullType;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionForm;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionMethods;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.query.util.CommandContext;
+import org.teiid.resource.cci.SourceSystemFunctions;
+
+
+@SuppressWarnings("nls")
+public class TestFunctionLibrary {
+
+ // These are just used as shorthand convenience to make unit tests more readable below
+ private static final Class<String> T_STRING = DataTypeManager.DefaultDataClasses.STRING;
+ private static final Class<Integer> T_INTEGER = DataTypeManager.DefaultDataClasses.INTEGER;
+ private static final Class<BigInteger> T_BIG_INTEGER = DataTypeManager.DefaultDataClasses.BIG_INTEGER;
+ private static final Class<BigDecimal> T_BIG_DECIMAL = DataTypeManager.DefaultDataClasses.BIG_DECIMAL;
+ private static final Class<Long> T_LONG = DataTypeManager.DefaultDataClasses.LONG;
+ private static final Class<Float> T_FLOAT = DataTypeManager.DefaultDataClasses.FLOAT;
+ private static final Class<Double> T_DOUBLE = DataTypeManager.DefaultDataClasses.DOUBLE;
+ private static final Class<NullType> T_NULL = DataTypeManager.DefaultDataClasses.NULL;
+ private static final Class<Time> T_TIME = DataTypeManager.DefaultDataClasses.TIME;
+ private static final Class<Date> T_DATE = DataTypeManager.DefaultDataClasses.DATE;
+ private static final Class<Timestamp> T_TIMESTAMP = DataTypeManager.DefaultDataClasses.TIMESTAMP;
+
+ private FunctionLibrary library = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
+
+ @Before public void setUp() {
+ TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00")); //$NON-NLS-1$
+ }
+
+ @After public void tearDown() {
+ TimestampWithTimezone.resetCalendar(null);
+ }
+
+ // ################################## TEST HELPERS ################################
+
+ private FunctionDescriptor helpCreateDescriptor(String name, Class[] types) {
+ final String fname = name;
+ final Class[] ftypes = types;
+ return new FunctionDescriptor() {
+ public String getName() {
+ return fname;
+ }
+ public int getPushdown() {
+ return FunctionMethod.CAN_PUSHDOWN;
+ }
+ public Class[] getTypes() {
+ return ftypes;
+ }
+ public Class getReturnType() {
+ return null;
+ }
+
+ public String toString() {
+ StringBuffer str = new StringBuffer(fname);
+ str.append("("); //$NON-NLS-1$
+ for(int i=0; i<ftypes.length; i++) {
+ if(ftypes[i] != null) {
+ str.append(ftypes[i].getName());
+ } else {
+ str.append("null"); //$NON-NLS-1$
+ }
+ if(i<(ftypes.length-1)) {
+ str.append(", "); //$NON-NLS-1$
+ }
+ }
+ return str.toString();
+ }
+ public boolean requiresContext() {
+ return false;
+ }
+ public boolean isNullDependent() {
+ return true;
+ }
+
+ };
+ }
+
+ private void helpFindFunction(String fname, Class[] types, FunctionDescriptor expected) {
+ FunctionDescriptor actual = library.findFunction(fname, types);
+
+ assertEquals("Function names do not match: ", expected.getName().toLowerCase(), actual.getName().toLowerCase()); //$NON-NLS-1$
+ assertEquals("Arg lengths do not match: ", expected.getTypes().length, actual.getTypes().length); //$NON-NLS-1$
+ }
+
+ private void helpFindFunctionFail(String fname, Class[] types) {
+ FunctionDescriptor actual = library.findFunction(fname, types);
+ assertNull("Function was found but should not have been: " + actual, actual); //$NON-NLS-1$
+ }
+
+ private void helpFindConversions(String fname, Class[] types, FunctionDescriptor[] expected) {
+
+ FunctionDescriptor[] actual = library.determineNecessaryConversions(fname, null, types, false);
+
+ if(expected == null) {
+ if(actual != null) {
+ fail("Expected to find no conversion for " + fname + Arrays.asList(types) + " but found: " + Arrays.asList(actual)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ if(actual == null) {
+ fail("Expected to find conversion for " + fname + Arrays.asList(types) + " but found none"); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ // Compare returned descriptors with expected descriptor
+ for(int i=0; i<expected.length; i++) {
+ if(expected[i] == null) {
+ if(actual[i] != null) {
+ fail("Expected no conversion at index " + i + ", but found: " + actual[i]); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ } else {
+ if(actual[i] == null) {
+ fail("Expected conversion at index " + i + ", but found none."); //$NON-NLS-1$ //$NON-NLS-2$
+ } else {
+ assertEquals("Expected conversion function names do not match: ", expected[i].getName(), actual[i].getName()); //$NON-NLS-1$
+ assertEquals("Expected conversion arg lengths do not match: ", expected[i].getTypes().length, actual[i].getTypes().length); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private void helpFindForm(String fname, int numArgs) {
+ FunctionForm form = library.findFunctionForm(fname, numArgs);
+ assertNotNull("Failed to find function '" + fname + "' with " + numArgs + " args", form); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ assertEquals("Function names do not match: ", fname.toUpperCase(), form.getName().toUpperCase()); //$NON-NLS-1$
+ assertEquals("Arg lengths do not match: ", numArgs, form.getArgNames().size()); //$NON-NLS-1$
+ }
+
+ private void helpInvokeMethod(String fname, Object[] inputs, Object expectedOutput) {
+ try {
+ helpInvokeMethod(fname, null, inputs, null, expectedOutput);
+ } catch (Exception err) {
+ throw new RuntimeException(err);
+ }
+ }
+
+ private void helpInvokeMethod(String fname, Class[] types, Object[] inputs, CommandContext context, Object expectedOutput) throws FunctionExecutionException {
+ Object actualOutput = helpInvokeMethod(fname, types, inputs, context);
+ assertEquals("Actual function output not equal to expected: ", expectedOutput, actualOutput); //$NON-NLS-1$
+ }
+
+ private Object helpInvokeMethod(String fname, Class[] types,
+ Object[] inputs, CommandContext context)
+ throws FunctionExecutionException {
+ if (types == null) {
+ // Build type signature
+ types = new Class[inputs.length];
+ for(int i=0; i<inputs.length; i++) {
+ types[i] = DataTypeManager.determineDataTypeClass(inputs[i]);
+ }
+ }
+ if (context == null) {
+ context = new CommandContext();
+ }
+ Object actualOutput = null;
+ // Find function descriptor
+ FunctionDescriptor descriptor = library.findFunction(fname, types);
+ if (descriptor.requiresContext()) {
+ // Invoke function with inputs
+ Object[] in = new Object[inputs.length+1];
+ in[0] = context;
+ for (int i = 0; i < inputs.length; i++) {
+ in[i+1] = inputs[i];
+ }
+ actualOutput = descriptor.invokeFunction(in);
+ }
+ else {
+ // Invoke function with inputs
+ actualOutput = descriptor.invokeFunction(inputs);
+ }
+ return actualOutput;
+ }
+
+ private void helpInvokeMethodFail(String fname, Object[] inputs) {
+ helpInvokeMethodFail(fname, null, inputs);
+ }
+
+ private void helpInvokeMethodFail(String fname, Class<?> types[], Object[] inputs) {
+ try {
+ helpInvokeMethod(fname, types, inputs, null);
+ fail("expected exception"); //$NON-NLS-1$
+ } catch (FunctionExecutionException err) {
+ }
+ }
+ // ################################## ACTUAL TESTS ################################
+
+ @Test public void testFindFunction1() {
+ helpFindFunction("convert", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }) );
+ }
+
+ @Test public void testFindFunction2() {
+ helpFindFunction("cast", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor(FunctionLibrary.CAST, new Class[] { T_INTEGER, T_STRING }) );
+ }
+
+ @Test public void testFindFunction3() {
+ helpFindFunction("curdate", new Class[0], //$NON-NLS-1$
+ helpCreateDescriptor("curdate", new Class[0])); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction4() {
+ helpFindFunctionFail("curdate", new Class[] { T_INTEGER }); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction5() {
+ helpFindFunction("+", new Class[] { T_INTEGER, T_INTEGER }, //$NON-NLS-1$
+ helpCreateDescriptor("+", new Class[] { T_INTEGER, T_INTEGER }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction6() {
+ helpFindFunctionFail("+", new Class[] {T_INTEGER, T_FLOAT}); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction7() {
+ helpFindFunctionFail("+", new Class[] {T_INTEGER, T_FLOAT, T_INTEGER}); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction8() {
+ helpFindFunctionFail("+", new Class[] {T_INTEGER}); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction9() {
+ helpFindFunctionFail("+", new Class[] {T_INTEGER, T_NULL }); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction10() {
+ helpFindFunction("substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
+ helpCreateDescriptor("substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction11() {
+ helpFindFunction("substring", new Class[] { T_STRING, T_INTEGER }, //$NON-NLS-1$
+ helpCreateDescriptor("substring", new Class[] { T_STRING, T_INTEGER }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction12() {
+ helpFindFunction("context", new Class[] { T_STRING, T_INTEGER }, //$NON-NLS-1$
+ helpCreateDescriptor("context", new Class[] { T_STRING, T_INTEGER }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction12a() {
+ helpFindFunction("rowlimit", new Class[] { T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("rowlimit", new Class[] { T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction12b() {
+ helpFindFunction("rowlimitexception", new Class[] { T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("rowlimitexception", new Class[] { T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFind0ArgConversion1() {
+ helpFindConversions(
+ "curdate", new Class[] {}, //$NON-NLS-1$
+ new FunctionDescriptor[0] );
+ }
+
+ @Test public void testFind0ArgConversion2() {
+ helpFindConversions(
+ "curdate", new Class[] { T_INTEGER }, //$NON-NLS-1$
+ null );
+ }
+
+ @Test public void testFind1ArgConversion1() {
+ helpFindConversions(
+ "length", new Class[] { T_STRING }, //$NON-NLS-1$
+ new FunctionDescriptor[1] );
+ }
+
+ @Test public void testFind1ArgConversion2() {
+ helpFindConversions(
+ "length", new Class[] { T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING })
+ } );
+ }
+
+ @Test public void testFind1ArgConversion3() {
+ helpFindConversions(
+ "length", new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, T_STRING })
+ } );
+ }
+
+ @Test public void testFind2ArgConversion1() {
+ helpFindConversions(
+ "+", new Class[] { T_INTEGER, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[2] );
+ }
+
+ @Test public void testFind2ArgConversion2() {
+ helpFindConversions(
+ "+", new Class[] { T_INTEGER, T_FLOAT }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_FLOAT, T_STRING }) } );
+ }
+
+ @Test public void testFind2ArgConversion3() {
+ helpFindConversions(
+ "+", new Class[] { T_FLOAT, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_FLOAT, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }) } );
+ }
+
+ @Test public void testFind2ArgConversion4() {
+ helpFindConversions(
+ "+", new Class[] { T_STRING, T_FLOAT }, //$NON-NLS-1$
+ null );
+ }
+
+ @Test public void testFind2ArgConversion5() {
+ helpFindConversions(
+ "+", new Class[] { T_NULL, T_NULL }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) } );
+ }
+
+ @Test public void testFind2ArgConversion6() {
+ helpFindConversions(
+ "+", new Class[] { T_NULL, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ null } );
+ }
+
+ @Test public void testFind2ArgConversion7() {
+ helpFindConversions(
+ "+", new Class[] { T_INTEGER, T_NULL }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ null,
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) } );
+ }
+
+ @Test public void testFind3ArgConversion1() {
+ helpFindConversions(
+ "substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[3] );
+ }
+
+ @Test public void testFind3ArgConversion2() {
+ helpFindConversions(
+ "substring", new Class[] { T_INTEGER, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }),
+ null,
+ null
+ } );
+ }
+
+ @Test public void testFind3ArgConversion3() {
+ helpFindConversions(
+ "substring", new Class[] { T_INTEGER, T_INTEGER, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }),
+ null,
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING })
+ } );
+ }
+
+ @Test public void testFind3ArgConversion4() {
+ helpFindConversions(
+ "substring", new Class[] { T_STRING, T_INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP }, //$NON-NLS-1$
+ null );
+ }
+
+ @Test public void testFind3ArgConversion5() {
+ helpFindConversions(
+ "substring", new Class[] { T_STRING, DataTypeManager.DefaultDataClasses.SHORT, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ null,
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING })
+ } );
+ }
+
+ @Test public void testFind3ArgConversion6() {
+ helpFindConversions(
+ "substring", new Class[] { T_INTEGER, DataTypeManager.DefaultDataClasses.SHORT, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING })
+ } );
+ }
+
+ @Test public void testFind3ArgConversion7() {
+ helpFindConversions(
+ "substring", new Class[] { T_NULL, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ null,
+ null }
+ );
+ }
+
+ @Test public void testFind3ArgConversion8() {
+ helpFindConversions(
+ "substring", new Class[] { T_NULL, T_NULL, T_INTEGER }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ null }
+ );
+ }
+
+ @Test public void testFind3ArgConversion9() {
+ helpFindConversions(
+ "substring", new Class[] { T_NULL, T_NULL, T_NULL }, //$NON-NLS-1$
+ new FunctionDescriptor[] {
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
+ helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) }
+ );
+ }
+
+ // Walk through all functions by metadata
+ @Test public void testEnumerateForms() {
+ Collection categories = library.getFunctionCategories();
+ Iterator catIter = categories.iterator();
+ while(catIter.hasNext()) {
+ String category = (String) catIter.next();
+ //System.out.println("Category: " + category);
+
+ Collection functions = library.getFunctionForms(category);
+ Iterator functionIter = functions.iterator();
+ while(functionIter.hasNext()) {
+ FunctionForm form = (FunctionForm) functionIter.next();
+ //System.out.println("\tFunction: " + form.getDisplayString());
+
+ // Lookup this form
+ helpFindForm(form.getName(), form.getArgNames().size());
+ }
+ }
+ }
+
+ @Test public void testFindForm1() {
+ helpFindForm("convert", 2); //$NON-NLS-1$
+ }
+
+ @Test public void testFindForm2() {
+ helpFindForm("locate", 2); //$NON-NLS-1$
+ }
+
+ @Test public void testFindForm3() {
+ helpFindForm("locate", 3); //$NON-NLS-1$
+ }
+
+ @Test public void testFindForm4() {
+ helpFindForm("substring", 2); //$NON-NLS-1$
+ }
+
+ @Test public void testFindForm5() {
+ helpFindForm("substring", 3); //$NON-NLS-1$
+ }
+
+ @Test public void testFindForm6() {
+ helpFindForm("now", 0); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokePlus1() {
+ helpInvokeMethod("+", new Object[] { new Integer(3), new Integer(2) }, new Integer(5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokePlus2() {
+ helpInvokeMethod("+", new Object[] { new Long(3), new Long(2) }, new Long(5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokePlus3() {
+ helpInvokeMethod("+", new Object[] { new Float(3), new Float(2) }, new Float(5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokePlus4() {
+ helpInvokeMethod("+", new Object[] { new Double(3), new Double(2) }, new Double(5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokePlus5() {
+ helpInvokeMethod("+", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokePlus6() {
+ helpInvokeMethod("+", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeMinus1() {
+ helpInvokeMethod("-", new Object[] { new Integer(3), new Integer(2) }, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMinus2() {
+ helpInvokeMethod("-", new Object[] { new Long(3), new Long(2) }, new Long(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMinus3() {
+ helpInvokeMethod("-", new Object[] { new Float(3), new Float(2) }, new Float(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMinus4() {
+ helpInvokeMethod("-", new Object[] { new Double(3), new Double(2) }, new Double(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMinus5() {
+ helpInvokeMethod("-", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeMinus6() {
+ helpInvokeMethod("-", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeMultiply1() {
+ helpInvokeMethod("*", new Object[] { new Integer(3), new Integer(2) }, new Integer(6)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMultiply2() {
+ helpInvokeMethod("*", new Object[] { new Long(3), new Long(2) }, new Long(6)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMultiply3() {
+ helpInvokeMethod("*", new Object[] { new Float(3), new Float(2) }, new Float(6)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMultiply4() {
+ helpInvokeMethod("*", new Object[] { new Double(3), new Double(2) }, new Double(6)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMultiply5() {
+ helpInvokeMethod("*", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("6")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeMultiply6() {
+ helpInvokeMethod("*", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("6")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeDivide1() {
+ helpInvokeMethod("/", new Object[] { new Integer(3), new Integer(2) }, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDivide2() {
+ helpInvokeMethod("/", new Object[] { new Long(3), new Long(2) }, new Long(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDivide3() {
+ helpInvokeMethod("/", new Object[] { new Float(3), new Float(2) }, new Float(1.5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDivide4() {
+ helpInvokeMethod("/", new Object[] { new Double(3), new Double(2) }, new Double(1.5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDivide5() {
+ helpInvokeMethod("/", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ // one digit precision
+ @Test public void testInvokeDivide6() {
+ helpInvokeMethod("/", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeDivide7() throws Exception {
+ helpInvokeMethodFail("/", new Object[] { new Float("3"), new Float("0") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeDivideMod() {
+ helpInvokeMethod("mod", new Object[] { new BigDecimal("3.1"), new BigDecimal("2") }, new BigDecimal("1.1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeAbs1() {
+ helpInvokeMethod("abs", new Object[] { new Integer(-3) }, new Integer(3)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAbs2() {
+ helpInvokeMethod("abs", new Object[] { new Long(-3) }, new Long(3)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAbs3() {
+ helpInvokeMethod("abs", new Object[] { new Float(-3) }, new Float(3)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAbs4() {
+ helpInvokeMethod("abs", new Object[] { new Double(-3) }, new Double(3)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAbs5() {
+ helpInvokeMethod("abs", new Object[] { new BigInteger("-3") }, new BigInteger("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeAbs6() {
+ helpInvokeMethod("abs", new Object[] { new BigDecimal("-3") }, new BigDecimal("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeAcos() {
+ helpInvokeMethod("acos", new Object[] { new Double(0.05) }, new Double(1.5207754699891267)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAsin() {
+ helpInvokeMethod("asin", new Object[] { new Double(0.05) }, new Double(0.050020856805770016)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAtan() {
+ helpInvokeMethod("atan", new Object[] { new Double(0.05) }, new Double(0.049958395721942765)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAtan2() {
+ helpInvokeMethod("atan2", new Object[] { new Double(0.05), new Double(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAtanBigDecimal() {
+ helpInvokeMethod("atan", new Object[] { new BigDecimal(0.05) }, new Double(0.049958395721942765)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAtan2BigDecimal() {
+ helpInvokeMethod("atan2", new Object[] { new BigDecimal(0.05), new BigDecimal(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeCos() {
+ helpInvokeMethod("cos", new Object[] { new Double(1.57) }, new Double(7.963267107332633E-4)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeCot() {
+ helpInvokeMethod("cot", new Object[] { new Double(1.57) }, new Double(7.963269632231926E-4)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDegrees() {
+ helpInvokeMethod("degrees", new Object[] { new Double(1.57) }, new Double(89.95437383553926)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokePI() {
+ helpInvokeMethod("pi", new Object[] { }, new Double(3.141592653589793)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeRadians() {
+ helpInvokeMethod("radians", new Object[] { new Double(89.95437383553926) }, new Double(1.57)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeSin() {
+ helpInvokeMethod("sin", new Object[] { new Double(1.57) }, new Double(0.9999996829318346)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeTan() {
+ helpInvokeMethod("tan", new Object[] { new Double(0.785) }, new Double(0.9992039901050427)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeAscii() {
+ helpInvokeMethod("ascii", new Object[] { " " }, new Integer(32)); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInvokeChr() {
+ helpInvokeMethod("chr", new Object[] { new Integer(32) }, new Character(' ')); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeNvl() {
+ helpInvokeMethod("nvl", new Object[] { new Integer(5), new Integer(10) }, new Integer(5) ); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeConcatOperator() {
+ helpInvokeMethod("||", new Object[] { "a", "b" }, "ab" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeInitcap() {
+ helpInvokeMethod("initcap", new Object[] { "my test\ndata" }, "My Test\nData" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeLpad1() {
+ helpInvokeMethod("lpad", new Object[] { "x", new Integer(3) }, " x" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeLpad2() {
+ helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), "y" }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeRpad1() {
+ helpInvokeMethod("rpad", new Object[] { "x", new Integer(3) }, "x " ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeRpad2() {
+ helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), "y" }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeTranslate() {
+ helpInvokeMethod("translate", new Object[] { "ababcd", "ad", "da" }, "dbdbca" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ }
+
+ @Test public void testFindFunction13() {
+ helpFindFunction("formatTime", new Class[] { T_TIME, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatTime", new Class[] { T_TIME, T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction14() {
+ helpFindFunction("formatDate", new Class[] { T_DATE, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatDate", new Class[] { T_DATE, T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction15() {
+ helpFindFunction("formatTimestamp", new Class[] { T_TIMESTAMP, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatTimestamp", new Class[] { T_TIMESTAMP, T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction16() {
+ helpFindFunction("parseTime", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseTime", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction17() {
+ helpFindFunction("parseDate", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseDate", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction18() {
+ helpFindFunction("parseTimestamp", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseTimestamp", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFunction19() {
+ helpFindFunction("env", new Class[] {T_STRING}, //$NON-NLS-1$
+ helpCreateDescriptor("env", new Class[] {T_STRING})); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeFormatTimestamp1() {
+ helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("mm/dd/yy h:mm a") }, "04/05/03 3:04 AM"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatTimestamp2() {
+ helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("yyyy-mm-dd k:mm a z") }, "2003-04-05 3:04 AM GMT-06:00"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatTimestamp3() {
+ helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("yyyy-mm-dd hh:mm:ss.SSSS") }, "2003-04-05 03:04:12.0000"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatTimestampFail() throws Exception {
+ helpInvokeMethodFail("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("mm/dd/nn h:mm a") }); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeParseTimestamp1() {
+ helpInvokeMethod("parseTimestamp", new Object[] {new String("05 Mar 2003 03:12:23 CST"), new String("dd MMM yyyy HH:mm:ss z") }, TimestampUtil.createTimestamp(103, 2, 5, 3, 12, 23, 0)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeParseTimestamp2() {
+ helpInvokeMethod("parseTimestamp", new Object[] {new String("05 Mar 2003 03:12:23.333"), new String("dd MMM yyyy HH:mm:ss.SSS") }, TimestampUtil.createTimestamp(103, 2, 5, 3, 12, 23, 333*1000000)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testFindFormatInteger() {
+ helpFindFunction("formatInteger", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatInteger", new Class[] { T_INTEGER, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFormatFloat() {
+ helpFindFunction("formatFloat", new Class[] { T_FLOAT, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatFloat", new Class[] { T_FLOAT, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFormatDouble() {
+ helpFindFunction("formatDouble", new Class[] { T_DOUBLE, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatDouble", new Class[] { T_DOUBLE, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFormatLong() {
+ helpFindFunction("formatLong", new Class[] { T_LONG, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatLong", new Class[] { T_LONG, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFormatBigInteger() {
+ helpFindFunction("formatBigInteger", new Class[] { T_BIG_INTEGER, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatBigInteger", new Class[] { T_BIG_INTEGER, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindFormatBigDecimal() {
+ helpFindFunction("formatBigDecimal", new Class[] { T_BIG_DECIMAL, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("formatBigDecimal", new Class[] { T_BIG_DECIMAL, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindParseInteger() {
+ helpFindFunction("parseInteger", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseInteger", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindParseLong() {
+ helpFindFunction("parseLong", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseLong", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindParseDouble() {
+ helpFindFunction("parseDouble", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseDouble", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
+ }
+ @Test public void testFindParseFloat() {
+ helpFindFunction("parseFloat", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseFloat", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindParseBigInteger() {
+ helpFindFunction("parseBigInteger", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseBigInteger", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testFindParseBigDecimal() {
+ helpFindFunction("parseBigDecimal", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
+ helpCreateDescriptor("parseBigDecimal", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeParseInteger() {
+ helpInvokeMethod("parseInteger", new Object[] {new String("-1234"), new String("######")}, new Integer(-1234)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeParseLong() {
+ helpInvokeMethod("parseLong", new Object[] {new String("123456"), new String("######.##")}, new Long(123456)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeParseDouble() {
+ helpInvokeMethod("parseDouble", new Object[] {new String("123456.78"), new String("#####.#")}, new Double(123456.78)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeParseFloat() {
+ helpInvokeMethod("parseFloat", new Object[] {new String("1234.56"), new String("####.###")}, new Float(1234.56)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeParseBigInteger() {
+ helpInvokeMethod("parseBigInteger", new Object[] {new String("12345678"), new String("###,###")}, new BigInteger("12345678")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeParseBigDecimal() {
+ helpInvokeMethod("parseBigDecimal", new Object[] {new String("1234.56"), new String("#####")}, new BigDecimal("1234.56")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeFormatInteger() {
+ helpInvokeMethod("formatInteger", new Object[] {new Integer(-1234), new String("######")}, "-1234"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatLong() {
+ helpInvokeMethod("formatLong", new Object[] {new Long(123456788), new String("##,###,#")}, "1,2,3,4,5,6,7,8,8"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatDouble() {
+ helpInvokeMethod("formatDouble", new Object[] {new Double(1234.67), new String("####.##")}, "1234.67"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatFloat() {
+ helpInvokeMethod("formatFloat", new Object[] {new Float(1234.67), new String("###.###")}, "1234.67"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFormatBigInteger() {
+ helpInvokeMethod("formatBigInteger", new Object[] {new BigInteger("45"), new String("###.###")}, "45"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeFormatBigDecimal() {
+ helpInvokeMethod("formatBigDecimal", new Object[] {new BigDecimal("1234.56"), new String("###.###")}, "1234.56"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokeQuarter1() {
+ // 2003-5-15
+ helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 4, 15)}, new Integer(2)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeQuarter2() {
+ // 2003-5-1
+ helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 3, 31)}, new Integer(2)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeQuarter3() {
+ // 2003-1-31
+ helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 0, 31)}, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeQuarter4() {
+ // 2003-9-30
+ helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 8, 30)}, new Integer(3)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeQuarter5() {
+ // 2003-12-31
+ helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 11, 31)}, new Integer(4)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeQuarter6() {
+ //bad date such as 2003-13-45
+ helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 12, 45)}, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeIfNull() {
+ helpInvokeMethod("ifnull", new Object[] {new Integer(5), new Integer(10)}, new Integer(5)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeLower() {
+ helpInvokeMethod("lower", new Object[] {new String("LOWER")}, new String("lower")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeUpper() {
+ helpInvokeMethod("upper", new Object[] {new String("upper")}, new String("UPPER")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeRepeat() {
+ helpInvokeMethod("repeat", new Object[] {new String("cat"), new Integer(3)}, new String("catcatcat")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeChar() {
+ helpInvokeMethod("char", new Object[] {new Integer(32) }, new Character(' ')); //$NON-NLS-1$
+ }
+
+ /** normal input */
+ @Test public void testInvokeInsert1() {
+ helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(4), //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(2), new String("cat")}, new String("Dowcatown")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /** empty string2 */
+ @Test public void testInvokeInsert2() {
+ helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(4), //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(2), new String("")}, new String("Dowown")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /** empty string1 with start = 1 and length = 0, so result is just string2 */
+ @Test public void testInvokeInsert3() {
+ helpInvokeMethod("insert", new Object[] {new String(""), new Integer(1), //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(0), new String("cat")}, new String("cat")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /** should fail, with start > string1.length() */
+ @Test public void testInvokeInsert4() throws Exception {
+ helpInvokeMethodFail("insert", new Object[] {new String(""), new Integer(2), //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(0), new String("cat")}); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /** should fail, with length > 0 and input string1.length() = 0 */
+ @Test public void testInvokeInsert5() throws Exception {
+ helpInvokeMethodFail("insert", new Object[] {new String(""), new Integer(1), //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(1), new String("cat")}); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /** (length + start) > string1.length(), then just append str2 starting at start position */
+ @Test public void testInvokeInsert6() {
+ helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(7), //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(5), new String("cat")}, new String("Downtocat")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInvokeTimestampAddDate_ignore_case() {
+ helpInvokeMethod("timestampAdd", new Object[] {"sql_TSI_day", //$NON-NLS-1$ //$NON-NLS-2$
+ new Integer(28), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(103, 5, 12).getTime()));
+ }
+
+ /** date + month --> count=18, inteval=month, result should be 2004-11-15 */
+ @Test public void testInvokeTimestampAddDate2() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
+ new Integer(18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 10, 15).getTime()));
+ }
+
+ /** date + month --> count=-18, inteval=month, result should be 2001-11-15 */
+ @Test public void testInvokeTimestampAddDate2a() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
+ new Integer(-18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(101, 10, 15).getTime()));
+ }
+
+ /** date + week --> count=6, inteval=week, result should be 2003-04-03 */
+ @Test public void testInvokeTimestampAddDate3() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
+ new Integer(-6), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(103, 3, 3).getTime()));
+ }
+
+ /** date + quarter --> count=3, inteval=quarter, result should be 2004-2-15 */
+ @Test public void testInvokeTimestampAddDate4() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_QUARTER, //$NON-NLS-1$
+ new Integer(3), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 1, 15).getTime()));
+ }
+
+ /** date + year --> count=-1, inteval=year, result should be 2002-5-15 */
+ @Test public void testInvokeTimestampAddDate5() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_YEAR, //$NON-NLS-1$
+ new Integer(-1), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(102, 4, 15).getTime()));
+ }
+
+ /** time + minute --> count=23, inteval=3, result should be 03:32:12 */
+ @Test public void testInvokeTimestampAddTime1() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MINUTE, //$NON-NLS-1$
+ new Integer(23), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 32, 12).getTime()));
+ }
+
+ /** time + hour --> count=21, inteval=4, result should be 00:09:12 and overflow */
+ @Test public void testInvokeTimestampAddTime2() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
+ new Integer(21), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 0, 9, 12, 0));
+ }
+
+ /** time + hour --> count=2, inteval=4, result should be 01:12:12*/
+ @Test public void testInvokeTimestampAddTime3() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
+ new Integer(2), new Timestamp(TimestampUtil.createTime(23, 12, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 1, 12, 12, 0));
+ }
+
+ /** time + second --> count=23, inteval=2, result should be 03:10:01 */
+ @Test public void testInvokeTimestampAddTime4() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
+ new Integer(49), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 10, 1).getTime()));
+ }
+
+ /** timestamp + second --> count=23, inteval=2, result should be 2003-05-15 03:09:35.100 */
+ @Test public void testInvokeTimestampAddTimestamp1() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
+ new Integer(23), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)},
+ TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 35, 100));
+ }
+
+ /** timestamp + nanos --> count=1, inteval=1, result should be 2003-05-15 03:09:12.000000101 */
+ @Test public void testInvokeTimestampAddTimestamp2() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ new Integer(1), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)},
+ TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 101));
+ }
+
+ /** timestamp + nanos --> count=2100000000, inteval=1, result should be 2003-05-15 03:10:01.100000003
+ * with increase in second and minutes, because second already at 59 sec originally
+ */
+ @Test public void testInvokeTimestampAddTimestamp3() {
+ helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ new Integer(2100000000), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 59, 1)},
+ TimestampUtil.createTimestamp(103, 4, 15, 3, 10, 1, 100000003));
+ }
+
+ /** time --> interval=hour, time1 = 03:04:45, time2= 05:05:36 return = 2 */
+ @Test public void testInvokeTimestampDiffTime1() {
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
+ new Timestamp(TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(TimestampUtil.createTime(5, 5, 36).getTime()) },
+ new Long(2));
+ }
+
+ @Test public void testInvokeTimestampDiffTime1_ignorecase() {
+ helpInvokeMethod("timestampDiff", new Object[] {"SQL_tsi_HOUR", //$NON-NLS-1$ //$NON-NLS-2$
+ new Timestamp(TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(TimestampUtil.createTime(5, 5, 36).getTime()) },
+ new Long(2));
+ }
+
+ /**
+ * timestamp --> interval=week, time1 = 2002-06-21 03:09:35.100,
+ * time2= 2003-05-02 05:19:35.500 return = 45
+ */
+ @Test public void testInvokeTimestampDiffTimestamp1() {
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
+ TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100), TimestampUtil.createTimestamp(103, 4, 2, 5, 19, 35, 500) },
+ new Long(45));
+ }
+
+ /**
+ * timestamp --> interval=frac_second, time1 = 2002-06-21 03:09:35.000000001,
+ * time2= 2002-06-21 03:09:35.100000000 return = 999999999
+ */
+ @Test public void testInvokeTimestampDiffTimestamp2() {
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 1), TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100000000) },
+ new Long(99999999));
+ }
+
+ /**
+ * timestamp --> interval=frac_second, time1 = 2002-06-21 03:09:35.000000002,
+ * time2= 2002-06-22 03:09:35.000000001 return =
+ */
+ @Test public void testInvokeTimestampDiffTimestamp3() {
+ helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
+ TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 2), TimestampUtil.createTimestamp(102, 5, 22, 3, 9, 35, 1) },
+ new Long(86399999999999L));
+ }
+
+ @Test public void testInvokeTimestampCreate1() {
+ helpInvokeMethod("timestampCreate", new Object[] {TimestampUtil.createDate(103, 4, 15), //$NON-NLS-1$
+ TimestampUtil.createTime(23, 59, 59)},
+ TimestampUtil.createTimestamp(103, 4, 15, 23, 59, 59, 0));
+ }
+
+ @Test public void testInvokeBitand() {
+ helpInvokeMethod("bitand", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0x0F0)); //$NON-NLS-1$
+ }
+ @Test public void testInvokeBitor() {
+ helpInvokeMethod("bitor", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0xFFF)); //$NON-NLS-1$
+ }
+ @Test public void testInvokeBitxor() {
+ helpInvokeMethod("bitxor", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0xF0F)); //$NON-NLS-1$
+ }
+ @Test public void testInvokeBitnot() {
+ helpInvokeMethod("bitnot", new Object[] {new Integer(0xF0F)}, new Integer(0xFFFFF0F0)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeRound1() {
+ helpInvokeMethod("round", new Object[] {new Integer(123), new Integer(-1)}, new Integer(120)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeRound2() {
+ helpInvokeMethod("round", new Object[] {new Float(123.456), new Integer(2)}, new Float(123.46)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeRound3() {
+ helpInvokeMethod("round", new Object[] {new Double(123.456), new Integer(2)}, new Double(123.46)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeRound4() {
+ helpInvokeMethod("round", new Object[] {new BigDecimal("123.456"), new Integer(2)}, new BigDecimal("123.460")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ /** defect 10941 */
+ @Test public void testInvokeConvertTime() {
+ helpInvokeMethod("convert", new Object[] {"05:00:00", "time"}, TimestampUtil.createTime(5, 0, 0)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeXpath1() {
+ helpInvokeMethod("xpathValue", //$NON-NLS-1$
+ new Object[] {
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>test</c></b></a>", //$NON-NLS-1$
+ "a/b/c"}, //$NON-NLS-1$
+ "test"); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeXpathWithNill() {
+ helpInvokeMethod("xpathValue", //$NON-NLS-1$
+ new Object[] {
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><b xsi:nil=\"true\"/></a>", //$NON-NLS-1$
+ "//*[local-name()='b' and not(@*[local-name()='nil' and string()='true'])]"}, //$NON-NLS-1$
+ null);
+ }
+
+ @Test public void testInvokeXpathWithNill1() {
+ helpInvokeMethod("xpathValue", //$NON-NLS-1$
+ new Object[] {
+ "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b>value</b></a>", //$NON-NLS-1$
+ "//*[local-name()='b' and not(@*[local-name()='nil' and string()='true'])]"}, //$NON-NLS-1$
+ "value"); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeModifyTimeZone() {
+ Timestamp ts = Timestamp.valueOf("2004-10-03 23:59:59.123"); //$NON-NLS-1$
+ Timestamp out = Timestamp.valueOf("2004-10-03 22:59:59.123"); //$NON-NLS-1$
+ helpInvokeMethod("modifyTimeZone", new Object[] {ts, "America/Chicago", "America/New_York" }, out); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ // TimestampWithTimezone has a static copy the default timezone object which makes this test not execute properly
+ public void defer_testInvokeModifyTimeZoneFromLocal() {
+ Timestamp ts = Timestamp.valueOf("2004-10-03 23:59:59.123"); //$NON-NLS-1$
+ Timestamp out = Timestamp.valueOf("2004-10-03 21:59:59.123"); //$NON-NLS-1$
+ helpInvokeMethod("modifyTimeZone", new Object[] {ts, "America/New_York" }, out); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInvokeRand() throws Exception {
+ helpInvokeMethod("rand", new Object[] {new Integer(100)}, new Double(0.7220096548596434)); //$NON-NLS-1$
+ // this does not actually fail but returns a result
+ assertNotNull(helpInvokeMethod("rand", new Class[] {Integer.class}, new Object[] {null}, null)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeUser() throws Exception {
+ CommandContext c = new CommandContext();
+ c.setUserName("foodude"); //$NON-NLS-1$
+ helpInvokeMethod("user", new Class[] {}, new Object[] {}, c, "foodude"); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testInvokeEnv() throws Exception {
+ CommandContext c = new CommandContext();
+ Properties props = new Properties();
+ props.setProperty("env_test", "env_value"); //$NON-NLS-1$ //$NON-NLS-2$
+ c.setEnvironmentProperties(props);
+ helpInvokeMethod("env", new Class[] {String.class}, new Object[] {"env_test"}, c, "env_value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ helpInvokeMethod("env", new Class[] {String.class}, new Object[] {null}, c, null); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeCommandPayload() throws Exception {
+ CommandContext c = new CommandContext();
+ c.setCommandPayload("payload_too heavy"); //$NON-NLS-1$
+ helpInvokeMethod("commandpayload", new Class[] {}, new Object[] {}, c, "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpInvokeMethod("commandpayload", new Class[] {String.class}, new Object[] {null}, c, null); //$NON-NLS-1$
+ Properties props = new Properties();
+ props.setProperty("payload", "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$
+ c.setCommandPayload(props);
+ helpInvokeMethod("commandpayload", new Class[] {String.class}, new Object[] {"payload"}, c, "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testNullDependent() {
+ FunctionDescriptor actual = library.findFunction("concat2", new Class[] {String.class, String.class}); //$NON-NLS-1$
+ assertTrue(actual.isNullDependent());
+
+ actual = library.findFunction("concat", new Class[] {String.class, String.class}); //$NON-NLS-1$
+ assertFalse(actual.isNullDependent());
+ }
+
+ @Test public void testInvokeCeiling() {
+ helpInvokeMethod("ceiling", new Object[] { new Double("3.14") }, new Double("4")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeFloor() {
+ helpInvokeMethod("floor", new Object[] { new Double("3.14") }, new Double("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeExp() {
+ helpInvokeMethod("exp", new Object[] { new Double("0") }, new Double("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeLog() {
+ helpInvokeMethod("log", new Object[] { new Double("1") }, new Double("0")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeLog10() {
+ helpInvokeMethod("log10", new Object[] { new Double("10") }, new Double("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeLog10Error() throws Exception {
+ helpInvokeMethodFail("log10", new Object[] { new Double("0") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokePower() {
+ helpInvokeMethod("power", new Object[] { new Double("10"), new Double("2") }, new Double("100")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ @Test public void testInvokePower1() {
+ helpInvokeMethod("power", new Object[] { new BigDecimal("10"), new Integer(2) }, new BigDecimal("100")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeSqrt() {
+ helpInvokeMethod("sqrt", new Object[] { new Double("4")}, new Double("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testInvokeDayName() {
+ for (int i = 0; i < FunctionMethods.dayNames.length; i++) {
+ Date time = TimestampUtil.createDate(100, 0, i + 2);
+ helpInvokeMethod("dayName", new Object[] { time }, FunctionMethods.dayNames[i]); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testInvokeDayOfMonth() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("dayOfMonth", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDayOfWeek() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("dayOfWeek", new Object[] { time }, new Integer(7)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeDayOfYear() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 2, 1, 2, 3, 4);
+ helpInvokeMethod("dayOfYear", new Object[] { time }, new Integer(2)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMonth() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("month", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeMonthName() {
+ for (int i = 0; i < FunctionMethods.monthNames.length; i++) {
+ Date time = TimestampUtil.createDate(100, i, 1);
+ helpInvokeMethod("monthName", new Object[] { time }, FunctionMethods.monthNames[i]); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testInvokeMinute() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("minute", new Object[] { time }, new Integer(2)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeSecond() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("second", new Object[] { time }, new Integer(3)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeWeek() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("week", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeYear() {
+ Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
+ helpInvokeMethod("year", new Object[] { time }, new Integer(2000)); //$NON-NLS-1$
+ }
+
+ @Test public void testInvokeCoalesce() {
+ helpInvokeMethod(FunctionLibrary.COALESCE, new Object[] { Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(2) }, Integer.valueOf(0));
+ }
+
+ @Test public void testInvokeCoalesce1() {
+ helpInvokeMethod(FunctionLibrary.COALESCE, new Object[] { null, null}, null);
+ }
+
+ @Test public void testInvokeNull() throws Exception {
+ helpInvokeMethod(SourceSystemFunctions.LTRIM, new Class[] {DataTypeManager.DefaultDataClasses.STRING}, new Object[] { null }, null, null);
+ }
+
+ @Test public void testInvokeNull1() throws Exception {
+ helpInvokeMethod(SourceSystemFunctions.CONCAT, new Class[] {DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING}, new Object[] { null, String.valueOf(1) }, null, null);
+ }
+
+ @Test public void testInvokeXslTransform() throws Exception {
+ CommandContext c = new CommandContext();
+ c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ ClobType result = (ClobType)helpInvokeMethod("xsltransform", new Class[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML},
+ new Object[] {DataTypeManager.transformValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML),
+ DataTypeManager.transformValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"@*|node()\"><xsl:copy><xsl:apply-templates select=\"@*|node()\"/></xsl:copy></xsl:template><xsl:template match=\"Quantity\"/></xsl:stylesheet>", DataTypeManager.DefaultDataClasses.XML)}, c);
+
+ String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
+ assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name></Item></Items></Catalog></Catalogs>", xml);
+ }
+
+ @Test public void testInvokeXmlConcat() throws Exception {
+ CommandContext c = new CommandContext();
+ c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ XMLType result = (XMLType)helpInvokeMethod("xmlconcat", new Class[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML},
+ new Object[] {DataTypeManager.transformValue("<bar/>", DataTypeManager.DefaultDataClasses.XML), DataTypeManager.transformValue("<Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML)}, c);
+
+ String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
+ assertEquals("<bar/><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", xml);
+ }
+
+ @Test public void testInvokeXmlComment() throws Exception {
+ CommandContext c = new CommandContext();
+ c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ XMLType result = (XMLType)helpInvokeMethod("xmlcomment", new Class[] {DataTypeManager.DefaultDataClasses.STRING},
+ new Object[] {"comment"}, c);
+
+ String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
+ assertEquals("<!--comment-->", xml);
+ }
+
+ @Test public void testInvokeXpathQuery() throws Exception {
+ CommandContext c = new CommandContext();
+ c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ XMLType result = (XMLType)helpInvokeMethod("xpathquery", new Class[] {DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING},
+ new Object[] {"<foo><bar>1</bar><bar>2</bar></foo>", "/foo/bar"}, c);
+
+ String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
+ assertEquals("<bar>1</bar><bar>2</bar>", xml);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionMetadataReader.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,100 @@
+/*
+ * 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.function;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.util.List;
+
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.function.metadata.FunctionMetadataReader;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
+
+
+import junit.framework.TestCase;
+
+public class TestFunctionMetadataReader extends TestCase {
+
+ public void testLoadFunctionMethods() throws Exception {
+
+ List<FunctionMethod> fns = FunctionMetadataReader.loadFunctionMethods(new FileInputStream(UnitTestUtil.getTestDataPath()+File.separator+"udf.xmi"));
+
+ assertEquals(3, fns.size());
+
+ for (FunctionMethod m:fns) {
+ if (m.getName().equals("GetSystemProperty")) {
+ assertEquals("MyFunctions", m.getCategory());
+ assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
+ assertEquals("getProperty", m.getInvocationMethod());
+ assertEquals(FunctionMethod.CAN_PUSHDOWN, m.getPushdown());
+ assertEquals(FunctionMethod.DETERMINISTIC, m.getDeterministic());
+ assertNull(m.getDescription());
+
+ assertEquals(1, m.getInputParameterCount());
+ FunctionParameter in = m.getInputParameters()[0];
+ assertEquals("prop", in.getName());
+ assertEquals("string", in.getType());
+ assertNull(in.getDescription());
+
+ assertNotNull(m.getOutputParameter());
+ assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
+ assertEquals("string", m.getOutputParameter().getType());
+
+ }
+ else if (m.getName().equals("getpushdown")) {
+ assertEquals("MyFunctions", m.getCategory());
+ assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
+ assertEquals("getPropertyNoArgs", m.getInvocationMethod());
+ assertEquals(FunctionMethod.CANNOT_PUSHDOWN, m.getPushdown());
+ assertEquals(FunctionMethod.DETERMINISTIC, m.getDeterministic());
+ assertNull(m.getDescription());
+
+ assertEquals(0, m.getInputParameterCount());
+
+ assertNotNull(m.getOutputParameter());
+ assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
+ assertEquals("string", m.getOutputParameter().getType());
+ }
+ else if (m.getName().equals("getxyz")) {
+ assertEquals("MyFunctions", m.getCategory());
+ assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
+ assertEquals("getPropertyNoArgs", m.getInvocationMethod());
+ assertEquals(FunctionMethod.CAN_PUSHDOWN, m.getPushdown());
+ assertEquals(FunctionMethod.NONDETERMINISTIC, m.getDeterministic());
+ assertNull(m.getDescription());
+
+ assertEquals(0, m.getInputParameterCount());
+
+ assertNotNull(m.getOutputParameter());
+ assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
+ assertEquals("string", m.getOutputParameter().getType());
+ }
+ else {
+ fail("unknown method");
+ }
+ }
+
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,161 @@
+/*
+ * 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.function;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.mockito.Mockito;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.logging.LogManager;
+import org.teiid.query.function.FunctionForm;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionMetadataSource;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
+import org.teiid.query.function.metadata.FunctionCategoryConstants;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
+import org.teiid.query.function.source.SystemSource;
+
+
+public class TestFunctionTree extends TestCase {
+
+ // ################################## FRAMEWORK ################################
+
+ public TestFunctionTree(String name) {
+ super(name);
+ }
+
+ // ################################## TEST HELPERS ################################
+
+ // ################################## ACTUAL TESTS ################################
+
+ /**
+ * Walk through all functions by metadata and verify that we can look
+ * each one up by signature
+ */
+ public void testWalkTree() {
+ SystemSource source = new SystemSource();
+ FunctionTree ft = new FunctionTree(source);
+
+ Collection categories = ft.getCategories();
+ Iterator catIter = categories.iterator();
+ while(catIter.hasNext()) {
+ String category = (String) catIter.next();
+ LogManager.logInfo("test", "Category: " + category); //$NON-NLS-1$ //$NON-NLS-2$
+
+ Collection functions = ft.getFunctionForms(category);
+ Iterator functionIter = functions.iterator();
+ while(functionIter.hasNext()) {
+ FunctionForm form = (FunctionForm) functionIter.next();
+ LogManager.logInfo("test", "\tFunction: " + form.getDisplayString()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+
+ /**
+ * Test what happens when a function is loaded that does not have a class in the
+ * classpath. This *should* be ok as long as the function is not invoked.
+ */
+ public void testUnloadableFunction() {
+ // Create dummy source
+ FunctionMetadataSource dummySource = new FunctionMetadataSource() {
+ public Collection getFunctionMethods() {
+ // Build dummy method
+ FunctionMethod method = new FunctionMethod(
+ "dummy", null, "no category", "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new FunctionParameter[0],
+ new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) ); //$NON-NLS-1$
+
+ // Wrap method in a list
+ List methods = new ArrayList();
+ methods.add(method);
+ return methods;
+ }
+
+ public Class getInvocationClass(String className) throws ClassNotFoundException {
+ throw new ClassNotFoundException("Could not find class " + className); //$NON-NLS-1$
+ }
+ };
+
+ new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(dummySource.getFunctionMethods())));
+ }
+
+ public void testNullCategory() {
+ FunctionMetadataSource fms = Mockito.mock(FunctionMetadataSource.class);
+ Mockito.stub(fms.getFunctionMethods()).toReturn(Arrays.asList(new FunctionMethod(
+ "dummy", null, null, FunctionMethod.MUST_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new FunctionParameter[0],
+ new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) //$NON-NLS-1$
+ )));
+ FunctionTree ft = new FunctionTree(fms);
+ assertEquals(1, ft.getFunctionForms(FunctionCategoryConstants.MISCELLANEOUS).size());
+ }
+
+/*
+
+//DEBUGGING CODE - this will print out the tree root in readable form
+//(This code will either have to be pasted in to FunctionTree class, or
+//somehow the Map treeRoot must be gotten from the FunctionTree)
+
+ private static void debugPrintTreeRoot(Map treeRoot){
+ System.out.println("<!><!><!><!><!><!><!><!><!><!><!><!>");
+ System.out.println("FunctionTree treeRoot");
+ StringBuffer s = new StringBuffer();
+ debugPrintNode(treeRoot, 0, s);
+ System.out.println(s.toString());
+ System.out.println("<!><!><!><!><!><!><!><!><!><!><!><!>");
+ }
+
+ private static void debugPrintNode(Map node, int depth, StringBuffer s){
+ Iterator i = node.entrySet().iterator();
+ Map.Entry anEntry = null;
+ while(i.hasNext()) {
+ anEntry = (Map.Entry)i.next();
+ appendLine(s, depth, "Key: " + anEntry.getKey());
+ Object value = anEntry.getValue();
+ if (value instanceof Map){
+ s.append(" Map... ");
+ debugPrintNode((Map)value, depth + 1, s);
+ } else {
+ s.append(" Value: " + value);
+ }
+ }
+ }
+
+ private static void appendLine(StringBuffer s, int depth, String value){
+ s.append("\n");
+ for (int i = 0; i< depth; i++){
+ s.append(" ");
+ }
+ s.append(value);
+ }
+*/
+}
Copied: trunk/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestResolvedFunctions.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,97 @@
+/*
+ * 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.function;
+
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+import junit.framework.TestCase;
+
+
+public class TestResolvedFunctions extends TestCase {
+
+ public void testPowerIntegers() throws Exception {
+
+ String sql = "power(10, 10)"; //$NON-NLS-1$
+
+ //BigInteger is a closer match here since the second argument matches
+ assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, getFunctionResult(sql).getClass());
+ }
+
+ public void testPowerDoubles() throws Exception {
+
+ String sql = "power(10.01, 10.01)"; //$NON-NLS-1$
+
+ assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
+ }
+
+ public void testPowerFloats() throws Exception {
+
+ String sql = "power(convert(10.01, float), convert(10.01, float))"; //$NON-NLS-1$
+
+ //since the second argument cannot be converted to an integer, the result is a double
+ assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
+ }
+
+ public void testPowerBigInteger() throws Exception {
+
+ String sql = "power(convert(10.01, BigInteger), 10)"; //$NON-NLS-1$
+
+ assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, getFunctionResult(sql).getClass());
+ }
+
+ //there should only be one signature for ceiling. The float argument will be converted to a double
+ public void testCeilingFloat() throws Exception {
+
+ String sql = "ceiling(convert(10.01, float))"; //$NON-NLS-1$
+
+ assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
+ }
+
+ //same as above
+ public void testFloorFloat() throws Exception {
+
+ String sql = "floor(convert(10.01, float))"; //$NON-NLS-1$
+
+ assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
+ }
+
+ private Object getFunctionResult(String sql) throws QueryParserException,
+ ExpressionEvaluationException,
+ BlockedException,
+ TeiidComponentException, QueryResolverException {
+ Expression expr = QueryParser.getQueryParser().parseExpression(sql);
+ ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1Cached());
+ return Evaluator.evaluate(expr);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/function/metadata (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/metadata)
Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/metadata/TestFunctionMetadataValidator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMetadataValidator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
+import org.teiid.api.exception.query.FunctionMetadataException;
+import org.teiid.query.function.metadata.FunctionMetadataValidator;
+import org.teiid.query.function.metadata.FunctionMethod;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.query.FunctionMetadataException;
public class TestFunctionMetadataValidator extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/metadata/TestFunctionMethod.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.function.metadata.FunctionCategoryConstants;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestFunctionMethod extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/metadata/TestSystemSource.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
+import org.teiid.query.function.metadata.FunctionMetadataValidator;
+import org.teiid.query.function.source.*;
+import org.teiid.query.report.*;
+
import junit.framework.*;
-import com.metamatrix.query.function.source.*;
-import com.metamatrix.query.report.*;
public class TestSystemSource extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/function/source (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/function/source)
Modified: trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/source/TestXMLSystemFunctions.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/function/source/TestXMLSystemFunctions.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.source;
+package org.teiid.query.function.source;
import static org.junit.Assert.*;
@@ -38,12 +38,13 @@
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.FileUtil;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.function.source.XMLSystemFunctions;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.util.FileUtil;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestXMLSystemFunctions {
Copied: trunk/engine/src/test/java/org/teiid/query/mapping/xml (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/mapping/xml)
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingAttribute.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingAttribute.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingAttribute.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingChoiceNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingChoiceNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingChoiceNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
+import org.teiid.query.mapping.xml.MappingAllNode;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingDocument.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingDocument.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingDocument.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingElement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingElement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,10 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.List;
+import org.teiid.query.mapping.xml.MappingAllNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCommentNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.Namespace;
+
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingLoader.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingLoader.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingLoader.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.ByteArrayInputStream;
import java.io.File;
@@ -28,9 +28,22 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingException;
+import org.teiid.query.mapping.xml.MappingLoader;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.Namespace;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* <p>Test cases for {@link MappingLoader} class. </p>
@@ -98,7 +111,7 @@
* <p>Utility to get an input stream to a file in the app's classpath. </p>
*/
private static InputStream getResourceStream( Class appClass, String filename ) {
- return appClass.getClassLoader().getResourceAsStream(filename);
+ return appClass.getResourceAsStream(filename);
}
// =========================================================================
@@ -148,7 +161,7 @@
* Positive test -- load from file in app classpath.
*/
public void testPos_LoadFromStream() {
- helpLoad( "com/metamatrix/query/mapping/xml/" + MAPPING_FILE, true, VALID ); //$NON-NLS-1$
+ helpLoad( MAPPING_FILE, true, VALID );
}
/**
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingOutputter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingOutputter.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.ByteArrayInputStream;
import java.io.IOException;
@@ -29,6 +29,16 @@
import java.io.StringWriter;
import java.util.ArrayList;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingException;
+import org.teiid.query.mapping.xml.MappingLoader;
+import org.teiid.query.mapping.xml.MappingOutputter;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+
import junit.framework.TestCase;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingRecursiveElement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestMappingRecursiveElement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestMappingRecursiveElement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestNamespace.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/TestNamespace.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/mapping/xml/TestNamespace.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.Namespace;
+
import junit.framework.TestCase;
public class TestNamespace extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,65 @@
+/*
+ * 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.optimizer;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import org.teiid.query.function.FunctionMetadataSource;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
+
+
+public class FakeFunctionMetadataSource implements FunctionMetadataSource {
+
+ public Collection getFunctionMethods() {
+ List methods = new ArrayList();
+ methods.add(new FunctionMethod("xyz", "", "misc", FunctionMethod.MUST_PUSHDOWN, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ FakeFunctionMetadataSource.class.getName(), "xyz", //$NON-NLS-1$
+ new FunctionParameter[0],
+ new FunctionParameter("out", "integer"))); //$NON-NLS-1$ //$NON-NLS-2$
+
+ FunctionParameter p1 = new FunctionParameter("astring", "string"); //$NON-NLS-1$ //$NON-NLS-2$
+ FunctionParameter result = new FunctionParameter("trimstring", "string"); //$NON-NLS-1$ //$NON-NLS-2$
+ FunctionMethod method = new FunctionMethod("MYRTRIM", "", "", FakeFunctionMetadataSource.class.getName(), "myrtrim", new FunctionParameter[] {p1}, result); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ method.setPushdown(FunctionMethod.CAN_PUSHDOWN);
+ methods.add(method);
+ return methods;
+ }
+
+ public Class getInvocationClass(String className) throws ClassNotFoundException {
+ return Class.forName(className);
+ }
+
+ // dummy function
+ public static Object xyz() {
+ return null;
+ }
+
+ /** defect 15348*/
+ public static Object myrtrim(Object astring) {
+ String string = (String)astring;
+ return string.trim();
+ }
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/InlineViewCase.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/InlineViewCase.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/InlineViewCase.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/InlineViewCase.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,45 @@
+/*
+ * 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.optimizer;
+
+import java.util.List;
+import java.util.Set;
+
+public class InlineViewCase {
+ public String name;
+ public String userQuery;
+ public String optimizedQuery;
+ public Set<String> sourceQueries;
+ public List<List<Object>> expectedResults;
+
+ public String getFullyQualifiedQuery() {
+ return optimizedQuery;
+ }
+ public InlineViewCase(String name, String userQuery, String optimizedQuery, Set<String> sourceQueries, List expectedResults) {
+ this.name = name;
+ this.userQuery = userQuery;
+ this.optimizedQuery = optimizedQuery;
+ this.sourceQueries = sourceQueries;
+ this.expectedResults = expectedResults;
+ }
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestAccessPatterns.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,294 @@
+/*
+ * 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.optimizer;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.validator.TestValidator;
+
+
+
+public class TestAccessPatterns {
+
+ /**
+ * The virtual access patterns should get satisfied
+ */
+ @Test public void testVirtualAccessPatternPassing() {
+ String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1 and e1='2'"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT test.\"group\".e0, test.\"group\".e2 FROM test.\"group\" WHERE (test.\"group\".e0 = 1) AND (test.\"group\".e1 = '2')"}); //$NON-NLS-1$
+ }
+
+ @Test public void testVirtualAccessPatternPassing1() {
+ String sql = "delete from vm1.g37 where e1 = 1"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
+ }
+
+ @Test public void testVirtualAccessPatternFailing() {
+ String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testVirtualAccessPatternFailing1() {
+ String sql = "delete from vm1.g37"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testAccessPattern1() throws Exception {
+ String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2'"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql,
+ TestValidator.exampleMetadata4(),
+ new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+ }
+
+ @Test public void testAccessPattern2() {
+ String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testAccessPattern3() {
+ String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e2='2'"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testAccessPattern4() throws Exception {
+ String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testAccessPattern5() {
+ String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testAccessPattern6() {
+ String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT e1, e0, e2 FROM test.\"group\""}); //$NON-NLS-1$
+ }
+
+ @Test public void testAccessPattern7() {
+ String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testAccessPattern8() {
+ String sql = "SELECT e0, e2 FROM vTest.vGroup"; //$NON-NLS-1$
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ /**
+ * Tests two access nodes, each with access patterns, but one already
+ * satisfied by user criteria - the other should be made dependent
+ */
+ @Test public void testNodesBothHaveAccessPatterns1() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g2 where pm4.g2.e5 = 'abc' and pm4.g1.e1 = pm4.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Tests two access nodes, each with access patterns, but one already
+ * satisfied by user criteria - the other should be made dependent
+ * (same query written slightly different).
+ */
+ @Test public void testNodesBothHaveAccessPatterns1a() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g2, pm4.g1 where pm4.g2.e1 = pm4.g1.e1 and pm4.g2.e5 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Self join - tests that both access nodes are satisfied by the select
+ * criteria (therefore merge join should be used)
+ */
+ @Test public void testSelfJoinAccessPatterns() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g1 as g1A where pm4.g1.e1 = 'abc' and g1A.e1 = 'abc' and pm4.g1.e2 = g1A.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g1A.e2 FROM pm4.g1 AS g1A WHERE g1A.e1 = 'abc'", "SELECT pm4.g1.e2, pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testAccessPatternsFails() {
+ TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2, pm4.g2 as g2A where pm4.g2.e2 = 123 and pm4.g2.e1 = g2A.e5", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, null, null,
+ TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testAccessPatternsFails2() {
+ TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, null, null,
+ TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testUnionWithAccessPatternFails() {
+ TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1 where pm4.g1.e2 = 1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testUnionWithAccessPatternFails2() {
+ TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ @Test public void testUnionWithAccessPattern() {
+ TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testUnionWithAccessPattern2() {
+ TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc' and pm4.g1.e2 = 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE (pm4.g1.e1 = 'abc') AND (pm4.g1.e2 = 1)" }); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testAccessPatternPartialMatch() throws Exception {
+ TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 and pm4.g2.e2 = 123", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ new String[] { "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE (g_0.e2 = 123) AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Similar to the query above, except the OR instead of an AND produces a
+ * completely different query plan which can't satisfy the access pattern.
+ * @see #testAccessPatternPartialMatch
+ */
+ @Test public void testAccessPatternFails3() {
+ TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 or pm4.g2.e2 = 123", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, null, null,
+ TestOptimizer.SHOULD_FAIL);
+ }
+
+ /**
+ * Access patterns on models that support joins requires that the access patterns are satisfied prior to
+ * RulePlanJoins
+ */
+ @Test public void testAccessPatternsGroupsInSameModelFails() {
+ TestOptimizer.helpPlan("select pm5.g1.e1 from pm5.g1, pm5.g2 where pm5.g1.e1 = pm5.g2.e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, null, null, TestOptimizer.SHOULD_FAIL);
+ }
+
+ // ==================================================================================
+ // ACCESS PATTERNS
+ // ==================================================================================
+
+ @Test public void testPushingCriteriaThroughFrameAccessPattern0() {
+ TestOptimizer.helpPlan("select * from vm1.g9 where vm1.g9.e1='abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ /**
+ * pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
+ */
+ @Test public void testPushingCriteriaThroughFrameAccessPattern1() {
+ TestOptimizer.helpPlan("select * from vm1.g1, vm1.g10 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g10.e1", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
+ null, TestOptimizer.SHOULD_FAIL );
+ }
+
+ @Test public void testPushingCriteriaThroughFrameAccessPattern2() {
+ TestOptimizer.helpPlan("select e1 from vm1.g11 where vm1.g11.e1='abc' and vm1.g11.e2=123", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm4.g2.e1 FROM pm4.g2 WHERE (pm4.g2.e1 = 'abc') AND (pm4.g2.e2 = 123)" }); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughFrameAccessPattern3() {
+ TestOptimizer.helpPlan("select * from vm1.g1, vm1.g9 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g9.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'"} ); //$NON-NLS-1$
+ }
+
+ /**
+ * pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
+ */
+ @Test public void testPushingCriteriaThroughFrameAccessPattern4() {
+ TestOptimizer.helpPlan("select * from vm1.g10 where vm1.g10.e1='abc'", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
+ null, TestOptimizer.SHOULD_FAIL );
+ }
+
+ /**
+ * TODO: in this case we should perform a criteria optimization to create set criteria
+ */
+ @Test public void testCase6425() {
+ String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e1 = '2'"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] {"SELECT e1 FROM pm4.g1 WHERE (e1 = '1') OR (e1 = '2')"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase6425_2() {
+ String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR (e1 = '2' AND e2 = 3)"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] {"SELECT e1 FROM pm4.g1 WHERE (e1 = '1') OR ((e1 = '2') AND (e2 = 3))"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase6425_4() throws Exception {
+ String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e2 = '2'"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ TestOptimizer.helpPlan(sql, metadata, null, TestOptimizer.ComparisonMode.FAILED_PLANNING);
+ }
+
+ /*
+ * Criteria was preventing rule choose dependent from creating the appropriate dependent join
+ */
+ @Test public void testMultiAccessPatternWithCriteria() throws Exception {
+ String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' "; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ TestOptimizer.helpPlan(sql, metadata,
+ new String[] {
+ "SELECT g_0.e2, g_0.e1 FROM pm5.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", //$NON-NLS-1$
+ "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$
+ "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)" }, TestOptimizer.getGenericFinder(false), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestAggregatePushdown.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,840 @@
+/*
+ * 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.optimizer;
+
+import static org.teiid.query.optimizer.TestOptimizer.*;
+
+import org.junit.Test;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestAggregatePushdown {
+
+ public static BasicSourceCapabilities getAggregateCapabilities() {
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ return caps;
+ }
+
+ public static CapabilitiesFinder getAggregatesFinder() {
+ return new DefaultCapabilitiesFinder(getAggregateCapabilities());
+ }
+
+ @Test public void testCase6327() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ String sql = "SELECT a12.intkey AS REGION_NBR, SUM(a11.intnum) AS WJXBFS1 FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey WHERE a11.stringkey = 0 GROUP BY a12.intkey"; //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT SUM(a11.intnum) FROM bqt1.smalla AS a11 WHERE a11.stringkey = '0' HAVING COUNT(*) > 0", "SELECT a12.intkey FROM bqt2.smalla AS a12 WHERE a12.stringkey = '0' group by a12.intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Note that intnum is retrieved from each source
+ *
+ * Note also that this test shows that the max aggregate is not placed on the bqt2 query since it would be on one of the group by expressions
+ */
+ @Test public void testAggregateOfJoinExpression() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ String sql = "SELECT a12.intkey, MAX(a12.stringkey), SUM(a11.intnum+a12.intnum) FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey GROUP BY a12.intkey"; //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_0.stringkey, g_0.intkey, g_0.intnum FROM bqt2.smalla AS g_0 GROUP BY g_0.stringkey, g_0.intkey, g_0.intnum", "SELECT g_0.stringkey, g_0.intnum FROM bqt1.smalla AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Note that even though this grouping is join invariant, we still do not remove the top level group by
+ * since we are not checking the uniqueness of the x side join expressions
+ */
+ @Test public void testInvariantAggregate() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ String sql = "SELECT max(y.e2) from pm1.g1 x, pm2.g1 y where x.e3 = y.e3 group by y.e3"; //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT g_0.e3 FROM pm1.g1 AS g_0", "SELECT g_0.e3, MAX(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e3"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test of an aggregate nested in an expression symbol
+ */
+ @Test public void testCase6211() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ String sql = "select sum(a11.intnum) Profit, (sum(a11.intnum) / sum(a11.floatnum)) WJXBFS2 from bqt1.smalla a11 join bqt2.smallb a12 on a11.intkey=a12.intkey group by a12.intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_0.intkey, SUM(g_0.intnum), SUM(g_0.floatnum) FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey", "SELECT g_0.intkey FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Note that until we can test the other side cardinality, we cannot fully push the group node
+ */
+ @Test public void testAggregatePushdown1() throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleAggregatesCached();
+ String sql = "SELECT o_dealerid, o_productid, sum(o_amount) FROM m1.order, m1.dealer, m2.product " + //$NON-NLS-1$
+ "WHERE o_dealerid=d_dealerid AND o_productid=p_productid AND d_state = 'CA' AND p_divid = 100 " + //$NON-NLS-1$
+ "GROUP BY o_dealerid, o_productid"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, getAggregatesFinder(),
+ new String[] {"SELECT DISTINCT g_0.p_productid AS c_0 FROM m2.product AS g_0 WHERE g_0.p_divid = 100 ORDER BY c_0", "SELECT DISTINCT g_0.o_productid AS c_0, g_0.o_dealerid AS c_1, SUM(g_0.o_amount) AS c_2 FROM m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.o_dealerid = g_1.d_dealerid) AND (g_1.d_state = 'CA') AND (g_0.o_productid IN (<dependent values>)) GROUP BY g_0.o_productid, g_0.o_dealerid ORDER BY c_0"}, //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testAggregatePushdown2() throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleAggregatesCached();
+ String sql = "SELECT o_dealerid, o_productid, sum(o_amount) FROM m1.order, m1.dealer, m2.product " + //$NON-NLS-1$
+ "WHERE o_dealerid=d_dealerid AND o_productid=p_productid AND d_state = 'CA' AND p_divid = 100 " + //$NON-NLS-1$
+ "GROUP BY o_dealerid, o_productid having max(o_amount) < 100"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, getAggregatesFinder(),
+ new String[] {"SELECT DISTINCT g_0.p_productid AS c_0 FROM m2.product AS g_0 WHERE g_0.p_divid = 100 ORDER BY c_0", "SELECT DISTINCT g_0.o_productid AS c_0, g_0.o_dealerid AS c_1, MAX(g_0.o_amount) AS c_2, SUM(g_0.o_amount) AS c_3 FROM m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.o_dealerid = g_1.d_dealerid) AND (g_1.d_state = 'CA') AND (g_0.o_productid IN (<dependent values>)) GROUP BY g_0.o_productid, g_0.o_dealerid ORDER BY c_0"}, //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Average requires the creation of staged sum and count aggregates
+ */
+ @Test public void testAvgAggregate() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ String sql = "SELECT avg(y.e2) from pm1.g1 x, pm2.g1 y where x.e3 = y.e3 group by x.e2, y.e1"; //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1, SUM(g_0.e2), COUNT(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e3, g_0.e1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCountAggregate() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ String sql = "SELECT count(y.e2) from pm1.g1 x, pm2.g1 y where x.e3 = y.e3 group by x.e2, y.e1"; //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1, COUNT(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e3, g_0.e1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOuterJoinPreventsPushdown() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ String sql = "SELECT count(y.e2) from pm1.g1 x left outer join pm2.g1 y on x.e3 = y.e3 group by x.e2, y.e1"; //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0", "SELECT g_0.e3, g_0.e1, g_0.e2 FROM pm2.g1 AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test to ensure count(*) isn't mistakenly pushed to either side, but that
+ * grouping can still be.
+ */
+ @Test public void testCase5724() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "select count(*), a.intnum from bqt1.smalla as a, bqt2.smallb as b where a.intkey = b.intkey group by a.intnum", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT a.intkey, a.intnum FROM bqt1.smalla AS a group by a.intkey, a.intnum", "SELECT b.intkey FROM bqt2.smallb AS b"}, //$NON-NLS-1$ //$NON-NLS-2$
+ true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCase6210() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ caps.setFunctionSupport("/", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ String sql = "select a11.intkey ITEM_ID, sum(a11.intnum) WJXBFS1 from bqt1.smalla a11 join bqt2.smalla a12 on (a11.stringkey = a12.stringkey) join bqt2.smallb a13 on (a11.intkey = a13.intkey) where a13.intnum in (10) group by a11.intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_0.stringkey FROM bqt2.smalla AS g_0", "SELECT g_0.stringkey, g_0.intkey, SUM(g_0.intnum) FROM bqt1.smalla AS g_0 GROUP BY g_0.stringkey, g_0.intkey", "SELECT g_0.intkey FROM bqt2.smallb AS g_0 WHERE g_0.intnum = 10"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testNoGroupAggregatePushdown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, false);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "select count(*) from bqt1.smalla", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT count(*) from bqt1.smalla"}, //$NON-NLS-1$
+ true);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testNoHavingAggregate() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT COUNT(g_0.intkey), g_0.stringkey, MAX(g_0.intkey) FROM bqt1.smalla AS g_0 GROUP BY g_0.stringkey"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testHavingCriteriaPushDown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select X.e1 FROM vm1.g1 X group by X.e1 having X.e1 = 1 and sum(X.e2) = 2", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = '1'"}, true); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testBusObjQuestion1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
+
+ capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
+
+ String sql = "SELECT Q1.S, Q2.C, Q1.PRODUCT, Q1.REGION AS Q1R, Q2.REGION AS Q2R FROM " + //$NON-NLS-1$
+ "(SELECT SUM(SALES) AS S, REGION, PRODUCT FROM DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT) Q1 " + //$NON-NLS-1$
+ "FULL OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT SUM(COSTS) AS C, REGION FROM ORACLE_TABLE WHERE \"YEAR\" = '1999' GROUP BY REGION) Q2 " + //$NON-NLS-1$
+ "ON Q1.REGION = Q2.REGION"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT REGION, SUM(SALES), PRODUCT FROM db2model.DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT", //$NON-NLS-1$
+ "SELECT REGION, SUM(COSTS) FROM oraclemodel.Oracle_table WHERE \"YEAR\" = '1999' GROUP BY REGION"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testBusObjQuestion2() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
+
+ capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
+
+ String sql = "SELECT SUM(F.SALES), G.REGION, T.YEAR " + //$NON-NLS-1$
+ "FROM SALES F, GEOGRAPHY G, msModel.TIME T " + //$NON-NLS-1$
+ "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + //$NON-NLS-1$
+ "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + //$NON-NLS-1$
+ "GROUP BY G.REGION, T.YEAR"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
+ "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
+ "SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testBusObjQuestion2Hint() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
+
+ capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
+
+ String sql = "SELECT SUM(F.SALES), G.REGION, T.YEAR " + //$NON-NLS-1$
+ "FROM SALES F MAKEDEP, GEOGRAPHY G, msModel.TIME T " + //$NON-NLS-1$
+ "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + //$NON-NLS-1$
+ "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + //$NON-NLS-1$
+ "GROUP BY G.REGION, T.YEAR"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
+ "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
+ "SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testBusObjQuestion2HintVariation() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
+
+ capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
+
+ String sql = "SELECT SUM(F.SALES), G.REGION, T.YEAR " + //$NON-NLS-1$
+ "FROM SALES F MAKEDEP, GEOGRAPHY2 G, msModel.TIME T " + //$NON-NLS-1$
+ "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + //$NON-NLS-1$
+ "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + //$NON-NLS-1$
+ "GROUP BY G.REGION, T.YEAR"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_1.REGION AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.\"MONTH\" IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_1.REGION ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.\"MONTH\" AS c_0, g_0.\"YEAR\" AS c_1 FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999' ORDER BY c_0"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testBusObjQuestion3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
+
+ capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
+
+ String sql = "select sum(c0), sum(b0), c1, b2 FROM db2Table, OraTable where c2=b2 group by c1, b2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT c2, c1, c0 FROM db2model.DB2TABLE", //$NON-NLS-1$
+ "SELECT DISTINCT b2, sum(b0) FROM oraclemodel.OraTable GROUP BY b2 ORDER BY b2"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushDownOverUnion() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select e1, max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm1.g2) y group by e1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT v_0.c_0, MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0", //$NON-NLS-1$
+ "SELECT v_0.c_0, MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g2 AS g_0) AS v_0 GROUP BY v_0.c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testPushDownOverUnion1() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm1.g2) z", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT MAX(v_0.c_0) FROM (SELECT g_0.e2 AS c_0 FROM pm1.g2 AS g_0) AS v_0 HAVING COUNT(*) > 0", //$NON-NLS-1$
+ "SELECT MAX(v_0.c_0) FROM (SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0) AS v_0 HAVING COUNT(*) > 0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ /**
+ * We won't do the pushdown here since the aggregate depends upon the cardinality
+ */
+ @Test public void testPushDownOverUnion2() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select count(e2) from (select e1, e2 from pm1.g1 union select e1, e2 from pm1.g2) z", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT g_0.e1, g_0.e2 FROM pm1.g2 AS g_0", //$NON-NLS-1$
+ "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testPushDownOverUnionMixed() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getAggregateCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm2.g2) z", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT MAX(v_0.c_0) FROM (SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0) AS v_0 HAVING COUNT(*) > 0", //$NON-NLS-1$
+ "SELECT g_0.e2 FROM pm2.g2 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAnsiJoinPushdown.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,57 @@
+/*
+ * 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.optimizer;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestAnsiJoinPushdown {
+
+ /**
+ * See {@link TestOptimizer.testPushMultiGroupCriteria}
+ *
+ * Notice that the non-join criteria is still in the on clause.
+ */
+ @Test public void testAnsiInnerJoin() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, true);
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "select pm2.g1.e1 from pm2.g1, pm2.g2 where pm2.g1.e1 = pm2.g2.e1 and (pm2.g1.e2 = 1 OR pm2.g2.e2 = 2) and pm2.g2.e3 = 1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null,
+ capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 INNER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND ((g_0.e2 = 1) OR (g_1.e2 = 2)) WHERE g_1.e3 = TRUE" }, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestAnsiJoinPushdown.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestComparableMetadataPushdown.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestComparableMetadataPushdown.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestComparableMetadataPushdown.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestComparableMetadataPushdown.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,78 @@
+/*
+ * 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.optimizer;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.validator.TestValidator;
+
+
+public class TestComparableMetadataPushdown {
+
+ @Test public void testCantPushSort() throws Exception {
+ String sql = "select e3, e2 from test.group order by e3, e2"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ capFinder.addCapabilities("test", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
+ new String[] {"SELECT g_0.e3, g_0.e2 FROM test.\"group\" AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCantPushGroupBy() throws Exception {
+ String sql = "select e3, e2 from test.group group by e3, e2"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ capFinder.addCapabilities("test", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
+ new String[] {"SELECT g_0.e3, g_0.e2 FROM test.\"group\" AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCantPushDup() throws Exception {
+ String sql = "select distinct e3, e2 from test.group"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ capFinder.addCapabilities("test", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
+ new String[] {"SELECT g_0.e3, g_0.e2 FROM test.\"group\" AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCantPushSetOp() throws Exception {
+ String sql = "select e3, e2 from test.group union select e0, e1 from test.group2"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ capFinder.addCapabilities("test", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
+ new String[] {"SELECT test.\"group\".e3, test.\"group\".e2 FROM test.\"group\"", "SELECT test.group2.e0, test.group2.e1 FROM test.group2"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestComparableMetadataPushdown.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestDependentJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,811 @@
+/*
+ * 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.optimizer;
+
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import junit.framework.TestCase;
+
+import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.RuleChooseDependent;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.DependentAccessNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+
+
+
+public class TestDependentJoins extends TestCase {
+
+ static void checkDependentGroups(ProcessorPlan plan, String[] groups) {
+ if(! (plan instanceof RelationalPlan)) {
+ return;
+ }
+
+ // Collect all the group names (uppercase) for all the dependent groups in the plan
+ Set depGroups = new HashSet();
+ getDependentGroups(((RelationalPlan)plan).getRootNode(), depGroups);
+
+ // Check that all the expected groups exist in depGroups
+ Set expectedGroups = new HashSet();
+ for(int i=0; i<groups.length; i++) {
+ expectedGroups.add(groups[i].toUpperCase());
+ }
+
+ assertEquals("Expected groups were not made dependent", expectedGroups, depGroups); //$NON-NLS-1$
+ }
+
+ static void getDependentGroups(RelationalNode node, Set depGroups) {
+ if(node instanceof DependentAccessNode) {
+ DependentAccessNode accessNode = (DependentAccessNode)node;
+ Command depCommand = accessNode.getCommand();
+ Collection groupSymbols = GroupCollectorVisitor.getGroups(depCommand, true);
+ Iterator groupIter = groupSymbols.iterator();
+ while(groupIter.hasNext()) {
+ GroupSymbol group = (GroupSymbol) groupIter.next();
+ depGroups.add(group.getName().toUpperCase());
+ }
+ }
+
+ // Recurse through children
+ RelationalNode[] children = node.getChildren();
+ for(int i=0; i<children.length; i++) {
+ if(children[i] != null) {
+ getDependentGroups(node.getChildren()[i], depGroups);
+ }
+ }
+ }
+
+ private void checkNotDependentGroups(ProcessorPlan plan, String[] groups) {
+ if(! (plan instanceof RelationalPlan)) {
+ return;
+ }
+
+ // Collect all the group names (uppercase) for all the dependent groups in the plan
+ Set notDepGroups = new HashSet();
+ getNotDependentGroups(((RelationalPlan)plan).getRootNode(), notDepGroups);
+
+ // Check that all the expected groups exist in depGroups
+ Set expectedGroups = new HashSet();
+ for(int i=0; i<groups.length; i++) {
+ expectedGroups.add(groups[i].toUpperCase());
+ }
+
+ assertEquals("Expected groups were made dependent", expectedGroups, notDepGroups); //$NON-NLS-1$
+ }
+
+ private void getNotDependentGroups(RelationalNode node, Set notDepGroups) {
+ if(node instanceof AccessNode && !(node instanceof DependentAccessNode)) {
+ AccessNode accessNode = (AccessNode)node;
+ Command depCommand = accessNode.getCommand();
+ Collection groupSymbols = GroupCollectorVisitor.getGroups(depCommand, true);
+ Iterator groupIter = groupSymbols.iterator();
+ while(groupIter.hasNext()) {
+ GroupSymbol group = (GroupSymbol) groupIter.next();
+ notDepGroups.add(group.getName().toUpperCase());
+ }
+ }
+
+ // Recurse through children
+ RelationalNode[] children = node.getChildren();
+ for(int i=0; i<children.length; i++) {
+ if(children[i] != null) {
+ getNotDependentGroups(node.getChildren()[i], notDepGroups);
+ }
+ }
+ }
+
+ public void testOptionMakeDep1() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1 option makedep pm2.g1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ checkDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
+ checkNotDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testOptionMakeDep2() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1, pm2.g1.e1 from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
+ checkNotDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testDepJoinHintForceLeft() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g1", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g2 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
+ }
+
+ public void testDepJoinHintForceRight() throws Exception {
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g2", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
+ }
+
+ public void testDepJoinMultiGroupBaseline() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select vm1.g4.*, pm1.g3.e1 FROM vm1.g4, pm1.g3 where pm1.g3.e1=vm1.g4.e1", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
+ "SELECT pm1.g3.e1 FROM pm1.g3" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[0]);
+ }
+
+ public void testDepJoinMultiGroupForceOther() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select vm1.g4.*, pm1.g3.e1 FROM vm1.g4, pm1.g3 where pm1.g3.e1=vm1.g4.e1 option makedep pm1.g2", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
+ }
+
+ public void testDepJoinHintForceLeft_NotDep() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g1 makenotdep pm1.g2", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g2 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
+ checkNotDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
+ }
+
+ public void testDepJoinHintForceRight_NotDep() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g2 makenotdep pm1.g1", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
+ checkNotDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
+ }
+
+ public void testDepJoinMultiGroupForceOther_NotDep() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select vm1.g4.*, pm1.g3.e1 FROM vm1.g4, pm1.g3 where pm1.g3.e1=vm1.g4.e1 option makedep pm1.g2 makenotdep pm1.g1, pm1.g3", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
+ checkNotDependentGroups(plan, new String[] {"pm1.g1", "pm1.g3"}); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Test that access node with unsatisfied access pattern is made dependent
+ */
+ public void testMakeDependentAccessPattern1() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm1.g1.e1 = pm4.g1.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Test that access node with unsatisfied access pattern is made dependent
+ * (Same query written slightly different way)
+ */
+ public void testMakeDependentAccessPattern1a() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm4.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Test that access node with unsatisfied access pattern is made dependent
+ */
+ public void testMakeDependentAccessPattern2() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm4.g1.e2 = 1 and pm1.g1.e1 = pm4.g1.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE (g_0.e2 = 1) AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Test that second access pattern of access node is chosen to make
+ * dependent with
+ */
+ public void testMakeDependentAccessPattern3() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e5", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e5 FROM pm4.g2 AS g_0 WHERE g_0.e5 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[] {"pm4.g2"}); //$NON-NLS-1$
+ }
+
+ /**
+ * This case actually tests the dead-tie case - either access node could
+ * be made dependent, but merge join is used since no access pattern
+ * needs to be fulfilled and there is no cost info available for either source
+ */
+ public void testPushSelectAndMakeDependentAccessPattern1() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm4.g1.e1 = 'abc' and pm1.g1.e1 = 'abc' and pm1.g1.e2 = pm4.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", "SELECT pm4.g1.e2 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[0]);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * This case actually tests the dead-tie case - either access node could
+ * be made dependent, but merge join is used since no access pattern
+ * needs to be fulfilled and there is no cost info available for either source
+ * (Same query written slightly different)
+ */
+ public void testPushSelectAndMakeDependentAccessPattern1a() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm4.g1, pm1.g1 where pm4.g1.e2 = pm1.g1.e2 and pm4.g1.e1 = 'abc' and pm1.g1.e1 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", "SELECT pm4.g1.e2 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[0]);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Tests that it is enforced if an access node can't be made dependent
+ * because of it's (already-satisfied) access pattern - merge join is used
+ */
+ public void testPushSelectAndMakeDependentAccessPattern2() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm4.g1.e1 = 'abc' and pm1.g1.e2 = pm4.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e2 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ checkDependentGroups(plan, new String[0] );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Should use dependent join since one access node is "strong" */
+ public void testUseMergeJoin1() throws Exception {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(10));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject obj = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ obj.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Should not use a dependent join since neither access node is "strong" */
+ public void testUseMergeJoin2() throws Exception {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject obj = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ obj.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1));
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, TestOptimizer.ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** should have one dependent joins */
+ public void testMultiMergeJoin3() throws Exception {
+ // Create query
+ String sql = "SELECT pm1.g2.e1 FROM pm1.g3, pm1.g2, pm1.g1 WHERE pm1.g2.e1 = pm1.g3.e1 AND pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1 ));
+ FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g2 AS g_0", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testMultiMergeJoin2() throws Exception {
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Defect 13448
+ * should be one merge join and one dependent join
+ * Unlike the above tests, here the model pm1 supports ORDER BY.
+ */
+ public void testMultiMergeJoin5_defect13448() throws Exception {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g1.e1 = pm1.g3.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g3 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testMergeJoinVirtualGroups() throws Exception {
+ String sql = "SELECT vm1.g1.e1 FROM vm1.g1, vm1.g2a WHERE vm1.g1.e1 = vm1.g2a.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testRLMCase2077() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT g_0.StringKey FROM BQT1.SmallA AS g_0 WHERE g_0.StringKey IN (<dependent values>)", "SELECT g_0.STRINGKEY, g_0.STRINGNUM, g_0.IntKey FROM BQT2.SmallA AS g_0"}, //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ public void testRLMCase2077_2() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ TransformationMetadata metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey AND table1comp.key1 = BQT1.SmallA.StringNum", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT g_0.STRINGKEY, g_0.STRINGNUM, g_0.IntKey FROM BQT2.SmallA AS g_0", "SELECT g_0.StringKey, g_0.StringNum FROM BQT1.SmallA AS g_0 WHERE (g_0.StringKey IN (<dependent values>)) AND (g_0.StringNum IN (<dependent values>))"}, //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestExpressionsInGroupBy.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestExpressionsInGroupBy.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,454 @@
+/*
+ * 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.optimizer;
+
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+import junit.framework.TestCase;
+
+
+/**
+ * expressions in group use lacks robust support in MySQL, PostGres, and Derby Expressions and it's nothing more than syntactic sugar for an inline view,
+ * a new approach was taken to use inline views rather than a non ANSI group by construct.
+ *
+ * Later we can add a connector binding property to support non-select expressions in group by.
+ */
+public class TestExpressionsInGroupBy extends TestCase {
+
+ public void testCase1565() throws Exception {
+ // Create query
+ String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM bqt1.smalla) as y GROUP BY x"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { "SELECT convert(TimestampValue, date), COUNT(*) FROM bqt1.smalla GROUP BY convert(TimestampValue, date)" }, //$NON-NLS-1$
+ true);
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ // Merge across multiple virtual groups - should be same outcome as testCase1565
+ public void testCase1565_2() throws Exception {
+ // Create query
+ String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM (SELECT TimestampValue from bqt1.smalla) as z) as y GROUP BY x"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { "SELECT convert(TimestampValue, date), COUNT(*) FROM bqt1.smalla GROUP BY convert(TimestampValue, date)" }, //$NON-NLS-1$
+ true);
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ // Merge across multiple virtual groups above the physical
+ public void testCase1565_3() throws Exception {
+ String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM (SELECT TimestampValue from bqt1.smalla) as z) as y GROUP BY x"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, TestOptimizer.getGenericFinder(),
+ new String[] { "SELECT TimestampValue FROM bqt1.smalla" }, //$NON-NLS-1$
+ true);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ // Test what happens when not all the functions in the virtual SELECT can be pushed
+ public void testCase1565_4() throws Exception {
+ // Create query
+ String sql = "SELECT x, y FROM (SELECT convert(TimestampValue, date) as x, length(stringkey) as y from bqt1.smalla) as z GROUP BY x, y"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { "SELECT TimestampValue, stringkey FROM bqt1.smalla" }, //$NON-NLS-1$
+ true);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ // Test nested functions
+ public void testCase1565_5() throws Exception {
+ // Create query
+ String sql = "SELECT x, COUNT(*) FROM (SELECT convert(intkey + 5, string) AS x FROM bqt1.smalla) as y GROUP BY x"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { "SELECT intkey FROM bqt1.smalla" }, //$NON-NLS-1$
+ true);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ // SELECT SUM(x) FROM (SELECT IntKey+1 AS x FROM BQT1.SmallA) AS g
+ public void testAggregateNoGroupByWithNestedFunction() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT SUM(x) FROM (SELECT IntKey+1 AS x FROM BQT1.SmallA) AS g", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] { "SELECT IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Without inline view support the agg is not pushed down
+ */
+ public void testFunctionInGroupBy() {
+ String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT CASE WHEN BQT1.SmallA.IntKey >= 5000 THEN '5000 +' ELSE '0-999' END, BQT1.SmallA.IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test what happens when we have a CASE in the GROUP BY and source has aggregate capability but
+ * does not have CASE capability. Should not be able to push down GROUP BY.
+ *
+ * @since 4.2
+ */
+ public void testFunctionInGroupByCantPush() {
+ String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, false);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test what happens when we have a CASE in the GROUP BY and source has aggregate capability but
+ * does not have CASE capability. Should not be able to push down GROUP BY.
+ *
+ * @since 4.2
+ */
+ public void testFunctionInGroupByHavingCantPush() {
+ String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "HAVING case when IntKey>=5000 then '5000 +' else '0-999' end = '5000 +'"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, false);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+ /**
+ * Test what happens when we have a CASE in the GROUP BY and source has aggregate capability but
+ * does not have CASE capability. Should not be able to push down GROUP BY.
+ *
+ * @since 4.2
+ */
+ public void testFunctionInGroupByCantPushRewritten() {
+ String sql = "SELECT SUM(IntKey), c FROM (SELECT IntKey, case when IntKey>=5000 then '5000 +' else '0-999' end AS c FROM BQT1.SmallA) AS temp GROUP BY c"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, false);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testFunctionOfAggregateCantPush2() {
+ String sql = "SELECT SUM(length(StringKey || 'x')) + 1 AS x FROM BQT1.SmallA GROUP BY StringKey || 'x' HAVING space(MAX(length((StringKey || 'x') || 'y'))) = ' '"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT StringKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+
+ public void testDontPushGroupByUnsupportedFunction() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(
+ "SELECT e2 as x FROM pm1.g1 GROUP BY upper(e1), e2", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestInlineView.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,304 @@
+/*
+ * 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.optimizer;
+
+import static org.teiid.query.optimizer.TestOptimizer.*;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestInlineView {
+
+ public static QueryMetadataInterface createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ caps.setFunctionSupport("case", true); //$NON-NLS-1$
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ return metadata;
+ }
+
+ @Test public void testANSIJoinInlineView() throws Exception {
+ runTest(createANSIJoinInlineView());
+ }
+
+ @Test public void testInlineView() throws Exception {
+ runTest(createInlineView());
+ }
+
+ @Test public void testInlineViewWithDistinctAndOrderBy() throws Exception {
+ runTest(createInlineViewWithDistinctAndOrderBy());
+ }
+
+ @Test public void testInlineViewOfVirtual() throws Exception{
+ runTest(createInlineViewOfVirtual());
+ }
+
+ @Test public void testInlineViewWithOuterOrderAndGroup() throws Exception {
+ runTest(createInlineViewWithOuterOrderAndGroup());
+ }
+
+ @Test public void testInlineViewsInUnions() throws Exception {
+ runTest(crateInlineViewsInUnions());
+ }
+
+ @Test public void testUnionInInlineView() throws Exception{
+ runTest(createUnionInInlineView());
+ }
+
+ public static InlineViewCase createANSIJoinInlineView() throws Exception {
+ String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.intkey) AS c_0 FROM bqt1.smalla AS g_0 WHERE g_0.intkey = 1 GROUP BY g_0.intkey) AS v_0 LEFT OUTER JOIN bqt1.smallb AS g_1 ON v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+ List row1 = new ArrayList();
+ row1.add(new Integer(1));
+ expectedResults.add(row1);
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testANSIJoinInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+
+ }
+
+ public static InlineViewCase createInlineView() throws Exception {
+ String userQuery = "select bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa from (select count(bqt1.smalla.intkey) as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, bqt1.smallb " + //$NON-NLS-1$
+ "where bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.intkey = 1 and bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = bqt1.smallb.intkey"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.intkey) AS c_0 FROM bqt1.smalla AS g_0 WHERE g_0.intkey = 1 GROUP BY g_0.intkey) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+ List row1 = new ArrayList();
+ row1.add(new Integer(1));
+ expectedResults.add(row1);
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+ }
+
+ public static InlineViewCase createInlineViewWithDistinctAndOrderBy() throws Exception {
+ String userQuery = "select Q1.a from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT DISTINCT COUNT(g_0.intkey) AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING ((COUNT(g_0.intkey) + g_0.intkey) = 2) AND (COUNT(g_0.intkey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+ List row1 = new ArrayList();
+ row1.add(new Integer(1));
+ expectedResults.add(row1);
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testInlineViewWithDistinctAndOrderBy", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+
+ }
+
+ public static InlineViewCase createInlineViewOfVirtual() throws Exception{
+ String userQuery = "select q1.A from (select count(intkey) as a, intkey, stringkey from vqt.smalla group by intkey, stringkey) q1 inner join vqt.smallb as q2 on q1.intkey = q2.a12345 where q1.a = 2"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.StringKey HAVING COUNT(g_0.IntKey) = 2) AS v_0, BQT1.SmallA AS g_1 WHERE v_0.c_0 = Concat(g_1.StringKey, g_1.StringNum)"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testInlineViewOfVirtual", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+ }
+
+ public static InlineViewCase createInlineViewWithOuterOrderAndGroup() throws Exception {
+ String userQuery = "select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.intkey) AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING ((COUNT(g_0.intkey) + g_0.intkey) = 2) AND (COUNT(g_0.intkey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0 ORDER BY c_0"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+ List row1 = new ArrayList();
+ row1.add(new Integer(1));
+ expectedResults.add(row1);
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testInlineViewWithOuterOrderAndGroup", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+ }
+
+ public static InlineViewCase crateInlineViewsInUnions() throws Exception {
+ String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+ List row1 = new ArrayList();
+ row1.add(new Integer(1));
+ expectedResults.add(row1);
+ List row2 = new ArrayList();
+ row2.add(new Integer(1));
+ expectedResults.add(row2);
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testInlineViewsInUnions", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+
+ }
+
+ public static InlineViewCase createUnionInInlineView() throws Exception{
+
+ String userQuery = "select t1.intkey from (select case when q1.a=1 then 2 else 1 end as a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)) as q3, bqt1.smallb as t1 where q3.a = t1.intkey order by t1.intkey"; //$NON-NLS-1$
+ String optimizedQuery = "SELECT g_4.intkey AS c_0 FROM (SELECT CASE WHEN v_1.c_0 = 1 THEN 2 ELSE 1 END AS c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0) AS v_2, bqt1.smallb AS g_4 WHERE v_2.c_0 = g_4.intkey ORDER BY c_0"; //$NON-NLS-1$
+
+ List expectedResults = new ArrayList();
+ List row1 = new ArrayList();
+ row1.add(new Integer(1));
+ expectedResults.add(row1);
+ List row2 = new ArrayList();
+ row2.add(new Integer(2));
+ expectedResults.add(row2);
+
+ Set<String> sourceQueries = new HashSet<String>();
+ sourceQueries.add("oracle"); //$NON-NLS-1$
+ /*
+ * fails in db2 since the intkey column is in the database as a decimal
+ */
+ //sourceQueries.add("db2"); //$NON-NLS-1$
+ sourceQueries.add("sybase"); //$NON-NLS-1$
+ sourceQueries.add("sqlserver"); //$NON-NLS-1$
+ sourceQueries.add("mysql"); //$NON-NLS-1$
+ sourceQueries.add("postgres"); //$NON-NLS-1$
+ return new InlineViewCase("testUnionInInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
+ sourceQueries, expectedResults);
+
+ }
+
+ protected void runTest(InlineViewCase testCase) throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testAliasCreationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testAliasPreservationWithInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Order by's will be added to the atomic queries
+ */
+ @Test public void testCrossSourceInlineView() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
+
+ ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinOptimization.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,926 @@
+/*
+ * 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.optimizer;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.JoinUtil;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.resource.cci.SourceSystemFunctions;
+
+
+public class TestJoinOptimization {
+
+ /**
+ * Single group criteria should get pushed and be eligible for copy criteria
+ */
+ @Test public void testInnerJoinPushAndCopyNonJoinCriteria() {
+ String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla inner join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt2.smalla.intkey = 1)"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla WHERE bqt1.smalla.intkey = 1", "SELECT bqt2.smalla.intkey FROM bqt2.smalla WHERE bqt2.smalla.intkey = 1"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Single group criteria should get pushed when it is on the inner side
+ */
+ @Test public void testOuterJoinPushNonJoinCriteria() {
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt2.smalla.stringkey = 1)"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0 ORDER BY c_0", "SELECT g_0.intkey AS c_0 FROM bqt2.smalla AS g_0 WHERE g_0.stringkey = '1' ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Single group criteria should not be pushed when it is on the outer side
+ */
+ @Test public void testOuterJoinPushNonJoinCriteriaA() {
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.stringkey = 1)"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt2.smalla AS g_0 ORDER BY c_0", "SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOuterJoinPushNonJoinCriteria_Case5547() {
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (1=1)"; //$NON-NLS-1$
+ String BQT1 = "BQT1"; //$NON-NLS-1$
+ String BQT2 = "BQT2"; //$NON-NLS-1$
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+
+ // === Must set the ORDER BY prop on the capabilities object to TRUE
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities(BQT1, caps);
+ capFinder.addCapabilities(BQT2, caps);
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null,
+ capFinder,
+ new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla", "SELECT BQT2.SmallA.IntKey FROM bqt2.smalla"}, true ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+
+ /**
+ * Single group criteria should not be pushed when it is used in a full outer join
+ * Note that the join has also degraded into a cross join rather than an outer join
+ */
+ @Test public void testFullOuterJoinPushNonJoinCriteria() {
+ String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla full outer join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.stringkey = 1 and bqt2.smalla.stringkey = 1)"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM bqt2.smalla AS g_0 ORDER BY c_0", "SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Copy criteria should still work here even though the join criteria has an implicit type conversion because
+ * the equality operation on the select criteria can be used.
+ */
+ @Test public void testCopyCriteriaWithFunction1() {
+ String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla, bqt2.smalla where bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = 1"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla WHERE bqt1.smalla.stringkey = '1'", "SELECT bqt2.smalla.intkey FROM bqt2.smalla WHERE bqt2.smalla.intkey = 1"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Copy criteria should not work here as the join criteria has an implicit convert and the where criteria is a non-equality predicate
+ */
+ @Test public void testCopyCriteriaWithFunction2() {
+ String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla, bqt2.smalla where bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey <> 1"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey FROM bqt2.smalla AS g_0 WHERE g_0.intkey <> 1", "SELECT g_0.stringkey AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * The intkey criteria should not be copied above to bqt1.smalla since the criteria is comming from the inner side in the join below
+ */
+ @Test public void testInvalidCopyCriteria() {
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla inner join (select bqt3.smalla.intkey from bqt2.smalla left outer join bqt3.smalla on bqt2.smalla.intkey = bqt3.smalla.intkey and bqt3.smalla.intkey = 1) foo on bqt1.smalla.intkey = foo.intkey"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey FROM bqt3.smalla AS g_0 WHERE g_0.intkey = 1", "SELECT g_0.intkey FROM bqt2.smalla AS g_0", "SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /*
+ * Note that the criteria does not get copied to the outer side.
+ */
+ @Test public void testCopyCriteriaFromInnerSide() throws Exception {
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join (select bqt3.smalla.intkey from bqt3.smalla where bqt3.smalla.intkey = 1) foo on bqt1.smalla.intkey = foo.intkey"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey FROM bqt3.smalla AS g_0 WHERE g_0.intkey = 1", "SELECT g_0.intkey FROM bqt1.smalla AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check to ensure that the full outer join does not get merged since the where criteria cannot be moved
+ */
+ @Test public void testFullOuterJoinPreservation() {
+ String sql = "select bqt2.mediumb.intkey from bqt2.mediumb full outer join (select bqt2.smallb.intkey from bqt2.smalla left outer join bqt2.smallb on bqt2.smalla.intkey = bqt2.smallb.intkey where bqt2.smalla.stringkey = 1) foo on bqt2.mediumb.intkey = foo.intkey"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {"SELECT g_1.intkey FROM bqt2.smalla AS g_0 LEFT OUTER JOIN bqt2.smallb AS g_1 ON g_0.intkey = g_1.intkey WHERE g_0.stringkey = '1'", "SELECT g_0.intkey AS c_0 FROM bqt2.mediumb AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Same as above but with a 0 group criteria
+ */
+ @Test public void testFullOuterJoinPreservation1() {
+ String sql = "select bqt2.mediumb.intkey from bqt2.mediumb full outer join (select bqt2.smallb.intkey from bqt2.smalla inner join bqt2.smallb on bqt2.smalla.intkey = bqt2.smallb.intkey where ? = 1) foo on bqt2.mediumb.intkey = foo.intkey"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt2.mediumb AS g_0 ORDER BY c_0", "SELECT g_1.intkey FROM bqt2.smalla AS g_0, bqt2.smallb AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (? = 1)"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Same as above but with a left outer join
+ */
+ @Test public void testOuterJoinPreservation() {
+ String sql = "select bqt2.mediumb.intkey from bqt2.mediumb left outer join (select bqt2.smallb.intkey from bqt2.smalla inner join bqt2.smallb on bqt2.smalla.intkey = bqt2.smallb.intkey where ? = 1) foo on bqt2.mediumb.intkey = foo.intkey"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt2.mediumb AS g_0 ORDER BY c_0", "SELECT g_1.intkey FROM bqt2.smalla AS g_0, bqt2.smallb AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (? = 1)"}); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCopyCriteriaCreatesFalseCriteria() {
+ String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla, bqt2.smalla where bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = 1 and bqt1.smalla.stringkey = '2'"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {});
+
+ TestOptimizer.checkNodeTypes(plan, TestRuleRaiseNull.FULLY_NULL);
+ }
+
+ @Test public void testPushNonJoinCriteriaWithFalse() {
+ String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = null)"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey, null FROM bqt1.smalla"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushMultiGroupJoinCriteria() throws Exception {
+ String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla right outer join (bqt1.smallb cross join (bqt1.mediuma cross join bqt1.mediumb)) on bqt1.smalla.stringkey = bqt1.smallb.stringkey" //$NON-NLS-1$
+ +" where bqt1.smallb.intkey + bqt1.mediuma.intkey + bqt1.mediumb.intkey = 1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_3.intkey, g_0.intkey FROM ((bqt1.smallb AS g_0 CROSS JOIN bqt1.mediuma AS g_1) INNER JOIN bqt1.mediumb AS g_2 ON ((g_0.intkey + g_1.intkey) + g_2.intkey) = 1) LEFT OUTER JOIN bqt1.smalla AS g_3 ON g_3.stringkey = g_0.stringkey"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Since the multigroup criteria spans the inner side, it should not be pushed.
+ */
+ @Test public void testPushMultiGroupJoinCriteria1() {
+ String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla right outer join (bqt1.smallb cross join (bqt1.mediuma cross join bqt1.mediumb)) on bqt1.smalla.stringkey = bqt1.smallb.stringkey" //$NON-NLS-1$
+ +" where bqt1.smalla.intkey + bqt1.mediuma.intkey + bqt1.mediumb.intkey is null"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_3.intkey, g_0.intkey FROM ((bqt1.smallb AS g_0 CROSS JOIN bqt1.mediuma AS g_1) CROSS JOIN bqt1.mediumb AS g_2) LEFT OUTER JOIN bqt1.smalla AS g_3 ON g_3.stringkey = g_0.stringkey WHERE ((g_3.intkey + g_1.intkey) + g_2.intkey) IS NULL"}, true); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Since the multigroup criteria is not null dependent, it should get pushed.
+ */
+ @Test public void testPushMultiGroupJoinCriteria2() {
+ String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla right outer join (bqt1.smallb cross join (bqt1.mediuma cross join bqt1.mediumb)) on bqt1.smalla.stringkey = bqt1.smallb.stringkey" //$NON-NLS-1$
+ +" where bqt1.smalla.intkey + bqt1.mediuma.intkey + bqt1.mediumb.intkey = 1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_3.intkey, g_2.intkey FROM bqt1.mediuma AS g_0, bqt1.mediumb AS g_1, bqt1.smallb AS g_2, bqt1.smalla AS g_3 WHERE (g_3.stringkey = g_2.stringkey) AND (((g_3.intkey + g_0.intkey) + g_1.intkey) = 1)"}, true); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+
+ /**
+ * Having criteria should not be considered as regular criteria (unless it contains no aggregate expressions).
+ */
+ @Test public void testHavingCriteriaNotUsedAsJoinCriteria() {
+ String sql = "select bqt1.smalla.intkey, max(bqt1.smallb.intkey) from bqt1.smalla, bqt1.smallb where bqt1.smalla.intkey = bqt1.smallb.intnum group by bqt1.smallb.intkey, bqt1.smalla.intkey having max(bqt1.smallb.intkey) = bqt1.smalla.intkey"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT bqt1.smalla.intkey, MAX(bqt1.smallb.intkey) FROM bqt1.smalla, bqt1.smallb WHERE bqt1.smalla.intkey = bqt1.smallb.intnum GROUP BY bqt1.smallb.intkey, bqt1.smalla.intkey HAVING MAX(bqt1.smallb.intkey) = bqt1.smalla.intkey"}, true); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Ensure that subqueries not initially pushable to the source still get replaced
+ */
+ @Test public void testSubqueryReplacement() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X left outer join vm1.g1 Y on Y.e1 = X.e1 where Y.e3 in (select e3 FROM vm1.g1) or Y.e3 IS NULL", metadata, null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 AS g1__1 LEFT OUTER JOIN pm1.g1 ON pm1.g1.e1 = g1__1.e1 WHERE (pm1.g1.e3 IN (SELECT pm1.g1.e3 FROM pm1.g1)) OR (pm1.g1.e3 IS NULL)"}, true); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testRulePushNonJoinCriteriaPreservesOuterJoin() throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select b.intkey from (select intkey from bqt1.smalla) a left outer join (select intkey from bqt1.smallb) b on (1 = 1)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ new String[]{"SELECT g_1.intkey FROM bqt1.smalla AS g_0 LEFT OUTER JOIN bqt1.smallb AS g_1 ON 1 = 1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOuterToInnerJoinConversion() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smallb.intnum = 1)"}); //$NON-NLS-1$
+ }
+
+ //same as above, but with a right outer join
+ @Test public void testOuterToInnerJoinConversion1() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla right outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb, bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = 1)"}); //$NON-NLS-1$
+ }
+
+ @Test public void testOuterToInnerJoinConversion2() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb LEFT OUTER JOIN bqt1.smalla ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smallb.intnum = 1"}); //$NON-NLS-1$
+ }
+
+ @Test public void testOuterToInnerJoinConversion3() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smalla.intnum = 1"}); //$NON-NLS-1$
+ }
+
+ /**
+ * non-depenent criteria on each side of a full outer creates an inner join
+ */
+ @Test public void testOuterToInnerJoinConversion4() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = bqt1.smallb.intnum"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = bqt1.smallb.intnum)"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Since concat2 is null dependent the join will not be changed
+ */
+ @Test public void testOuterToInnerJoinConversionNullDependent() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setFunctionSupport("concat2", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where concat2(bqt1.smallb.intnum, '1') = 1"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[]{"SELECT bqt1.smallb.intnum, bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+ }
+
+ @Test public void testInlineViewToHaving() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "select x.y, x.intkey from (select max(intnum) y, intkey from bqt1.smalla group by intkey) x where x.y = 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[]{"SELECT MAX(intnum), intkey FROM bqt1.smalla GROUP BY intkey HAVING MAX(intnum) = 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * <p>In RuleBreakMultiJoin terminology:
+ * If any of the regions contains a group with any unsatisfied access patterns, one
+ * of those access patterns could be satisfied by arranging for a dependent join,
+ * provided that group has join criteria which covers the column(s) in an access
+ * pattern, and which joins the group to group(s) in other region(s). The task, then,
+ * is to ensure that an ordering isn't picked which makes such a dependent join
+ * impossible.</p>
+ *
+ * <p>A physical group can have zero or more access patterns; each access pattern can have one
+ * or more columns. So a group could implicitly be dependent on one or more other physical
+ * groups in one or more other regions. A table can be used to illustrate the potential
+ * complexity of access patterns:
+ * <pre>
+ * Region with | Target
+ * Access Patterns| Regions
+ * -------------------------
+ * Reg3 | Reg1, Reg2
+ * Reg3 | Reg4
+ * Reg1 | Reg2
+ * Reg4 | Reg3
+ * </pre></p>
+ *
+ * This tests now passes with RulePlanJoins
+ */
+ @Test public void testPathologicalAccessPatternCaseCase2976Defect19018() throws Exception{
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+
+ // add single access pattern to pm1.g4 containing elements e1, e2, and e3
+ FakeMetadataStore store = metadata.getStore();
+ FakeMetadataObject pm4g1 = store.findObject("pm4.g1", FakeMetadataObject.GROUP);//$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(pm4g1);
+ elementIDs.remove(2);
+ FakeMetadataObject pm4g1ap1 = FakeMetadataFactory.createAccessPattern("pm4.g1.ap1", pm4g1, elementIDs); //e1,e2,e4 //$NON-NLS-1$
+ store.addObject(pm4g1ap1);
+
+ String sql = "SELECT pm1.g1.e1, pm2.g1.e1, pm4.g1.e1 " +//$NON-NLS-1$
+ "FROM pm1.g1, pm2.g1, pm4.g1 WHERE " +//$NON-NLS-1$
+ "pm1.g1.e1 = pm4.g1.e1 AND pm2.g1.e2 = pm4.g1.e2 AND pm1.g1.e4 = pm2.g1.e4 " +//$NON-NLS-1$
+ "AND pm4.g1.e4 = 3.2";//$NON-NLS-1$
+
+ String[] expected = new String[] {"SELECT g_0.e4 AS c_0, g_0.e1 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm4.g1 AS g_0 WHERE (g_0.e4 = 3.2) AND (g_0.e1 IN (<dependent values>)) AND (g_0.e2 IN (<dependent values>)) ORDER BY c_0, c_1", //$NON-NLS-1$
+ "SELECT g_0.e4 AS c_0, g_0.e2 AS c_1, g_0.e1 AS c_2 FROM pm2.g1 AS g_0 ORDER BY c_0",//$NON-NLS-1$
+ };
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, expected, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * non-null dependent criteria should get pushed down
+ */
+ @Test public void testPushMultiGroupCriteriaOuterJoin() {
+ String sql = "select m.intkey, m.intnum, s.intkey, s.intnum from BQT2.mediuma m left outer join BQT2.smalla s on m.intkey = s.intkey where not (m.intkey + s.intnum = 26)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {
+ "SELECT m.intkey, m.intnum, s.intkey, s.intnum FROM BQT2.mediuma AS m, BQT2.smalla AS s WHERE (m.intkey = s.intkey) AND (NOT ((m.intkey + s.intnum) = 26))" }, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+
+ }
+
+ /**
+ * Assumes that pm1.g1 is the only inner group
+ */
+ private void helpTestNullDependentVisitor(String critSQL,
+ boolean dependent) throws QueryParserException,
+ QueryResolverException,
+ QueryMetadataException,
+ TeiidComponentException {
+ List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
+ innerGroups.add(new GroupSymbol("pm1.g1")); //$NON-NLS-1$
+
+ Criteria crit = QueryParser.getQueryParser().parseCriteria(critSQL);
+
+ QueryResolver.resolveCriteria(crit, FakeMetadataFactory.example1Cached());
+
+ assertEquals(dependent, JoinUtil.isNullDependent(FakeMetadataFactory.example1Cached(), innerGroups, crit));
+ }
+
+ private void helpTestNullDependent(String expressionSQL,
+ boolean dependent) throws QueryParserException,
+ QueryResolverException,
+ QueryMetadataException,
+ TeiidComponentException {
+ List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
+ innerGroups.add(new GroupSymbol("pm1.g1")); //$NON-NLS-1$
+
+ Expression expr = QueryParser.getQueryParser().parseExpression(expressionSQL);
+
+ ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1Cached());
+
+ assertEquals(dependent, JoinUtil.isNullDependent(FakeMetadataFactory.example1Cached(), innerGroups, expr));
+ }
+
+ @Test public void testNullDependentVisitor() throws Exception {
+ helpTestNullDependentVisitor("nvl(pm1.g1.e1, 1) = 1", true); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor1() throws Exception {
+ helpTestNullDependentVisitor("ifnull(pm1.g1.e1, 1) = 1", true); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor2() throws Exception {
+ helpTestNullDependentVisitor("rand(pm1.g1.e2) = 1", true); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor3() throws Exception {
+ helpTestNullDependentVisitor("concat2(pm1.g1.e1, pm1.g1.e2) = '1'", false); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor4() throws Exception {
+ helpTestNullDependentVisitor("nvl(pm1.g2.e1, 1) = 1", true); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor5() throws Exception {
+ helpTestNullDependentVisitor("pm1.g1.e1 is null", true); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor6() throws Exception {
+ helpTestNullDependentVisitor("pm1.g1.e1 is not null", false); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor7() throws Exception {
+ helpTestNullDependentVisitor("pm1.g2.e1 is not null", true); //$NON-NLS-1$
+ }
+
+ //this is an important test, the or causes this criteria to be null dependent
+ @Test public void testNullDependentVisitor8() throws Exception {
+ helpTestNullDependentVisitor("pm1.g1.e1 = 1 or pm1.g2.e1 = 1", true); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor9() throws Exception {
+ helpTestNullDependentVisitor("pm1.g1.e1 = 1 or pm1.g1.e2 = 2", false); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor10() throws Exception {
+ helpTestNullDependentVisitor("pm1.g1.e1 in (1, pm1.g2.e1)", false); //$NON-NLS-1$
+ }
+
+ @Test public void testNullDependentVisitor11() throws Exception {
+ helpTestNullDependentVisitor("pm1.g2.e1 in (1, pm1.g1.e1)", true); //$NON-NLS-1$
+ }
+
+ @Test public void testIsNullDependent() throws Exception {
+ helpTestNullDependent("pm1.g1.e2 + 1", false); //$NON-NLS-1$
+ }
+
+ @Test public void testIsNullDependent1() throws Exception {
+ helpTestNullDependent("pm1.g2.e2 + 1", true); //$NON-NLS-1$
+ }
+
+ /**
+ * The criteria will still get pushed to appropriate location, and
+ * the other side of the join will be removed
+ */
+ @Test public void testCriteriaPushedWithUnionJoin() throws Exception {
+ String sql = "select * from pm1.g1 union join pm1.g2 where g1.e1 = 1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = '1'" }, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ /**
+ * union joins allow RuleRemoveVirtual to still take effect
+ */
+ @Test public void testCriteriaPushedWithUnionJoin1() throws Exception {
+ String sql = "select vm1.g1.e1 from vm1.g1 union join vm1.g2 where g2.e1 = 1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] {
+ "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = '1') AND (g_1.e1 = '1')" }, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ /**
+ * null-dependent expressions should prevent merging of virtual layers
+ */
+ @Test public void testNullDependentPreventsMerge() throws Exception {
+ String sql = "select x from pm1.g1 left outer join (select nvl(e2, 1) x from pm1.g2) y on e2 = x"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setFunctionSupport(SourceSystemFunctions.IFNULL, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] {
+ "SELECT v_0.c_0 FROM pm1.g1 AS g_0 LEFT OUTER JOIN (SELECT ifnull(g_1.e2, 1) AS c_0 FROM pm1.g2 AS g_1) AS v_0 ON g_0.e2 = v_0.c_0" }, //$NON-NLS-1$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+
+ }
+
+ /**
+ * RuleCopyCriteria will remove the first join criteria and the source doesn't support the * function. However we still
+ * want the join to be pushed since it originally contained proper criteria.
+ */
+ @Test public void testCopyCriteriaJoinPushed() throws Exception {
+ String sql = "select pm1.g1.e1 from pm1.g1, pm1.g2 where pm1.g1.e1 = pm1.g2.e1 and pm1.g1.e1 = 5 and pm1.g1.e2 * 5 = pm1.g2.e2"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,metadata,
+ new String[] { "SELECT g_0.e2, g_1.e2, g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = '5') AND (g_1.e1 = '5')" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinPushdownRestrictions.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,143 @@
+/*
+ * 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.optimizer;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
+
+
+public class TestJoinPushdownRestrictions {
+
+ @Test public void testThetaRestriction() throws Exception {
+ String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 + pm1.g2.e2 = 5)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.ANY);
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e2 + g_1.e2) = 5"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testEquiRestriction() throws Exception {
+ String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 < pm1.g2.e2)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.EQUI);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e2 < g_1.e2"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testKeyRestriction() throws Exception {
+ String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 = pm1.g2.e2)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.KEY);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm1.g2 AS g_0 ORDER BY c_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.EQUI);
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e2 = g_1.e2"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testKeyPasses() throws Exception {
+ String sql = "select a.e1, b.e1 from pm4.g1 a, pm4.g2 b where a.e1 = b.e1 and a.e2 = b.e2"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.KEY);
+ capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example4(),
+ new String[] {"SELECT g_0.e1, g_1.e1 FROM pm4.g1 AS g_0, pm4.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e2 = g_1.e2)"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCrossJoinWithRestriction() throws Exception {
+ String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1, pm1.g2"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testOuterRestriction() throws Exception {
+ String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 + pm1.g2.e2 = 5)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.ANY);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testCriteriaRestrictionWithNonJoinCriteria() throws Exception {
+ String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e2 = pm1.g2.e2 and pm1.g2.e1 = 'hello')"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm1.g2 AS g_0 WHERE g_0.e1 = 'hello' ORDER BY c_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinPushdownRestrictions.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinWithFunction.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinWithFunction.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinWithFunction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,438 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.optimizer;
+
+import java.util.List;
+
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+
+import junit.framework.TestCase;
+
+
+/**
+ * <p><code>TestCase</code> to cover planning and optimization of JOINs which
+ * use a scalar function as a symbol or as part of the JOIN criteria.</p>
+ *
+ * <p>All tests should verify and validate that the scalar function is being
+ * pushed/merged with the correct layer of the plan. For example, if a
+ * non-deterministic function is being merged with a parent node the resulting
+ * query may alter the final result set. Most specifically, if the function is
+ * executed too late during the processing of a command, the results may be
+ * different than if it were executed earlier during processing.</p>
+ * @since 6.0
+ */
+public class TestJoinWithFunction extends TestCase {
+
+ /**
+ * <p>Test the use of a non-deterministic function on a user command that
+ * performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed on the result returned from the JOIN and
+ * is expected to be executed for each row of the final result set.</p>
+ * @throws TeiidComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ */
+ public void testNonDeterministicPostJoin() throws Exception {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. RandomTop is the use of RAND() on
+ * the user command and should result in unique random numbers for each
+ * row in the JOINed output.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, RAND() AS RandomTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ // The user command should result in two atomic commands
+ String[] expected = new String[] {
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ };
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * <p>Test the use of a non-deterministic function on the source command of a JOIN
+ * defined by a user command which performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed on the result that will be used for one side
+ * of the JOIN. The function should only be executed for each row of the the result
+ * set returned from the left-side of the JOIN which should result in the same return
+ * value for multiple rows of the final result set after the JOIN is completed. For
+ * example, if the left-side query is expected to return one row and the right-side
+ * query will return three rows which match the JOIN criteria for the one row on the
+ * left-side then the expected result should be that the function be executed once to
+ * represent the one row from the left-side and the function's return value will be
+ * repeated for each of the three post-JOINed results.</p>
+ * @throws TeiidComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ */
+ public void testNonDeterministicPreJoin() throws Exception {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. TopRandom is the use of RAND() on
+ * the user command while RandomLeft is the use of RAND() within a
+ * source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ // The user command should result in two atomic commands
+ String[] expected = new String[] {
+ "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ };
+
+ // create a plan and assert our atomic queries
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * <p>Test the use of a non-deterministic function on the sub-command of a user
+ * command and the user command itself, which performs a JOIN of two sources.</p>
+ *
+ * <p>This test combines the PostJoin and PreJoin test cases.</p>
+ * @throws TeiidComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ * @see #testNonDeterministicPostJoin
+ * @see #testNonDeterministicPreJoin
+ */
+ public void testNonDeterministicPrePostJoin() throws Exception {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. TopRandom is the use of RAND() on
+ * the user command while RandomLeft is the use of RAND() within a
+ * source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft, RAND() AS RandomTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ // The user command should result in two atomic commands
+ String[] expected = new String[] {
+ "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ };
+
+ // create a plan and assert our atomic queries
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * <p>Test the use of a deterministic function on the user command which
+ * performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed prior to the JOIN being executed and should
+ * result in the projected symbol becoming a constant.</p>
+ * @throws TeiidComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ */
+ public void testDeterministicPostJoin() throws Exception {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
+ * the user command and should result in 10 for each row in the JOINed
+ * output.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ // The user command should result in two atomic commands
+ String[] expected = new String[] {
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ };
+
+ // create a plan and assert our atomic queries
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ /*
+ * Retrieve root nodes elements to assert that a constant has
+ * has replaced the SQRT() function.
+ */
+ List<?> elem = ((RelationalPlan) plan).getRootNode().getElements();
+ Constant expectedConst = new Constant(new Double(10.0));
+ assertEquals("Did not get expected constant value for SqrtTop in root node of plan: ", //$NON-NLS-1$
+ expectedConst,
+ ((ExpressionSymbol) ((AliasSymbol) elem.get(8)).getSymbol()).getExpression() // should be a AliasSymbol containing an expression
+ );
+ }
+
+ /**
+ * <p>The function should be executed prior to the JOIN being executed and should
+ * result in the projected symbol becoming a constant.</p>
+
+ * <p>Test the use of a deterministic function on the source command of a JOIN
+ * defined by a user command which performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed prior to the commands from either side of the
+ * JOIN being executed and merged into user command prior to the JOIN actually being
+ * executed.</p>
+ * @throws TeiidComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ */
+ public void testDeterministicPreJoin() throws Exception {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. SqrtLeft is the use of SQRT()
+ * within a source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ // The user command should result in two atomic commands
+ String[] expected = new String[] {
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ };
+
+ // create a plan and assert our atomic queries
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ /*
+ * Retrieve root nodes elements to assert that a constant has
+ * has replaced the SQRT() function.
+ */
+ List<?> elem = ((RelationalPlan) plan).getRootNode().getElements();
+ Constant expectedConst = new Constant(new Double(10.0));
+ assertEquals("Did not get expected constant value for SqrtLeft in root node of plan: ", //$NON-NLS-1$
+ expectedConst,
+ ((ExpressionSymbol)elem.get(8)).getExpression() // should be a AliasSymbol containing an expression
+ );
+ }
+
+ /**
+ * <p>Test the use of a deterministic function on the sub-command of a user
+ * command and the user command itself, which performs a JOIN of two sources.</p>
+ *
+ * <p>This test combines the PostJoin and PreJoin test cases.</p>
+ * @throws TeiidComponentException
+ * @throws QueryValidatorException
+ * @throws QueryResolverException
+ * @throws QueryParserException
+ * @see #testDeterministicPostJoin
+ * @see #testDeterministicPreJoin
+ */
+ public void testDeterministicPrePostJoin() throws Exception {
+ // sub-query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // sub-query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
+ * the user command while SqrtLeft is the use of SQRT() within a
+ * source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ // The user command should result in two atomic commands
+ String[] expected = new String[] {
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
+ };
+
+ // create a plan and assert our atomic queries
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
+ ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ /*
+ * Retrieve root nodes elements to assert that a constant has
+ * replaced the SQRT() function for both SqrtTop and SqrtLeft.
+ */
+ List<?> elem = ((RelationalPlan) plan).getRootNode().getElements();
+ Constant expectedConst = new Constant(new Double(10.0));
+ assertEquals("Did not get expected constant value for SqrtLeft in root node of plan: ", //$NON-NLS-1$
+ expectedConst,
+ ((ExpressionSymbol) elem.get(8)).getExpression() // should be a AliasSymbol containing an expression
+ );
+ assertEquals("Did not get expected constant value for SqrtTop in root node of plan: ", //$NON-NLS-1$
+ expectedConst,
+ ((ExpressionSymbol) ((AliasSymbol) elem.get(9)).getSymbol()).getExpression() // should be a AliasSymbol containing an expression
+ );
+ }
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestJoinWithFunction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestLimit.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,890 @@
+/*
+ * 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.optimizer;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.optimizer.TestOptimizer.DependentProjectNode;
+import org.teiid.query.optimizer.TestOptimizer.DependentSelectNode;
+import org.teiid.query.optimizer.TestOptimizer.DupRemoveNode;
+import org.teiid.query.optimizer.TestOptimizer.DupRemoveSortNode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.DependentAccessNode;
+import org.teiid.query.processor.relational.GroupingNode;
+import org.teiid.query.processor.relational.LimitNode;
+import org.teiid.query.processor.relational.MergeJoinStrategy;
+import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
+import org.teiid.query.processor.relational.NullNode;
+import org.teiid.query.processor.relational.PlanExecutionNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.SelectNode;
+import org.teiid.query.processor.relational.SortNode;
+import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+
+import junit.framework.TestCase;
+
+
+
+/**
+ * @since 4.3
+ */
+public class TestLimit extends TestCase {
+
+ private static final int[] FULL_PUSHDOWN = new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ };
+
+ public static final Class<?>[] NODE_TYPES = new Class[] {
+ AccessNode.class,
+ DependentAccessNode.class,
+ DependentSelectNode.class,
+ DependentProjectNode.class,
+ DupRemoveNode.class,
+ GroupingNode.class,
+ LimitNode.class,
+ NestedLoopJoinStrategy.class,
+ MergeJoinStrategy.class,
+ NullNode.class,
+ PlanExecutionNode.class,
+ ProjectNode.class,
+ SelectNode.class,
+ SortNode.class,
+ UnionAllNode.class
+ };
+
+ public TestLimit(String name) {
+ super(name);
+ }
+
+ private static FakeMetadataFacade exampleMetadata() {
+ // Create models
+ FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
+ FakeMetadataObject vm1 = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
+
+ // Create physical groups
+ FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g2 = FakeMetadataFactory.createPhysicalGroup("pm1.g2", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g3 = FakeMetadataFactory.createPhysicalGroup("pm1.g3", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g4 = FakeMetadataFactory.createPhysicalGroup("pm1.g4", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g5 = FakeMetadataFactory.createPhysicalGroup("pm1.g5", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g6 = FakeMetadataFactory.createPhysicalGroup("pm1.g6", pm1); //$NON-NLS-1$
+
+ // Create physical elements
+ List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm1g2e = FakeMetadataFactory.createElements(pm1g2,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm1g3e = FakeMetadataFactory.createElements(pm1g3,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm1g4e = FakeMetadataFactory.createElements(pm1g4,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ ((FakeMetadataObject)pm1g4e.get(1)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
+ ((FakeMetadataObject)pm1g4e.get(3)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
+ List pm1g5e = FakeMetadataFactory.createElements(pm1g5,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ ((FakeMetadataObject)pm1g5e.get(0)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
+ List pm1g6e = FakeMetadataFactory.createElements(pm1g6,
+ new String[] { "in", "in3" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
+
+ // Create virtual groups
+ QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM pm1.g1 LIMIT 100"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g1 = FakeMetadataFactory.createVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
+
+ // Create virtual elements
+ List vm1g1e = FakeMetadataFactory.createElements(vm1g1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+
+ QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT * FROM vm1.g1 ORDER BY e1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g2 = FakeMetadataFactory.createVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
+
+ // Create virtual elements
+ List vm1g2e = FakeMetadataFactory.createElements(vm1g2,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+
+ // Add all objects to the store
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(pm1);
+ store.addObject(pm1g1);
+ store.addObjects(pm1g1e);
+ store.addObject(pm1g2);
+ store.addObjects(pm1g2e);
+ store.addObject(pm1g3);
+ store.addObjects(pm1g3e);
+ store.addObject(pm1g4);
+ store.addObjects(pm1g4e);
+ store.addObject(pm1g5);
+ store.addObjects(pm1g5e);
+ store.addObject(pm1g6);
+ store.addObjects(pm1g6e);
+
+ store.addObject(vm1);
+ store.addObject(vm1g1);
+ store.addObjects(vm1g1e);
+ store.addObject(vm1g2);
+ store.addObjects(vm1g2e);
+
+ // Create the facade from the store
+ return new FakeMetadataFacade(store);
+ }
+ public void testLimit() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 limit 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitPushdown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 limit 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 100" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ public void testLimitWithOffset() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testPushedLimitWithOffset() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitWithOffsetFullyPushed() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 50, 100" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ public void testSort() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 order by e1 limit 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testSortPushed() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ // pm3 model supports order by
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm3.g1 order by e1 limit 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testSortPushedWithLimit() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ // pm3 model supports order by
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm3.g1 order by e1 limit 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1 LIMIT 100" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ public void testSortUnderLimitNotRemoved() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ // pm3 model supports order by
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM (SELECT * FROM pm3.g1 order by e1 limit 100) AS V1 ORDER BY v1.e2";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 2, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ //TODO: there is a redundent project node here
+ public void testSortAboveLimitNotPushed() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM vm1.g2 order by e1";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 100" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, exampleMetadata(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitNotPushedWithUnion() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ // pm1 model supports order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 UNION SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM PM1.g2" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitPushedWithUnion() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ // pm1 model supports order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM PM1.g2 LIMIT 100", "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 100" //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitWithOffsetPushedWithUnion() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
+ // pm1 model supports order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 50, 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT PM1.g2.e1 AS c_0, PM1.g2.e2 AS c_1, PM1.g2.e3 AS c_2, PM1.g2.e4 AS c_3 FROM PM1.g2 LIMIT (100 + 50)", "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitNotPushedWithUnionOrderBy() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ // pm1 model supports order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 ORDER BY e1 LIMIT 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM PM1.g2", "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ }, NODE_TYPES);
+ TestOptimizer.checkNodeTypes(plan, new int[] {1}, new Class[]{DupRemoveSortNode.class});
+ }
+
+ public void testCombinedLimits() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ // pm1 model supports order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT CASE WHEN (75 + (20 + 10)) < (100 + 10) THEN (75 + (20 + 10)) ELSE (100 + 10) END" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testCombinedLimitsWithOffset() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
+ // pm1 model supports order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (20 + 10), CASE WHEN 75 < 100 THEN 75 ELSE 100 END" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ public void testInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ //caps.setCapabilitySupport(SourceCapabilities.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ // pm3 model supports order by
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM (SELECT * FROM pm3.g1) as v1 limit 100";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 LIMIT 100" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ /**
+ * This turns out to be an important test for LIMIT: there are several nodes
+ * (e.g. grouping, inline views, aggregates, sorting, joins, etc) that should not be pushed
+ * down (because they change row order or row count) if there is already a limit node in that plan branch,
+ * which can only be placed above LIMIT with an inline view. This test acts as a gatekeeper for avoiding
+ * several of those pushdowns.
+ *
+ * @since 4.3
+ */
+ public void testInlineViewAboveLimitNotMerged() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ // pm3 model supports order by
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM (SELECT * FROM pm3.g1 limit 100) as v1 order by e1";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT v_0.c_0, v_0.c_1, v_0.c_2, v_0.c_3 FROM (SELECT pm3.g1.e1 AS c_0, pm3.g1.e2 AS c_1, pm3.g1.e3 AS c_2, pm3.g1.e4 AS c_3 FROM pm3.g1 LIMIT 100) AS v_0 ORDER BY c_0" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * since there is no order by with the nested limit, the criteria can be pushed through
+ *
+ */
+ public void testCriteriaPushedUnderLimit() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ // pm3 model supports order by
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ String sql = "SELECT * FROM (SELECT * FROM pm3.g1 limit 100) as v1 where v1.e1 = 1";//$NON-NLS-1$
+ String[] expectedSql = new String[] {
+ "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 WHERE pm3.g1.e1 = '1' LIMIT 100" //$NON-NLS-1$
+ };
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ public void testInlineViewJoin() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT x FROM ((SELECT e1 as x FROM pm1.g1 LIMIT 700) c INNER JOIN (SELECT e1 FROM pm1.g2) d ON d.e1 = c.x) order by x LIMIT 5";//$NON-NLS-1$
+ String[] expectedSql = new String[] {"SELECT e1 FROM pm1.g1 LIMIT 700", "SELECT e1 FROM pm1.g2"};//$NON-NLS-1$ //$NON-NLS-2$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+
+ //test to ensure that the unnecessary inline view removal is done properly
+ FakeDataManager fdm = new FakeDataManager();
+ TestProcessor.sampleData1(fdm);
+ TestProcessor.helpProcess(plan, fdm, new List[] {
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("a"), //$NON-NLS-1$
+ Arrays.asList("a"), //$NON-NLS-1$
+ });
+ }
+
+ public void testDontPushSelectWithOrderedLimit() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select * from (SELECT e1 as x FROM pm1.g1 order by x LIMIT 700) y where x = 1";//$NON-NLS-1$
+ String[] expectedSql = new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"};//$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testDontPushSelectWithOrderedLimit1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select * from (SELECT e1 as x FROM pm1.g1 order by x LIMIT 10, 700) y where x = 1";//$NON-NLS-1$
+ String[] expectedSql = new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"};//$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ public void testLimitWithNoAccessNode() {
+ String sql = "select 1 limit 1";//$NON-NLS-1$
+ String[] expectedSql = new String[] {};
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), expectedSql);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+ /**
+ * Note here that the criteria made it to the having clause
+ */
+ public void testAggregateCriteriaOverUnSortedLimit() {
+ String sql = "select a from (SELECT MAX(e2) as a FROM pm1.g1 GROUP BY e2 LIMIT 1) x where a = 0"; //$NON-NLS-1$
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String[] expectedSql = new String[] {"SELECT MAX(e2) FROM pm1.g1 GROUP BY e2 HAVING MAX(e2) = 0 LIMIT 1"};//$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, expectedSql, true);
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
+ }
+
+ public void testSortWithLimitInlineView() {
+ String sql = "select e1 from (select pm1.g1.e1, pm1.g1.e2 from pm1.g1 order by pm1.g1.e1, pm1.g1.e2 limit 1) x"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0, g_0.e2"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Limit
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ }, NODE_TYPES);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,6782 @@
+/*
+ * 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.optimizer;
+
+import static org.junit.Assert.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.Test;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.AliasGenerator;
+import org.teiid.query.optimizer.relational.rules.CapabilitiesUtil;
+import org.teiid.query.optimizer.relational.rules.RuleChooseDependent;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.DependentAccessNode;
+import org.teiid.query.processor.relational.GroupingNode;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.JoinStrategy;
+import org.teiid.query.processor.relational.MergeJoinStrategy;
+import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
+import org.teiid.query.processor.relational.NullNode;
+import org.teiid.query.processor.relational.PartitionedSortJoin;
+import org.teiid.query.processor.relational.PlanExecutionNode;
+import org.teiid.query.processor.relational.ProjectIntoNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.processor.relational.SelectNode;
+import org.teiid.query.processor.relational.SortNode;
+import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.BindVariableVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorReport;
+import org.teiid.resource.cci.SourceSystemFunctions;
+
+
+public class TestOptimizer {
+
+ public interface DependentJoin {}
+ public interface DependentSelectNode {}
+ public interface DependentProjectNode {}
+ public interface DupRemoveNode {}
+ public interface DupRemoveSortNode {}
+
+ public static final int[] FULL_PUSHDOWN = new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ };
+
+ public enum ComparisonMode { EXACT_COMMAND_STRING, CORRECTED_COMMAND_STRING, FAILED_PLANNING }
+
+ public static final boolean SHOULD_SUCCEED = true;
+ public static final boolean SHOULD_FAIL = false;
+
+ // ################################## TEST HELPERS ################################
+
+ public static BasicSourceCapabilities getTypicalCapabilities() {
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_BETWEEN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_ISNULL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_OR, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, true);
+
+ // set typical max set size
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ return caps;
+ }
+
+ public static CapabilitiesFinder getGenericFinder(boolean supportsJoins) {
+ final BasicSourceCapabilities caps = getTypicalCapabilities();
+ if (!supportsJoins) {
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ }
+ return new DefaultCapabilitiesFinder(caps);
+ }
+
+ public static CapabilitiesFinder getGenericFinder() {
+ return getGenericFinder(true);
+ }
+
+ public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, String[] expectedAtomic) {
+ return helpPlan(sql, md, null, getGenericFinder(), expectedAtomic, SHOULD_SUCCEED);
+ }
+
+ public static ProcessorPlan helpPlan(String sql,
+ QueryMetadataInterface md, String[] expected,
+ CapabilitiesFinder capFinder,
+ ComparisonMode mode) throws TeiidComponentException, TeiidProcessingException {
+ return helpPlan(sql, md, null, capFinder, expected, mode);
+ }
+
+ public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, String[] expectedAtomic, ComparisonMode mode) throws TeiidComponentException, TeiidProcessingException {
+ return helpPlan(sql, md, null, getGenericFinder(), expectedAtomic, mode);
+ }
+
+ public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, boolean shouldSucceed) {
+ Command command;
+ try {
+ command = helpGetCommand(sql, md, bindings);
+ } catch (TeiidException err) {
+ throw new TeiidRuntimeException(err);
+ }
+
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
+ }
+
+ public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) throws TeiidComponentException, TeiidProcessingException {
+ Command command = helpGetCommand(sql, md, bindings);
+
+ return helpPlanCommand(command, md, capFinder, null, expectedAtomic, mode);
+ }
+
+
+ public static Command helpGetCommand(String sql, QueryMetadataInterface md, List bindings) throws TeiidComponentException, TeiidProcessingException {
+ if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
+ Command command = QueryParser.getQueryParser().parseCommand(sql);
+
+ // resolve
+ QueryResolver.resolveCommand(command, md);
+
+ ValidatorReport repo = Validator.validate(command, md);
+
+ Collection failures = new ArrayList();
+ repo.collectInvalidObjects(failures);
+ if (failures.size() > 0){
+ fail("Exception during validation (" + repo); //$NON-NLS-1$
+ }
+
+ // bind variables
+ if(bindings != null) {
+ BindVariableVisitor.bindReferences(command, bindings, md);
+ }
+
+ // rewrite
+ command = QueryRewriter.rewrite(command, md, new CommandContext());
+
+ return command;
+ }
+
+ public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, String[] expectedAtomic, ComparisonMode mode) {
+ if (capFinder == null){
+ capFinder = getGenericFinder();
+ }
+
+ // Collect atomic queries
+ ProcessorPlan plan = getPlan(command, md, capFinder, analysisRecord, mode != ComparisonMode.FAILED_PLANNING);
+
+ if (mode == ComparisonMode.CORRECTED_COMMAND_STRING) {
+ checkAtomicQueries(expectedAtomic, plan, md, capFinder);
+ } else if (mode == ComparisonMode.EXACT_COMMAND_STRING) {
+ checkAtomicQueries(expectedAtomic, plan);
+ }
+
+ return plan;
+ }
+
+ public static void checkAtomicQueries(String[] expectedAtomic,
+ ProcessorPlan plan) {
+ Set<String> actualQueries = getAtomicQueries(plan);
+
+ if (actualQueries.size() != 1 || expectedAtomic.length != 1) {
+ // Compare atomic queries
+ HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(expectedAtomic));
+ assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
+ } else {
+ assertEquals("Did not get expected atomic query: ", expectedAtomic[0], actualQueries.iterator().next()); //$NON-NLS-1$
+ }
+ }
+
+ public static void checkAtomicQueries(String[] expectedAtomic,
+ ProcessorPlan plan, QueryMetadataInterface md, CapabilitiesFinder capFinder) {
+ Set actualQueries = getAtomicQueries(plan);
+
+ HashSet<String> expectedQueries = new HashSet<String>();
+
+ // Compare atomic queries
+ for (int i = 0; i < expectedAtomic.length; i++) {
+ final String sql = expectedAtomic[i];
+ Command command;
+ try {
+ command = helpGetCommand(sql, md, null);
+ Collection groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(command, false);
+ final GroupSymbol symbol = (GroupSymbol)groups.iterator().next();
+ Object modelId = md.getModelID(symbol.getMetadataID());
+ boolean supportsGroupAliases = CapabilitiesUtil.supportsGroupAliases(modelId, md, capFinder);
+ command.acceptVisitor(new AliasGenerator(supportsGroupAliases));
+ expectedQueries.add(command.toString());
+ } catch (Exception err) {
+ throw new RuntimeException(err);
+ }
+ }
+
+ assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
+ }
+
+ static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, boolean shouldSucceed) {
+ // plan
+ ProcessorPlan plan = null;
+ if (analysisRecord == null) {
+ analysisRecord = new AnalysisRecord(false, DEBUG);
+ }
+ if (shouldSucceed) {
+ try {
+ //do planning
+ plan = QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, new CommandContext());
+
+ } catch (Throwable e) {
+ throw new TeiidRuntimeException(e);
+ } finally {
+ if(DEBUG) {
+ System.out.println(analysisRecord.getDebugLog());
+ }
+ }
+ } else {
+ Exception exception = null;
+ try {
+ //do planning
+ QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, null);
+
+ } catch (QueryPlannerException e) {
+ exception = e;
+ } catch (TeiidComponentException e) {
+ exception = e;
+ } catch (Throwable e) {
+ throw new TeiidRuntimeException(e);
+ } finally {
+ if(DEBUG) {
+ System.out.println(analysisRecord.getDebugLog());
+ }
+ }
+ assertNotNull("Expected exception but did not get one.", exception); //$NON-NLS-1$
+ return null;
+ }
+
+ assertNotNull("Output elements are null", plan.getOutputElements()); //$NON-NLS-1$
+
+ if(DEBUG) System.out.println("\n" + plan); //$NON-NLS-1$
+
+ return plan;
+ }
+
+ public static Set<String> getAtomicQueries(ProcessorPlan plan) {
+ Set<Command> atomicQueries = new HashSet<Command>();
+ if(plan instanceof RelationalPlan) {
+ getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
+ }
+
+ Set<String> stringQueries = new HashSet<String>();
+
+ for (Command command : atomicQueries) {
+ stringQueries.add(command.toString());
+ }
+
+ return stringQueries;
+ }
+
+ private static void getAtomicCommands(RelationalNode node, Set<Command> atomicQueries) {
+ if(node instanceof AccessNode) {
+ AccessNode accessNode = (AccessNode) node;
+ atomicQueries.add( accessNode.getCommand());
+ }
+
+ // Recurse through children
+ RelationalNode[] children = node.getChildren();
+ for(int i=0; i<children.length; i++) {
+ if(children[i] != null) {
+ getAtomicCommands(children[i], atomicQueries);
+ } else {
+ break;
+ }
+ }
+ }
+
+ // Counts are (mostly) alphabetical:
+ // Access, DependentAccess, DependentSelect, DependentProject, DupRemove, Grouping, NestedLoopJoinStrategy, Null, PlanExecution, Project, Select, Sort, UnionAll
+ private static final Class[] COUNT_TYPES = new Class[] {
+ AccessNode.class,
+ DependentAccessNode.class,
+ DependentSelectNode.class,
+ DependentProjectNode.class,
+ DupRemoveNode.class,
+ GroupingNode.class,
+ NestedLoopJoinStrategy.class,
+ MergeJoinStrategy.class,
+ NullNode.class,
+ PlanExecutionNode.class,
+ ProjectNode.class,
+ SelectNode.class,
+ SortNode.class,
+ UnionAllNode.class
+ };
+
+ public static void checkNodeTypes(ProcessorPlan root, int[] expectedCounts) {
+ checkNodeTypes(root, expectedCounts, COUNT_TYPES);
+ }
+
+ public static void checkNodeTypes(ProcessorPlan root, int[] expectedCounts, Class[] types) {
+ if(! (root instanceof RelationalPlan)) {
+ return;
+ }
+
+ int[] actualCounts = new int[types.length];
+ collectCounts(((RelationalPlan)root).getRootNode(), actualCounts, types);
+
+ for(int i=0; i<expectedCounts.length; i++) {
+ assertEquals("Did not find the correct number of nodes for type " + types[i], //$NON-NLS-1$
+ expectedCounts[i], actualCounts[i]);
+ }
+ }
+
+ /**
+ * Method collectCounts.
+ * @param relationalNode
+ * @return int[]
+ */
+ static void collectCounts(RelationalNode relationalNode, int[] counts, Class<?>[] types) {
+ Class<?> nodeType = relationalNode.getClass();
+ if(nodeType.equals(JoinNode.class)) {
+ JoinStrategy strategy = ((JoinNode)relationalNode).getJoinStrategy();
+ if (strategy instanceof NestedLoopJoinStrategy) {
+ updateCounts(NestedLoopJoinStrategy.class, counts, types);
+ } else if (strategy instanceof MergeJoinStrategy) {
+ updateCounts(MergeJoinStrategy.class, counts, types);
+ if (strategy instanceof PartitionedSortJoin) {
+ updateCounts(PartitionedSortJoin.class, counts, types);
+ }
+ }
+ if (((JoinNode)relationalNode).isDependent()) {
+ updateCounts(DependentJoin.class, counts, types);
+ }
+ }else if (nodeType.equals(ProjectNode.class)){
+ if (ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((ProjectNode)relationalNode).getSelectSymbols()).isEmpty()) {
+ updateCounts(ProjectNode.class, counts, types);
+ } else {
+ updateCounts(DependentProjectNode.class, counts, types);
+ }
+ }else if (nodeType.equals(SelectNode.class)){
+ if (ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((SelectNode)relationalNode).getCriteria()).isEmpty()) {
+ updateCounts(SelectNode.class, counts, types);
+ } else {
+ updateCounts(DependentSelectNode.class, counts, types);
+ }
+ } else if (nodeType.equals(SortNode.class)) {
+ Mode mode = ((SortNode)relationalNode).getMode();
+ switch(mode) {
+ case DUP_REMOVE:
+ updateCounts(DupRemoveNode.class, counts, types);
+ break;
+ case DUP_REMOVE_SORT:
+ updateCounts(DupRemoveSortNode.class, counts, types);
+ break;
+ case SORT:
+ updateCounts(SortNode.class, counts, types);
+ break;
+ }
+ } else {
+ updateCounts(nodeType, counts, types);
+ }
+
+ RelationalNode[] children = relationalNode.getChildren();
+ for(int i=0; i<children.length; i++) {
+ if(children[i] != null) {
+ collectCounts(children[i], counts, types);
+ } else {
+ break;
+ }
+ }
+ }
+
+ private static void updateCounts(Class nodeClass, int[] counts, Class[] types) {
+ for(int i=0; i<types.length; i++) {
+ if(types[i].equals(nodeClass)) {
+ counts[i] = counts[i] + 1;
+ return;
+ }
+ }
+ }
+
+ public static void checkDependentJoinCount(ProcessorPlan plan, int expectedCount) {
+ checkNodeTypes(plan, new int[] {expectedCount}, new Class[] {DependentJoin.class});
+ }
+
+ public static FakeMetadataFacade example1() {
+ // Create models
+ FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
+ FakeMetadataObject pm2 = FakeMetadataFactory.createPhysicalModel("pm2"); //$NON-NLS-1$
+ FakeMetadataObject vm1 = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
+
+ // Create physical groups
+ FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g2 = FakeMetadataFactory.createPhysicalGroup("pm1.g2", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g3 = FakeMetadataFactory.createPhysicalGroup("pm1.g3", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g4 = FakeMetadataFactory.createPhysicalGroup("pm1.g4", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g5 = FakeMetadataFactory.createPhysicalGroup("pm1.g5", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g6 = FakeMetadataFactory.createPhysicalGroup("pm1.g6", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g7 = FakeMetadataFactory.createPhysicalGroup("pm1.g7", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm1g8 = FakeMetadataFactory.createPhysicalGroup("pm1.g8", pm1); //$NON-NLS-1$
+ FakeMetadataObject pm2g1 = FakeMetadataFactory.createPhysicalGroup("pm2.g1", pm2); //$NON-NLS-1$
+ FakeMetadataObject pm2g2 = FakeMetadataFactory.createPhysicalGroup("pm2.g2", pm2); //$NON-NLS-1$
+ FakeMetadataObject pm2g3 = FakeMetadataFactory.createPhysicalGroup("pm2.g3", pm2); //$NON-NLS-1$
+
+ // Create physical elements
+ List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm1g2e = FakeMetadataFactory.createElements(pm1g2,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm1g3e = FakeMetadataFactory.createElements(pm1g3,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm1g4e = FakeMetadataFactory.createElements(pm1g4,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List pm1g5e = FakeMetadataFactory.createElements(pm1g5,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List pm1g6e = FakeMetadataFactory.createElements(pm1g6,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List pm1g7e = FakeMetadataFactory.createElements(pm1g7,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List pm1g8e = FakeMetadataFactory.createElements(pm1g8,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List pm2g1e = FakeMetadataFactory.createElements(pm2g1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm2g2e = FakeMetadataFactory.createElements(pm2g2,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List pm2g3e = FakeMetadataFactory.createElements(pm2g3,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+
+ // Create virtual groups
+ QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
+
+ QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
+
+ //defect 8096
+ QueryNode vm1sub1n1 = new QueryNode("vm1.sub1", "SELECT * FROM vm1.g1 WHERE e1 IN (SELECT e1 FROM vm1.g3)"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1sub1 = FakeMetadataFactory.createVirtualGroup("vm1.sub1", vm1, vm1sub1n1); //$NON-NLS-1$
+
+ QueryNode vm1g3n1 = new QueryNode("vm1.g3", "SELECT * FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g3", vm1, vm1g3n1); //$NON-NLS-1$
+
+ QueryNode vm1g4n1 = new QueryNode("vm1.g4", "SELECT pm1.g1.e1, pm1.g2.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1=pm1.g2.e1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g4", vm1, vm1g4n1); //$NON-NLS-1$
+
+ QueryNode vm1g5n1 = new QueryNode("vm1.g5", "SELECT DISTINCT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g5", vm1, vm1g5n1); //$NON-NLS-1$
+
+ QueryNode vm1g6n1 = new QueryNode("vm1.g6", "SELECT e1, convert(e2, string), 3 as e3, ((e2+e4)/3) as e4 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g6 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g6", vm1, vm1g6n1); //$NON-NLS-1$
+
+ QueryNode vm1u1n1 = new QueryNode("vm1.u1", "SELECT * FROM pm1.g1 UNION SELECT * FROM pm1.g2 UNION ALL SELECT * FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u1", vm1, vm1u1n1); //$NON-NLS-1$
+
+ QueryNode vm1u2n1 = new QueryNode("vm1.u2", "SELECT * FROM pm1.g1 UNION SELECT * FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u2", vm1, vm1u2n1); //$NON-NLS-1$
+
+ QueryNode vm1u3n1 = new QueryNode("vm1.u3", "SELECT e1 FROM pm1.g1 UNION SELECT convert(e2, string) as x FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u3", vm1, vm1u3n1); //$NON-NLS-1$
+
+ QueryNode vm1u4n1 = new QueryNode("vm1.u4", "SELECT concat(e1, 'x') as v1 FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u4", vm1, vm1u4n1); //$NON-NLS-1$
+
+ QueryNode vm1u5n1 = new QueryNode("vm1.u5", "SELECT concat(e1, 'x') as v1 FROM pm1.g1 UNION ALL SELECT concat('a', e1) FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u5", vm1, vm1u5n1); //$NON-NLS-1$
+
+ QueryNode vm1u6n1 = new QueryNode("vm1.u6", "SELECT x1.e1 AS elem, 'xyz' AS const FROM pm1.g1 AS x1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u6 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u6", vm1, vm1u6n1); //$NON-NLS-1$
+
+ QueryNode vm1u7n1 = new QueryNode("vm1.u7", "SELECT 's1' AS const, e1 FROM pm1.g1 UNION ALL SELECT 's2', e1 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u7 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u7", vm1, vm1u7n1); //$NON-NLS-1$
+
+ QueryNode vm1u8n1 = new QueryNode("vm1.u8", "SELECT const, e1 FROM vm1.u7 UNION ALL SELECT 's3', e1 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u8 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u8", vm1, vm1u8n1); //$NON-NLS-1$
+
+ QueryNode vm1u9n1 = new QueryNode("vm1.u9", "SELECT e1 as a, e1 as b FROM pm1.g1 UNION ALL SELECT e1, e1 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1u9 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u9", vm1, vm1u9n1); //$NON-NLS-1$
+
+ QueryNode vm1a1n1 = new QueryNode("vm1.a1", "SELECT e1, SUM(e2) AS sum_e2 FROM pm1.g1 GROUP BY e1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1a1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a1", vm1, vm1a1n1); //$NON-NLS-1$
+
+ QueryNode vm1a2n1 = new QueryNode("vm1.a2", "SELECT e1, SUM(e2) AS sum_e2 FROM pm1.g1 GROUP BY e1 HAVING SUM(e2) > 5"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1a2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a2", vm1, vm1a2n1); //$NON-NLS-1$
+
+ QueryNode vm1a3n1 = new QueryNode("vm1.a3", "SELECT SUM(e2) AS sum_e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1a3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a3", vm1, vm1a3n1); //$NON-NLS-1$
+
+ QueryNode vm1a4n1 = new QueryNode("vm1.a4", "SELECT COUNT(*) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1a4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a4", vm1, vm1a4n1); //$NON-NLS-1$
+
+ QueryNode vm1a5n1 = new QueryNode("vm1.a5", "SELECT vm1.a4.count FROM vm1.a4 UNION ALL SELECT COUNT(*) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1a5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a5", vm1, vm1a5n1); //$NON-NLS-1$
+
+ QueryNode vm1a6n1 = new QueryNode("vm1.a6", "SELECT COUNT(*) FROM vm1.u2"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1a6 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a6", vm1, vm1a6n1); //$NON-NLS-1$
+
+ QueryNode vm1g7n1 = new QueryNode("vm1.g7", "select DECODESTRING(e1, 'S,Pay,P,Rec') as e1, e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vm1g7 = FakeMetadataFactory.createVirtualGroup("vm1.g7", vm1, vm1g7n1); //$NON-NLS-1$
+
+ // Create virtual elements
+ List vm1g1e = FakeMetadataFactory.createElements(vm1g1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List vm1g2e = FakeMetadataFactory.createElements(vm1g2,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List vm1g3e = FakeMetadataFactory.createElements(vm1g3,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ //for defect 8096
+ List vm1sub1e = FakeMetadataFactory.createElements(vm1sub1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List vm1g4e = FakeMetadataFactory.createElements(vm1g4,
+ new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
+ List vm1g5e = FakeMetadataFactory.createElements(vm1g5,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING});
+ List vm1g6e = FakeMetadataFactory.createElements(vm1g6,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List vm1g7e = FakeMetadataFactory.createElements(vm1g7,
+ new String[] { "e1", "e2"}, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER});
+ List vm1u1e = FakeMetadataFactory.createElements(vm1u1,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List vm1u2e = FakeMetadataFactory.createElements(vm1u2,
+ new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
+ List vm1u3e = FakeMetadataFactory.createElements(vm1u3,
+ new String[] { "e1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List vm1u4e = FakeMetadataFactory.createElements(vm1u4,
+ new String[] { "v1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List vm1u5e = FakeMetadataFactory.createElements(vm1u5,
+ new String[] { "v1" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING });
+ List vm1u6e = FakeMetadataFactory.createElements(vm1u6,
+ new String[] { "elem", "const" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
+ List vm1u7e = FakeMetadataFactory.createElements(vm1u7,
+ new String[] { "const", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
+ List vm1u8e = FakeMetadataFactory.createElements(vm1u8,
+ new String[] { "const", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
+ List vm1u9e = FakeMetadataFactory.createElements(vm1u9,
+ new String[] { "a", "b" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
+ List vm1a1e = FakeMetadataFactory.createElements(vm1a1,
+ new String[] { "e1", "sum_e2" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
+ List vm1a2e = FakeMetadataFactory.createElements(vm1a2,
+ new String[] { "e1", "sum_e2" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
+ List vm1a3e = FakeMetadataFactory.createElements(vm1a3,
+ new String[] { "sum_e2" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
+ List vm1a4e = FakeMetadataFactory.createElements(vm1a4,
+ new String[] { "count" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
+ List vm1a5e = FakeMetadataFactory.createElements(vm1a5,
+ new String[] { "count" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
+ List vm1a6e = FakeMetadataFactory.createElements(vm1a6,
+ new String[] { "count" }, //$NON-NLS-1$
+ new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
+
+ // Add all objects to the store
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(pm1);
+ store.addObject(pm1g1);
+ store.addObjects(pm1g1e);
+ store.addObject(pm1g2);
+ store.addObjects(pm1g2e);
+ store.addObject(pm1g3);
+ store.addObjects(pm1g3e);
+ store.addObject(pm1g4);
+ store.addObjects(pm1g4e);
+ store.addObject(pm1g5);
+ store.addObjects(pm1g5e);
+ store.addObject(pm1g6);
+ store.addObjects(pm1g6e);
+ store.addObject(vm1g7);
+ store.addObjects(vm1g7e);
+ store.addObject(pm1g7);
+ store.addObjects(pm1g7e);
+ store.addObject(pm1g8);
+ store.addObjects(pm1g8e);
+
+ store.addObject(pm2);
+ store.addObject(pm2g1);
+ store.addObjects(pm2g1e);
+ store.addObject(pm2g2);
+ store.addObjects(pm2g2e);
+ store.addObject(pm2g3);
+ store.addObjects(pm2g3e);
+
+ store.addObject(vm1);
+ store.addObject(vm1g1);
+ store.addObjects(vm1g1e);
+ store.addObject(vm1g2);
+ store.addObjects(vm1g2e);
+ store.addObject(vm1g3);
+ store.addObjects(vm1g3e);
+
+ //for defect 8096
+ store.addObject(vm1sub1);
+ store.addObjects(vm1sub1e);
+
+ store.addObject(vm1g4);
+ store.addObjects(vm1g4e);
+ store.addObject(vm1g5);
+ store.addObjects(vm1g5e);
+ store.addObject(vm1g6);
+ store.addObjects(vm1g6e);
+ store.addObject(vm1u1);
+ store.addObjects(vm1u1e);
+ store.addObject(vm1u2);
+ store.addObjects(vm1u2e);
+ store.addObject(vm1u3);
+ store.addObjects(vm1u3e);
+ store.addObject(vm1u4);
+ store.addObjects(vm1u4e);
+ store.addObject(vm1u5);
+ store.addObjects(vm1u5e);
+ store.addObject(vm1u6);
+ store.addObjects(vm1u6e);
+ store.addObject(vm1u7);
+ store.addObjects(vm1u7e);
+ store.addObject(vm1u8);
+ store.addObjects(vm1u8e);
+ store.addObject(vm1u9);
+ store.addObjects(vm1u9e);
+ store.addObject(vm1a1);
+ store.addObjects(vm1a1e);
+ store.addObject(vm1a2);
+ store.addObjects(vm1a2e);
+ store.addObject(vm1a3);
+ store.addObjects(vm1a3e);
+ store.addObject(vm1a4);
+ store.addObjects(vm1a4e);
+ store.addObject(vm1a5);
+ store.addObjects(vm1a5e);
+ store.addObject(vm1a6);
+ store.addObjects(vm1a6e);
+
+ // Create the facade from the store
+ return new FakeMetadataFacade(store);
+ }
+
+ // ################################## ACTUAL TESTS ################################
+
+ /**
+ * Test defect 8096 - query a virtual group with subquery of another virtual group
+ */
+ @Test public void testVirtualSubqueryINClause_8096() {
+ helpPlan("SELECT * FROM vm1.sub1", example1(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
+ }
+
+ @Test public void testQueryPhysical() {
+ ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1, e2, pm1.g1.e3, e4 FROM pm1.g1"} ); //$NON-NLS-1$
+ assertTrue(!plan.requiresTransaction(true));
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testSelectStarPhysical() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testQuerySingleSourceVirtual() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testQueryMultiSourceVirtual() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_0.e2, g_1.e3, g_1.e4 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPhysicalVirtualJoinWithCriteria() throws Exception {
+ ProcessorPlan plan = helpPlan("SELECT vm1.g2.e1 from vm1.g2, pm1.g3 where vm1.g2.e1=pm1.g3.e1 and vm1.g2.e2 > 0", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = g_2.e1) AND (g_0.e2 > 0)" }, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testQueryWithExpression() {
+ helpPlan("SELECT e4 FROM pm3.g1 WHERE e4 < convert('2001-11-01 10:30:40.42', timestamp)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e4 FROM pm3.g1 WHERE e4 < {ts'2001-11-01 10:30:40.42'}"} ); //$NON-NLS-1$
+ }
+
+ @Test public void testInsert() {
+ helpPlan("Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES ('MyString', 1)"} ); //$NON-NLS-1$
+ }
+
+ @Test public void testUpdate1() {
+ helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e3= 'true'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e3 = TRUE"} ); //$NON-NLS-1$
+ }
+
+ @Test public void testUpdate2() {
+ helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e2= convert(pm1.g1.e4, integer)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e2 = convert(pm1.g1.e4, integer)"} ); //$NON-NLS-1$
+ }
+
+ @Test public void testDelete() {
+ helpPlan("Delete from pm1.g1 where pm1.g1.e1 = cast(pm1.g1.e2 AS string)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "DELETE FROM pm1.g1 WHERE pm1.g1.e1 = cast(pm1.g1.e2 AS string)"} ); //$NON-NLS-1$
+ }
+
+ // ############################# TESTS ON EXAMPLE 1 ############################
+
+ @Test public void testCopyInAcrossJoin() throws Exception {
+ ProcessorPlan plan = helpPlan("select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCopyMatchAcrossJoin() throws Exception {
+ helpPlan("select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 LIKE '%1'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 LIKE '%1' ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 LIKE '%1' ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCopyOrAcrossJoin() throws Exception {
+ helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and (pm1.g1.e1 = 'abc' OR pm1.g1.e1 = 'def')", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e1 = 'def')", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e1 = 'def')" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCopyMultiElementCritAcrossJoin() throws Exception {
+ helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and pm1.g1.e2=pm1.g2.e2 and (pm1.g1.e1 = 'abc' OR pm1.g1.e2 = 5)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e2 = 5)", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testCantCopyAcrossJoin1() throws Exception {
+ helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and concat(pm1.g1.e1, pm1.g1.e2) = 'abc'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testCantCopyAcrossJoin2() throws Exception {
+ helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and (pm1.g1.e1 = 'abc' OR pm1.g1.e2 = 5)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughFrame1() {
+ helpPlan("select * from vm1.g1, vm1.g2 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g2.e1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughFrame2() throws Exception {
+ helpPlan("select * from vm1.g1, vm1.g3 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g3.e1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughFrame3() {
+ helpPlan("select * from vm1.g1, vm1.g2, vm1.g1 as a where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g2.e1 and vm1.g1.e1=a.e1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT g1__2.e1, g1__2.e2, g1__2.e3, g1__2.e4 FROM pm1.g1 AS g1__2 WHERE g1__2.e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughUnion1() {
+ helpPlan("select e1 from vm1.u1 where e1='abc'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE pm1.g3.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughUnion2() {
+ helpPlan("select e1 from vm1.u2 where e1='abc'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughUnion3() {
+ helpPlan("select e1 from vm1.u1 where e1='abc' and e2=5", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE (pm1.g3.e1 = 'abc') AND (pm1.g3.e2 = 5)", //$NON-NLS-1$
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') AND (pm1.g2.e2 = 5)", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') AND (pm1.g1.e2 = 5)" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushingCriteriaThroughUnion4() {
+ helpPlan("select e1 from vm1.u1 where e1='abc' or e2=5", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE (pm1.g3.e1 = 'abc') OR (pm1.g3.e2 = 5)", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)", //$NON-NLS-1$
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e2 = 5)" } ); //$NON-NLS-1$
+ }
+
+ // expression in a subquery of the union
+ @Test public void testPushingCriteriaThroughUnion5() {
+ helpPlan("select e1 from vm1.u3 where e1='abc'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT e1 FROM pm1.g1 WHERE e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ /** defect #4956 */
+ @Test public void testPushCriteriaThroughUnion6() {
+ helpPlan("select v1 from vm1.u4 where vm1.u4.v1='x'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2 WHERE e1 = 'x'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushCriteriaThroughUnion7() {
+ helpPlan("select v1 from vm1.u5 where vm1.u5.v1='x'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushCriteriaThroughUnion8() {
+ helpPlan("select v1 from vm1.u5 where length(v1) > 0", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushCriteriaThroughUnion11() {
+ helpPlan("select * from vm1.u8 where const = 's3' or e1 is null", example1(), //$NON-NLS-1$
+ new String[] { "SELECT 's3', e1 FROM pm1.g3", //$NON-NLS-1$
+ "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
+ "SELECT 's1', e1 FROM pm1.g1 WHERE e1 IS NULL" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushCriteriaThroughUnion12() {
+ helpPlan("select * from vm1.u8 where const = 's1' or e1 is null", example1(), //$NON-NLS-1$
+ new String[] { "SELECT 's3', e1 FROM pm1.g3 WHERE e1 IS NULL", //$NON-NLS-1$
+ "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
+ "SELECT 's1', e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ }
+
+ /** defect #4997 */
+ @Test public void testCountStarNoRows() {
+ ProcessorPlan plan = helpPlan("select count(*) from vm1.u4", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g2", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testPushingCriteriaWithCopy() {
+ ProcessorPlan plan = helpPlan("select vm1.u1.e1 from vm1.u1, pm1.g1 where vm1.u1.e1='abc' and vm1.u1.e1=pm1.g1.e1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE pm1.g3.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
+ "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 4, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 2 // UnionAll
+ });
+ }
+
+ @Test public void testVirtualGroupWithAliasedElement() {
+ helpPlan("select elem FROM vm1.u6 where elem='abc' and const='xyz'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT x1.e1 FROM pm1.g1 AS x1 WHERE x1.e1 = 'abc'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushThroughGroup1() {
+ helpPlan("select * FROM vm1.a1 WHERE e1 = 'x'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = 'x'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushThroughGroup2() {
+ helpPlan("select * FROM vm1.a2 WHERE e1 = 'x'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = 'x'" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushThroughGroup3() {
+ helpPlan("select * FROM vm1.a3 WHERE sum_e2 > 0", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushMultiGroupCriteria() {
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1 from pm2.g1, pm2.g2 where pm2.g1.e1 = pm2.g2.e1 and (pm2.g1.e2 = 1 OR pm2.g2.e2 = 2)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2 WHERE (pm2.g1.e1 = pm2.g2.e1) AND ((pm2.g1.e2 = 1) OR (pm2.g2.e2 = 2))" } ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleCrossJoin1() throws Exception {
+ helpPlan("select pm1.g1.e1 FROM pm1.g1, pm1.g2", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+ }
+
+ @Test public void testSimpleCrossJoin2() {
+ helpPlan("select pm2.g1.e1 FROM pm2.g1, pm2.g2", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2"} ); //$NON-NLS-1$
+
+ }
+
+ @Test public void testSimpleCrossJoin3() {
+ helpPlan("select pm2.g1.e1 FROM pm2.g1 CROSS JOIN pm2.g2", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2"} ); //$NON-NLS-1$
+
+ }
+
+ @Test public void testMultiSourceCrossJoin() throws Exception {
+ helpPlan("select pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
+ "SELECT pm1.g3.e1 FROM pm1.g3" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+ }
+
+ @Test public void testSingleSourceCrossJoin() {
+ helpPlan("select pm2.g1.e1 FROM pm2.g1, pm2.g2, pm2.g3", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2, pm2.g3"} ); //$NON-NLS-1$
+ }
+
+ @Test public void testSelfJoins() {
+ helpPlan("select pm2.g1.e1 FROM pm2.g1 JOIN pm2.g1 AS x ON pm2.g1.e1=x.e1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1 FROM pm2.g1 order by e1", //$NON-NLS-1$
+ "SELECT x.e1 FROM pm2.g1 AS x order by e1" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect5282_1() {
+ helpPlan("select * FROM vm1.a4 WHERE vm1.a4.count > 0", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect5282_2() {
+ helpPlan("select count(*) FROM vm1.a4", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect5282_3() {
+ helpPlan("select * FROM vm1.a5 WHERE vm1.a5.count > 0", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testDepJoinHintBaseline() throws Exception {
+ ProcessorPlan plan = helpPlan("select * FROM vm1.g4", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testDefect6425_1() {
+ helpPlan("select * from vm1.u9", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT e1, e1 FROM pm1.g2" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect6425_2() {
+ helpPlan("select count(*) from vm1.u9", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testPushMatchCritWithReference() {
+ List bindings = new ArrayList();
+ bindings.add("pm1.g2.e1"); //$NON-NLS-1$
+ helpPlan("select e1 FROM pm1.g1 WHERE e1 LIKE ?", example1(), bindings, null, //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 LIKE ?" }, true ); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect6517() {
+ helpPlan("select count(*) from vm1.g5", example1(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT pm1.g1.e1 FROM pm1.g1" }); //$NON-NLS-1$
+ }
+
+ @Test public void testDefect5283() {
+ helpPlan("select * from vm1.a6", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2" } ); //$NON-NLS-1$
+ }
+
+ @Test public void testManyJoinsOverThreshold() throws Exception {
+ long begin = System.currentTimeMillis();
+ helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3, pm1.g4, pm1.g5, pm1.g6, pm1.g7, pm1.g8, pm1.g1 AS x, pm1.g2 AS y WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1 AND pm1.g3.e1 = pm1.g4.e1 AND pm1.g4.e1 = pm1.g5.e1 AND pm1.g5.e1=pm1.g6.e1 AND pm1.g6.e1=pm1.g7.e1 AND pm1.g7.e1=pm1.g8.e1", //$NON-NLS-1$
+ example1(),
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
+ "SELECT pm1.g3.e1 FROM pm1.g3", //$NON-NLS-1$
+ "SELECT pm1.g4.e1 FROM pm1.g4", //$NON-NLS-1$
+ "SELECT pm1.g5.e1 FROM pm1.g5", //$NON-NLS-1$
+ "SELECT pm1.g6.e1 FROM pm1.g6", //$NON-NLS-1$
+ "SELECT pm1.g7.e1 FROM pm1.g7", //$NON-NLS-1$
+ "SELECT pm1.g8.e1 FROM pm1.g8", //$NON-NLS-1$
+ "SELECT x.e1 FROM pm1.g1 AS x", //$NON-NLS-1$
+ "SELECT y.e1 FROM pm1.g2 AS y" }, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
+
+ long elapsed = System.currentTimeMillis() - begin;
+ assertTrue("Did not plan many join query in reasonable time frame: " + elapsed + " ms", elapsed < 4000); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testAggregateWithoutGroupBy() {
+ ProcessorPlan plan = helpPlan("select count(e2) from pm1.g1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testHavingWithoutGroupBy() {
+ ProcessorPlan plan = helpPlan("select count(e2) from pm1.g1 HAVING count(e2) > 0", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testHavingAndGroupBy() {
+ ProcessorPlan plan = helpPlan("select e1, count(e2) from pm1.g1 group by e1 having count(e2) > 0 and sum(e2) > 0", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1" } ); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testAllJoinsInSingleClause() throws Exception {
+ ProcessorPlan plan = helpPlan("select pm1.g1.e1 FROM pm1.g1 join (pm1.g2 right outer join pm1.g3 on pm1.g2.e1=pm1.g3.e1) on pm1.g1.e1=pm1.g3.e1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
+ "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
+ "SELECT pm1.g3.e1 FROM pm1.g3" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testSelectCountStarFalseCriteria() {
+ ProcessorPlan plan = helpPlan("Select count(*) from pm1.g1 where 1=0", example1(), //$NON-NLS-1$
+ new String[] { });
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 1, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testSubquery1() {
+ ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1) AS x", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testSubquery2() {
+ ProcessorPlan plan = helpPlan("Select e1, a from (select e1 FROM pm1.g1) AS x, (select e1 as a FROM pm1.g2) AS y WHERE x.e1=y.a", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_1.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testSubquery3() {
+ ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1) AS x WHERE x.e1 = 'a'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = 'a'" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testSubquery4() {
+ ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1 WHERE e1 = 'a') AS x", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = 'a'" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testSubqueryInClause1() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCompareSubquery1() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 < any (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCompareSubquery2() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 <= some (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCompareSubquery3() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 >= all (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCompareSubquery4() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 > (select e1 FROM pm2.g1 where e2 = 13)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testExistsSubquery1() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where exists (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testScalarSubquery1() {
+ ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') from pm1.g1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 1, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testScalarSubquery2() {
+ ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') as X from pm1.g1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 1, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testTempGroup() {
+ ProcessorPlan plan = helpPlan("select e1 from tm1.g1 where e1 = 'x'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM tm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testNotPushDistinct() throws Exception {
+ ProcessorPlan plan = helpPlan("select distinct e1 from pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushDistinct() {
+ ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT e1 FROM pm3.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctSort() {
+ ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1 order by e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT e1 FROM pm3.g1 ORDER BY e1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctWithCriteria() {
+ ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1 where e1 = 'x'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT e1 FROM pm3.g1 WHERE e1 = 'x'" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual1() {
+ ProcessorPlan plan = helpPlan("select * from vm1.g12", FakeMetadataFactory.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$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual2() {
+ ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g12", FakeMetadataFactory.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$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual3() {
+ ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g12 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual4() {
+ ProcessorPlan plan = helpPlan("select * from vm1.g13", FakeMetadataFactory.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$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual5() {
+ ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g13", FakeMetadataFactory.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$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual6() {
+ ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g13 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual7() {
+ ProcessorPlan plan = helpPlan("select * from vm1.g14", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual8() {
+ ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g14", FakeMetadataFactory.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$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushDistinctVirtual9() {
+ ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g14 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Defect #7819
+ */
+ @Test public void testPushDistinctWithExpressions() {
+ ProcessorPlan plan = helpPlan("SELECT DISTINCT * FROM vm1.g15", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm3.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testNestedSubquery() {
+ ProcessorPlan plan = helpPlan("SELECT IntKey, LongNum FROM (SELECT IntKey, LongNum FROM (SELECT IntKey, LongNum, DoubleNum FROM BQT2.SmallA ) AS x ) AS y ORDER BY IntKey", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] { "SELECT IntKey, LongNum FROM BQT2.SmallA order by intkey" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** Tests a user's order by is pushed to the source */
+ @Test public void testPushOrderBy() {
+ ProcessorPlan plan = helpPlan("SELECT pm3.g1.e1 FROM pm3.g1 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm3.g1.e1 FROM pm3.g1 ORDER BY pm3.g1.e1"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** Tests an order by is not pushed to source due to join */
+ @Test public void testDontPushOrderByWithJoin() {
+ ProcessorPlan plan = helpPlan("SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 INNER JOIN pm2.g2 ON pm3.g1.e1 = pm2.g2.e1 ORDER BY pm3.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e1", //$NON-NLS-1$
+ "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Tests that user's order by gets pushed to the source, but query
+ * transformation order by is discarded
+ */
+ @Test public void testPushOrderByThroughFrame() {
+ ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g14 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e2"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Tests that query transformation order by is discarded by
+ */
+ @Test public void testPushOrderByThroughFrame2() {
+ ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g1 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 order by e2"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Tests that query transformation order by is discarded by
+ * user order by, and that user order by is discarded because
+ * of the function in the query transformation
+ */
+ @Test public void testPushOrderByThroughFrame3() {
+ ProcessorPlan plan = helpPlan("SELECT e, e2 FROM vm1.g16 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm3.g1"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Tests that a user's order by does not get pushed to the source
+ * if there is a UNION in the query transformation
+ */
+ @Test public void testPushOrderByThroughFrame4_Union() {
+ ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g17 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1", //$NON-NLS-1$
+ "SELECT pm3.g2.e1, pm3.g2.e2 FROM pm3.g2"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 1, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ /** Tests outer join defect #7945 - see also defect #10050*/
+ @Test public void testOuterJoinDefect7945() {
+ ProcessorPlan plan = helpPlan(
+ "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey, BQT3.MediumB.IntKey AS MediumC_IntKey " + //$NON-NLS-1$
+ "FROM (BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey) " + //$NON-NLS-1$
+ "RIGHT OUTER JOIN BQT3.MediumB ON BQT2.MediumB.IntKey = BQT3.MediumB.IntKey " + //$NON-NLS-1$
+ "WHERE BQT3.MediumB.IntKey < 1500", //$NON-NLS-1$
+ FakeMetadataFactory.exampleBQTCached(),
+ new String[] {
+ "SELECT BQT3.MediumB.IntKey FROM BQT3.MediumB WHERE BQT3.MediumB.IntKey < 1500 order by intkey", //$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE BQT1.SmallA.IntKey < 1500 order by intkey", //$NON-NLS-1$
+ "SELECT BQT2.MediumB.IntKey FROM BQT2.MediumB WHERE BQT2.MediumB.IntKey < 1500 order by intkey" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Tests outer join defect #7945 */
+ @Test public void testFunctionSimplification1() {
+ ProcessorPlan plan = helpPlan(
+ "SELECT x FROM vm1.g18 WHERE x = 92.0", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ new String[] {
+ "SELECT e4 FROM pm1.g1 WHERE e4 = 0.92" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCantPushJoin1() {
+ ProcessorPlan plan = helpPlan(
+ "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g2 b WHERE a.e1 = b.e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, TestOptimizer.getGenericFinder(false),
+ new String[] {"SELECT a.e1 FROM pm1.g1 AS a", "SELECT b.e1, b.e2 FROM pm1.g2 AS b"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCantPushJoin2() {
+ ProcessorPlan plan = helpPlan(
+ "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g2 b, pm2.g1 c WHERE a.e1 = b.e1 AND b.e1 = c.e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, TestOptimizer.getGenericFinder(false),
+ new String[] {"SELECT a.e1 FROM pm1.g1 AS a", //$NON-NLS-1$
+ "SELECT b.e1, b.e2 FROM pm1.g2 AS b", //$NON-NLS-1$
+ "SELECT c.e1 FROM pm2.g1 AS c"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushSelfJoin1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g1 b WHERE a.e1 = b.e1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT a.e1, b.e2 FROM pm1.g1 AS a, pm1.g1 AS b WHERE a.e1 = b.e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushSelfJoin2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT a.e1 AS x, concat(a.e2, b.e2) AS y FROM pm1.g1 a, pm1.g1 b WHERE a.e1 = b.e1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT a.e1, a.e2, b.e2 FROM pm1.g1 AS a, pm1.g1 AS b WHERE a.e1 = b.e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushOuterJoin1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT pm1.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm1.g2 ON pm1.g1.e1 = pm1.g2.e1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g2 LEFT OUTER JOIN pm1.g1 ON pm1.g1.e1 = pm1.g2.e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushOuterJoin2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT pm1.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm1.g2 ON pm1.g1.e1 = pm1.g2.e1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ // With join expression that can't be pushed
+ @Test public void testPushOuterJoin3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT pm1.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm1.g2 ON pm1.g1.e1 = pm1.g2.e1 || 'x'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ @Test public void testPushGroupBy1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1, e2 as x FROM pm1.g1 GROUP BY e1, e2", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1 GROUP BY e1, e2"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ }
+
+ @Test public void testPushGroupBy2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1, MAX(e2) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ }
+
+ @Test public void testPushGroupBy3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1, e2 as x FROM pm1.g1 GROUP BY e1, e2", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ @Test public void testPushGroupBy4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT x+2 AS y FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT MAX(e2) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ @Test public void testPushHaving1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushHaving2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushHaving3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushAggregate1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT MAX(e1) FROM pm1.g1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT MAX(e1) FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushAggregate2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT MAX(e1) FROM pm1.g1 GROUP BY e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT MAX(e1) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushAggregate3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushAggregate4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Can't push aggs due to not being able to push COUNT in the HAVING clause.
+ */
+ @Test public void testPushAggregate5() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e2, e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Can't push aggs due to not being able to push function inside the aggregate
+ */
+ @Test public void testPushAggregate6() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT COUNT(length(e1)) FROM pm1.g1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Can't push aggs due to not being able to push function inside having
+ */
+ @Test public void testPushAggregate7() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT COUNT(*) FROM pm1.g1 GROUP BY e1 HAVING length(e1) > 0", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * BQT query that is failing
+ */
+ @Test public void testPushAggregate8() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sqlIn =
+ "SELECT intkey FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND " + //$NON-NLS-1$
+ "(sa.stringkey IN (46)) AND (sa.datevalue = (" + //$NON-NLS-1$
+ "SELECT MAX(sa.datevalue) FROM bqt1.smalla AS sb " + //$NON-NLS-1$
+ "WHERE (sb.intkey = sa.intkey) AND (sa.stringkey = sb.stringkey) ))"; //$NON-NLS-1$
+
+ String sqlOut = "SELECT intkey FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND (sa.stringkey = '46') AND (sa.datevalue = (SELECT sa.datevalue FROM bqt1.smalla AS sb WHERE (sb.intkey = sa.intkey) AND (sb.stringkey = sa.stringkey)))"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sqlIn,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {sqlOut},
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testQueryManyJoin() throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 JOIN ((pm1.g2 JOIN pm1.g3 ON pm1.g2.e1=pm1.g3.e1) JOIN pm1.g4 ON pm1.g3.e1=pm1.g4.e1) ON pm1.g1.e1=pm1.g4.e1", //$NON-NLS-1$
+ metadata,
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2, pm1.g4 AS g_3 WHERE (g_1.e1 = g_2.e1) AND (g_2.e1 = g_3.e1) AND (g_0.e1 = g_3.e1)"}, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushSelectDistinct() {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ ProcessorPlan plan = helpPlan("SELECT DISTINCT e1 FROM pm3.g1", //$NON-NLS-1$
+ metadata,
+ new String[] { "SELECT DISTINCT e1 FROM pm3.g1"} ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInCriteria1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1 FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInSelect1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT lower(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInSelect2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInSelect3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT lower(e1), upper(e1) FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushFunctionInSelect4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT x FROM (SELECT lower(e1) AS x, upper(e1) AS y FROM pm1.g1 WHERE upper(e1) = 'X') AS z", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInSelect5() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT y, e, x FROM (SELECT lower(e1) AS x, upper(e1) AS y, 5 as z, e1 AS e FROM pm1.g1 WHERE upper(e1) = 'X') AS w", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT ucase(e1), e1, lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInSelect6_defect_10081() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setFunctionSupport("upper", true); //$NON-NLS-1$
+ caps.setFunctionSupport("lower", false); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT upper(lower(e1)) FROM pm1.g1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushFunctionInSelectWithOrderBy1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1, lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY e1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1, lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY e1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** defect 13336 */
+ @Test public void testPushFunctionInSelectWithOrderBy1a() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY x", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1, lcase(e1) AS x FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY x"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** defect 13336 */
+ @Test public void testPushFunctionInSelectWithOrderBy2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1, x FROM (SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X') AS z ORDER BY x", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1, lcase(e1) AS EXPR FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY EXPR"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInJoin1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushFunctionInJoin2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(pm1.g3.e1, 'a') AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
+ "SELECT pm1.g3.e1 FROM pm1.g3"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushFunctionInJoin3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, (SELECT e1 AS x FROM pm1.g3) AS g WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(g.x, 'a') AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
+ "SELECT e1 FROM pm1.g3"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testUnionOverFunctions() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT StringCol AS E " + //$NON-NLS-1$
+ "FROM (SELECT CONVERT(BQT1.SmallA.IntNum, string) AS StringCol, BQT1.SmallA.IntNum AS IntCol FROM BQT1.SmallA " + //$NON-NLS-1$
+ "UNION ALL SELECT BQT1.SmallB.StringNum, CONVERT(BQT1.SmallB.StringNum, integer) FROM BQT1.SmallB) AS x", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT CONVERT(BQT1.SmallA.IntNum, string) FROM BQT1.SmallA", //$NON-NLS-1$
+ "SELECT BQT1.SmallB.StringNum FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testDefect9827() {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan("SELECT intkey, c FROM (SELECT DISTINCT b.intkey, b.intnum, a.stringkey AS c FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY) AS x ORDER BY x.intkey", metadata, //$NON-NLS-1$
+ new String[] {"SELECT DISTINCT b.intkey, b.intnum, a.stringkey FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY"} ); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * This tests that a criteria with no elements is not pushed down,
+ * but instead is cleaned up properly later
+ * See defect 9865
+ */
+ @Test public void testCrossJoinNoElementCriteriaOptimization2() {
+ ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} = {b'true'}", example1(), //$NON-NLS-1$
+ new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * <p>This tests that a SELECT node with no groups is not pushed down without the capability to have a subquery in the where clause.
+ */
+ @Test public void testCrossJoinNoElementCriteriaOptimization3() {
+ ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} in (select e3 FROM vm1.g1)", example1(), //$NON-NLS-1$
+ new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * <p>This tests that a SELECT node with no groups is pushed down.
+ */
+ @Test public void testCrossJoinNoElementCriteriaOptimization4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} in (select e3 FROM vm1.g1)", example1(), null, capFinder, //$NON-NLS-1$
+ new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1 WHERE TRUE IN (SELECT pm1.g1.e3 FROM pm1.g1)", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}, true); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Criteria should be copied across this join
+ */
+ @Test public void testCopyCriteriaWithOuterJoin_defect10050(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 where pm2.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1 LEFT OUTER JOIN pm2.g2 ON pm2.g1.e1 = pm2.g2.e1 AND pm2.g2.e1 IN ('a', 'b') WHERE pm2.g1.e1 IN ('a', 'b')" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Criteria should be copied across this join
+ */
+ @Test public void testCopyCriteriaWithOuterJoin2_defect10050(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2=pm2.g2.e2 where pm2.g1.e1 = 'a' and pm2.g1.e2 = 1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0 LEFT OUTER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND g_0.e2 = g_1.e2 AND g_1.e2 = 1 AND g_1.e1 = 'a' WHERE (g_0.e1 = 'a') AND (g_0.e2 = 1)" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * See also case 2912.
+ */
+ @Test public void testCopyCriteriaWithOuterJoin5_defect10050(){
+
+ ProcessorPlan plan = helpPlan(
+ "select pm2.g1.e1, pm2.g2.e1, pm2.g3.e1 from ( (pm2.g1 right outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1) right outer join pm2.g3 on pm2.g2.e1=pm2.g3.e1) where pm2.g3.e1 = 'a'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_2.e1, g_1.e1, g_0.e1 FROM pm2.g3 AS g_0 LEFT OUTER JOIN (pm2.g2 AS g_1 LEFT OUTER JOIN pm2.g1 AS g_2 ON g_2.e1 = g_1.e1 AND g_2.e1 = 'a') ON g_1.e1 = g_0.e1 AND g_1.e1 = 'a' WHERE g_0.e1 = 'a'" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ *
+ */
+ @Test public void testCopyCriteriaWithOuterJoin6_defect10050(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g2.e1=pm2.g1.e1 where pm2.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1 LEFT OUTER JOIN pm2.g2 ON pm2.g2.e1 = pm2.g1.e1 AND pm2.g2.e1 IN ('a', 'b') WHERE pm2.g1.e1 IN ('a', 'b')" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Same as previous test, only right outer join
+ */
+ @Test public void testCopyCriteriaWithOuterJoin7_defect10050(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 right outer join pm2.g2 on pm2.g2.e1=pm2.g1.e1 where pm2.g2.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g2 LEFT OUTER JOIN pm2.g1 ON pm2.g2.e1 = pm2.g1.e1 AND pm2.g1.e1 IN ('a', 'b') WHERE pm2.g2.e1 IN ('a', 'b')" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCleanCriteria(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2 where pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2 IN (1, 2)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1, pm2.g2 WHERE (pm2.g1.e1 = pm2.g2.e1) AND (pm2.g1.e2 IN (1, 2))" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCleanCriteria2(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2 where pm2.g1.e1=pm2.g2.e1 and pm2.g1.e1 = 'a'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'a') AND (g_1.e1 = 'a')" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCleanCriteria3(){
+
+ ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 inner join pm2.g2 on pm2.g1.e1=pm2.g2.e1 where pm2.g1.e1 = 'a'", example1(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'a') AND (g_1.e1 = 'a')" }); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+
+ @Test public void testPushSubqueryInWhereClause1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm1.g2)", example1(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT e1 FROM pm1.g2)"}, SHOULD_SUCCEED ); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushSubqueryInWhereClause2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select max(e1) FROM pm1.g2)", example1(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT MAX(e1) FROM pm1.g2)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Check that subquery is pushed if the subquery selects a function that is pushed
+ */
+ @Test public void testPushSubqueryInWhereClause3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setFunctionSupport("ltrim", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT ltrim(e1) FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT ltrim(e1) FROM pm1.g2)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Check that subquery is pushed if the subquery selects an aliased function that is pushed
+ */
+ @Test public void testPushSubqueryInWhereClause4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setFunctionSupport("ltrim", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT ltrim(e1) as m FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT ltrim(e1) FROM pm1.g2)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** Case 1456, defect 10492*/
+ @Test public void testAliasingDefect1(){
+ // Create query
+ String sql = "SELECT e1 FROM vm1.g1 X WHERE e2 = (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1)";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder,
+ new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1 WHERE g1__1.e2 = (SELECT MAX(pm1.g1.e2) FROM pm1.g1 WHERE pm1.g1.e1 = g1__1.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** Case 1456, defect 10492*/
+ @Test public void testAliasingDefect2(){
+ // Create query
+ String sql = "SELECT X.e1 FROM vm1.g1 X, vm1.g1 Z WHERE X.e2 = (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1 AND Y.e2 = Z.e2) AND X.e1 = Z.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1, pm1.g1 AS g1__2 WHERE (g1__1.e2 = (SELECT MAX(pm1.g1.e2) FROM pm1.g1 WHERE (pm1.g1.e1 = g1__1.e1) AND (pm1.g1.e2 = g1__2.e2))) AND (g1__1.e1 = g1__2.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** Case 1456, defect 10492*/
+ @Test public void testAliasingDefect3(){
+ // Create query
+ String sql = "SELECT X.e1 FROM pm1.g2, vm1.g1 X WHERE X.e2 = ANY (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1) AND X.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_1.e1 FROM pm1.g2 AS g_0, pm1.g1 AS g_1 WHERE (g_1.e1 = g_0.e1) AND (g_1.e2 = SOME (SELECT MAX(g_2.e2) FROM pm1.g1 AS g_2 WHERE g_2.e1 = g_1.e1))" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /** Should use merge join since neither access node is "strong" - order by's pushed to source */
+ @Test public void testUseMergeJoin3(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Model supports order by, should be pushed to the source */
+ @Test public void testUseMergeJoin4(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Should use merge join, since costs are not known, neither access node is "strong" */
+ @Test public void testUseMergeJoin5_CostsNotKnown(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** one side of join supports order by, the other doesn't*/
+ @Test public void testUseMergeJoin7(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE pm1.g1.e1 = pm2.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm2.g2.e1 FROM pm2.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** reverse of testUseMergeJoin7 */
+ @Test public void testUseMergeJoin7a(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE pm1.g1.e1 = pm2.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** function on one side of join should prevent order by from being pushed down*/
+ @Test public void testUseMergeJoin8(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE concat(pm1.g1.e1, 'x') = pm2.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Model supports order by, functions in join criteria */
+ @Test public void testUseMergeJoin9(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE concat(pm1.g1.e1, 'x') = concat(pm1.g2.e1, 'x')";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 3, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** should be one dependent join */
+ @Test public void testMultiMergeJoin1(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE / 4));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE));
+ FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g3.e1 FROM pm1.g3" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testLargeSetCriteria() {
+ // Create query
+ String sql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA INNER JOIN BQT2.SmallB ON BQT1.SmallA.IntKey = BQT2.SmallB.IntKey WHERE BQT1.SmallA.IntKey IN (1,2,3,4,5)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA ORDER BY BQT1.SmallA.IntKey", //$NON-NLS-1$
+ "SELECT BQT2.SmallB.IntKey FROM BQT2.SmallB ORDER BY BQT2.SmallB.IntKey" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 2, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testMergeJoin_defect11236(){
+ // Create query
+ String sql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE BQT1.SmallA.IntKey = (BQT1.SmallB.IntKey + 1)"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT BQT1.SmallB.IntKey FROM BQT1.SmallB", //$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA ORDER BY BQT1.SmallA.IntKey" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testNoFrom() {
+ ProcessorPlan plan = helpPlan("SELECT 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {} );
+
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testINCriteria_defect10718(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g2.e1"}, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testDefect10711(){
+ ProcessorPlan plan = helpPlan("SELECT * from vm1.g1a as X", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ }
+
+ // SELECT 5, SUM(IntKey) FROM BQT1.SmallA
+ @Test public void testAggregateNoGroupByWithExpression() {
+ ProcessorPlan plan = helpPlan("SELECT 5, SUM(IntKey) FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] { "SELECT IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** defect 11630 - note that the lookup function is not pushed down, it will actually be evaluated before being sent to the connector */
+ @Test public void testLookupFunction() {
+
+ ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1', 'e1', 'e2', 1) IS NULL" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ }
+
+ /** case 5213 - note here that the lookup cannot be pushed down since it is dependent upon an element symbol*/
+ @Test public void testLookupFunction2() throws Exception {
+
+ ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', e2) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e2, g_0.e1 FROM pm1.g2 AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ /** defect 21965 */
+ @Test public void testLookupFunctionInSelect() {
+ ProcessorPlan plan = helpPlan("SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ // SELECT * FROM (SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT DISTINCT IntNum FROM BQT1.SmallA) AS x WHERE IntKey = 0
+ @Test public void testCase1649() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA) AS x WHERE IntKey = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT IntKey FROM BQT1.SmallA WHERE IntKey = 0", "SELECT IntNum FROM BQT1.SmallA WHERE IntNum = 0" }); //$NON-NLS-1$ //$NON-NLS-2$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
+ @Test public void testCase1727_1() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] {
+ "SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
+ "SELECT IntKey, IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
+ @Test public void testCase1727_2() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntKey b FROM BQT1.SmallA UNION ALL SELECT IntKey, IntNum FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] {
+ "SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
+ "SELECT IntKey, IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testCountStarOverSelectDistinct() {
+ ProcessorPlan plan = helpPlan("SELECT COUNT(*) FROM (SELECT DISTINCT IntNum, Intkey FROM bqt1.smalla) AS x", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] {
+ "SELECT DISTINCT IntNum, Intkey FROM bqt1.smalla" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ //virtual group with two elements. One selectable, one not
+ @Test public void testVirtualGroup1() {
+ ProcessorPlan plan = helpPlan("select e2 from vm1.g35", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
+
+ checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testBQT9500_126() {
+ String sql = "SELECT IntKey, LongNum, expr FROM (SELECT IntKey, LongNum, concat(LongNum, 'abc') FROM BQT2.SmallA ) AS x ORDER BY IntKey"; //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {
+ "SELECT IntKey, LongNum FROM BQT2.SmallA" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ public void helpTestUnionPushdown(boolean queryHasOrderBy, boolean hasUnionCapability, boolean hasUnionOrderByCapability) {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, hasUnionCapability);
+ caps.setCapabilitySupport((Capability.QUERY_ORDERBY), hasUnionOrderByCapability);
+ caps.setCapabilitySupport((Capability.QUERY_SET_ORDER_BY), hasUnionOrderByCapability);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sqlUnion = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB";//$NON-NLS-1$
+ String sqlOrderBy = sqlUnion + " ORDER BY IntKey"; //$NON-NLS-1$
+ String sql = null;
+ if(queryHasOrderBy) {
+ sql = sqlOrderBy;
+ } else {
+ sql = sqlUnion;
+ }
+
+ String[] expectedSql = null;
+ if(hasUnionCapability) {
+ if(queryHasOrderBy && hasUnionOrderByCapability) {
+ expectedSql = new String[] {sqlOrderBy };
+ } else {
+ expectedSql = new String[] {sqlUnion };
+ }
+ } else {
+ expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" }; //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder, expectedSql, SHOULD_SUCCEED);
+
+ int accessCount = hasUnionCapability ? 1 : 2;
+ int projectCount = 0;
+ int sortCount = 0;
+ if(queryHasOrderBy && ! (hasUnionCapability && hasUnionOrderByCapability)) {
+ sortCount = 1;
+ }
+ int unionCount = hasUnionCapability ? 0 : 1;
+
+
+
+ checkNodeTypes(plan, new int[] {
+ accessCount, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ projectCount, // Project
+ 0, // Select
+ sortCount, // Sort
+ unionCount // UnionAll
+ });
+ }
+
+ /**
+ * Query has union but no order by and no capabilities.
+ */
+ @Test public void testUnionPushdown1() {
+ helpTestUnionPushdown(false, false, false);
+ }
+
+ /**
+ * Query has union but no order by and only union capability.
+ */
+ @Test public void testUnionPushdown2() {
+ helpTestUnionPushdown(false, true, false);
+ }
+
+ /**
+ * Query has union with order by and no capabilities.
+ */
+ @Test public void testUnionPushdown3() {
+ helpTestUnionPushdown(true, false, false);
+ }
+
+ /**
+ * Query has union with order by and just union capability.
+ */
+ @Test public void testUnionPushdown4() {
+ helpTestUnionPushdown(true, true, false);
+ }
+
+ /**
+ * Query has union with order by and both capabilities.
+ */
+ @Test public void testUnionPushdown5() {
+ helpTestUnionPushdown(true, true, true);
+ }
+
+ @Test public void testUnionPushdownWithSelectNoFrom() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT 1 UNION ALL SELECT 2", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder, new String[] {}, SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testUnionPushdownWithSelectNoFromFirstBranch() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT 1 UNION ALL SELECT IntKey FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder, new String[] {"SELECT IntKey FROM BQT1.SmallA"}, SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testUnionPushdownWithSelectNoFromSecondBranch() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT 1", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder, new String[] {"SELECT IntKey FROM BQT1.SmallA"}, SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testUnionPushdownMultipleBranches() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB UNION ALL SELECT IntKey FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB UNION ALL SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionPushdownMultipleBranchesMixedModels1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB UNION ALL SELECT IntKey FROM BQT2.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB", "SELECT IntKey FROM BQT2.SmallA"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testUnionPushdownMultipleBranchesNoDupRemoval() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB UNION SELECT IntKey FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB UNION SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testAggregateOverUnionPushdown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT COUNT(*) FROM (SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB) AS x", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testUnionPushdownWithFunctionsAndAliases() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT IntKey+2, StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT (IntKey + 2), StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionPushdownWithInternalOrderBy() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("(SELECT IntKey FROM BQT1.SmallA ORDER BY IntKey) UNION ALL SELECT IntKey FROM BQT1.SmallB", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionPushdownWithInternalDistinct() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan("SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionNoAllPushdownInInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT x FROM (SELECT IntKey+2, StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB) AS g", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT (IntKey + 2), StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testUnionAllPushdownInInlineView() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT x FROM (SELECT IntKey+2, StringKey AS x FROM BQT1.SmallA UNION ALL SELECT IntKey, StringKey FROM BQT1.SmallB) AS g", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT StringKey AS x FROM BQT1.SmallA UNION ALL SELECT StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionAllPushdownVirtualGroup() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g4", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1 UNION ALL SELECT convert(e2, string) FROM pm1.g2"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionAllPushdownVirtualGroup2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT e2 FROM vm1.g17", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] {"SELECT pm3.g1.e2 FROM pm3.g1 UNION ALL SELECT pm3.g2.e2 FROM pm3.g2"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUnionAllPushdownVirtualGroup3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT intnum, 10 FROM bqt1.smalla) AS x", //$NON-NLS-1$
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT intkey FROM BQT1.SmallA", "SELECT IntNum FROM bqt1.smalla"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ // Allow pushing literals
+ @Test public void testUnionAllPushdownVirtualGroup4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT intnum, 10 FROM bqt1.smalla) AS x", //$NON-NLS-1$
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT IntNum, 10 FROM bqt1.smalla"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushCaseInSelect() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testCantPushCaseInSelectWithFunction() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT CASE e1 WHEN 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushSearchedCaseInSelect() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testCantPushSearchedCaseInSelectWithFunction() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT CASE WHEN e1 = 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushdownFunctionNotEvaluated() {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
+ caps.setFunctionSupport("xyz", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT e1 FROM pm1.g1 WHERE xyz() > 0", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT e1 FROM pm1.g1 WHERE xyz() > 0"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testNoSourceQuery() {
+ ProcessorPlan plan = helpPlan("SELECT * FROM (select parsetimestamp(x,'yyyy-MM-dd') as c1 from (select '2004-10-20' as x) as y) as z " +//$NON-NLS-1$
+ "WHERE c1= '2004-10-20 00:00:00.0'", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ new String[] { });
+
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** defect 14510 */
+ @Test public void testDefect14510LookupFunction() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.smallb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = lookup('BQT1.SmallB', 'IntKey', 'StringKey', BQT1.SmallB.StringKey)) AND (BQT1.SmallA.IntKey = 1)", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE BQT1.SmallA.IntKey = 1", "SELECT BQT1.SmallB.StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** defect 14510 */
+ @Test public void testDefect14510LookupFunction2() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT1.MediumB ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey', BQT1.MediumB.StringKey)", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA", "SELECT BQT1.MediumB.StringKey, BQT1.MediumB.IntKey FROM BQT1.MediumB"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** defect 14510 */
+ @Test public void testDefect14510LookupFunction3() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
+ FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
+ FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.MediumB RIGHT OUTER JOIN BQT1.SmallA ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey',BQT1.MediumB.StringKey)", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA", "SELECT BQT1.MediumB.StringKey, BQT1.MediumB.IntKey FROM BQT1.MediumB"}, //$NON-NLS-1$ //$NON-NLS-2$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCase2125() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, false);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "SELECT OD.IntKEy, P.IntKEy, O.IntKey " + //$NON-NLS-1$
+ "FROM (bqt1.smalla AS OD INNER JOIN bqt1.smallb AS P ON OD.StringKey = P.StringKey) " + //$NON-NLS-1$
+ "INNER JOIN bqt1.mediuma AS O ON O.IntKey = OD.IntKey " + //$NON-NLS-1$
+ "WHERE (OD.IntNum > (SELECT SUM(IntNum) FROM bqt1.smalla)) AND " + //$NON-NLS-1$
+ "(P.longnum > (SELECT AVG(LongNum) FROM bqt1.smallb WHERE bqt1.smallb.datevalue = O.datevalue))"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT g_1.longnum, g_2.datevalue, g_0.IntKEy, g_1.IntKEy, g_2.IntKey FROM bqt1.smalla AS g_0, bqt1.smallb AS g_1, bqt1.mediuma AS g_2 WHERE (g_0.StringKey = g_1.StringKey) AND (g_2.IntKey = g_0.IntKey) AND (g_0.IntNum > (SELECT SUM(g_3.IntNum) FROM bqt1.smalla AS g_3))"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushdownLiteralInSelectUnderAggregate() {
+ String sql = "SELECT COUNT(*) FROM (SELECT '' AS y, a.IntKey FROM BQT1.SmallA a union all select '', b.intkey from bqt1.smallb b) AS x"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT '' AS y FROM BQT1.SmallA AS a UNION ALL SELECT '' FROM bqt1.smallb AS b"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushdownLiteralInSelectUnderAggregate2() {
+ String sql = "SELECT SUM(z) FROM (SELECT '' AS y, a.IntKey as z FROM BQT1.SmallA a union all select b.stringkey, 0 from bqt1.smallb b) AS x group by z"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT a.IntKey AS z FROM BQT1.SmallA AS a UNION ALL SELECT 0 FROM bqt1.smallb AS b"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushdownLiteralInSelectUnderAggregate3() {
+ String sql = "SELECT code, SUM(ID) FROM (SELECT IntKey AS ID, '' AS Code FROM BQT1.SmallA union all select intkey, stringkey from bqt1.smallb b) AS x group by code"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT '' AS Code, IntKey AS ID FROM BQT1.SmallA UNION ALL SELECT stringkey, intkey FROM bqt1.smallb AS b"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushdownLiteralInSelectWithOrderBy() {
+ String sql = "SELECT 1, concat('a', 'b' ) AS X FROM BQT1.SmallA where intkey = 0 " + //$NON-NLS-1$
+ "UNION ALL " + //$NON-NLS-1$
+ "select 2, 'Hello2' from BQT1.SmallA where intkey = 1 order by X desc"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT 1, 'ab' AS X FROM BQT1.SmallA WHERE intkey = 0 UNION ALL SELECT 2, 'Hello2' FROM BQT1.SmallA WHERE IntKey = 1 ORDER BY X DESC"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testUpdateWithElement() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "UPDATE BQT1.SmallA SET IntKey = IntKey + 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"UPDATE BQT1.SmallA SET IntKey = (IntKey + 1)"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase2187() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT t.intkey FROM (SELECT a.IntKey FROM bqt1.smalla a left outer join bqt1.smallb b on a.intkey=b.intkey, bqt1.smalla x) as t full outer JOIN bqt1.smallb c on t.intkey = c.intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT a.IntKey FROM ((bqt1.smalla AS a LEFT OUTER JOIN bqt1.smallb AS b ON a.intkey = b.intkey) CROSS JOIN bqt1.smalla AS x) FULL OUTER JOIN bqt1.smallb AS c ON a.IntKey = c.intkey"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testMultiUnionMergeVirtual() throws Exception {
+ String sql = "SELECT * FROM " + //$NON-NLS-1$
+ "(SELECT IntKey, 'a' AS s FROM (SELECT intkey, stringkey from BQT1.SmallA) as a union all " + //$NON-NLS-1$
+ "select IntKey, 'b' FROM (SELECT intkey, stringkey from BQT1.SmallA) as b union all " + //$NON-NLS-1$
+ "select IntKey, 'c' FROM (SELECT intkey, stringkey from BQT1.SmallA) as c " + //$NON-NLS-1$
+ ") AS x"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"(SELECT g_2.intkey AS c_0, 'a' AS c_1 FROM BQT1.SmallA AS g_2 UNION ALL SELECT g_1.IntKey AS c_0, 'b' AS c_1 FROM BQT1.SmallA AS g_1) UNION ALL SELECT g_0.IntKey AS c_0, 'c' AS c_1 FROM BQT1.SmallA AS g_0"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testDefect16848_groupAliasNotSupported_1() {
+ String sql = "SELECT sa.intkey, sa.objectvalue FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND (sa.stringkey IN (46)) AND (sa.datevalue = (SELECT MAX(sb.datevalue) FROM bqt1.smalla AS sb WHERE (sb.intkey = sa.intkey) AND (sa.stringkey = sb.stringkey) ))"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ RelationalPlan plan = (RelationalPlan)helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT bqt1.smalla.datevalue, bqt1.smalla.intkey, bqt1.smalla.stringkey, bqt1.smalla.objectvalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = 46) AND (bqt1.smalla.stringkey = '46')"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ ProcessorPlan subplan = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((SelectNode)plan.getRootNode().getChildren()[0]).getCriteria()).get(0).getCommand().getProcessorPlan();
+
+ // Collect atomic queries
+ Set<String> actualQueries = getAtomicQueries(subplan);
+
+ // Compare atomic queries
+ HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(new String[] { "SELECT bqt1.smalla.datevalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smalla.intkey) AND (bqt1.smalla.stringkey = bqt1.smalla.stringkey)"})); //$NON-NLS-1$
+ assertEquals("Did not get expected atomic queries for subplan: ", expectedQueries, actualQueries); //$NON-NLS-1$
+
+ checkNodeTypes(subplan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ @Test public void testFunctionOfAggregate1() {
+ String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT (SUM(IntKey) + 1) FROM BQT1.SmallA GROUP BY IntKey"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testFunctionOfAggregateCantPush1() {
+ String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testFunctionOfAggregateCantPush3() {
+ String sql = "SELECT avg(intkey) * 2 FROM BQT1.SmallA "; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] {"SELECT intkey FROM BQT1.SmallA"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ private void helpTestCase2589NonPushdown(String sql, String[] expected) {
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ expected,
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ private void helpTestCase2589(String sql, String expected) throws Exception {
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {expected},
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase2589() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589a() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589a ON MediumA.IntKey = SmallA_2589a.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589b() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589c() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB, BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey " + //$NON-NLS-1$
+ "WHERE BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN (BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10') ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589d() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
+ "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN (BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10') ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589e() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
+ "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN (BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10') ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589f() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA INNER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
+ "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN (BQT1.MediumA INNER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey AND BQT1.SmallA.StringNum = '10'";//$NON-NLS-1$";
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589g() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA INNER JOIN VQT.SmallA_2589c ON MediumA.IntKey = SmallA_2589c.IntKey) " + //$NON-NLS-1$
+ "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA INNER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB " + //$NON-NLS-1$
+ "ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey AND " + //$NON-NLS-1$
+ "concat(BQT1.SmallA.StringNum, BQT1.SmallB.StringNum) = '1010') " + //$NON-NLS-1$
+ "ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589h() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589c " + //$NON-NLS-1$
+ "ON MediumA.IntKey = SmallA_2589c.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey AND concat(BQT1.SmallA.StringNum, BQT1.SmallB.StringNum) = '1010') ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ @Test public void testCase2589i() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589d " + //$NON-NLS-1$
+ "ON MediumA.IntKey = SmallA_2589d.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' AND BQT1.SmallA.IntNum = 10"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Test optimization doesn't happen if an outer join isn't involved
+ */
+ @Test public void testCase2589j() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA INNER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA, BQT1.SmallA WHERE (BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) AND (BQT1.SmallA.StringNum = '10')"; //$NON-NLS-1$
+
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Test optimization doesn't happen if an outer join isn't involved
+ */
+ @Test public void testCase2589k() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA INNER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA, BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) AND (BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) AND (BQT1.SmallA.StringNum = '10')"; //$NON-NLS-1$
+
+
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Same as testCase2589 except right outer join
+ */
+ @Test public void testCase2589l() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM VQT.SmallA_2589 RIGHT OUTER JOIN " + //$NON-NLS-1$
+ "BQT1.MediumA ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Same as testCase2589 except full outer join - criteria "below" full outer join cannot be
+ * raised into the join criteria, so basically the virtual groups cannot be merged in this test.
+ */
+ @Test public void testCase2589m() {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM VQT.SmallA_2589 FULL OUTER JOIN " + //$NON-NLS-1$
+ "BQT1.MediumA ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String[] expected = new String[] {
+ "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" //$NON-NLS-1$
+ };
+
+ helpTestCase2589NonPushdown(sql, expected);
+ }
+
+ /**
+ * Same as testCase2589b except full outer join
+ */
+ @Test public void testCase2589n() {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
+
+ String[] expected = new String[] {
+ "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) AND (BQT1.SmallA.StringNum = '10')" //$NON-NLS-1$
+ };
+ helpTestCase2589NonPushdown(sql, expected);
+
+ }
+
+ /**
+ * Same as testCase2589 except with two virtual layers instead of one
+ */
+ @Test public void testCase2589o() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589f ON MediumA.IntKey = SmallA_2589f.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Same as testCase2589b except with two virtual layers instead of one
+ */
+ @Test public void testCase2589p() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589g ON MediumA.IntKey = SmallA_2589g.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Test 3 frames, where top frame has outer join, middle frame has inner join, and
+ * bottom frame has criteria that must be made into join criteria.
+ */
+ @Test public void testCase2589q() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589h ON MediumA.IntKey = SmallA_2589h.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Similar to testCase2589b, except virtual transformation has criteria on an
+ * element from each physical table
+ */
+ @Test public void testCase2589r() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589i ON MediumA.IntKey = SmallA_2589i.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' AND BQT1.SmallB.StringNum = '10'"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Test user criteria that should NOT be moved into join clause
+ */
+ @Test public void testCase2589s() throws Exception {
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey " + //$NON-NLS-1$
+ "WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Test user criteria that should NOT be moved into join clause
+ */
+ @Test public void testCase2589t() throws Exception {
+ String sql = "SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE BQT1.MediumA.IntNum = 10) as z " + //$NON-NLS-1$
+ "LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589 ON z.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * The above test written with an inline view instead of a virtual group.
+ * This test translates to - how can this query be rewritten without subqueries such
+ * that the same results are produced? More specifically, where should the criteria
+ * go - WHERE clause or FROM clause?
+ */
+ @Test public void testCase2589u() throws Exception {
+ String sql = "SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
+ "LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
+ "ON z.IntKey = y.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Same sql as testCase2589, but the model doesn't support outer joins, so
+ * case 2589 optimization shouldn't happen.
+ */
+ @Test public void testCase2589v() {
+
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String expected[] = new String[] {
+ "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" //$NON-NLS-1$
+ };
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ expected,
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Same as previous testCase2589v, but with full outer join.
+ */
+ @Test public void testCase2589w() {
+
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + //$NON-NLS-1$
+ "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
+
+ String expected[] = new String[] {
+ "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" //$NON-NLS-1$
+ };
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ expected,
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test a complicated join tree involving multiple models, but with a nested
+ * outer join predicate spanning only one model, and see if the case 2589
+ * fix happens. The important thing is the criteria "StringNum = '10'" needs
+ * to be put in the join criteria, not the where clause, of the second atomic
+ * query, because in the user query it is on the inner side of an outer join.
+ */
+ @Test public void testCase2589x() throws Exception {
+
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT2.SmallA INNER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
+ "ON MediumA.IntKey = y.IntKey) " + //$NON-NLS-1$
+ "ON BQT2.SmallA.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected[] = new String[] {
+ "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA", //$NON-NLS-1$
+ "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'" //$NON-NLS-1$
+ };
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ expected,
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test two outer joins, one nested within the other, all pushable to one source,
+ * with inline views having criteria that each need to be migrated to their
+ * respective join predicate join criteria.
+ *
+ * The tree below illustrates the canonical plan (plus access nodes). 'y' and
+ * 'z' are two inline views. Notice each has a SELECT node underneath - the
+ * criteria represented by each of those SELECT nodes is on the inner side of
+ * their respective left outer joins (LOJ). So, each criteria needs to be
+ * migrated to the join criteria.
+ *
+ * <pre>
+ * LOJ
+ * / \
+ * LOJ SRC z
+ * / \ |
+ * SRC SRC y SEL
+ * MedB | |
+ * SEL ACC
+ * | |
+ * ACC SRC SmA
+ * |
+ * SRC MedA
+ * </pre>
+ * Here's a diagram of what the join plan of the resulting atomic query should
+ * look like.
+ * <pre>
+ * ACC
+ * |
+ * LOJ**
+ * / \
+ * LOJ** SRC **criteria migrated to here
+ * / \ SmA
+ * SRC SRC
+ * MedB MedA
+ * </pre>
+ */
+ @Test public void testCase2589y() throws Exception {
+ String sql = "SELECT L.IntKey, y.IntKey, z.IntKey " + //$NON-NLS-1$
+ "FROM (BQT1.MediumB as L LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT IntKey FROM BQT1.MediumA as M WHERE M.IntNum = 4) as y ON y.IntKey = L.IntKey) " + //$NON-NLS-1$
+ "LEFT OUTER JOIN (SELECT IntKey FROM BQT1.SmallA as S WHERE S.StringNum = '10') as z " + //$NON-NLS-1$
+ "ON z.IntKey = y.IntKey"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumB.IntKey, BQT1.MediumA.IntKey, BQT1.SmallA.IntKey " + //$NON-NLS-1$
+ "FROM (BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
+ "BQT1.MediumA ON BQT1.MediumA.IntKey = BQT1.MediumB.IntKey AND BQT1.MediumA.IntNum = 4) " + //$NON-NLS-1$
+ "LEFT OUTER JOIN BQT1.SmallA " + //$NON-NLS-1$
+ "ON BQT1.SmallA.IntKey = BQT1.MediumA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Test a complicated join tree involving multiple models, but with a nested
+ * outer join predicate spanning only one model, and see if the case 2589
+ * fix happens. The important thing is the criteria "StringNum = '10'" needs
+ * to be put in the join criteria, not the where clause, of the second atomic
+ * query, because in the user query it is on the inner side of an outer join.
+ */
+ @Test public void testCase2589z() {
+
+ String sql = "SELECT BQT1.MediumA.IntKey FROM BQT2.SmallA INNER JOIN " + //$NON-NLS-1$
+ "(BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB " + //$NON-NLS-1$
+ "WHERE BQT1.SmallA.IntKey = BQT1.SmallB.IntKey AND BQT1.SmallA.StringNum = '10') as y " + //$NON-NLS-1$
+ "ON MediumA.IntKey = y.IntKey) " + //$NON-NLS-1$
+ "ON BQT2.SmallA.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
+
+ String expected[] = new String[] {
+ "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA", //$NON-NLS-1$
+ "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'" //$NON-NLS-1$
+ };
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ expected,
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Union with multiple joins underneath
+ */
+ @Test public void testCase2589aa() throws Exception {
+ String sql = "SELECT * FROM (SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
+ "LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
+ "ON z.IntKey = y.IntKey " + //$NON-NLS-1$
+ "UNION ALL SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
+ "LEFT OUTER JOIN " + //$NON-NLS-1$
+ "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
+ "ON z.IntKey = y.IntKey) as x"; //$NON-NLS-1$
+
+ String expected = "SELECT BQT1.MediumA.IntKey AS c_0 FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10 UNION ALL SELECT BQT1.MediumA.IntKey AS c_0 FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
+ helpTestCase2589(sql, expected);
+ }
+
+ /**
+ * Since can now guarantee unique select column names, it's ok to have repeated entries in the order by clause.
+ */
+ @Test public void testOrderByDuplicates() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT intkey, x FROM (select intkey, intkey x from bqt1.smalla) z ORDER BY x, intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT g_0.intkey AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_1, c_0"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ //Test use of OrderBy with expression
+ @Test public void testCase2507() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT vqt.smallb.a12345 FROM vqt.smallb ORDER BY vqt.smallb.a12345"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT Concat(stringKey, stringNum) AS EXPR FROM BQT1.SmallA ORDER BY EXPR"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase2507A() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as EXPR, bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR, EXPR_1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR, bqt1.smalla.stringKey AS EXPR_1 FROM bqt1.smalla ORDER BY EXPR, EXPR_1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase2507B() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum), bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR_1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum), bqt1.smalla.stringKey AS EXPR_1 FROM bqt1.smalla ORDER BY EXPR_1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * RulePlanJoins does not initially allow the cross join push.
+ * The subsequent RuleRaiseAccess does since we believe it was the intent of the user
+ */
+ @Test public void testPushCrossJoins() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT b1.intkey from (bqt1.SmallA a1 cross join bqt1.smalla a2 cross join bqt1.mediuma b1) " + //$NON-NLS-1$
+ " left outer join bqt1.mediumb b2 on b1.intkey = b2.intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT g_2.intkey FROM ((bqt1.SmallA AS g_0 CROSS JOIN bqt1.smalla AS g_1) CROSS JOIN bqt1.mediuma AS g_2) LEFT OUTER JOIN bqt1.mediumb AS g_3 ON g_2.intkey = g_3.intkey"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase3023() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT bqt1.SmallA.intkey from (bqt1.SmallA inner join (" //$NON-NLS-1$
+ + "SELECT BAD.intkey from bqt1.SmallB as BAD left outer join bqt1.MediumB on BAD.intkey = bqt1.MediumB.intkey) as X on bqt1.SmallA.intkey = X.intkey) inner join bqt1.MediumA on X.intkey = bqt1.MediumA.intkey"; //$NON-NLS-1$
+
+ helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT bqt1.SmallA.intkey FROM (bqt1.SmallA INNER JOIN (bqt1.SmallB AS BAD LEFT OUTER JOIN bqt1.MediumB ON BAD.intkey = bqt1.MediumB.intkey) ON bqt1.SmallA.intkey = BAD.intkey) INNER JOIN bqt1.MediumA ON BAD.intkey = bqt1.MediumA.intkey"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+ }
+
+ @Test public void testCase3367() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = example1();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select e1 from pm1.g1 where pm1.g1.e1 IN (SELECT pm1.g2.e1 FROM pm1.g2 WHERE (pm1.g1.e1 = 2))", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE pm1.g1.e1 IN (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g1.e1 = '2')" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /*
+ * Set criteria was not getting pushed down correctly when there was a self-join
+ * of a virtual table containing a join in it's transformation. All virtual
+ * models use the same physical model pm1.
+ */
+ @Test public void testCase3778() throws Exception {
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(
+ "select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in (select e2 from vm1.g1)", //$NON-NLS-1$
+ metadata, null, capFinder, new String[] {"SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Ensures that order by expressions are not repeated when multiple criteria span a merge join
+ */
+ @Test public void testCase3832() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "select bqt1.smalla.intkey from bqt1.smalla, bqt2.smalla, bqt2.smallb where bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.intkey = bqt2.smallb.intkey and bqt2.smalla.stringkey = bqt2.smallb.stringkey"; //$NON-NLS-1$
+
+ helpPlan(sql,
+ metadata,
+ null,
+ capFinder,
+ new String[] {
+ "SELECT bqt2.smallb.intkey AS c_0, bqt2.smalla.intkey AS c_1 FROM bqt2.smalla, bqt2.smallb WHERE bqt2.smalla.stringkey = bqt2.smallb.stringkey ORDER BY c_0, c_1", //$NON-NLS-1$
+ "SELECT bqt1.smalla.intkey AS c_0 FROM bqt1.smalla ORDER BY c_0"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING);
+
+ }
+
+ /*
+ * Functions containing exec statements should not be evaluated
+ */
+ @Test public void testDefect21972() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select e1 from pm1.g1 where e1 = convert((exec pm1.sq11(1, 2)), integer)"; //$NON-NLS-1$
+
+ helpPlan(sql,
+ FakeMetadataFactory.example1Cached(),
+ null,
+ capFinder,
+ new String[] {
+ "SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
+ SHOULD_SUCCEED);
+
+ }
+
+ @Test public void testExpressionSymbolPreservation() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT * from (select '1' as test, intkey from bqt2.smalla) foo, (select '2' as test, intkey from bqt2.smalla) foo2 where foo.intkey = foo2.intkey"; //$NON-NLS-1$
+
+ helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT '1', g_0.intkey, '2', g_1.IntKey FROM bqt2.smalla AS g_0, bqt2.smalla AS g_1 WHERE g_0.intkey = g_1.IntKey"}, //$NON-NLS-1$
+ ComparisonMode.EXACT_COMMAND_STRING );
+
+ }
+
+ //since this does not support convert, it should not be collapsed
+ @Test public void testBadCollapseUnion() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select convert(e2+1,string) from pm1.g1 union all select e1 from pm1.g2";//$NON-NLS-1$
+ String[] expectedSql = new String[] {"SELECT e2 FROM pm1.g1", "SELECT e1 FROM pm1.g2"};//$NON-NLS-1$ //$NON-NLS-2$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ null, capFinder, expectedSql, SHOULD_SUCCEED);
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+
+ }
+
+ @Test public void testCase3966() {
+ ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {} );
+
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 1, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /*
+ * Select literals created by runtime evaluation should not be pushed down.
+ */
+ @Test public void testCase4017() throws Exception {
+
+ String sql = "SELECT env('soap_host') AS HOST, intkey from bqt2.smalla"; //$NON-NLS-1$
+
+ helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(),
+ new String[] {"SELECT bqt2.smalla.intkey FROM bqt2.smalla"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ /**
+ * Test of RuleCopyCriteria. Criteria should NOT be copied across a join if the join has any other operator
+ * other than an equality operator, but if the single group criteria is equality, then we can copy into a join criteria
+ */
+ @Test public void testCase4265() throws Exception {
+ String sql = "SELECT X.intkey, Y.intkey FROM BQT1.SmallA X, BQT1.SmallA Y WHERE X.IntKey <> Y.IntKey and Y.IntKey = 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {
+ "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey <> 1", //$NON-NLS-1$
+ "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ /**
+ * Test of RuleCopyCriteria. Criteria should be copied across a join only for an equality operator in
+ * the join criteria.
+ */
+ @Test public void testCase4265ControlTest() throws Exception {
+ String sql = "SELECT X.intkey, Y.intkey FROM BQT1.SmallA X, BQT1.SmallA Y WHERE X.IntKey = Y.IntKey and Y.IntKey = 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {
+ "SELECT g_0.intkey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ /**
+ * The bug was in FrameUtil.convertCriteria() method, where ExistsCriteria was not being checked for.
+ */
+ @Test public void testExistsCriteriaInSelect() {
+ String sql = "select intkey, case when exists (select stringkey from bqt1.smallb) then 'nuge' end as a from vqt.smalla"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 1, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ /**
+ * Try substituting "is not null" for "exists" criteria
+ */
+ @Test public void testScalarSubQueryInSelect() {
+ String sql = "select intkey, case when (select stringkey from bqt1.smallb) is not null then 'nuge' end as a from vqt.smalla"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {
+ "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 1, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ }
+
+ @Test public void testCase4263() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = example1();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select vm1.g1.e1 from vm1.g1 left outer join (select * from vm1.g2 as v where v.e1 = (select max(vm1.g2.e1) from vm1.g2 where v.e1 = vm1.g2.e1)) f2 on (f2.e1 = vm1.g1.e1)", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1 LEFT OUTER JOIN pm1.g1 AS g1__2 ON g1__2.e1 = g1__1.e1 AND g1__2.e1 = (SELECT MAX(pm1.g1.e1) FROM pm1.g1 WHERE pm1.g1.e1 = g1__2.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase4263b() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = example1();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select vm1.g1.e1 from vm1.g1 left outer join (select * from vm1.g2 as v where v.e1 = (select max(pm2.g1.e1) from pm2.g1 where v.e1 = pm2.g1.e1)) f2 on (f2.e1 = vm1.g1.e1)", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT g1__1.e1 FROM pm1.g1 AS g1__1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCase4279() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = example1();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select * from (select v1.e1, v2.e1 as e1_1, v1.e2, v2.e2 as e2_2 from (select * from vm1.g7 where vm1.g7.e2 = 1) v1 left outer join (select * from vm1.g7 where vm1.g7.e2 = 1) v2 on v1.e2 = v2.e2) as v3 where v3.e2 = 1", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT CASE WHEN g_0.e1 = 'S' THEN 'Pay' WHEN g_0.e1 = 'P' THEN 'Rec' ELSE g_0.e1 END, CASE WHEN g_1.e1 = 'S' THEN 'Pay' WHEN g_1.e1 = 'P' THEN 'Rec' ELSE g_1.e1 END, g_0.e2, g_1.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g1 AS g_1 ON g_0.e2 = g_1.e2 AND g_1.e2 = 1 WHERE g_0.e2 = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase4312() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ helpPlan("select ? + 1, pm1.g1.e1 AS EXPR_1 FROM pm1.g1", example1(), null, capFinder, //$NON-NLS-1$
+ new String[] {
+ "SELECT (? + 1) AS expr, pm1.g1.e1 FROM pm1.g1"}, true); //$NON-NLS-1$
+
+ }
+
+ @Test public void testCase2507_2(){
+
+ String sql = "SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " + //$NON-NLS-1$
+ "FROM BQT1.SmallA, BQT1.SmallB WHERE SmallA.IntKey = SmallB.IntKey) as X ORDER BY X.a"; //$NON-NLS-1$
+
+ String expected = "SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) AS EXPR " + //$NON-NLS-1$
+ "FROM BQT1.SmallA, BQT1.SmallB WHERE BQT1.SmallA.IntKey = BQT1.SmallB.IntKey ORDER BY EXPR"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {expected},
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ private void helpTestCase2430and2507(String sql, String expected) {
+
+ // TEST PLANNING
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {expected},
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ //Test use of OrderBy with Alias
+ @Test public void testCase2430D() {
+ String sql = "SELECT bqt1.smalla.longnum + bqt1.smalla.longnum as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
+ "bqt1.smalla.doublenum as EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
+
+ String expected = "SELECT (bqt1.smalla.longnum + bqt1.smalla.longnum) AS c1234567890123456789012345678901234567890, bqt1.smalla.doublenum AS EXPR " + //$NON-NLS-1$
+ "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR"; //$NON-NLS-1$
+ helpTestCase2430and2507(sql, expected);
+ }
+
+ /*
+ * If expressionsymbol comparison would ignore expression names then this should just select a single column,
+ * but for now it will select 2.
+ */
+ @Test public void testCase2430E() {
+ String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
+ "CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
+
+ String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c1234567890123456789012345678901234567890, CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) " + //$NON-NLS-1$
+ "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+ helpTestCase2430and2507(sql, expected);
+ }
+
+ @Test public void testCase2430G() {
+ String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
+ "CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+
+ String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c1234567890123456789012345678901234567890, CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) " + //$NON-NLS-1$
+ "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+ helpTestCase2430and2507(sql, expected);
+ }
+
+ @Test public void testCase2507_1(){
+
+ String sql = "SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " + //$NON-NLS-1$
+ "FROM BQT1.SmallA) as X ORDER BY X.a"; //$NON-NLS-1$
+
+ String expected = "SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) AS EXPR FROM BQT1.SmallA ORDER BY EXPR"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {expected},
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * This is taken from testPushCorrelatedSubquery1. However this subquery is not expected to be pushed down since the correlated
+ * reference expression cannot be evaluated by the source.
+ */
+ @Test public void testDefect23614() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = concat(n.stringkey, 'a') )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT intkey, n.stringkey FROM bqt1.smalla AS n" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Normally the following queries would plan as if they were federated, but setting the connector_id source property
+ * allows them to be planned as if they were the same source.
+ */
+ @Test public void testSameConnector() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setSourceProperty(Capability.CONNECTOR_ID, "1"); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA A LEFT OUTER JOIN BQT2.MediumB B ON A.IntKey = B.IntKey", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA AS A LEFT OUTER JOIN BQT2.MediumB AS B ON A.IntKey = B.IntKey"}, //$NON-NLS-1$
+ true);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ plan = helpPlan(
+ "SELECT A.IntKey FROM BQT1.SmallA A UNION select B.intkey from BQT2.MediumB B", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT A.IntKey FROM BQT1.SmallA AS A UNION SELECT B.intkey FROM BQT2.MediumB AS B"}, //$NON-NLS-1$
+ true);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test changes to RuleCollapseSource for removing aliases
+ */
+ @Test public void testCase4898() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT 'a' as A FROM BQT1.SmallA A UNION select 'b' as B from BQT1.MediumB B", //$NON-NLS-1$
+ metadata, null, capFinder,
+ new String[] {
+ "SELECT 'a' AS A FROM BQT1.SmallA AS A UNION SELECT 'b' FROM BQT1.MediumB AS B"}, //$NON-NLS-1$
+ true);
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testDefect13971() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "select b from (select distinct booleanvalue b, intkey from bqt1.smalla) as x"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] {"SELECT DISTINCT booleanvalue, intkey FROM bqt1.smalla"}, SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Ensures that aliases are not stripped from projected symbols if they might conflict with an order by element
+ */
+ @Test public void testCase5067() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String sql = "SELECT a.intkey as stringkey, b.stringkey as key2 from bqt1.smalla a, bqt1.smallb b where a.intkey = b.intkey order by stringkey"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] {"SELECT a.intkey AS stringkey, b.stringkey AS key2 FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.intkey = b.intkey ORDER BY stringkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testDontPushConvertObject() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT intkey from bqt1.smalla WHERE stringkey = convert(objectvalue, string)", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT stringkey, objectvalue, intkey FROM bqt1.smalla"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testDontPushConvertClobToString() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("LOB", caps); //$NON-NLS-1$
+
+ // Add join capability to pm1
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = helpPlan(
+ "SELECT ClobValue from LOB.LobTbl WHERE convert(ClobValue, string) = ?", //$NON-NLS-1$
+ metadata,
+ null, capFinder,
+ new String[] {"SELECT ClobValue FROM LOB.LobTbl"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testSelectIntoWithDistinct() throws Exception {
+ String sql = "select distinct e1 into #temp from pm1.g1"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata, new String[] {"SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+
+ checkNodeTypes(plan, new int[] {1}, new Class[] {ProjectIntoNode.class});
+ }
+
+ /**
+ * previously the subqueries were being pushed too far and then not having the appropriate correlated references
+ */
+ @Test public void testCorrelatedSubqueryOverJoin() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ String sql = "select pm1.g1.e1 from pm1.g1, (select * from pm1.g2) y where (pm1.g1.e1 = y.e1) and exists (select e2 from pm1.g2 where e1 = y.e1) and exists (select e3 from pm1.g2 where e1 = y.e1)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] {"SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 AS g2__1 WHERE (pm1.g1.e1 = g2__1.e1) AND (EXISTS (SELECT e2 FROM pm1.g2 WHERE e1 = g2__1.e1)) AND (EXISTS (SELECT e3 FROM pm1.g2 WHERE e1 = g2__1.e1))"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * see testSimpleCrossJoin3
+ */
+ @Test public void testMaxFromGroups() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(1));
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ helpPlan("select pm2.g1.e1 FROM pm2.g1 CROSS JOIN pm2.g2", example1(), null, capFinder, //$NON-NLS-1$
+ new String[] { "SELECT pm2.g1.e1 FROM pm2.g1", "SELECT pm2.g2.e1 FROM pm2.g2"}, true ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ }
+
+ @Test public void testCase6249() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
+
+ String sql = "select count(*) from (select intkey from bqt1.smalla union all select intkey from bqt1.smallb) as a"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT COUNT(*) FROM (SELECT intkey FROM bqt1.smalla UNION ALL SELECT intkey FROM bqt1.smallb) AS a"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase6181() throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select a.e1 from (select 1 e1) a, (select e1, 1 as a, x from (select e1, CASE WHEN e1 = 'a' THEN e2 ELSE e3 END as x from pm1.g2) y group by e1, x) b where a.e1 = b.x"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder,
+ new String[] {"SELECT v_1.c_0 FROM (SELECT v_0.c_1 AS c_0 FROM (SELECT g_0.e1 AS c_0, CASE WHEN g_0.e1 = 'a' THEN g_0.e2 ELSE g_0.e3 END AS c_1 FROM pm1.g2 AS g_0 WHERE CASE WHEN g_0.e1 = 'a' THEN g_0.e2 ELSE g_0.e3 END IN (<dependent values>)) AS v_0 GROUP BY v_0.c_0, v_0.c_1) AS v_1 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCase6325() {
+ String sql = "select e1 into #temp from pm4.g1 where e1='1'"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpPlan(sql, metadata, new String[] {"SELECT e1 FROM pm4.g1 WHERE e1 = '1'"}); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase6364() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "select * from (SELECT 1+ SUM(intnum) AS s FROM bqt1.smalla) a WHERE a.s>10"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT (1 + SUM(intnum)) FROM bqt1.smalla HAVING SUM(intnum) > 9"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testExceptPushdown() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_EXCEPT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select e1 from pm1.g1 except select e1 from pm1.g2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT g_1.e1 AS c_0 FROM pm1.g1 AS g_1 EXCEPT SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testCase6597() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_NOT, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Create query
+ String sql = "select IntKey from bqt1.smalla where stringkey not like '2%'"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT stringkey, IntKey FROM bqt1.smalla"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCopyCriteriaWithIsNull() {
+ String sql = "select * from (select a.intnum, a.intkey y, b.intkey from bqt1.smalla a, bqt2.smalla b where a.intkey = b.intkey) x where intkey is null"; //$NON-NLS-1$
+
+ helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {});
+ }
+
+ /**
+ * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
+ * query containing a <code>BETWEEN</code> comparison in the queries
+ * <code>WHERE</code> statement.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT * FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2
+ */
+ @Test public void testBetween() {
+ helpPlan("select * from pm1.g1 where e2 between 1 and 2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (e2 >= 1) AND (e2 <= 2)"} ); //$NON-NLS-1$
+ }
+
+ /**
+ * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
+ * query containing a <code>CASE</code> expression in which a
+ * <code>BETWEEN</code> comparison is used in the queries
+ * <code>SELECT</code> statement.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
+ */
+ @Test public void testBetweenInCase() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ helpPlan("select case when e2 between 3 and 5 then e2 else -1 end from pm1.g1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] { "SELECT CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END FROM pm1.g1"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED);
+ }
+
+ /**
+ * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
+ * query containing an aggregate SUM with a <code>CASE</code> expression
+ * in which a <code>BETWEEN</code> comparison is used in the queries
+ * <code>SELECT</code> statement.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1
+ */
+ @Test public void testBetweenInCaseInSum() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ helpPlan("select sum(case when e2 between 3 and 5 then e2 else -1 end) from pm1.g1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] { "SELECT SUM(CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END) FROM pm1.g1"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED);
+ }
+
+ /**
+ * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
+ * query containing an aggregate SUM with a <code>CASE</code> expression
+ * in which a <code>BETWEEN</code> comparison is used in the queries
+ * <code>SELECT</code> statement and a GROUP BY is specified.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END)
+ * FROM pm1.g1 GROUP BY e1
+ */
+ @Test public void testBetweenInCaseInSumWithGroupBy() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ helpPlan("select sum(case when e2 between 3 and 5 then e2 else -1 end) from pm1.g1 group by e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] { "SELECT SUM(CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
+ TestOptimizer.SHOULD_SUCCEED);
+ }
+
+ /**
+ * Test the query optimizer's ability to properly plan and optimize a query
+ * that uses ambiguous alias names in the top level query and its sub-query.
+ * <p>
+ * No source table is being used. For example, <code>SELECT A.e2 FROM
+ * (SELECT e2 FROM (SELECT 1 AS e2) AS A) AS A</code>
+ * <p>
+ * The test is to ensure that A.e2 from the top level is not confused with
+ * e2 in the second level.
+ * <p>
+ * Related Defects: JBEDSP-1137
+ */
+ @Test public void testAmbiguousAliasInSubQueryNoSource() {
+ // Create query
+ String sql = "SELECT A.e2 AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT e2 AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT 5 AS e2" + //$NON-NLS-1$
+ " ) AS A" + //$NON-NLS-1$
+ ") AS A"; //$NON-NLS-1$
+
+ helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
+ }
+
+ /**
+ * Test the query optimizer's ability to properly plan and optimize a query
+ * that uses ambiguous alias names in the top level query and its sub-query
+ * and uses columns belonging to the alias as a parameter to a function.
+ * <p>
+ * No source table is being used. For example, <code>SELECT CONVERT(A.e2,
+ * biginteger) AS e2 FROM (SELECT CONVERT(e2, long) AS e2 FROM (SELECT 1 AS
+ * e2) AS A) AS A</code>
+ * <p>
+ * The test is to ensure that A.e2 from the top level is not confused with
+ * e2 in the second level.
+ * <p>
+ * Related Defects: JBEDSP-1137
+ */
+ @Test public void testAmbiguousAliasFunctionInSubQueryNoSource() {
+ // Create query
+ String sql = "SELECT CONVERT(A.e2, biginteger) AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT CONVERT(e2, long) AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT 5 AS e2" + //$NON-NLS-1$
+ " ) AS A" + //$NON-NLS-1$
+ ") AS A"; //$NON-NLS-1$
+
+ helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
+ }
+
+ /**
+ * Test the query optimizer's ability to properly plan and optimize a query
+ * that uses ambiguous alias names in the top level query and its sub-query.
+ * <p>
+ * For example, <code>SELECT A.e2 FROM (SELECT e12FROM pm1.g1 AS A) AS A</code>
+ * <p>
+ * The test is to ensure that A.e2 from the top level is not confused with
+ * e2 in the second level.
+ * <p>
+ * Related Defects: JBEDSP-1137
+ */
+ @Test public void testAmbiguousAliasInSubQuerySource() {
+ // Create query
+ String sql = "SELECT A.e2 AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT e2 AS e2 FROM pm1.g1 AS A" + //$NON-NLS-1$
+ ") AS A"; //$NON-NLS-1$
+
+ helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT e2 FROM pm1.g1 AS A"}); //$NON-NLS-1$
+ }
+
+ /**
+ * Test the query optimizer's ability to properly plan and optimize a query
+ * that uses ambiguous alias names in the top level query and its sub-query
+ * and uses columns belonging to the alias as a parameter to a function.
+ * <p>
+ * For example, <code>SELECT CONVERT(A.e2, biginteger) AS e2 FROM (SELECT
+ * CONVERT(e2, long) AS e2 FROM pm1.g1 AS A) AS A</code>
+ * <p>
+ * The test is to ensure that A.e2 from the top level is not confused with
+ * e2 in the second level.
+ * <p>
+ * Related Defects: JBEDSP-1137
+ */
+ @Test public void testAmbiguousAliasFunctionInSubQuerySource() {
+ // Create query
+ String sql = "SELECT CONVERT(A.e2, biginteger) AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT CONVERT(e2, long) AS e2 FROM pm1.g1 AS A" + //$NON-NLS-1$
+ ") AS A"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ helpPlan(sql, metadata, new String[] {"SELECT e2 FROM pm1.g1 AS A"}); //$NON-NLS-1$
+
+ // Add convert capability to pm1 and try it again
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ helpPlan(sql, metadata, null, capFinder,
+ new String[] {"SELECT CONVERT(CONVERT(e2, long), biginteger) FROM pm1.g1 AS A"}, //$NON-NLS-1$
+ SHOULD_SUCCEED );
+ }
+
+ public static final boolean DEBUG = false;
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestOptionalJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,503 @@
+/*
+ * 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.optimizer;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestOptionalJoins {
+
+ @Test public void testOptionalJoinNode1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode1_1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1,pm2.g2.e1 FROM pm1.g1, /* optional */ pm2.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm2.g2.e1 FROM pm2.g2"} ); //$NON-NLS-1$//$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinNode2() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2, pm1.g3", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g3 AS g_1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode3() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode3_1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1, pm2.g2.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm2.g2 on pm1.g1.e1 = pm2.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"} ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinNode4() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode5() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g2 AS g_1 ON g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode6() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g3 AS g_1 ON g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode7() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g3.e1 FROM pm1.g3"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode8() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ (select * from pm1.g2) as X on pm1.g1.e1 = x.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode9() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g2.e1 FROM pm1.g2, /* optional */ vm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g2.e1 FROM pm1.g2"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode10() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM /* optional */ vm1.g1, pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode11() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ vm1.g2 on pm1.g1.e1 = vm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode12() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN vm1.g1 on pm1.g1.e1 = vm1.g1.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g3.e1 FROM pm1.g3"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode13() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT count(pm1.g1.e1) FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * The distinct prevents the removal of the optional join
+ */
+ @Test public void testOptionalJoinNode14() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT ve1 FROM vm1.g4", FakeMetadataFactory.example4(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0", "SELECT DISTINCT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 ORDER BY c_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinNode15() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinNode16() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1, (select distinct e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY y, z) AS x", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT e2, e3 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinNode17() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT e3 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinWithIntersection() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM pm1.g3 inner join (select pm1.g1.e2 as y from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1) AS x on pm1.g3.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e1 FROM pm1.g3 AS g_0, pm1.g1 AS g_1, pm1.g2 AS g_2 WHERE (g_1.e1 = g_2.e1) AND (g_0.e2 = g_1.e2)"}, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinWithNestedOrderBy() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM pm1.g3 inner join (select pm1.g2.e1, pm1.g1.e2 as y from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1 order by pm1.g2.e1 limit 10000) AS x on pm1.g3.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm1.g3 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1 ORDER BY g_1.e1"} ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Grouping will prevent the removal from happening
+ */
+ @Test public void testOptionalJoinWithGroupingOverAllColumns() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM pm1.g3, (select max(pm1.g1.e4) y from /* optional */ pm1.g1, pm1.g2 where pm1.g1.e1 = pm1.g2.e1) AS x where pm1.g3.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT g_0.e2, g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e4 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1"} ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 3, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Union should prevent the removal from happening
+ */
+ @Test public void testOptionalJoinWithUnion() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g2.e4 from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1 union all select convert(pm1.g2.e2, double) from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT pm1.g2.e4 FROM pm1.g2", "SELECT pm1.g2.e2 FROM pm1.g2"} ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinWithCompoundCriteria() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y and concat(x.y, x.z) = '1'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT e3 FROM pm1.g1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinWithDupRemoval() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT a.e1 from (SELECT distinct pm1.g1.e1, x.y FROM pm1.g1, /* optional */ (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x where pm1.g1.e2=x.y) as a", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] {"SELECT DISTINCT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT DISTINCT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"} ); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Cross Joins do not allow for join removal
+ * This could be optimized though as an exists predicate
+ */
+ @Test public void testOptionalJoinWithoutHint_crossJoin() {
+ ProcessorPlan plan = TestOptimizer
+ .helpPlan(
+ "SELECT distinct pm1.g1.e1 from pm1.g1, pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinWithoutHint_outerJoin() {
+ ProcessorPlan plan = TestOptimizer
+ .helpPlan(
+ "SELECT distinct pm1.g1.e2 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT DISTINCT g_0.e2 FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testOptionalJoinWithoutHint_aggregate() {
+ ProcessorPlan plan = TestOptimizer
+ .helpPlan(
+ "SELECT pm1.g1.e3, max(pm1.g1.e2) from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) group by pm1.g1.e3", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * The average agg will prevent the join removal
+ */
+ @Test public void testOptionalJoinWithoutHint_aggregate1() {
+ ProcessorPlan plan = TestOptimizer
+ .helpPlan(
+ "SELECT pm1.g1.e3, avg(pm1.g1.e2) from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) group by pm1.g1.e3", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g2 AS g_1 ON g_0.e1 = g_1.e1" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinWithoutHint_union() {
+ ProcessorPlan plan = TestOptimizer
+ .helpPlan(
+ "SELECT pm1.g1.e3 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) union select 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e3 FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Test public void testOptionalJoinWithOrderedLimit() {
+ ProcessorPlan plan = TestOptimizer
+ .helpPlan(
+ "select distinct * from (SELECT pm1.g1.e3 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) order by e3 limit 10) x", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e3 AS c_0 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g2 AS g_1 ON g_0.e1 = g_1.e1 ORDER BY c_0" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestPartitionedJoinPlanning.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,83 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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.optimizer;
+
+import static org.teiid.query.optimizer.TestOptimizer.*;
+
+import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.PartitionedSortJoin;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+
+
+public class TestPartitionedJoinPlanning {
+
+ @Test public void testUsePartitionedMergeJoin(){
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, 100);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE);
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE * 16);
+
+ ProcessorPlan plan = helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkNodeTypes(plan, new int[] {1}, new Class[] {PartitionedSortJoin.class});
+ }
+
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestPartitionedJoinPlanning.java
___________________________________________________________________
Name: svn:mergeinfo
+
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleMergeVirtual.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,321 @@
+/*
+ * 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.optimizer;
+
+import static junit.framework.Assert.*;
+
+import org.junit.Test;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.processor.relational.SortNode;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestRuleMergeVirtual {
+
+ @Test public void testSimpleMergeGroupBy() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT MAX(e2) AS x FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeGroupBy1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT v_0.c_1 FROM (SELECT DISTINCT g_0.e1 AS c_0, MAX(g_0.e2) AS c_1 FROM pm1.g1 AS g_0 GROUP BY g_0.e1) AS v_0"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Same as above but all required symbols are selected
+ */
+ @Test public void testSimpleMergeGroupBy2() {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x, e1 FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ metadata, null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeGroupBy3() {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x, e1 FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ metadata, null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeGroupBy4() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x, x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT v_0.c_0, v_0.c_0 FROM (SELECT MAX(g_0.e2) AS c_0 FROM pm1.g1 AS g_0 GROUP BY g_0.e1) AS v_0"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeGroupBy5() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z where z.x = 1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT MAX(e2) AS x FROM pm1.g1 GROUP BY e1 HAVING MAX(e2) = 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeGroupBy6() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z where z.x = 1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT MAX(e2) AS x FROM pm1.g1 GROUP BY e1 HAVING MAX(e2) = 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeGroupBy7() {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x, e1 FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
+ metadata, null, TestAggregatePushdown.getAggregatesFinder(),
+ new String[] {
+ "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeUnion() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {
+ "SELECT '1' AS x FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeUnion1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {
+ "SELECT '1' AS x FROM pm1.g1 UNION SELECT e1 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Same as above, but the expression will prevent the source removal
+ */
+ @Test public void testSimpleMergeUnion2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x || 'b' FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {
+ "SELECT '1' AS x FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testSimpleMergeUnion3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT distinct x FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x) y, pm1.g2", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {
+ "SELECT '1' AS x FROM pm1.g1 UNION SELECT e1 FROM pm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testSimpleMergeWithLimit() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * from (select e1 from pm1.g1 limit 1) x", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {
+ "SELECT e1 FROM pm1.g1 LIMIT 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSimpleMergeWithLimit1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * from (select e1 from pm1.g1 limit 1) x order by e1", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {
+ "SELECT e1 FROM pm1.g1 LIMIT 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Limit
+ 0, // NestedLoopJoinStrategy
+
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ }, TestLimit.NODE_TYPES);
+ }
+
+ /**
+ * Note that the merge is not performed since it would create an expression in the group by clause
+ */
+ @Test public void testViewPreservationWithGroupByExpression() throws Exception {
+ String sql = "SELECT gbl_date " + //$NON-NLS-1$
+ "FROM " + //$NON-NLS-1$
+ "(SELECT a.intkey as x, convert(a.TimestampValue, date) AS gbl_date, b.intkey as y " + //$NON-NLS-1$
+ "FROM bqt1.smalla a INNER JOIN bqt1.smallb b on a.stringkey=b.stringkey) as z " + //$NON-NLS-1$
+ "GROUP BY gbl_date"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT v_0.c_0 FROM (SELECT convert(g_0.TimestampValue, date) AS c_0 FROM bqt1.smalla AS g_0, bqt1.smallb AS g_1 WHERE g_0.stringkey = g_1.stringkey) AS v_0 GROUP BY v_0.c_0" }, //$NON-NLS-1$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testSortAliasWithSameName() throws Exception {
+ String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x order by e1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ SortNode node = (SortNode)plan.getRootNode();
+ assertTrue("Alias was not accounted for in sort node", node.getElements().containsAll(node.getSortElements())); //$NON-NLS-1$
+ }
+
+ @Test public void testMergeImplicitGroupBy() throws Exception {
+ BasicSourceCapabilities caps = TestAggregatePushdown.getAggregateCapabilities();
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT min(y), max(x) as x FROM (select e1 x, e2 + 1 y from pm1.g1) a) AS b", //$NON-NLS-1$
+ FakeMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
+ new String[] {
+ "SELECT MAX(g_0.e1) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRaiseNull.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,359 @@
+/*
+ * 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.optimizer;
+
+import java.util.Arrays;
+
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+import junit.framework.TestCase;
+
+
+
+public class TestRuleRaiseNull extends TestCase {
+
+ public static final int[] FULLY_NULL = new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 1, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ };
+
+ /**
+ * Test that criteria will cause a branch of a union to be excised if the criteria renders it
+ * impossible that the branch of the union would return results. In the following test,
+ * each branch of the union projects a "null" in a different column. So, an equality criteria on
+ * one of those columns should render one of the branches of the union unnecessary (since null
+ * never equals anything). Expected behavior is that a NullNode is inserted in place of the
+ * unnecessary access node.
+ */
+ public void testUnionCriteriaOptimization() {
+
+ String sql = "select * from ( select intkey as cola, null as colb, intnum as colc from bqt1.smalla union all select null, intkey, intnum from bqt2.smalla) as X where X.cola = 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {"SELECT intkey, null, intnum FROM bqt1.smalla WHERE intkey = 1"} ); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+
+ }
+
+ public void testRaiseNullWithInnerJoin() {
+ String sql = "select b.intkey from (select intkey from bqt1.smalla where 1 = 0) a inner join (select intkey from bqt1.smallb) b on (a.intkey = b.intkey)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{});
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
+ public void testRaiseNullWithFullOuterJoin() {
+ String sql = "select b.intkey from (select intkey from bqt1.smalla) a full outer join (select intkey from bqt1.smallb where 1 = 0) b on (a.intkey = b.intkey)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT null FROM bqt1.smalla"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithOuterJoin() {
+ String sql = "select b.intkey from (select intkey from bqt1.smalla) a left outer join (select intkey from bqt1.smallb where 1 = 0) b on (a.intkey = b.intkey)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT null FROM bqt1.smalla"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithOuterJoin1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "select smallb.intkey, smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (1 = 2)"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[]{"SELECT null, bqt1.smalla.intkey FROM bqt1.smalla"}, true); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithUnion() {
+ String sql = "select b.x from (select intkey as x from bqt1.smalla where 1 = 0 union all select intnum as y from bqt1.smalla) b"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT IntNum FROM bqt1.smalla"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+
+ assertEquals(Arrays.asList(new Object[] {new ElementSymbol("b.x")}), plan.getOutputElements()); //$NON-NLS-1$
+ }
+
+ public void testRaiseNullWithUnion1() {
+ String sql = "select b.intkey from (select intkey from bqt1.smalla union all select intnum from bqt1.smalla where 1 = 0) b"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT intkey FROM bqt1.smalla"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithUnion2() {
+ String sql = "select b.intkey, b.x from (select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select intnum as a, null from bqt1.smalla union all select 1 as z, intkey as b from bqt1.smallb) b"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT 1, intkey FROM bqt1.smallb", "SELECT IntNum, null FROM bqt1.smalla"}); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ public void testRaiseNullWithUnion3() {
+ String sql = "select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select intnum, intkey as z from bqt1.smalla where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{});
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
+ public void testRaiseNullWithUnion4() throws Exception {
+ String sql = "select b.intkey, b.x from (select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select 1 as z, intkey as b from bqt1.smallb) b inner join bqt1.smalla on b.intkey = bqt1.smalla.intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT 1, g_0.intkey FROM bqt1.smallb AS g_0, bqt1.smalla AS g_1 WHERE g_1.IntKey = 1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithUnion5() {
+ String sql = "select intkey from bqt1.smalla union all select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT intkey FROM bqt1.smalla"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithUnion6() {
+ String sql = "select intkey from bqt1.smalla union all select intkey from bqt2.smalla union all select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT intkey FROM bqt1.smalla", "SELECT intkey FROM bqt2.smalla"}); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ public void testPushCriteriaThroughUnion9() {
+ TestOptimizer.helpPlan("select * from vm1.u8 where const = 's1'", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT 's1', e1 FROM pm1.g1" } ); //$NON-NLS-1$
+ }
+
+ public void testPushCriteriaThroughUnion10() {
+ TestOptimizer.helpPlan("select * from vm1.u8 where const = 's3'", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { "SELECT 's3', e1 FROM pm1.g3" } ); //$NON-NLS-1$
+ }
+
+ public void testRaiseNullWithOuterJoinAndHaving() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "select smallb.intkey, smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (1 = 2) group by smalla.intkey, smallb.intkey having max(smallb.intkey) = 1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla"}, true); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Ensures proper handling of the removal of the first branch and
+ * duplicate symbol names in the next branch
+ */
+ public void testRaiseNullWithUnion7() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ String sql = "select max(intkey), intnum from (select intkey, intnum from bqt2.smalla where 1 = 0 union all select intnum, intnum from bqt2.smalla union all select intkey, stringkey from bqt2.smalla) x group by intnum"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[]{"SELECT MAX(v_0.c_1), v_0.c_0 FROM (SELECT g_1.IntNum AS c_0, g_1.IntNum AS c_1 FROM bqt2.smalla AS g_1 UNION ALL SELECT g_0.StringKey AS c_0, g_0.IntKey AS c_1 FROM bqt2.smalla AS g_0) AS v_0 GROUP BY v_0.c_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithUnionOrderBy() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "select intkey from bqt1.smalla where 1 = 0 union all select intnum from bqt2.smalla order by intkey"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder,
+ new String[]{"SELECT intnum AS intkey FROM bqt2.smalla ORDER BY intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithGroupBy() {
+ String sql = "select max(e2), e1 from pm1.g1 where 1 = 0 group by e1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{});
+
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
+ public void testRaiseNullWithGroupBy1() {
+ String sql = "select max(e2) from pm1.g1 where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{});
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 1, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ public void testRaiseNullWithExcept() {
+ String sql = "select e1 from pm1.g1 except select e2 from pm1.g2 where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{"SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithIntersect() {
+ String sql = "select max(e2) from pm1.g1 intersect select e2 from pm1.g2 where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{});
+
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
+ /**
+ * This tests that a criteria with no elements is not pushed down,
+ * but instead is cleaned up properly later
+ * See defect 9865
+ */
+ public void testCrossJoinNoElementCriteriaOptimization() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} = {b'false'}", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[0]);
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
+ public void testSelectLiteralFalseCriteria() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("Select 'x' from pm1.g1 where 1=0", TestOptimizer.example1(), //$NON-NLS-1$
+ new String[] { });
+ TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
+ }
+
+ public void testRaiseNullWithUnionNotAll() {
+ String sql = "select intkey from bqt2.smalla union select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[]{"SELECT DISTINCT intkey FROM bqt2.smalla"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ public void testRaiseNullWithUnionAndAliases() {
+ String sql = "select pm1.g1.e1 from pm1.g1, (select e1 from pm1.g1 where (1 = 0) union all select e1 as x from pm1.g2) x where pm1.g1.e1 <> x.e1"; //$NON-NLS-1$
+
+ RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[]{"SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 <> g_1.e1"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRemoveSorts.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestRuleRemoveSorts.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,125 @@
+/*
+ * 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.optimizer;
+
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+import junit.framework.TestCase;
+
+
+public class TestRuleRemoveSorts extends TestCase {
+
+ /** Tests an order by in a query transformation */
+ public void testRemovedOrderByFromQueryTransform() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1, e2 FROM vm1.g14", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Tests an order by in a query transformation, where the
+ * physical model does not support pushing order bys
+ */
+ public void testRemovedOrderByFromQueryTransform2() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e, e2 FROM vm1.g8", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Tests an order by in a query transformation, where the
+ * query transformation contains a function
+ */
+ public void testRemovedOrderByFromQueryTransform3() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e, e2 FROM vm1.g16", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm3.g1"}); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Tests an order by in a query transformation */
+ public void testRemovedOrderByFromQueryTransform4() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1, e2 FROM vm1.g13", FakeMetadataFactory.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$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /** Order by is not removed */
+ public void testOrderByWithLimit() throws Exception {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT e1, e2 FROM pm1.g1 order by e1 limit 10) x", FakeMetadataFactory.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$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSortOptimization.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,171 @@
+/*
+ * 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.optimizer;
+
+import static org.teiid.query.optimizer.TestOptimizer.*;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestSortOptimization {
+
+ @Test public void testSortDupCombination() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Create query
+ String sql = "select distinct e1, e2 from pm1.g1 order by e2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ checkNodeTypes(plan, new int[] {1}, new Class[] {DupRemoveSortNode.class});
+ }
+
+ @Test public void testSortDupCombination1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Create query
+ String sql = "select e1, e2 from pm1.g1 union select e1, e2 from pm1.g2 order by e2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1", "SELECT e1, e2 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ checkNodeTypes(plan, new int[] {1}, new Class[] {DupRemoveSortNode.class});
+ }
+
+ @Test public void testSortDupCombination2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Create query
+ String sql = "select x.*, y.* from (select distinct e1, e2 from pm1.g1) x, (select distinct e1, e2 from pm1.g2) y where x.e1 = y.e1"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT e1, e2 FROM pm1.g1", "SELECT e1, e2 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+
+ checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkNodeTypes(plan, new int[] {0}, new Class[] {DupRemoveSortNode.class});
+ }
+
+ @Test public void testGroupDupCombination() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Create query
+ String sql = "select max(e1), e2 from (select distinct e1, e2 from pm1.g1) x group by e2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkNodeTypes(plan, new int[] {0}, new Class[] {DupRemoveSortNode.class});
+ }
+
+ @Test public void testSortGroupCombination() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Create query
+ String sql = "select max(e1), e2 from pm1.g1 x group by e2 order by e2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
+ new String[] {"SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
+
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ checkNodeTypes(plan, new int[] {0}, new Class[] {DupRemoveSortNode.class});
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSortOptimization.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestStoredProcedurePlanning.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,415 @@
+/*
+ * 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.optimizer;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestStoredProcedurePlanning {
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 1a
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery2() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 1b
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery3() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq2('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery4() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select x.e1 from (EXEC pm1.sq1()) as x", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testStoredQuery5() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testStoredQuery6() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select x.e1 from (EXEC pm1.sp1()) as x", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery7() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sqsp1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 1c
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery8() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq3('1', 1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'", "SELECT e1, e2 FROM pm1.g1 WHERE e2 = 1" }); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 5a
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery9() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq4()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] {"SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 5b
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery10() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq5('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'"}); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 5c
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery11() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq6()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] {"SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 6a
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery12() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq7()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 6c
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery13() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq8('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 6b
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery14() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq9('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 6d
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery15() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq10('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ /**
+ * Test planning stored queries.
+ */
+ @Test public void testStoredQuery16() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp2(1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp2(1)" }); //$NON-NLS-1$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Test planning stored queries. GeminiStoredQueryTestPlan - 6d
+ */
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery17() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq11(1, 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp2(?)" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ //GeminiStoredQueryTestPlan - 2a, 2b
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery18() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq12('1', 1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 1)" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ //GeminiStoredQueryTestPlan - 2c
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery19() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq13('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 2)" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ //GeminiStoredQueryTestPlan - 3c
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery20() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq14('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "UPDATE pm1.g1 SET e1 = '1' WHERE e2 = 2" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ //GeminiStoredQueryTestPlan - 4b
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery21() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq15('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery22() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (EXEC pm1.sq1()) as x where e1='a' union (select e1 from vm1.g2 where e1='b')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'a'", "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'b') AND (g_1.e1 = 'b')" }); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery23() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq16()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 2)" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testStoredQuery24() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp3()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp3()" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ // test implicit type conversion of argument
+ @Ignore("stored procedure wrapper removal logic has been removed")
+ @Test public void testStoredQuery25() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq15(1, 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+ }
+
+ @Test public void testStoredQueryXML1() {
+ TestOptimizer.helpPlan("EXEC pm1.sq18()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), new String[] { }); //$NON-NLS-1$
+ }
+
+ /**
+ * union of two stored procs - case #1466
+ */
+ @Test public void testStoredProc1() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT * FROM (EXEC pm1.sp2(1)) AS x UNION ALL SELECT * FROM (EXEC pm1.sp2(2)) AS y", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp2(1)", "EXEC pm1.sp2(2)" }); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 4, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ /**
+ * union of stored proc and query - case #1466
+ */
+ @Test public void testStoredProc2() {
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT * FROM (EXEC pm1.sp2(1)) AS x UNION ALL SELECT e1, e2 FROM pm1.g1", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
+ new String[] { "EXEC pm1.sp2(1)", "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$ //$NON-NLS-2$
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,715 @@
+/*
+ * 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.optimizer;
+
+import static org.teiid.query.optimizer.TestOptimizer.*;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.resource.cci.SourceSystemFunctions;
+
+
+public class TestSubqueryPushdown {
+
+ @Test public void testPushSubqueryBelowVirtual() throws Exception {
+ String sql = "select g3.e1 from (select e1, max(e2) y from pm1.g1 group by e1) x, pm1.g3 where exists (select e1 from pm1.g2 where x.e1 = e1)"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE EXISTS (SELECT g_1.e1 FROM pm1.g2 AS g_1 WHERE g_1.e1 = g_0.e1)", //$NON-NLS-1$
+ "SELECT g_0.e1 FROM pm1.g3 AS g_0" }, //$NON-NLS-1$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Same as above, but using a correlated variable based on an aggregate
+ * @throws Exception
+ */
+ @Test public void testDontPushSubqueryBelowVirtual() throws Exception {
+ String sql = "select g3.e1 from (select e1, max(e2) y from pm1.g1 group by e1) x, pm1.g3 where exists (select e1 from pm1.g2 where x.y = e1)"; //$NON-NLS-1$
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
+ null, capFinder,
+ new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", //$NON-NLS-1$
+ "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0" }, //$NON-NLS-1$
+ TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 1, // Grouping
+ 1, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushCorrelatedSubquery1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey)" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushCorrelatedSubquery2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sqlIn =
+ "SELECT c37n.intkey " + //$NON-NLS-1$
+ "FROM bqt1.mediuma AS c37n, bqt1.smallb AS m37n " + //$NON-NLS-1$
+ "WHERE (m37n.stringkey LIKE '%0') AND " + //$NON-NLS-1$
+ "(c37n.stringkey = ('1' || (m37n.intkey || '0'))) AND " + //$NON-NLS-1$
+ "(c37n.datevalue = (" + //$NON-NLS-1$
+ "SELECT MAX(c37s.datevalue) " + //$NON-NLS-1$
+ "FROM bqt1.mediuma AS c37s, bqt1.smallb AS m37s " + //$NON-NLS-1$
+ "WHERE (m37s.stringkey LIKE '%0') AND " + //$NON-NLS-1$
+ "(c37s.stringkey = ('1' || (m37s.intkey || '0'))) AND " + //$NON-NLS-1$
+ "(m37s.stringkey = m37n.stringkey) ))"; //$NON-NLS-1$
+
+ String sqlOut = "SELECT g_0.intkey FROM bqt1.mediuma AS g_0, bqt1.smallb AS g_1 WHERE (g_0.stringkey = concat('1', concat(g_1.intkey, '0'))) AND (g_0.datevalue = (SELECT MAX(g_2.datevalue) FROM bqt1.mediuma AS g_2, bqt1.smallb AS g_3 WHERE (g_2.stringkey = concat('1', concat(g_3.intkey, '0'))) AND (g_3.stringkey LIKE '%0') AND (g_3.stringkey = g_1.stringkey))) AND (g_1.stringkey LIKE '%0')"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sqlIn, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { sqlOut }, SHOULD_SUCCEED);
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ @Test public void testPushCorrelatedSubquery3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
+ caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sqlIn =
+ "SELECT intkey " + //$NON-NLS-1$
+ "FROM vqt.smalla AS e " + //$NON-NLS-1$
+ "WHERE (stringkey = 'VOD.L') AND " + //$NON-NLS-1$
+ "(datevalue = (" + //$NON-NLS-1$
+ "SELECT MAX(datevalue) " + //$NON-NLS-1$
+ "FROM vqt.smalla " + //$NON-NLS-1$
+ "WHERE (stringkey = e.stringkey) ))"; //$NON-NLS-1$
+
+ String sqlOut =
+ "SELECT SmallA__1.IntKey FROM BQT1.SmallA AS SmallA__1 WHERE (SmallA__1.StringKey = 'VOD.L') AND (SmallA__1.DateValue = (SELECT MAX(BQT1.SmallA.DateValue) FROM BQT1.SmallA WHERE BQT1.SmallA.StringKey = SmallA__1.StringKey))"; //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan(sqlIn, FakeMetadataFactory.exampleBQTCached(),
+ null, capFinder,
+ new String[] { sqlOut }, SHOULD_SUCCEED);
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /**
+ * Check that scalar subquery in select is pushed
+ */
+ public void DEFER_testPushSubqueryInSelectClause1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT stringkey, (SELECT intkey FROM BQT1.SmallA AS b WHERE Intnum = 22) FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT stringkey, (SELECT intkey FROM BQT1.SmallA AS b WHERE Intnum = 22) FROM BQT1.SmallA" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCorrelatedSubquery1() {
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1 WHERE pm1.g1.e2 = pm2.g1.e2)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, pm1.g1.e2 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCorrelatedSubquery2() {
+ ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 WHERE pm1.g1.e2 = pm2.g1.e2) from pm1.g1", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, pm1.g1.e2 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 1, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer1() {
+ ProcessorPlan plan = helpPlan("Select e1 from vm1.g6 where e1 in (select e1 FROM pm2.g1 WHERE vm1.g6.e3 = pm2.g1.e2)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer2() {
+ ProcessorPlan plan = helpPlan("Select e1 from vm1.g6 where e1 in (select e1 FROM pm2.g1 WHERE vm1.g6.e4 = pm2.g1.e4)", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2, e4 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer3() {
+ ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 WHERE vm1.g6.e4 = pm2.g1.e4) from vm1.g6", example1(), //$NON-NLS-1$
+ new String[] { "SELECT e1, e2, e4 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 1, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation2() {
+ String sql = "Select * from vm1.g20"; //$NON-NLS-1$
+ ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" }); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery cannot all be pushed to the source.
+ */
+ @Test public void testNoPushSubqueryInWhereClause1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select max(e1) FROM pm1.g2)", example1(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery is from a different model
+ * than the outer query.
+ */
+ @Test public void testNoPushSubqueryInWhereClause2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", getTypicalCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Do not support XML query as subquery
+ * Check that subquery is not pushed if the subquery is not relational.
+ */
+ public void defer_testNoPushSubqueryInWhereClause3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select * from xmltest.doc1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery has a function that can't be pushed
+ * in the SELECT clause
+ */
+ @Test public void testNoPushSubqueryInWhereClause4() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT ltrim(e1) FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery selects a constant value
+ */
+ @Test public void testNoPushSubqueryInWhereClause5() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT 'xyz' FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery does ORDER BY
+ */
+ @Test public void testNoPushSubqueryInWhereClause6() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT e1 FROM pm1.g2 ORDER BY e1 limit 2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery has a function that can't be pushed
+ * in the SELECT clause
+ */
+ @Test public void testNoPushSubqueryInWhereClause7() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setFunctionSupport("ltrim", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT rtrim(ltrim(e1)) FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery holds non-query access node.
+ */
+ @Test public void testNoPushSubqueryInWhereClause8() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (EXEC pm1.sqsp1())", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Check that subquery is not pushed if the subquery is correlated and correlated not supported
+ */
+ @Test public void testNoPushSubqueryInWhereClause9() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = pm1.g1.e1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 1, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ @Test public void testPushMultipleCorrelatedSubquery1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_OR, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey ) or intkey = (SELECT MIN(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT g_0.intkey FROM bqt1.smalla AS g_0 WHERE (g_0.intkey = (SELECT MAX(g_1.intkey) FROM bqt1.smallb AS g_1 WHERE g_1.stringkey = g_0.stringkey)) OR (g_0.intkey = (SELECT MIN(g_2.IntKey) FROM bqt1.smallb AS g_2 WHERE g_2.StringKey = g_0.stringkey))" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+ /*
+ * Expressions containing subqueries can be pushed down
+ */
+ @Test public void testProjectSubqueryPushdown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ FakeMetadataFacade metadata = example1();
+
+ BasicSourceCapabilities caps = getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setFunctionSupport("+", true); //$NON-NLS-1$
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = helpPlan("select pm1.g1.e1, convert((select max(vm1.g1.e1) from vm1.g1), integer) + 1 from pm1.g1", metadata, //$NON-NLS-1$
+ null, capFinder,
+ new String[] { "SELECT g_0.e1, (convert((SELECT MAX(g_1.e1) FROM pm1.g1 AS g_1), integer) + 1) FROM pm1.g1 AS g_0" }, SHOULD_SUCCEED); //$NON-NLS-1$
+ checkNodeTypes(plan, FULL_PUSHDOWN);
+ }
+
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/TestSubqueryPushdown.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestUnionPlanning.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/TestUnionPlanning.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,159 @@
+/*
+ * 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.optimizer;
+
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+import junit.framework.TestCase;
+
+public class TestUnionPlanning extends TestCase {
+
+ public void testUnionPushDown() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
+ new String[] { "SELECT IntNum FROM BQT2.SmallA", "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+ }
+
+ /**
+ * Here the change in the all causes us not to pushdown
+ */
+ public void testUnionPushDown1() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
+ new String[] { "SELECT IntNum FROM BQT2.SmallA", "SELECT IntKey FROM BQT1.SmallA", "SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 2 // UnionAll
+ });
+ }
+
+ public void testUnionPushDown2() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
+ capFinder.addCapabilities("BQT3", caps1); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT3.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
+ new String[] { "SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA", "SELECT IntNum FROM BQT3.SmallA", "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 2 // UnionAll
+ });
+ }
+
+ public void testUnionPushDown3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
+ capFinder.addCapabilities("BQT3", caps1); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT3.SmallA UNION ALL (SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA)", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
+ new String[] { "SELECT IntNum FROM BQT3.SmallA", "SELECT IntNum FROM BQT2.SmallA UNION ALL (SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA)", "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 0, // Project
+ 0, // Select
+ 0, // Sort
+ 2 // UnionAll
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/batch (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch)
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/batch/TestBatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/TestBatchedUpdatePlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/batch/TestBatchedUpdatePlanner.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,40 +20,41 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.batch;
+package org.teiid.query.optimizer.batch;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.batch.BatchedUpdatePlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.BatchedUpdateNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorReport;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.batch.BatchedUpdatePlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.BatchedUpdateNode;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorReport;
/**
@@ -65,7 +66,7 @@
super(name);
}
- public static List<Command> helpGetCommands(String[] sql, QueryMetadataInterface md) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public static List<Command> helpGetCommands(String[] sql, QueryMetadataInterface md) throws TeiidComponentException, TeiidProcessingException {
if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
List<Command> commands = new ArrayList<Command>(sql.length);
for (int i = 0; i < sql.length; i++) {
@@ -84,12 +85,12 @@
return commands;
}
- private BatchedUpdateCommand helpGetCommand(String[] sql, QueryMetadataInterface md) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private BatchedUpdateCommand helpGetCommand(String[] sql, QueryMetadataInterface md) throws TeiidComponentException, TeiidProcessingException {
BatchedUpdateCommand command = new BatchedUpdateCommand(helpGetCommands(sql, md));
return command;
}
- private BatchedUpdatePlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ private BatchedUpdatePlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// plan
ProcessorPlan plan = null;
@@ -113,7 +114,7 @@
} catch (QueryPlannerException e) {
exception = e;
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
exception = e;
} finally {
if(DEBUG) {
@@ -128,11 +129,11 @@
return new DefaultCapabilitiesFinder(new FakeCapabilities(true));
}
- private BatchedUpdatePlan helpPlan(String[] sql, QueryMetadataInterface md) throws MetaMatrixComponentException, QueryMetadataException, MetaMatrixProcessingException {
+ private BatchedUpdatePlan helpPlan(String[] sql, QueryMetadataInterface md) throws TeiidComponentException, QueryMetadataException, TeiidProcessingException {
return helpPlan(sql, md, getGenericFinder(), true);
}
- private BatchedUpdatePlan helpPlan(String[] sql, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) throws MetaMatrixComponentException, QueryMetadataException, MetaMatrixProcessingException {
+ private BatchedUpdatePlan helpPlan(String[] sql, QueryMetadataInterface md, CapabilitiesFinder capFinder, boolean shouldSucceed) throws TeiidComponentException, QueryMetadataException, TeiidProcessingException {
Command command = helpGetCommand(sql, md);
if (capFinder == null){
@@ -154,7 +155,7 @@
}
}
- private void helpTestPlanner(String[] sql, boolean[] expectedBatching) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void helpTestPlanner(String[] sql, boolean[] expectedBatching) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
BatchedUpdatePlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached());
List plans = plan.getUpdatePlans();
assertEquals("Number of child plans did not match expected", expectedBatching.length, plans.size()); //$NON-NLS-1$
@@ -163,7 +164,7 @@
}
}
- private void helpTestPlanner(String[] sql, boolean[] expectedBatching, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void helpTestPlanner(String[] sql, boolean[] expectedBatching, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
BatchedUpdatePlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), capFinder, true);
List plans = plan.getUpdatePlans();
assertEquals("Number of child plans did not match expected", expectedBatching.length, plans.size()); //$NON-NLS-1$
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/capabilities)
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/capabilities/AllCapabilities.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/AllCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -23,8 +23,10 @@
/**
*
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+
public class AllCapabilities implements SourceCapabilities {
public boolean supportsCapability(Capability capability) {
return true;
@@ -35,7 +37,7 @@
}
/**
- * @see com.metamatrix.query.optimizer.capabilities.SourceCapabilities#getSourceProperty(java.lang.String)
+ * @see org.teiid.query.optimizer.capabilities.SourceCapabilities#getSourceProperty(java.lang.String)
* @since 4.4
*/
public Object getSourceProperty(Capability propertyName) {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/FakeCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/capabilities/FakeCapabilitiesFinder.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/FakeCapabilitiesFinder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+
/**
*/
public class FakeCapabilitiesFinder implements CapabilitiesFinder {
@@ -46,7 +49,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder#findCapabilities(java.lang.String)
*/
- public SourceCapabilities findCapabilities(String connectorBindingID) throws MetaMatrixComponentException {
+ public SourceCapabilities findCapabilities(String connectorBindingID) throws TeiidComponentException {
return caps.get(connectorBindingID);
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/TestBasicSourceCapabilities.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/capabilities/TestBasicSourceCapabilities.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/TestBasicSourceCapabilities.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,9 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import junit.framework.*;
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/TestDefaultCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/capabilities/TestDefaultCapabilitiesFinder.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/capabilities/TestDefaultCapabilitiesFinder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+
import junit.framework.TestCase;
/**
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/proc (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc)
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/TestProcedurePlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/proc/TestProcedurePlanner.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,28 +20,29 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.proc;
+package org.teiid.query.optimizer.proc;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorFailure;
+import org.teiid.query.validator.ValidatorReport;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorFailure;
-import com.metamatrix.query.validator.ValidatorReport;
public class TestProcedurePlanner extends TestCase {
@@ -55,14 +56,14 @@
// ################ getReplacementClause tests ###################
- private ProcessorPlan helpPlanProcedure(String procedure, String procedureType) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private ProcessorPlan helpPlanProcedure(String procedure, String procedureType) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
return helpPlanProcedure(null, procedure, procedureType);
}
private ProcessorPlan helpPlanProcedure(String userQuery,
String procedure,
- String procedureType) throws MetaMatrixComponentException,
- QueryMetadataException, MetaMatrixProcessingException {
+ String procedureType) throws TeiidComponentException,
+ QueryMetadataException, TeiidProcessingException {
QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
QueryParser parser = QueryParser.getQueryParser();
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestAliasGenerator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,153 @@
+/*
+ * 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.optimizer.relational;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.AliasGenerator;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.TestResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestAliasGenerator {
+
+ private Command helpTest(String sql,
+ String expected,
+ boolean aliasGroups,
+ QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException {
+ Command command = TestResolver.helpResolve(sql, metadata, null);
+ command = QueryRewriter.rewrite(command, metadata, null);
+ command.acceptVisitor(new AliasGenerator(aliasGroups));
+ assertEquals(expected, command.toString());
+ return command;
+ }
+
+ /**
+ * Ensures that views are named with v_ even without metadata
+ */
+ @Test public void testViewAliasing() throws Exception {
+ String sql = "select y.e1 from (select pm1.g1.e1 from pm1.g1) y"; //$NON-NLS-1$
+ Query command = (Query)QueryParser.getQueryParser().parseCommand(sql);
+ ((ElementSymbol)command.getSelect().getSymbol(0)).setGroupSymbol(new GroupSymbol("y")); //$NON-NLS-1$
+ command.acceptVisitor(new AliasGenerator(true));
+ assertEquals("SELECT v_0.c_0 FROM (SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 AS g_0) AS v_0", command.toString()); //$NON-NLS-1$
+ }
+
+ @Test public void testLongOrderByAlias() throws Exception {
+ String sql = "select pm1.g1.e1 || pm1.g1.e2 as asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa, pm1.g1.e2 from pm1.g1 order by asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa"; //$NON-NLS-1$
+ String expected = "SELECT concat(g_0.e1, g_0.e2) AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ }
+
+ @Test public void testOrderBySymbolName() throws Exception {
+ String sql = "select e1 from pm1.g1 order by e1"; //$NON-NLS-1$
+ String expected = "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
+ Query command = (Query)helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ assertEquals(command.getOrderBy().getSortKeys().get(0).getName(), "e1"); //$NON-NLS-1$
+ assertEquals(((SingleElementSymbol)command.getProjectedSymbols().get(0)).getShortName(), "e1"); //$NON-NLS-1$
+ }
+
+ @Test public void testInlineViewWithSubQuery() throws Exception {
+ String sql = "select intnum from (select intnum from bqt1.smallb where intnum in (select intnum a from bqt1.smalla)) b"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT g_1.intnum FROM bqt1.smalla AS g_1)) AS v_0"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testInlineViewOrderBy() throws Exception {
+ String sql = "select intnum from (select intnum from bqt1.smallb) b order by b.intnum"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0 ORDER BY c_0"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testNestedInlineViewOrderBy() throws Exception {
+ String sql = "select x from (select intnum x from (select intnum from bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
+ String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0) AS v_1 ORDER BY c_0"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testInlineViewWithOnClause() throws Exception {
+ String sql = "select abcd.efg from (select intkey as efg from bqt1.smalla) abcd inner join (select intnum from bqt1.smallb) b on (b.intnum = abcd.efg)"; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0) AS v_0 INNER JOIN (SELECT g_1.intnum AS c_0 FROM bqt1.smallb AS g_1) AS v_1 ON v_1.c_0 = v_0.c_0"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testUnionOrderBy() throws Exception {
+ String sql = "select e1, e2 as c_0 from pm1.g1 union all select 1, e1 from pm1.g2 order by e1"; //$NON-NLS-1$
+ String expected = "SELECT g_1.e1 AS c_0, g_1.e2 AS c_1 FROM pm1.g1 AS g_1 UNION ALL SELECT '1' AS c_0, g_0.e1 AS c_1 FROM pm1.g2 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ }
+
+ @Test public void testDuplicateShortElementName() throws Exception {
+ String sql = "select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 order by pm1.g1.e1, pm1.g2.e1"; //$NON-NLS-1$
+ String expected = "SELECT g_0.e1 AS c_0, g_1.e1 AS c_1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 ORDER BY c_0, c_1"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
+ }
+
+ @Test public void testCorrelatedRefernce() throws Exception {
+ String sql = "select intnum, stringnum from (select intnum, stringnum from bqt1.smallb) b where intnum in (select b.stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
+ String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0, g_0.stringnum AS c_1 FROM bqt1.smallb AS g_0) AS v_0 WHERE v_0.c_0 IN (SELECT concat(v_0.c_1, v_1.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_1)"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testCorrelatedRefernce1() throws Exception {
+ String sql = "select intnum, stringnum from bqt1.smallb where intnum in (select stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
+ String expected = "SELECT g_0.intnum, g_0.stringnum FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT concat(g_0.stringnum, v_0.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_0)"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testGroupAliasNotSupported() throws Exception {
+ String sql = "select b.intkey from bqt1.smalla b"; //$NON-NLS-1$
+ String expected = "SELECT bqt1.smalla.intkey FROM bqt1.smalla"; //$NON-NLS-1$
+ helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testUnionAliasing() throws Exception {
+ String sql = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA"; //$NON-NLS-1$
+ String expected = "SELECT BQT1.SmallA.IntKey AS c_0 FROM BQT1.SmallA UNION ALL SELECT BQT1.SmallA.IntNum AS c_0 FROM BQT1.SmallA"; //$NON-NLS-1$
+ helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testUnrelatedOrderBy() throws Exception {
+ String sql = "SELECT b.IntKey FROM BQT1.SmallA a, BQT1.SmallA b ORDER BY a.StringKey"; //$NON-NLS-1$
+ String expected = "SELECT g_1.IntKey AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallA AS g_1 ORDER BY g_0.StringKey"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+ @Test public void testUnrelatedOrderBy1() throws Exception {
+ String sql = "SELECT b.IntKey FROM (select intkey, stringkey from BQT1.SmallA) a, (select intkey, stringkey from BQT1.SmallA) b ORDER BY a.StringKey"; //$NON-NLS-1$
+ String expected = "SELECT v_1.c_0 FROM (SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.intkey AS c_0, g_1.stringkey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY v_0.c_1"; //$NON-NLS-1$
+ helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -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.query.optimizer.relational;
+
+import static org.junit.Assert.*;
+import static org.teiid.query.optimizer.TestOptimizer.*;
+
+import java.util.Collection;
+
+import org.junit.Ignore;
+import org.junit.Test;
+import org.teiid.client.plan.Annotation;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestMaterialization {
+
+ @Test public void testMaterializedTransformation() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection<Annotation> annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
+ @Test public void testMaterializedTransformationLoading() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection<Annotation> annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testMaterializedTransformationNoCache() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection<Annotation> annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ //related to defect 14423
+ @Test public void testMaterializedTransformationNoCache2() throws Exception {
+ String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ Collection<Annotation> annotations = analysis.getAnnotations();
+ assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
+ assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
+ assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheInTransformation() throws Exception {
+ String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testTableNoCacheDoesntCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+ @Test public void testNoCacheCascade() throws Exception {
+ String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
+ AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
+
+ Command command = helpGetCommand(userSql, metadata, null);
+
+ TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestMaterialization.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestRuleStack.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestRuleStack.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestRuleStack.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/TestRuleStack.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,102 @@
+/*
+ * 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.optimizer.relational;
+
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.rules.RuleConstants;
+import org.teiid.query.optimizer.relational.rules.RulePushSelectCriteria;
+
+import junit.framework.TestCase;
+
+
+/**
+ */
+public class TestRuleStack extends TestCase {
+
+ /**
+ * Constructor for TestRuleStack.
+ * @param arg0
+ */
+ public TestRuleStack(String arg0) {
+ super(arg0);
+ }
+
+
+ public void testInitialization() {
+ RuleStack stack = new RuleStack();
+ assertEquals("Initial stack is not empty", true, stack.isEmpty()); //$NON-NLS-1$
+ assertEquals("Initial size is not 0", 0, stack.size()); //$NON-NLS-1$
+ assertNull("Top is not null", stack.pop()); //$NON-NLS-1$
+ }
+
+ public void helpTestPop(RuleStack stack, OptimizerRule expectedPop, int expectedSize) {
+ OptimizerRule out = stack.pop();
+ int outSize = stack.size();
+
+ assertSame("Did not get same object", expectedPop, out); //$NON-NLS-1$
+ assertEquals("Stack changed size", expectedSize, outSize); //$NON-NLS-1$
+ }
+
+ public void testPopOneRule() {
+ RuleStack stack = new RuleStack();
+ int expectedSize = stack.size();
+
+ OptimizerRule rule = new RulePushSelectCriteria();
+ stack.push(rule);
+
+ helpTestPop(stack, rule, expectedSize);
+ }
+
+ public void testPopNothing() {
+ RuleStack stack = new RuleStack();
+ helpTestPop(stack, null, 0);
+ }
+
+ public void testRemove() {
+ // Set up
+ RuleStack stack = new RuleStack();
+ stack.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
+ stack.push(RuleConstants.COLLAPSE_SOURCE);
+ stack.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
+
+ // Remove all instances of ASSIGN_OUTPUT_ELEMENTS
+ stack.remove(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
+
+ // Verify size and pop'ed values
+ assertEquals(1, stack.size());
+ assertEquals(RuleConstants.COLLAPSE_SOURCE, stack.pop());
+ assertEquals(null, stack.pop());
+ }
+
+ public void testContains() {
+ // Set up
+ RuleStack stack = new RuleStack();
+ stack.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
+ stack.push(RuleConstants.COLLAPSE_SOURCE);
+
+ assertEquals(true, stack.contains(RuleConstants.ASSIGN_OUTPUT_ELEMENTS));
+ assertEquals(false, stack.contains(RuleConstants.PLACE_ACCESS));
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/plantree (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/plantree)
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/plantree/TestNodeEditor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/plantree/TestNodeEditor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/plantree/TestNodeEditor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.plantree;
+package org.teiid.query.optimizer.relational.plantree;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
*/
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules)
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCalculateCostUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCalculateCostUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCalculateCostUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,32 +20,33 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import static org.junit.Assert.*;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.rules.NewCalculateCostUtil;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.TestVirtualDepJoin;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.TestVirtualDepJoin;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.util.CommandContext;
public class TestCalculateCostUtil {
@@ -53,7 +54,7 @@
// HELPERS
// =====================================================================
- private static Criteria helpGetCriteria(String critString, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ private static Criteria helpGetCriteria(String critString, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException{
Criteria result = QueryParser.getQueryParser().parseCriteria(critString);
QueryResolver.resolveCriteria(result, metadata);
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCapabilitiesUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCapabilitiesUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,33 +20,34 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.CapabilitiesUtil;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
/**
*/
@@ -60,7 +61,7 @@
super(name);
}
- public void helpTestSupportsSelfJoin(boolean supportsSelfJoin, boolean supportsGroupAlias, boolean expectedValue) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsSelfJoin(boolean supportsSelfJoin, boolean supportsGroupAlias, boolean expectedValue) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -100,7 +101,7 @@
}
- public void helpTestSupportsOuterJoin(boolean capsSupportsOuterJoin, boolean capsSupportsFullOuterJoin, JoinType joinType, boolean expectedValue) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsOuterJoin(boolean capsSupportsOuterJoin, boolean capsSupportsFullOuterJoin, JoinType joinType, boolean expectedValue) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -137,7 +138,7 @@
helpTestSupportsOuterJoin(true, true, JoinType.JOIN_FULL_OUTER, true);
}
- public void helpTestSupportsAggregates(boolean capsSupportsAggregates, boolean supportsFunctionInGroupBy, List groupCols) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsAggregates(boolean capsSupportsAggregates, boolean supportsFunctionInGroupBy, List groupCols) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -172,7 +173,7 @@
helpTestSupportsAggregates(false, false, cols);
}
- public void helpTestSupportsAggregateFunction(SourceCapabilities caps, AggregateSymbol aggregate, boolean expectedValue) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsAggregateFunction(SourceCapabilities caps, AggregateSymbol aggregate, boolean expectedValue) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -368,7 +369,7 @@
helpTestSupportsAggregateFunction(caps, aggregate, true);
}
- public void helpTestSupportsScalar(SourceCapabilities caps, Function function, boolean expectedValue) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsScalar(SourceCapabilities caps, Function function, boolean expectedValue) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -478,7 +479,7 @@
assertEquals("Got wrong answer for supports", false, actual); //$NON-NLS-1$
}
- public void helpTestSupportsUnion(boolean supports) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsUnion(boolean supports) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -502,7 +503,7 @@
helpTestSupportsUnion(false);
}
- public void helpTestSupportsLiterals(boolean supports) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTestSupportsLiterals(boolean supports) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
@@ -526,7 +527,7 @@
helpTestSupportsLiterals(false);
}
- public void helpTtestSupportsCaseExpression(boolean supports, boolean searched) throws QueryMetadataException, MetaMatrixComponentException {
+ public void helpTtestSupportsCaseExpression(boolean supports, boolean searched) throws QueryMetadataException, TeiidComponentException {
// Set up metadata
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
FakeMetadataObject modelID = metadata.getStore().findObject("pm1", FakeMetadataObject.MODEL); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCriteriaCapabilityValidatorVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestCriteriaCapabilityValidatorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestCriteriaCapabilityValidatorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,25 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidException;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.CriteriaCapabilityValidatorVisitor;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
import static org.junit.Assert.*;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
/**
*/
@@ -55,7 +56,7 @@
if (!expectException) {
throw new RuntimeException(e);
}
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
}
@@ -72,7 +73,7 @@
if (!expectException) {
throw new RuntimeException(e);
}
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestFrameUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestFrameUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestFrameUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import static org.junit.Assert.*;
@@ -29,18 +29,19 @@
import java.util.Set;
import org.junit.Test;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.optimizer.relational.rules.FrameUtil;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
public class TestFrameUtil {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestGroupRecontext.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestGroupRecontext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestGroupRecontext.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,19 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import org.teiid.query.optimizer.relational.rules.FrameUtil;
+import org.teiid.query.optimizer.relational.rules.RulePlaceAccess;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestGroupRecontext extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestJoinRegion.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestJoinRegion.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestJoinRegion.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,16 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.JoinType;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.rules.JoinRegion;
+import org.teiid.query.optimizer.relational.rules.RulePlanJoins;
+import org.teiid.query.sql.lang.JoinType;
+
import junit.framework.TestCase;
public class TestJoinRegion extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAccessPatternValidation.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import static org.junit.Assert.*;
@@ -28,27 +28,27 @@
import java.util.Collection;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.PlanHints;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.PlanHints;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
/**
* Tests {@link RuleChooseAccessPattern}
@@ -108,7 +108,7 @@
* Simulate execution of the QueryOptimizer rules stack
*/
private static PlanNode helpExecuteRules(RuleStack rules, PlanNode plan, QueryMetadataInterface metadata, boolean debug)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
CommandContext context = new CommandContext();
while(! rules.isEmpty()) {
if(debug) {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAssignOutputElements.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleAssignOutputElements.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleAssignOutputElements.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,10 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
-import com.metamatrix.query.optimizer.relational.plantree.*;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.optimizer.relational.plantree.*;
+import org.teiid.query.optimizer.relational.rules.RuleAssignOutputElements;
+import org.teiid.query.sql.lang.SetQuery.Operation;
import junit.framework.*;
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleChooseDependent.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleChooseDependent.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleChooseDependent.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,38 +30,43 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.rules.FrameUtil;
+import org.teiid.query.optimizer.relational.rules.RuleChooseDependent;
+import org.teiid.query.optimizer.relational.rules.RuleChooseJoinStrategy;
+import org.teiid.query.optimizer.relational.rules.RulePlaceAccess;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.util.CommandContext;
public class TestRuleChooseDependent extends TestCase {
@@ -186,7 +191,7 @@
* @param atomicRequestCrit2 optional, may be null
* @param joinCriteria Collection of Criteria to add to join node
* @param expectedMadeDependent one of the three outcome possibility class constants
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
* @throws QueryPlannerException
*/
@@ -195,7 +200,7 @@
GroupSymbol atomicRequestGroup2,
Criteria atomicRequestCrit2,
Collection joinCriteria,
- int expectedMadeDependent) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ int expectedMadeDependent) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
helpTestChooseSiblingAndMarkDependent(atomicRequestGroup1,
atomicRequestCrit1,
@@ -233,7 +238,7 @@
* @param atomicJoinCriteria2 optional, may be null
* @param joinCriteria Collection of Criteria to add to outer join node
* @param expectedMadeDependent one of the three outcome possibility class constants
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
* @throws QueryPlannerException
*/
@@ -248,7 +253,7 @@
Criteria atomicRequestCrit2a, //optional
Collection atomicJoinCriteria2, //optional
Collection joinCriteria,
- int expectedMadeDependent) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ int expectedMadeDependent) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
//EXAMPLE:
// Project(groups=[])
// Join(groups=[], props={21=joinCriteria, 23=true, 22=INNER JOIN})
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePlaceAccess.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePlaceAccess.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePlaceAccess.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,22 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Collection;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.rules.RulePlaceAccess;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.TestCase;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestRulePlaceAccess extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRulePushSelectCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import static org.junit.Assert.*;
@@ -30,27 +30,28 @@
import java.util.Set;
import org.junit.Test;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.optimizer.relational.rules.RulePushSelectCriteria;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
public class TestRulePushSelectCriteria {
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleValidateWhereAll.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/TestRuleValidateWhereAll.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/relational/rules/TestRuleValidateWhereAll.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,20 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.RuleValidateWhereAll;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.TestCase;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestRuleValidateWhereAll extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/optimizer/xml (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml)
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/FakeXMLMetadata.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/FakeXMLMetadata.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/FakeXMLMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,16 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingChoiceNode;
-import com.metamatrix.query.mapping.xml.MappingCommentNode;
-import com.metamatrix.query.mapping.xml.MappingCriteriaNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCommentNode;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestContextReplacerVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestContextReplacerVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestContextReplacerVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,16 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.query.optimizer.xml.ContextReplacerVisitor;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestHandleNillableNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestHandleNillableNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestHandleNillableNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Properties;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.optimizer.xml.HandleNillableVisitor;
+
import junit.framework.TestCase;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestMarkExcludeVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestMarkExcludeVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestMarkExcludeVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,21 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Collection;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingOutputter;
+import org.teiid.query.optimizer.xml.XMLPlanner;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+
import junit.framework.TestCase;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingOutputter;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestNameInSourceResolverVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestNameInSourceResolverVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestNameInSourceResolverVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,25 +29,29 @@
import java.util.List;
import java.util.Map;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.xml.NameInSourceResolverVisitor;
+import org.teiid.query.optimizer.xml.SourceNodeGenaratorVisitor;
+import org.teiid.query.optimizer.xml.XMLPlannerEnvironment;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestRemoveExcludedVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestRemoveExcludedVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestRemoveExcludedVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.io.PrintWriter;
import java.io.StringWriter;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingOutputter;
+import org.teiid.query.optimizer.xml.XMLPlanner;
+
import junit.framework.TestCase;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingOutputter;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestXMLNodeMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestXMLNodeMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestXMLNodeMappingVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,21 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.xml.SourceNodeGenaratorVisitor;
+import org.teiid.query.optimizer.xml.XMLNodeMappingVisitor;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
/**
*/
@@ -48,7 +51,7 @@
super(arg0);
}
- public void helpTestMapping(Criteria crit, String expectedCritString, MappingDocument mappingDoc, QueryMetadataInterface metadata) throws QueryPlannerException, MetaMatrixComponentException {
+ public void helpTestMapping(Criteria crit, String expectedCritString, MappingDocument mappingDoc, QueryMetadataInterface metadata) throws QueryPlannerException, TeiidComponentException {
crit = XMLNodeMappingVisitor.convertCriteria(crit, mappingDoc, metadata);
String actualCritString = crit.toString();
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestXMLPlanner.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/TestXMLPlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/xml/TestXMLPlanner.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,48 +20,52 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.id.IntegerIDFactory;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.Namespace;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.xml.CriteriaPlanner;
+import org.teiid.query.optimizer.xml.XMLPlanner;
+import org.teiid.query.optimizer.xml.XMLPlannerEnvironment;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.xml.BlockInstruction;
+import org.teiid.query.processor.xml.EndBlockInstruction;
+import org.teiid.query.processor.xml.ExecSqlInstruction;
+import org.teiid.query.processor.xml.ExecStagingTableInstruction;
+import org.teiid.query.processor.xml.MoveCursorInstruction;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.processor.xml.WhileInstruction;
+import org.teiid.query.processor.xml.XMLPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingSequenceNode;
-import com.metamatrix.query.mapping.xml.Namespace;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.xml.BlockInstruction;
-import com.metamatrix.query.processor.xml.EndBlockInstruction;
-import com.metamatrix.query.processor.xml.ExecSqlInstruction;
-import com.metamatrix.query.processor.xml.ExecStagingTableInstruction;
-import com.metamatrix.query.processor.xml.MoveCursorInstruction;
-import com.metamatrix.query.processor.xml.Program;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.processor.xml.WhileInstruction;
-import com.metamatrix.query.processor.xml.XMLPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.util.CommandContext;
public class TestXMLPlanner extends TestCase {
@@ -78,7 +82,7 @@
return preparePlan(command, md, TestOptimizer.getGenericFinder(), null);
}
- private void helpPlanException(String sql, QueryMetadataInterface md) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void helpPlanException(String sql, QueryMetadataInterface md) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
Command command = TestXMLProcessor.helpGetCommand(sql, md);
try {
@@ -784,10 +788,10 @@
* @return The XML plan returned as an XMLPlan object
* @throws QueryPlannerException
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
public static XMLPlan preparePlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
IDGenerator idGenerator = new IDGenerator();
idGenerator.setDefaultFactory(new IntegerIDFactory());
AnalysisRecord analysis = new AnalysisRecord(false, DEBUG);
Copied: trunk/engine/src/test/java/org/teiid/query/parser (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/parser)
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestCallableStatementParsing.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestCallableStatementParsing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
import static org.junit.Assert.*;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.StoredProcedure;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.sql.lang.StoredProcedure;
public class TestCallableStatementParsing {
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestOptionsAndHints.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestOptionsAndHints.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
import static org.junit.Assert.*;
@@ -29,39 +29,40 @@
import java.util.List;
import org.junit.Test;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.AbstractCompareCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.Statement;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.Statement;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
public class TestOptionsAndHints {
/** Select a From db.g1 MAKENOTDEP, db.g2 MAKENOTDEP WHERE a = b */
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParser.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParser.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
import static org.junit.Assert.*;
@@ -33,84 +33,83 @@
import java.util.List;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryParserException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.PredicateCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+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.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.BreakStatement;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.ContinueStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.proc.RaiseErrorStatement;
+import org.teiid.query.sql.proc.Statement;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.TestCaseExpression;
+import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLElement;
+import org.teiid.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.symbol.XMLNamespaces;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Create;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.PredicateCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.BreakStatement;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.ContinueStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.proc.RaiseErrorStatement;
-import com.metamatrix.query.sql.proc.Statement;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.TestCaseExpression;
-import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.XMLAttributes;
-import com.metamatrix.query.sql.symbol.XMLElement;
-import com.metamatrix.query.sql.symbol.XMLForest;
-import com.metamatrix.query.sql.symbol.XMLNamespaces;
-
@SuppressWarnings("nls")
public class TestParser {
@@ -147,7 +146,7 @@
try {
QueryParser.getQueryParser().parseCommand(sql);
fail("Expected exception for parsing " + sql); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
if (expected != null) {
assertEquals(expected, e.getMessage());
}
@@ -1409,7 +1408,7 @@
try {
QueryParser.getQueryParser().parseCommand(sql);
fail("Expected exception for parsing " + sql); //$NON-NLS-1$
- } catch (MetaMatrixException e) {
+ } catch (TeiidException e) {
//e.printStackTrace();
//if (e.getMessage().length() > 1000) {
// fail("Expected max length of message 1000; but received " + e.getMessage().length()); //$NON-NLS-1$
@@ -6382,7 +6381,7 @@
try {
QueryParser.getQueryParser().parseCommand(""); //$NON-NLS-1$
fail("Expected exception for parsing empty string"); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
emptyMessage = e.getMessage();
}
@@ -6390,7 +6389,7 @@
try {
QueryParser.getQueryParser().parseCommand(null);
fail("Expected exception for parsing null string"); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
nullMessage = e.getMessage();
}
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestParserXQuery.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestParserXQuery.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestParserXQuery.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
+import org.teiid.query.sql.lang.XQuery;
+
import junit.framework.TestCase;
-import com.metamatrix.query.sql.lang.XQuery;
public class TestParserXQuery extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/parser/TestSetQueryParsing.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/parser/TestSetQueryParsing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,18 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
import junit.framework.TestCase;
Copied: trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataManager.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeDataManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,403 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.logging.LogManager;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.TranslatableProcedureContainer;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+
+
+public class FakeDataManager implements ProcessorDataManager {
+ private Map tuples = new HashMap();
+ private static final String LOG_CONTEXT = "FAKE_DATA_MANAGER"; //$NON-NLS-1$
+
+ //used to test blocked exception. If true,
+ //the first time nextTuple is called on FakeTupleSource,
+ //it will throws BlockedExceptiom
+ private boolean blockOnce;
+
+ // ---- Cached code table stuff ----
+
+ // upper table name + upper key col name + upper ret col name -> map of values
+ private Map codeTableValues = new HashMap();
+
+ // throw Blocked on first request
+ private boolean throwBlocked = false;
+
+ // upper table name + upper key col name + upper ret col name -> flag of whether this table has blocked yet
+ private Map blockedState = new HashMap();
+
+ // Track history to verify it later
+ private List<String> queries = new ArrayList<String>();
+ private boolean recordingCommands = true;
+
+ /**
+ * Return string form of all queries run against this FDM
+ * @return List<String> recorded commands
+ */
+ public List<String> getQueries() {
+ return this.queries;
+ }
+
+ /**
+ * Clears the list of recorded commands and returns a copy
+ * @return a copy of the recorded commands prior to clearing the list
+ */
+ public List<String> clearQueries() {
+ List<String> rc = new ArrayList<String>(this.getQueries());
+ this.queries.clear();
+ return rc;
+ }
+
+ public void registerTuples(Object groupID, List elements, List[] data) {
+ tuples.put(groupID, new Object[] { elements, data });
+ }
+
+ public void closeRequest(Object requestID) {
+ // does nothing?
+ }
+
+ public TupleSource registerRequest(Object processorID, Command command, String modelName, String connectorBindingId, int nodeID)
+ throws TeiidComponentException {
+
+ LogManager.logTrace(LOG_CONTEXT, new Object[]{"Register Request:", command, ",processorID:", processorID, ",model name:", modelName,",TupleSourceID nodeID:",new Integer(nodeID)}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ if (this.recordingCommands) {
+ if (! (command instanceof BatchedUpdateCommand) ) {
+ this.queries.add(command.toString());
+ }
+ }
+
+ if (ReferenceCollectorVisitor.getReferences(command).size() > 0) {
+ throw new IllegalArgumentException("Found references in the command registered with the DataManager."); //$NON-NLS-1$
+ }
+ // Get group ID from atomic command
+ GroupSymbol group = null;
+ if(command instanceof Query){
+ group = getQueryGroup((Query)command);
+ }else if(command instanceof SetQuery) {
+ SetQuery union = (SetQuery) command;
+ group = getQueryGroup(union.getProjectedQuery());
+ } else if (command instanceof ProcedureContainer) {
+ group = ((ProcedureContainer) command).getGroup();
+ } else if ( command instanceof BatchedUpdateCommand ) {
+ if ( command.getSubCommands().get(0) instanceof Update ) {
+ group = ((Update)command.getSubCommands().get(0)).getGroup();
+ }
+ if (this.recordingCommands) {
+ for ( Iterator<Command> it = ((BatchedUpdateCommand) command).getUpdateCommands().iterator(); it.hasNext(); ) {
+ this.queries.add(it.next().toString());
+ }
+ }
+ }
+
+ Object groupID = group.getMetadataID();
+
+ Object[] tupleInfo = (Object[]) tuples.get(groupID);
+ List elements = (List) tupleInfo[0];
+ List[] tuples = (List[]) tupleInfo[1];
+
+ List projectedSymbols = command.getProjectedSymbols();
+ int[] columnMap = getColumnMap(elements, projectedSymbols);
+
+ /*
+ * updateCommands is used to hold a list of commands that
+ * either came from a BatchedUpdateCommand or a signle
+ * command from an Update command.
+ */
+ List<Command> updateCommands = new ArrayList<Command>();
+
+ // Apply query criteria to tuples
+ if(command instanceof Query){
+ Query query = (Query)command;
+ if(query.getCriteria() != null) {
+ // Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
+ Map lookupMap = new HashMap();
+ for(int i=0; i<elements.size(); i++) {
+ Object element = elements.get(i);
+ mapElementToIndex(lookupMap, element, new Integer(i), group);
+ }
+ for(int i=0; i<projectedSymbols.size(); i++) {
+ Object element = projectedSymbols.get(i);
+ mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
+ }
+
+ List filteredTuples = new ArrayList();
+ for(int i=0; i<tuples.length; i++) {
+ try {
+ if(new Evaluator(lookupMap, null, null).evaluate(query.getCriteria(), tuples[i])) {
+ filteredTuples.add(tuples[i]);
+ }
+ } catch(CriteriaEvaluationException e) {
+ throw new TeiidComponentException(e, e.getMessage());
+ }
+ }
+
+ tuples = new List[filteredTuples.size()];
+ filteredTuples.toArray(tuples);
+ }
+ } else if ( command instanceof Insert || command instanceof Update || command instanceof Delete) {
+ // add single update command to a list to be executed
+ updateCommands.add(command);
+ } else if ( command instanceof BatchedUpdateCommand ) {
+ // add all update commands to a list to be executed
+ updateCommands.addAll(((BatchedUpdateCommand) command).getUpdateCommands());
+ }
+
+ // if we had update commands added to the list, execute them now
+ if ( updateCommands.size() > 0 ) {
+ List<List<Integer>> filteredTuples = new ArrayList<List<Integer>>();
+ for ( int c = 0; c < updateCommands.size(); c++ ) {
+ Command cmd = updateCommands.get(c);
+ if (cmd instanceof TranslatableProcedureContainer) {
+ TranslatableProcedureContainer update = (TranslatableProcedureContainer)cmd;
+ if ( update.getCriteria() != null ) {
+ // Build lookupMap from BOTH all the elements and the projected symbols - both may be needed here
+ Map<Object, Integer> lookupMap = new HashMap<Object, Integer>();
+ for(int i=0; i<elements.size(); i++) {
+ Object element = elements.get(i);
+ mapElementToIndex(lookupMap, element, new Integer(i), group);
+ }
+ for(int i=0; i<projectedSymbols.size(); i++) {
+ Object element = projectedSymbols.get(i);
+ mapElementToIndex(lookupMap, element, new Integer(columnMap[i]), group);
+ }
+
+ int updated = 0;
+ for(int i=0; i<tuples.length; i++) {
+ try {
+ if(new Evaluator(lookupMap, null, null).evaluate(update.getCriteria(), tuples[i])) {
+ updated++;
+ }
+ } catch(CriteriaEvaluationException e) {
+ throw new TeiidComponentException(e, e.getMessage());
+ }
+ }
+ List<Integer> updateTuple = new ArrayList<Integer>(1);
+ updateTuple.add( new Integer(updated) );
+ filteredTuples.add(updateTuple);
+ }
+ } else {
+ filteredTuples.add(Arrays.asList(1)); //TODO: check for bulk
+ }
+ }
+ tuples = new List[filteredTuples.size()];
+ filteredTuples.toArray(tuples);
+ elements = new ArrayList<Object>(projectedSymbols);
+ columnMap[0] = 0;
+ }
+
+ FakeTupleSource ts= new FakeTupleSource(elements, tuples, projectedSymbols, columnMap);
+ if(this.blockOnce){
+ ts.setBlockOnce();
+ }
+ return ts;
+ }
+
+ private GroupSymbol getQueryGroup(Query query) throws TeiidComponentException {
+ GroupSymbol group;
+ From from = query.getFrom();
+ List groups = from.getGroups();
+ if(groups.size() != 1) {
+ throw new TeiidComponentException("Cannot build fake tuple source for command: " + query); //$NON-NLS-1$
+ }
+ group = (GroupSymbol) groups.get(0);
+ Iterator projSymbols = query.getSelect().getProjectedSymbols().iterator();
+ while (projSymbols.hasNext()) {
+ Object symbol = projSymbols.next();
+ if (symbol instanceof ElementSymbol){
+ ElementSymbol elementSymbol = (ElementSymbol)symbol;
+ GroupSymbol g = elementSymbol.getGroupSymbol();
+ if (!g.equals(group)){
+ throw new TeiidComponentException("Illegal symbol " + elementSymbol + " in SELECT of command: " + query); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ if (elementSymbol.getMetadataID() == null){
+ throw new TeiidComponentException("Illegal null metadata ID in ElementSymbol " + elementSymbol + " in SELECT of command: " + query); //$NON-NLS-1$ //$NON-NLS-2$
+ } else if (elementSymbol.getMetadataID() instanceof TempMetadataID){
+ throw new TeiidComponentException("Illegal TempMetadataID in ElementSymbol " + elementSymbol + " in SELECT of command: " + query); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+ }
+ return group;
+ }
+
+ /**
+ * @param lookupMap
+ * @param element
+ * @param integer
+ * @param group
+ */
+ private void mapElementToIndex(Map lookupMap, Object element, Integer index, GroupSymbol group) {
+ if (group.getDefinition() != null){
+ String groupAlias = group.getCanonicalName();
+ ElementSymbol elementSymbol = (ElementSymbol)SymbolMap.getExpression((SingleElementSymbol)element);
+ String newName = groupAlias + "." + elementSymbol.getShortName(); //$NON-NLS-1$
+ ElementSymbol aliasedElement = new ElementSymbol(newName, elementSymbol.getDisplayFullyQualified());
+ aliasedElement.setGroupSymbol(elementSymbol.getGroupSymbol());
+ aliasedElement.setMetadataID(elementSymbol.getMetadataID());
+ aliasedElement.setType(elementSymbol.getType());
+ lookupMap.put(aliasedElement, index);
+ } else {
+ lookupMap.put(element, index);
+ }
+ }
+
+ // columnMap[expectedElementIndex] = allElementIndex
+ private int[] getColumnMap(List allElements, List expectedElements) {
+ int[] map = new int[expectedElements.size()];
+
+ for(int i=0; i<expectedElements.size(); i++) {
+ SingleElementSymbol symbol = (SingleElementSymbol) expectedElements.get(i);
+
+ if (symbol instanceof AliasSymbol) {
+ symbol = ((AliasSymbol)symbol).getSymbol();
+ }
+
+ String shortName = symbol.getShortName();
+
+ // Find matching short name in all elements
+ boolean foundMatch = false;
+ for(int j=0; j<allElements.size(); j++) {
+ SingleElementSymbol tupleSymbol = (SingleElementSymbol) allElements.get(j);
+ if(tupleSymbol.getShortName().equalsIgnoreCase(shortName)) {
+ map[i] = j;
+ foundMatch = true;
+ break;
+ }
+ }
+
+ if(! foundMatch) {
+ map[i] = -1;
+ }
+ }
+
+ return map;
+ }
+
+
+ public void setThrowBlocked(boolean throwBlocked) {
+ this.throwBlocked = throwBlocked;
+ }
+
+ public void defineCodeTable(String tableName, String keyCol, String retCol, Map values) {
+ String key = tableName.toUpperCase() + keyCol.toUpperCase() + retCol.toUpperCase();
+ this.codeTableValues.put(key, values);
+ this.blockedState.put(key, Boolean.FALSE);
+ }
+
+ public Object lookupCodeValue(
+ CommandContext context,
+ String codeTableName,
+ String returnElementName,
+ String keyElementName,
+ Object keyValue)
+ throws BlockedException, TeiidComponentException {
+
+ String tableKey = codeTableName.toUpperCase() + keyElementName.toUpperCase() + returnElementName.toUpperCase();
+ if(! codeTableValues.containsKey(tableKey)) {
+ throw new TeiidComponentException("Unknown code table: " + codeTableName); //$NON-NLS-1$
+ }
+
+ if(throwBlocked) {
+ if(blockedState.get(tableKey).equals(Boolean.FALSE)) {
+ blockedState.put(tableKey, Boolean.TRUE);
+ throw BlockedException.INSTANCE;
+ }
+ }
+
+ Map values = (Map) codeTableValues.get(tableKey);
+ return values.get(keyValue);
+ }
+
+ public void setBlockOnce() {
+ blockOnce = true;
+ }
+
+ @Override
+ public void clearCodeTables() {/* does nothing */}
+
+ /**
+ * Are commands/queries that are registered with the data manager being
+ * recorded?
+ * <p>
+ * Recorded commands can be retrieved by {@link #getQueries()}
+ *
+ * @return whether or not commands should be recorded
+ */
+ public boolean isRecordingCommands() {
+ return recordingCommands;
+ }
+
+ /**
+ * Indicate whether or not commands/queries registered with the data
+ * manager are to be recorded in {@link #queries}.
+ * <p>
+ * Recorded commands can be retrieved by {@link #getQueries()}
+ *
+ * @param shouldRecord should commands be recorded?
+ */
+ public void setRecordingCommands(boolean shouldRecord) {
+ this.recordingCommands = shouldRecord;
+ }
+
+ public void registerTuples(QueryMetadataInterface metadata, String groupName, List[] tuples) throws QueryResolverException, TeiidComponentException {
+ GroupSymbol group = new GroupSymbol(groupName);
+ ResolverUtil.resolveGroup(group, metadata);
+ List<ElementSymbol> elementSymbols = ResolverUtil.resolveElementsInGroup(group, metadata);
+ this.registerTuples(group.getMetadataID(), elementSymbols, tuples);
+ }
+
+
+}
\ No newline at end of file
Copied: trunk/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/FakeDataStore.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeDataStore.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,321 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+
+
+
+/**
+ * This is sample data go along with FakeMetaDataFactory and FakeDataManager
+ */
+public class FakeDataStore {
+
+ // Helper to create a list of elements - used in creating sample data
+ public static List createElements(List elementIDs) {
+ List elements = new ArrayList();
+ for(int i=0; i<elementIDs.size(); i++) {
+ FakeMetadataObject elementID = (FakeMetadataObject) elementIDs.get(i);
+ ElementSymbol element = new ElementSymbol(elementID.getName());
+ elements.add(element);
+ }
+
+ return elements;
+ }
+
+ private static List getProcResultSetSymbols(List params){
+ List result = new ArrayList();
+ Iterator iter = params.iterator();
+ while(iter.hasNext()){
+ SPParameter param = (SPParameter)iter.next();
+ if(param.getResultSetColumns() != null){
+ result.addAll(param.getResultSetColumns());
+ }
+ }
+ iter = params.iterator();
+ while(iter.hasNext()){
+ SPParameter param = (SPParameter)iter.next();
+ if(param.getParameterType() == ParameterInfo.INOUT || param.getParameterType() == ParameterInfo.RETURN_VALUE) {
+ result.add(param.getParameterSymbol());
+ }
+ }
+ return result;
+ }
+
+ public static void sampleData1(FakeDataManager dataMgr) throws QueryMetadataException, TeiidComponentException {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ // Group pm1.g2
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ // Group pm1.g3
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g3"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ // Group pm2.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ // Group pm2.g2
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g2"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ // Group pm2.g3
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g3"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ // Group tm1.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("tm1.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ } );
+
+ //stored procedure pm1.sp1
+ TempMetadataStore tempStore = new TempMetadataStore();
+ StoredProcedureInfo procInfo = metadata.getStoredProcedureInfoForProcedure("pm1.sp1"); //$NON-NLS-1$
+ elementSymbols = getProcResultSetSymbols(procInfo.getParameters());
+ tempStore.addTempGroup("pm1.sp1", elementSymbols); //$NON-NLS-1$
+ Object procID = tempStore.getTempGroupID("pm1.sp1"); //$NON-NLS-1$
+ dataMgr.registerTuples(
+ procID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1)}),
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ } );
+ }
+
+ public static void sampleData2(FakeDataManager dataMgr) throws QueryMetadataException, TeiidComponentException {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata
+ .getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(groupID, elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] {
+ "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ });
+
+ // Group pm1.g2
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(groupID, elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] {
+ "a", new Integer(1), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(0), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(5), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(2), Boolean.FALSE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "d", new Integer(2), Boolean.FALSE, new Double(1.0) }), //$NON-NLS-1$
+ });
+
+ // Group pm2.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(groupID, elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] {
+ "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ });
+
+ // Group pm2.g2
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g2"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(groupID, elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] {
+ "a", new Integer(1), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(0), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(5), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(2), Boolean.FALSE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "d", new Integer(2), Boolean.FALSE, new Double(1.0) }), //$NON-NLS-1$
+ });
+
+ // Group pm1.table1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm1.table1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = createElements(elementIDs);
+
+ dataMgr.registerTuples(groupID, elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] {
+ "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ });
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/FakeProcessorPlan.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeProcessorPlan.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,145 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
+
+
+/**
+ */
+public class FakeProcessorPlan extends ProcessorPlan {
+
+ private List outputElements;
+ private List batches;
+ int batchIndex = 0;
+ private int nextBatchRow = 1;
+ private boolean opened = false;
+
+ /**
+ * Constructor for FakeProcessorPlan.
+ * @param batches List of things to return in response to nextBatch() - typically
+ * this is TupleBatch, but it can also be BlockedException or a
+ * MetaMatrixComponentException.
+ */
+ public FakeProcessorPlan(List outputElements, List batches) {
+ this.outputElements = outputElements;
+ this.batches = batches;
+ }
+
+ public FakeProcessorPlan(int counts) {
+ List[] rows = new List[counts];
+ for (int i = 0; i < counts; i++) {
+ rows[i] = Arrays.asList(new Object[] {new Integer(1)});
+ }
+ TupleBatch batch = new TupleBatch(1, rows);
+ batch.setTerminationFlag(true);
+ this.batches = Arrays.asList(batch);
+ this.outputElements = Command.getUpdateCommandSymbol();
+ }
+
+ public boolean isOpened() {
+ return opened;
+ }
+
+ /**
+ * @see java.lang.Object#clone()
+ */
+ public FakeProcessorPlan clone() {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorPlan#initialize(org.teiid.query.processor.ProcessorDataManager, java.lang.Object, org.teiid.common.buffer.BufferManager, java.lang.String, int)
+ */
+ public void initialize(
+ CommandContext context,
+ ProcessorDataManager dataMgr,
+ BufferManager bufferMgr) {
+
+ // nothing
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorPlan#getOutputElements()
+ */
+ public List getOutputElements() {
+ return this.outputElements;
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorPlan#open()
+ */
+ public void open() throws TeiidComponentException {
+ assertFalse("ProcessorPlan.open() should not be called more than once", opened); //$NON-NLS-1$
+ opened = true;
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorPlan#nextBatch()
+ */
+ public TupleBatch nextBatch() throws BlockedException, TeiidComponentException {
+ if(this.batches == null || this.batches.size() == 0 || batchIndex >= this.batches.size()) {
+ // Return empty terminator batch
+ TupleBatch batch = new TupleBatch(nextBatchRow, Collections.EMPTY_LIST);
+ batch.setTerminationFlag(true);
+ return batch;
+ }
+ Object nextReturn = this.batches.get(batchIndex);
+ batchIndex++;
+
+ if(nextReturn instanceof TupleBatch) {
+ TupleBatch batch = (TupleBatch) nextReturn;
+ nextBatchRow = nextBatchRow + batch.getRowCount();
+ return batch;
+ }
+ throw (TeiidComponentException) nextReturn;
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorPlan#close()
+ */
+ public void close() throws TeiidComponentException {
+ // nothing
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorPlan#getSchema()
+ */
+ public List getSchema() {
+ return this.outputElements;
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/FakeTupleSource.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/FakeTupleSource.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/FakeTupleSource.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/FakeTupleSource.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,125 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.common.buffer.*;
+import org.teiid.core.TeiidComponentException;
+
+
+public class FakeTupleSource implements TupleSource {
+
+ public static class FakeComponentException extends TeiidComponentException {
+
+ }
+
+ private List elements;
+ private List[] tuples;
+ private int index = 0;
+ private List expectedSymbols;
+ private int[] columnMap;
+
+ //used to test blocked exception. If true,
+ //the first time nextTuple is called, it will throws BlockedExceptiom
+ private boolean blockOnce;
+
+ private boolean exceptionOnClose;
+
+ public FakeTupleSource(List elements, List[] tuples) {
+ this.elements = elements;
+ this.tuples = tuples;
+ }
+
+ public FakeTupleSource(List elements, List[] tuples, List expectedSymbols, int[] columnMap) {
+ this.elements = elements;
+ this.tuples = tuples;
+ this.expectedSymbols = expectedSymbols;
+ this.columnMap = columnMap;
+ }
+
+ public List getSchema() {
+ List theElements = null;
+ if(expectedSymbols != null) {
+ theElements = expectedSymbols;
+ } else {
+ theElements = elements;
+ }
+
+ return theElements;
+ }
+
+ public void openSource()
+ throws TeiidComponentException {
+
+ index = 0;
+ }
+
+ public List nextTuple()
+ throws TeiidComponentException {
+
+ if(this.blockOnce){
+ this.blockOnce = false;
+ throw BlockedException.INSTANCE;
+ }
+
+ if(index < tuples.length) {
+ // Get full data tuple, with elements
+ List tuple = tuples[index++];
+
+ if(expectedSymbols == null) {
+ return tuple;
+ }
+ // Build mapped data tuple, with expectedSymbols
+ List mappedTuple = new ArrayList(expectedSymbols.size());
+ for(int i=0; i<columnMap.length; i++) {
+ int colIndex = columnMap[i];
+ if(colIndex >= 0) {
+ mappedTuple.add( tuple.get(colIndex) );
+ } else {
+ mappedTuple.add( null );
+ }
+ }
+ return mappedTuple;
+ }
+ return null;
+ }
+
+ public void closeSource() {
+ }
+
+ public void setBlockOnce(){
+ this.blockOnce = true;
+ }
+
+ public void setExceptionOnClose(boolean exceptionOnClose) {
+ this.exceptionOnClose = exceptionOnClose;
+ }
+
+ @Override
+ public int available() {
+ return 0;
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/HardcodedDataManager.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/HardcodedDataManager.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,157 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
+
+
+
+/**
+ * @since 4.2
+ */
+public class HardcodedDataManager implements
+ ProcessorDataManager {
+
+ // sql string to data
+ private Map data = new HashMap();
+
+ // valid models - if null, any is assumed valid
+ private Set validModels;
+
+ private boolean mustRegisterCommands = true;
+
+ private boolean blockOnce;
+
+ // Collect all commands run against this class
+ private Collection commandHistory = new ArrayList(); // Commands
+
+ public HardcodedDataManager() {
+ this(true);
+ }
+
+ public HardcodedDataManager(boolean mustRegisterCommands) {
+ this.mustRegisterCommands = mustRegisterCommands;
+ }
+
+ public void addData(String sql, List[] rows) {
+ data.put(sql, rows);
+ }
+
+ public void clearData() {
+ this.data.clear();
+ this.commandHistory.clear();
+ }
+
+ public void setBlockOnce(boolean blockOnce) {
+ this.blockOnce = blockOnce;
+ }
+
+ /**
+ * Set of model names that are valid. Invalid ones will throw an error.
+ * @param models
+ * @since 4.2
+ */
+ public void setValidModels(Set models) {
+ this.validModels = models;
+ }
+
+ /**
+ * Return collection of Command that has occurred on this data manager
+ * @return
+ * @since 4.2
+ */
+ public Collection getCommandHistory() {
+ return this.commandHistory;
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorDataManager#lookupCodeValue(org.teiid.query.util.CommandContext, java.lang.String, java.lang.String, java.lang.String, java.lang.Object)
+ * @since 4.2
+ */
+ public Object lookupCodeValue(CommandContext context,
+ String codeTableName,
+ String returnElementName,
+ String keyElementName,
+ Object keyValue) throws BlockedException,
+ TeiidComponentException {
+ return null;
+ }
+
+ /**
+ * @see org.teiid.query.processor.ProcessorDataManager#registerRequest(java.lang.Object, org.teiid.query.sql.lang.Command, java.lang.String, String, int)
+ * @since 4.2
+ */
+ public TupleSource registerRequest(Object processorID,
+ Command command,
+ String modelName,
+ String connectorBindingId, int nodeID) throws TeiidComponentException {
+
+ if(modelName != null && validModels != null && ! validModels.contains(modelName)) {
+ throw new TeiidComponentException("Detected query against invalid model: " + modelName + ": " + command); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ this.commandHistory.add(command);
+
+ List projectedSymbols = command.getProjectedSymbols();
+
+ List[] rows = (List[]) data.get(command.toString());
+ if(rows == null) {
+ if (mustRegisterCommands) {
+ throw new TeiidComponentException("Unknown command: " + command.toString()); //$NON-NLS-1$
+ }
+ // Create one row of nulls
+ rows = new List[1];
+ rows[0] = new ArrayList();
+
+ for(int i=0; i<projectedSymbols.size(); i++) {
+ rows[0].add(null);
+ }
+ }
+
+ FakeTupleSource source = new FakeTupleSource(projectedSymbols, rows);
+ if (blockOnce) {
+ source.setBlockOnce();
+ }
+ return source;
+ }
+
+ public void setMustRegisterCommands(boolean mustRegisterCommands) {
+ this.mustRegisterCommands = mustRegisterCommands;
+ }
+
+ public void clearCodeTables() {
+
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestAggregateProcessing.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,286 @@
+/*
+ * 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.teiid.query.processor.TestProcessor.*;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestAggregatePushdown;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestAggregateProcessing {
+
+ static void sampleDataBQT3(FakeDataManager dataMgr) throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ // Group bqt1.smalla
+
+ List[] tuples = new List[20];
+ for (int i = 0; i < tuples.length; i++) {
+ tuples[i] = new ArrayList(17);
+ tuples[i].add(new Integer(i));
+ tuples[i].add("" + i); //$NON-NLS-1$
+ tuples[i].add(new Integer(i + 1));
+ for (int j = 0; j < 14; j++) {
+ tuples[i].add(null);
+ }
+ }
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
+
+ tuples = new List[20];
+ for (int i = 0; i < tuples.length; i++) {
+ tuples[i] = new ArrayList(17);
+ tuples[i].add(new Integer(i));
+ for (int j = 0; j < 16; j++) {
+ tuples[i].add(null);
+ }
+ }
+
+ dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
+ }
+
+ private void sampleDataBQT_defect9842(FakeDataManager dataMgr) throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ List[] tuples = new List[5];
+ for (int i = 0; i < tuples.length; i++) {
+ int k = i + 10;
+ tuples[i] = new ArrayList(17);
+ if (i < 2) {
+ tuples[i].add(new Integer(1)); // need duplicate values
+ } else {
+ tuples[i].add(new Integer(2)); // need duplicate values
+ }
+ tuples[i].add("" + k); //$NON-NLS-1$
+ tuples[i].add(new Integer(k + 1));
+ tuples[i].add("" + (k + 1)); //$NON-NLS-1$
+ tuples[i].add(new Float(0.5));
+ for (int j = 0; j < 8; j++) {
+ tuples[i].add(null);
+ }
+ tuples[i].add(new Short((short) k));
+ tuples[i].add(null);
+ tuples[i].add(new BigDecimal("" + k)); //$NON-NLS-1$
+ tuples[i].add(null);
+ }
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
+ }
+
+ @Test public void testAggregateOnBQT() throws Exception {
+ // Create query
+ String sql = "SELECT IntKey, SUM(IntNum) FROM BQT1.SmallA GROUP BY IntKey, IntNum HAVING IntNum > 10 ORDER BY IntKey"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(10), new Long(11) }),
+ Arrays.asList(new Object[] { new Integer(11), new Long(12) }),
+ Arrays.asList(new Object[] { new Integer(12), new Long(13) }),
+ Arrays.asList(new Object[] { new Integer(13), new Long(14) }),
+ Arrays.asList(new Object[] { new Integer(14), new Long(15) }),
+ Arrays.asList(new Object[] { new Integer(15), new Long(16) }),
+ Arrays.asList(new Object[] { new Integer(16), new Long(17) }),
+ Arrays.asList(new Object[] { new Integer(17), new Long(18) }),
+ Arrays.asList(new Object[] { new Integer(18), new Long(19) }),
+ Arrays.asList(new Object[] { new Integer(19), new Long(20) }) };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT3(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory
+ .exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testAggregateOnBQT2() throws Exception {
+ // Create query
+ String sql = "SELECT IntNum, IsNotNull FROM (SELECT IntNum, LongNum, COUNT(IntNum) AS IsNotNull FROM BQT1.SmallA GROUP BY IntNum, LongNum HAVING LongNum IS NULL ) AS x ORDER BY IntNum, IsNotNull"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(4), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(5), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(6), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(7), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(8), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(9), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(10), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(11), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(12), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(13), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(14), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(15), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(16), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(17), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(18), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(19), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(20), new Integer(1) }) };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT3(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory
+ .exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testAggregateOnBQT_defect9842() throws Exception {
+ // Create query
+ String sql = "SELECT IntKey, SUM((BigDecimalValue)*(ShortValue)-(BigDecimalValue)*(ShortValue)*(FloatNum)) " + //$NON-NLS-1$
+ "AS MySum FROM BQT1.SmallA GROUP BY IntKey ORDER BY IntKey"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1),
+ new BigDecimal("110.5") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2),
+ new BigDecimal("254.5") }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT_defect9842(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory
+ .exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCase186260() {
+ /*
+ * This case revealed that an expression like "COUNT( DISTINCT e1 )", where the type of e1 is
+ * anything but integer, was not handled properly. We tried to use "integer" (the type of the
+ * COUNT expression) to work with the e1 tuples.
+ */
+ // Create query
+ String sql = "SELECT COUNT(DISTINCT pm1.g2.e1), COUNT(DISTINCT pm1.g3.e1) FROM pm1.g2, pm1.g3"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(3), new Integer(3) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @SuppressWarnings("unchecked")
+ @Test public void testAggregatePushdown() {
+ Command command = helpParse("select e1, count(e2), max(e2) from (select e1, e2, e3 from pm1.g1 union all select e1, e2, e3 from pm1.g2 union all select e1, e2, e3 from pm2.g1) z group by e1"); //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ capFinder.addCapabilities("pm1", TestAggregatePushdown.getAggregateCapabilities()); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT v_0.c_0, COUNT(v_0.c_1), MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0", //$NON-NLS-1$
+ new List[] {
+ Arrays.asList("a", Integer.valueOf(2), Integer.valueOf(1)), //$NON-NLS-1$
+ });
+ dataManager.addData("SELECT v_0.c_0, COUNT(v_0.c_1), MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g2 AS g_0) AS v_0 GROUP BY v_0.c_0", //$NON-NLS-1$
+ new List[] {
+ Arrays.asList("a", Integer.valueOf(3), Integer.valueOf(2)), //$NON-NLS-1$
+ });
+ dataManager.addData("SELECT g_0.e1, g_0.e2 FROM pm2.g1 AS g_0", //$NON-NLS-1$
+ new List[] {
+ Arrays.asList("a", Integer.valueOf(3)), //$NON-NLS-1$
+ Arrays.asList("xyz", Integer.valueOf(4)), //$NON-NLS-1$
+ Arrays.asList(null, Integer.valueOf(5)),
+ });
+
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(null, Integer.valueOf(1), Integer.valueOf(5)),
+ Arrays.asList("a", Integer.valueOf(6), Integer.valueOf(3)), //$NON-NLS-1$
+ Arrays.asList("xyz", Integer.valueOf(1), Integer.valueOf(4)) //$NON-NLS-1$
+ };
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testUnionAggregatePushdown() {
+ Command command = helpParse("select count(*), max(e3) from (select e1, e2, e3 from pm1.g1 union all (select convert(e2, string) as a, e2, e3 from pm2.g2 order by a limit 10)) x group by e1, e2"); //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ capFinder.addCapabilities("pm1", TestAggregatePushdown.getAggregateCapabilities()); //$NON-NLS-1$
+ BasicSourceCapabilities bac = TestAggregatePushdown.getAggregateCapabilities();
+ bac.setFunctionSupport("convert", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", bac); //$NON-NLS-1$
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT v_0.c_1, v_0.c_0, COUNT(*), MAX(v_0.c_2) FROM (SELECT g_0.e2 AS c_0, g_0.e1 AS c_1, g_0.e3 AS c_2 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0, v_0.c_1", //$NON-NLS-1$
+ new List[] {
+ Arrays.asList("2", Integer.valueOf(2), Integer.valueOf(2), Boolean.FALSE), //$NON-NLS-1$
+ Arrays.asList("1", Integer.valueOf(1), Integer.valueOf(3), Boolean.TRUE), //$NON-NLS-1$
+ });
+ dataManager.addData("SELECT v_0.c_1, v_0.c_0, COUNT(*), MAX(v_0.c_2) FROM (SELECT g_0.e2 AS c_0, convert(g_0.e2, string) AS c_1, g_0.e3 AS c_2 FROM pm2.g2 AS g_0 ORDER BY c_1 LIMIT 10) AS v_0 GROUP BY v_0.c_0, v_0.c_1", //$NON-NLS-1$
+ new List[] {
+ Arrays.asList("1", Integer.valueOf(1), Integer.valueOf(4), Boolean.FALSE), //$NON-NLS-1$
+ });
+
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(Integer.valueOf(7), Boolean.TRUE),
+ Arrays.asList(Integer.valueOf(2), Boolean.FALSE),
+ };
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestAggregateProcessing.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestBaseProcessorPlan.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestBaseProcessorPlan.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,49 @@
+/*
+ * 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 java.util.Collections;
+import java.util.List;
+
+import org.teiid.core.TeiidException;
+
+import junit.framework.TestCase;
+
+
+public class TestBaseProcessorPlan extends TestCase {
+
+ public TestBaseProcessorPlan(String name) {
+ super(name);
+ }
+
+ public void testGetAndClearWarnings() {
+ FakeProcessorPlan plan = new FakeProcessorPlan(Collections.emptyList(), Collections.emptyList());
+ TeiidException warning = new TeiidException("test"); //$NON-NLS-1$
+ plan.addWarning(warning);
+
+ List warnings = plan.getAndClearWarnings();
+ assertEquals("Did not get expected number of warnings", 1, warnings.size()); //$NON-NLS-1$
+ assertEquals("Did not get expected warning", warning, warnings.get(0)); //$NON-NLS-1$
+ assertNull("Did not clear warnings from plan", plan.getAndClearWarnings()); //$NON-NLS-1$
+ }
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestBatchIterator.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,55 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.relational.FakeRelationalNode;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
+
+@SuppressWarnings("nls")
+public class TestBatchIterator {
+
+ @Test public void testReset() throws Exception {
+ BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
+ Arrays.asList(1),
+ Arrays.asList(1),
+ Arrays.asList(1)
+ }, 1));
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")), "test", TupleSourceType.PROCESSOR), true); //$NON-NLS-1$
+ bi.mark();
+ bi.nextTuple();
+ bi.nextTuple();
+ bi.reset();
+ bi.nextTuple();
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestCollectionTupleSource.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestCollectionTupleSource.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestCollectionTupleSource.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestCollectionTupleSource.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,71 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.query.processor.CollectionTupleSource;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
+/**
+ */
+public class TestCollectionTupleSource {
+
+ @Test public void testNullSource() {
+ List<SingleElementSymbol> elements = new ArrayList<SingleElementSymbol>();
+ elements.add(new ElementSymbol("x")); //$NON-NLS-1$
+ elements.add(new ElementSymbol("y")); //$NON-NLS-1$
+ CollectionTupleSource nts = CollectionTupleSource.createNullTupleSource(elements);
+
+ // Check schema
+ assertEquals("Didn't get expected schema", elements, nts.getSchema()); //$NON-NLS-1$
+
+ // Walk it and get no data
+ List tuple = nts.nextTuple();
+ nts.closeSource();
+
+ assertEquals("Didn't get termination tuple for first tuple", null, tuple); //$NON-NLS-1$
+ }
+
+ @Test public void testUpdateCountSource() {
+ CollectionTupleSource nts = CollectionTupleSource.createUpdateCountTupleSource(5);
+
+ // Check schema
+ assertEquals("Didn't get expected schema", Command.getUpdateCommandSymbol(), nts.getSchema()); //$NON-NLS-1$
+
+ // Walk it and get no data
+ List tuple = nts.nextTuple();
+ nts.closeSource();
+
+ assertEquals("Didn't get termination tuple for first tuple", Arrays.asList(5), tuple); //$NON-NLS-1$
+ }
+
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestDependentJoins.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,785 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+
+import junit.framework.TestCase;
+
+
+
+public class TestDependentJoins extends TestCase {
+
+ /**
+ * @param sql
+ * @return
+ */
+ static ProcessorPlan helpGetPlan(String sql) {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(2));
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false); //fake data manager doesn't support order by
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(TestProcessor.helpParse(sql),
+ FakeMetadataFactory.example1Cached(),
+ capFinder);
+ return plan;
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1=pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin1() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1=pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin2() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(sql);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin3() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin4() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND concat(pm1.g1.e1, 'a') = concat(pm2.g1.e1, 'a') AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin5() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE concat(pm1.g1.e1, 'a') = concat(pm2.g1.e1, 'a') AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ public void testMultiCritDepJoin5a() {
+ // Create query
+ String sql = "SELECT X.e1 FROM pm1.g1 as X, pm2.g1 WHERE concat(X.e1, 'a') = concat(pm2.g1.e1, 'a') AND X.e2=pm2.g1.e2 order by x.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ public void testMultiCritDepJoin5b() {
+ //Create query
+ String sql = "SELECT X.e1, X.e2 FROM pm1.g1 as X, pm2.g1 WHERE concat(X.e1, convert(X.e4, string)) = concat(pm2.g1.e1, convert(pm2.g1.e4, string)) AND X.e2=pm2.g1.e2 order by x.e1 option makedep x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = concat(pm2.g1.e1, '') AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin6() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = concat(pm2.g1.e1, '') AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE concat(pm1.g1.e1, '') = pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 */
+ public void testMultiCritDepJoin7() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE concat(pm1.g1.e1, '') = pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = pm2.g1.e1 AND pm1.g1.e2 <> pm2.g1.e2 */
+ public void testMultiCritDepJoin8() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1 = pm2.g1.e1 AND pm1.g1.e2 <> pm2.g1.e2 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 <> pm2.g1.e2 */
+ public void testMultiCritDepJoin9() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 <> pm2.g1.e2 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e3=pm2.g1.e3 AND pm1.g1.e2=pm2.g1.e2 AND pm2.g1.e1 = 'a' */
+ public void testMultiCritDepJoin10() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e3=pm2.g1.e3 AND pm1.g1.e2=pm2.g1.e2 AND pm2.g1.e1 = 'a' option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ public void testLargeSetInDepJoinWAccessPatternCausingSortNodeInsertCanHandleAlias() {
+ helpTestDepAccessCausingSortNodeInsert(true);
+ }
+
+ public void testLargeSetInDepJoinWAccessPatternCausingSortNodeInsertCannotHandleAlias() {
+ helpTestDepAccessCausingSortNodeInsert(false);
+ }
+
+ public void helpTestDepAccessCausingSortNodeInsert(boolean accessNodeHandlesAliases) {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a INNER JOIN pm1.g1 b ON a.e2=b.e2 AND a.e1 = b.e1 OPTION MAKEDEP a"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "aa ", "aa ", new Integer(0)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "bb ", "bb ", new Integer(1)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "cc ", "cc ", new Integer(2)}) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData2b(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
+ depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+ depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ if(accessNodeHandlesAliases) {
+ depcaps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ }
+
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+
+ capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Slightly modify metadata to set max set size to just a few rows - this
+ // will allow us to test the dependent overflow case
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
+
+ //Verify a dependent join (not merge join) was used
+ assertTrue(plan instanceof RelationalPlan);
+ RelationalPlan relationalPlan = (RelationalPlan)plan;
+ RelationalNode project = relationalPlan.getRootNode();
+ RelationalNode join = project.getChildren()[0];
+ assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ public void testCase5130() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ String sql = "select a.intkey from bqt1.smalla a, bqt1.smallb b where concat(a.stringkey, 't') = b.stringkey option makedep a"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder, new String[] {"SELECT a.stringkey, a.intkey FROM bqt1.smalla AS a", "SELECT b.stringkey FROM bqt1.smallb AS b"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT g_0.stringkey FROM bqt1.smallb AS g_0", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1t" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2" })}); //$NON-NLS-1$
+ dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1", new Integer(1) })}); //$NON-NLS-1$
+
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ };
+
+ TestProcessor.helpProcess(plan, dataManager, expected);
+
+ assertFalse(dataManager.getCommandHistory().contains("SELECT a.stringkey, a.intkey FROM bqt1.smalla AS a WHERE concat(a.stringkey, 't') IN ('1', '2')")); //$NON-NLS-1$
+ }
+
+ public void testCase5130a() throws Exception {
+ HardcodedDataManager dataManager = helpTestDependentJoin(false);
+
+ assertFalse(dataManager.getCommandHistory().contains("SELECT a.stringkey, a.intkey FROM bqt2.smalla AS a WHERE (concat(a.stringkey, 't') IN ('1t', '2')) AND (a.intkey IN (1))")); //$NON-NLS-1$
+ }
+
+ public void testUnlimitedIn() throws Exception {
+ helpTestDependentJoin(true);
+ }
+
+ private HardcodedDataManager helpTestDependentJoin(boolean unlimitIn)
+ throws TeiidComponentException, TeiidProcessingException {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+ if (unlimitIn) {
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, -1);
+ }
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ String sql = "select a.intkey from bqt1.smalla a, bqt2.smallb b where concat(a.stringkey, 't') = b.stringkey and a.intkey = b.intkey option makedep a"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
+ new String[] {"SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0 WHERE g_0.intkey IN (<dependent values>)", "SELECT g_0.stringkey, g_0.intkey FROM bqt2.smallb AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ unlimitIn?2:1, // Access
+ unlimitIn?0:1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 1, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 2, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM bqt2.smallb AS g_0", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1t", new Integer(1) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2t", new Integer(2) })}); //$NON-NLS-1$
+ dataManager.addData("SELECT g_0.stringkey, g_0.intkey FROM bqt1.smalla AS g_0 WHERE g_0.intkey IN (1, 2)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1", new Integer(1) })}); //$NON-NLS-1$
+
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ };
+
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ return dataManager;
+ }
+
+ static void sampleData4(FakeDataManager dataMgr) throws Exception {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+ // Group pm6.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm6.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "b", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "e", new Integer(1) }), //$NON-NLS-1$
+ } );
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm6.g1 WHERE pm1.g1.e1=pm6.g1.e1 OPTION MAKEDEP pm6.g1 */
+ public void testLargeSetInDepAccess() throws Exception {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm6.g1 WHERE pm1.g1.e1=pm6.g1.e1 OPTION MAKEDEP pm6.g1"; //$NON-NLS-1$
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData4(dataManager);
+
+ // Slightly modify metadata to set max set size to just a few rows - this
+ // will allow us to test the dependent overflow case
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
+ depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+ depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm6", depcaps); //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {
+ new String("b")})}; //$NON-NLS-1$
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ public void testLargeSetInDepAccessMultiJoinCriteria() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e1=pm2.g1.e1 AND pm1.g1.e2=pm2.g1.e2 order by e1 OPTION MAKEDEP pm2.g1"; //$NON-NLS-1$
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Slightly modify metadata to set max set size to just a few rows - this
+ // will allow us to test the dependent overflow case
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
+ depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", depcaps); //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {
+ new String("a")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ new String("a")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ new String("a")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ new String("a")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ new String("a")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ new String("b")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {
+ new String("c")})}; //$NON-NLS-1$
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+
+ }
+
+ public void testLargeSetInDepAccessWithAccessPattern() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a INNER JOIN pm1.g1 b ON a.e1=b.e1 AND a.e2 = b.e2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {
+ "aa ", "aa ", new Integer(0)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] {
+ "bb ", "bb ", new Integer(1)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] {
+ "cc ", "cc ", new Integer(2)}) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData2b(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities depcaps = new BasicSourceCapabilities();
+ depcaps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ depcaps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+ depcaps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+
+ capFinder.addCapabilities("pm4", depcaps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade fakeMetadata = FakeMetadataFactory.example1Cached();
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, capFinder);
+
+ //Verify a dependent join (not merge join) was used
+ assertTrue(plan instanceof RelationalPlan);
+ RelationalPlan relationalPlan = (RelationalPlan)plan;
+ RelationalNode project = relationalPlan.getRootNode();
+ RelationalNode join = project.getChildren()[0];
+ assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g1.e2 = -100 OPTION MAKEDEP pm1.g2 */
+ public void testDependentNoRows() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g1.e2 = -100 OPTION MAKEDEP pm1.g2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE (pm1.g1.e2+1)=pm2.g1.e2 OPTION MAKEDEP pm1.g2 */
+ public void testExpressionInDepJoin() {
+ // Create query
+ String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE (pm1.g1.e2+1)=pm2.g1.e2 OPTION MAKEDEP pm2.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(0), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(3) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestInsertProcessing.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,407 @@
+package org.teiid.query.processor;
+
+import static org.junit.Assert.*;
+import static org.teiid.query.processor.TestProcessor.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+
+
+public class TestInsertProcessing {
+
+ @Test public void testSelectIntoWithTypeConversion() {
+ FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
+ FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.BATCHED_UPDATES, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
+ new String[] { "e1", "e2", "e3" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.FLOAT});
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(pm1);
+ store.addObject(pm1g1);
+ store.addObjects(pm1g1e);
+
+ FakeMetadataFacade metadata = new FakeMetadataFacade(store);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("BatchedUpdate{I}", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1) })});
+
+ String sql = "SELECT 1, convert(1, float), convert(1, float) INTO pm1.g1"; //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ };
+
+ helpProcess(plan, dataManager, expected);
+
+ BatchedUpdateCommand buc = (BatchedUpdateCommand)dataManager.getCommandHistory().iterator().next();
+ Insert insert = (Insert)buc.getUpdateCommands().get(0);
+
+ Constant value0 = (Constant)insert.getValues().get(0);
+ Constant value1 = (Constant)insert.getValues().get(1);
+
+ assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, value0.getValue().getClass());
+ assertEquals(DataTypeManager.DefaultDataClasses.FLOAT, value1.getValue().getClass());
+ }
+
+
+ @Test public void testSelectInto_Case5569a_BATCH_NO_BULK_NO() {
+ boolean doBatching = false;
+ boolean doBulkInsert = false;
+ helpSelectInto_Case5569Processor( doBatching, doBulkInsert );
+ }
+
+ @Test public void testSelectInto_Case5569b_BATCH_YES_BULK_NO() {
+ boolean doBatching = true;
+ boolean doBulkInsert = false;
+ helpSelectInto_Case5569Processor( doBatching, doBulkInsert );
+ }
+
+ @Test public void testSelectInto_Case5569c_BATCH_NO_BULK_YES() {
+ boolean doBatching = false;
+ boolean doBulkInsert = true;
+ helpSelectInto_Case5569Processor( doBatching, doBulkInsert );
+ }
+
+ public void helpSelectInto_Case5569Processor( boolean doBatching, boolean doBulkInsert ) {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+
+ caps.setCapabilitySupport(Capability.BATCHED_UPDATES, doBatching);
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, doBulkInsert);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1", new Integer(1), Boolean.FALSE, new Double(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2", new Integer(2), Boolean.TRUE, new Double(2) })}); //$NON-NLS-1$
+
+ if (doBulkInsert) {
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (?, ?, ?, ?)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ }
+ else
+ if (doBatching) {
+ dataManager.addData("BatchedUpdate{I,I}", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ } else {
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1)})});
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1)})});
+ }
+
+ String sql = "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 INTO pm1.g2 from pm1.g1"; //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2) }),
+ };
+
+ helpProcess(plan, dataManager, expected);
+
+ // if not doBulkInsert and is doBatching,
+ // check the command hist to ensure it contains the expected commands
+ if ( !doBulkInsert && doBatching ) {
+ BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(1);
+ assertEquals(2, bu.getUpdateCommands().size());
+ assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
+ assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
+ }
+ }
+
+
+ @Test public void testSelectInto_Case5412a() {
+
+ // test setting BULK_INSERT capability to true
+ FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
+ FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
+ new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.FLOAT});
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(pm1);
+ store.addObject(pm1g1);
+ store.addObjects(pm1g1e);
+
+ FakeMetadataFacade metadata = new FakeMetadataFacade(store);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (?, ?)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1) })});
+
+ String sql = "SELECT 1, convert(1, float) INTO pm1.g1"; //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ };
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+
+ @Test public void testSelectInto_Case5412b() {
+
+ // test setting BULK_INSERT capability to false
+ FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
+ FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
+ new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.FLOAT});
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(pm1);
+ store.addObject(pm1g1);
+ store.addObjects(pm1g1e);
+
+ FakeMetadataFacade metadata = new FakeMetadataFacade(store);
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES (1, 1.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1) })});
+
+ String sql = "SELECT 1, convert(1, float) INTO pm1.g1"; //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ };
+
+ helpProcess(plan, dataManager, expected);
+
+ Insert insert = (Insert)dataManager.getCommandHistory().iterator().next();
+
+ Constant value0 = (Constant)insert.getValues().get(0);
+ Constant value1 = (Constant)insert.getValues().get(1);
+
+ assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, value0.getValue().getClass());
+ assertEquals(DataTypeManager.DefaultDataClasses.FLOAT, value1.getValue().getClass());
+ }
+
+ @Test public void testInsertIntoWithSubquery_None() {
+ helpInsertIntoWithSubquery( null );
+ }
+
+ @Test public void testInsertIntoWithSubquery_Batch() {
+ helpInsertIntoWithSubquery( Capability.BATCHED_UPDATES );
+ }
+
+ @Test public void testInsertIntoWithSubquery_Bulk() {
+ helpInsertIntoWithSubquery( Capability.BULK_UPDATE );
+ }
+
+ @Test public void testInsertIntoWithSubquery_Pushdown() {
+ helpInsertIntoWithSubquery( Capability.INSERT_WITH_QUERYEXPRESSION );
+ }
+
+ public void helpInsertIntoWithSubquery( Capability cap ) {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+
+ caps.setCapabilitySupport(cap, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1", new Integer(1), Boolean.FALSE, new Double(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2", new Integer(2), Boolean.TRUE, new Double(2) })}); //$NON-NLS-1$
+
+ if (cap != null) {
+ switch (cap) {
+ case BULK_UPDATE:
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (?, ?, ?, ?)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ break;
+ case BATCHED_UPDATES:
+ dataManager.addData("BatchedUpdate{I,I}", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ break;
+ case INSERT_WITH_QUERYEXPRESSION:
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ break;
+ }
+ } else {
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1)})});
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1)})});
+ }
+
+ String sql = "INSERT INTO pm1.g2 SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 from pm1.g1"; //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2) }),
+ };
+
+ helpProcess(plan, dataManager, expected);
+
+ // if not doBulkInsert and is doBatching,
+ // check the command hist to ensure it contains the expected commands
+ if ( cap == Capability.BATCHED_UPDATES ) {
+ BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(1);
+ assertEquals(2, bu.getUpdateCommands().size());
+ assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
+ assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testInsertIntoWithSubquery2_BATCH_NO_BULK_NO() {
+ boolean doBatching = false;
+ boolean doBulkInsert = false;
+ helpInsertIntoWithSubquery2( doBatching, doBulkInsert );
+ }
+
+ @Test public void testInsertIntoWithSubquery2_BATCH_YES_BULK_NO() {
+ boolean doBatching = true;
+ boolean doBulkInsert = false;
+ helpInsertIntoWithSubquery2( doBatching, doBulkInsert );
+ }
+
+ @Test public void testInsertIntoWithSubquery2_BATCH_NO_BULK_YES() {
+ boolean doBatching = false;
+ boolean doBulkInsert = true;
+ helpInsertIntoWithSubquery2( doBatching, doBulkInsert );
+ }
+
+ public void helpInsertIntoWithSubquery2( boolean doBatching, boolean doBulkInsert ) {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+
+ caps.setCapabilitySupport(Capability.BATCHED_UPDATES, doBatching);
+ caps.setCapabilitySupport(Capability.BULK_UPDATE, doBulkInsert);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { "1", new Integer(1), Boolean.FALSE, new Double(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2", new Integer(2), Boolean.TRUE, new Double(2) })}); //$NON-NLS-1$
+
+ if (doBulkInsert) {
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES (?, ?, ?, ?)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ }
+ else
+ if (doBatching) {
+ dataManager.addData("BatchedUpdate{I,I}", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(2)})});
+ } else {
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1)})});
+ dataManager.addData("INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1)})});
+ }
+
+ String sql = "INSERT INTO pm1.g2 SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 from pm1.g1 UNION ALL SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 from pm1.g1"; //$NON-NLS-1$
+// String sql = "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 INTO pm1.g2 from pm1.g1"; //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(4) }),
+ };
+
+ helpProcess(plan, dataManager, expected);
+
+ // if not doBulkInsert and is doBatching,
+ // check the command hist to ensure it contains the expected commands
+ if ( !doBulkInsert && doBatching ) {
+ BatchedUpdateCommand bu = (BatchedUpdateCommand)new ArrayList(dataManager.getCommandHistory()).get(2);
+ assertEquals(2, bu.getUpdateCommands().size());
+ assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('1', 1, FALSE, 1.0)", bu.getUpdateCommands().get(0).toString() ); //$NON-NLS-1$
+ assertEquals( "INSERT INTO pm1.g2 (pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4) VALUES ('2', 2, TRUE, 2.0)", bu.getUpdateCommands().get(1).toString() ); //$NON-NLS-1$
+ }
+ }
+
+ @Test public void testInsertIntoVirtualWithQueryExpression() {
+ String sql = "insert into vm1.g1 (e1, e2, e3, e4) select * from pm1.g1"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(6),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestInsertProcessing.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestJoinWithFunction.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,439 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+import junit.framework.TestCase;
+
+
+/**
+ * <p><code>TestCase</code> to cover processing of JOINs which use a scalar
+ * function as a symbol or as part of the JOIN criteria.</p>
+ *
+ * <p>All tests should verify and validate that the scalar function's result
+ * is being used appropriately from the pre-JOIN and post-JOIN aspect. Most
+ * specifically, the results returned from the JOIN should match the expected
+ * results defined in each test method.</p>
+ * @since 6.0
+ */
+public class TestJoinWithFunction extends TestCase {
+
+ /**
+ * <p>Test the use of a non-deterministic function on a user command that
+ * performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed on the result returned from the JOIN and
+ * is expected to be executed for each row of the final result set.</p>
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ */
+ public void testNonDeterministicPostJoin() throws QueryMetadataException, TeiidComponentException {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. RandomTop is the use of RAND() on
+ * the user command and should result in unique random numbers for each
+ * row in the JOINed output.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, RAND() AS RandomTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ /*
+ * Populate a List with our expected results. We can predict the return value
+ * for RAND() because the TestProcessor.helpProcess() method seeds the random
+ * number generator.
+ */
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(0.24053641567148587) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(0.0), new Double(0.6374174253501083) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(0.5504370051176339) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
+ new Boolean(false), null, new Double(0.5975452777972018) }), };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ FakeDataStore.sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * <p>Test the use of a non-deterministic function on a source command of a JOIN
+ * defined by a user command that performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed on the result that will be used for one side
+ * of the JOIN. The function should only be executed for each row of the the result
+ * set returned from the left-side of the JOIN which should result in the same return
+ * value for multiple rows of the final result set after the JOIN is completed. For
+ * example, if the left-side query is expected to return one row and the right-side
+ * query will return three rows which match the JOIN criteria for the one row on the
+ * left-side then the expected result should be that the function be executed once to
+ * represent the one row from the left-side and the function's return value will be
+ * repeated for each of the three post-JOINed results.</p>
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ */
+ public void testNonDeterministicPreJoin() throws QueryMetadataException, TeiidComponentException {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. TopRandom is the use of RAND() on
+ * the user command while RandomLeft is the use of RAND() within a
+ * source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ /*
+ * Populate a List with our expected results. We can predict the return value
+ * for RAND() because the TestProcessor.helpProcess() method seeds the random
+ * number generator.
+ */
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(0.24053641567148587) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(0.0), new Double(0.6374174253501083) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(0.6374174253501083) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
+ new Boolean(false), null, new Double(0.6374174253501083) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ FakeDataStore.sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * <p>Test the use of a non-deterministic function on the sub-command of a user
+ * command and the user command itself, which performs a JOIN of two sources.</p>
+ *
+ * <p>This test combines the PostJoin and PreJoin test cases.</p>
+ * @see #testNonDeterministicPostJoin
+ * @see #testNonDeterministicPreJoin
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ */
+ public void testNonDeterministicPrePostJoin() throws TeiidComponentException, QueryMetadataException {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. TopRandom is the use of RAND() on
+ * the user command while RandomLeft is the use of RAND() within a
+ * source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft, RAND() AS RandomTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ /*
+ * Populate a List with our expected results. We can predict the return value
+ * for RAND() because the TestProcessor.helpProcess() method seeds the random
+ * number generator.
+ */
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(0.24053641567148587), new Double(0.5975452777972018) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(0.0), new Double(0.6374174253501083), new Double(0.3332183994766498) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(0.6374174253501083), new Double(0.3851891847407185) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
+ new Boolean(false), null, new Double(0.6374174253501083), new Double(0.984841540199809) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ FakeDataStore.sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * <p>Test the use of a deterministic function on the user command which
+ * performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed prior to the JOIN being executed and should
+ * result in the projected symbol becoming a constant.</p>
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ */
+ public void testDeterministicPostJoin() throws TeiidComponentException, QueryMetadataException {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
+ * the user command and should result in 10 for each row in the JOINed
+ * output.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ /*
+ * Populate a List with our expected results.
+ */
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(10) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(0.0), new Double(10) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(10) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
+ new Boolean(false), null, new Double(10) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ FakeDataStore.sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * <p>The function should be executed prior to the JOIN being executed and should
+ * result in the projected symbol becoming a constant.</p>
+
+ * <p>Test the use of a deterministic function on the source command of a JOIN
+ * defined by a user command which performs a JOIN of two sources.</p>
+ *
+ * <p>The function should be executed prior to the commands from either side of the
+ * JOIN being executed and merged into user command prior to the JOIN actually being
+ * executed.</p>
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ */
+ public void testDeterministicPreJoin() throws QueryMetadataException, TeiidComponentException {
+ // source query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // source query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. SqrtLeft is the use of SQRT()
+ * within a source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ /*
+ * Populate a List with our expected results.
+ */
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(10) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(0.0), new Double(10) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(10) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
+ new Boolean(false), null, new Double(10) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ FakeDataStore.sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * <p>Test the use of a deterministic function on the sub-command of a user
+ * command and the user command itself, which performs a JOIN of two sources.</p>
+ *
+ * <p>This test combines the PostJoin and PreJoin test cases.</p>
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ * @see #testDeterministicPostJoin
+ * @see #testDeterministicPreJoin
+ */
+ public void testDeterministicPrePostJoin() throws QueryMetadataException, TeiidComponentException {
+ // sub-query for one side of a JOIN
+ String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
+ + "FROM pm1.g1"; //$NON-NLS-1$
+ // sub-query for other side of a JOIN
+ String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
+ + "FROM pm2.g2"; //$NON-NLS-1$
+
+ // User Command
+ /*
+ * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
+ * the user command while SqrtLeft is the use of SQRT() within a
+ * source node.
+ */
+ String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
+ "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
+ "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
+ "WHERE l.ID = r.ID"; //$NON-NLS-1$
+
+ /*
+ * Populate a List with our expected results.
+ */
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(2), "a", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(10.0), new Double(10.0) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(0), //$NON-NLS-1$
+ new Boolean(false), new Double(0.0), new Double(10.0), new Double(10.0) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(5), //$NON-NLS-1$
+ new Boolean(true), new Double(2.0), new Double(10.0), new Double(10.0) }),
+ Arrays.asList(new Object[] { "b", new Integer(1), //$NON-NLS-1$
+ new Boolean(true), null, "b", new Integer(2), //$NON-NLS-1$
+ new Boolean(false), null, new Double(10.0), new Double(10.0) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ FakeDataStore.sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestJoinWithFunction.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestOptionalJoins.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestOptionalJoins.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,492 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestOptionalJoins {
+
+ @Test public void testOptionalJoinNode1() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2 where pm1.g1.e1 = 'a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode2() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2, pm1.g3 where pm1.g1.e1 = 'a' and pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode3() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode4() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode5() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode6() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode7() {
+ // Create query
+ String sql = "SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode8() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ (select * from pm1.g2) as X on pm1.g1.e1 = x.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode9() {
+ // Create query
+ String sql = "SELECT pm1.g2.e1 FROM pm1.g2, /* optional */ vm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode10() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM /* optional */ vm1.g1, pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode11() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ vm1.g2 on pm1.g1.e1 = vm1.g2.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode12() {
+ // Create query
+ String sql = "SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN vm1.g1 on pm1.g1.e1 = vm1.g1.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode13() {
+ // Create query
+ String sql = "SELECT count(pm1.g1.e1) FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode15() {
+ // Create query
+ String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode16() {
+ // Create query
+ String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x order by x.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode17() {
+ // Create query
+ String sql = "SELECT length(z) FROM /* optional */ pm1.g1, (select distinct e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY y, z) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(5) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode18() {
+ // Create query
+ String sql = "SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOptionalJoinNode19() {
+ // Create query
+ String sql = "SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(6) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcedureRelational.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcedureRelational.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,764 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.proc.CreateCursorResultSetInstruction;
+import org.teiid.query.processor.proc.ProcedurePlan;
+import org.teiid.query.processor.proc.TestProcedureProcessor;
+import org.teiid.query.processor.relational.DependentProcedureExecutionNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+
+
+public class TestProcedureRelational {
+
+ @Test public void testProcInExistsSubquery() throws Exception {
+ String sql = "select pm1.g1.e1 from pm1.g1 where exists (select * from (EXEC pm1.vsp9(pm1.g1.e2 + 1)) x where x.e1 = pm1.g1.e1)"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcInSelectScalarSubquery() throws Exception {
+ String sql = "select (EXEC pm1.vsp36(pm1.g1.e2)) from pm1.g1 where pm1.g1.e1 = 'a'"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(0) }),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsTable(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ //virtual group with procedure in transformation
+ @Test public void testAliasedProcAsTable(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 as x where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testAliasedJoin(){
+ String sql = "select x.param1, x.param2, y.param1, y.param2, x.e1 from pm1.vsp26 as x, pm1.vsp26 as y where x.param1=1 and x.param2='a' and y.param1 = 2 and y.param2 = 'b'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "a", new Integer(2), "b", "a"}), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+
+ @Test public void testAliasedJoin1(){
+ String sql = "select x.param1, x.param2, y.param1, y.param2, x.e1 from pm1.vsp26 as x, pm1.vsp26 as y where x.param1=1 and x.param2='a' and y.param1 = x.param1 and y.param2 = x.param2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "a", new Integer(1), "a", "a"}), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Will fail due to access pattern validation (missing param2 assignment)
+ */
+ @Test public void testProcAsTable1(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=1"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
+ }
+
+ /**
+ * Will fail since less than does not constitue an input
+ */
+ @Test public void testProcAsTable2(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1<1 and param2='a'"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
+ }
+
+ @Test public void testProcAsTable3(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1 in (1,2,3) and param2 in ('a', 'b') order by param1, param2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Integer(1), "b", "b", new Integer(2)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Integer(2), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Integer(2), "b", "b", new Integer(2)}), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Integer(3), "a", "a", new Integer(3)}), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Will fail missing param2 assignment
+ */
+ @Test public void testProcAsTable4(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=1 and not(param2 = 'a')"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
+ }
+
+ /**
+ * Will fail missing param2 assignment
+ */
+ @Test public void testProcAsTable5(){
+ String sql = "select param1, param2, e1, e2 from pm1.vsp26 where param1=e2 and param2 = 'a'"; //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), null, false);
+ }
+
+ @Test public void testProcAsTableInJoin(){
+ String sql = "select param1, param2, pm1.vsp26.e2 from pm1.vsp26, pm1.g1 where param1 = pm1.g1.e2 and param2 = pm1.g1.e1 order by param1, param2, e2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(1), "c", new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), "b", new Integer(2)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(3), "a", new Integer(3)}), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsTableInSubquery(){
+ String sql = "select param1, param2, pm1.vsp26.e2, (select count(e1) from pm1.vsp26 where param1 = 1 and param2 = 'a') x from pm1.vsp26, pm1.g1 where param1 = pm1.g1.e2 and param2 = pm1.g1.e1 order by param1, param2, e2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(0), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(1), "c", new Integer(1), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), "b", new Integer(2), new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(3), "a", new Integer(3), new Integer(1)}), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ private void helpTestProcRelational(String userQuery,
+ String inputCriteria,
+ String atomicQuery) {
+ ProcessorPlan plan = TestOptimizer.helpPlan(userQuery, FakeMetadataFactory.example1Cached(),
+ new String[] {} );
+
+ RelationalPlan rplan = (RelationalPlan)plan;
+
+ RelationalNode root = rplan.getRootNode();
+
+ while (root.getChildren() != null) {
+ root = root.getChildren()[0];
+
+ if (root instanceof DependentProcedureExecutionNode) {
+ break;
+ }
+ }
+
+ DependentProcedureExecutionNode dep = (DependentProcedureExecutionNode)root;
+
+ assertEquals(inputCriteria, dep.getInputCriteria().toString());
+
+ ProcedurePlan pp = (ProcedurePlan)dep.getProcessorPlan();
+
+ CreateCursorResultSetInstruction ccrsi = (CreateCursorResultSetInstruction)pp.getOriginalProgram().getInstructionAt(0);
+
+ plan = ccrsi.getCommand();
+
+ TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
+
+ TestOptimizer.checkAtomicQueries(new String[] {atomicQuery}, plan);
+ }
+
+ //virtual group with procedure in transaformation
+ @Test public void testProcInVirtualGroup1() {
+
+ String userQuery = "select e1 from pm1.vsp26 where param1=1 and param2='a'"; //$NON-NLS-1$
+ String inputCriteria = "(pm1.vsp26.param1 = 1) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
+ String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
+
+ helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
+ }
+
+ //virtual group with procedure in transformation
+ @Test public void testCase3403() {
+ String userQuery = "select e1 from pm1.vsp26 where param1=2 and param2='a' and 'x'='x'"; //$NON-NLS-1$
+ String inputCriteria = "(pm1.vsp26.param1 = 2) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
+ String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
+
+ helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
+ }
+
+ @Test public void testCase3448() {
+ String userQuery = "select e1 from pm1.vsp26 where (param1=1 and e2=2) and param2='a'"; //$NON-NLS-1$
+ String inputCriteria = "(pm1.vsp26.param1 = 1) AND (pm1.vsp26.param2 = 'a')"; //$NON-NLS-1$
+ String atomicQuery = "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0 WHERE (g_0.e2 >= pm1.vsp26.param1) AND (g_0.e1 = pm1.vsp26.param2)"; //$NON-NLS-1$
+
+ helpTestProcRelational(userQuery, inputCriteria, atomicQuery);
+ }
+
+ @Test public void testProcAsVirtualGroup2(){
+ String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup3(){
+ String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup4(){
+ String sql = "SELECT P.e1 as ve3 FROM pm1.vsp26 as P, pm1.g2 where P.e1=g2.e1 and param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}) //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup5(){
+ String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2='a' and e1='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup6(){
+ String sql = "SELECT P.e1 as ve3 FROM pm1.vsp26 as P, vm1.g1 where P.e1=g1.e1 and param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}) //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup7(){
+ String sql = "SELECT e1 FROM (SELECT p.e1, param1, param2 FROM pm1.vsp26 as P, vm1.g1 where P.e1=g1.e1) x where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}) //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup10_Defect20164(){
+ String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where (param1=1 and param2='a') and e1='c'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testProcAsVirtualGroup8(){
+ String sql = "SELECT P.e1 as ve3, P.e2 as ve4 FROM pm1.vsp26 as P where param1=1 and param2='a' and e2=3"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(3)}), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ //virtual group with procedure in transformation
+ @Test public void testProcAsVirtualGroup9(){
+ String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "FOO" }), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Relies upon a default value of null for param1
+ *
+ * This is marked as defered since it is not desirable to support this behavior for a single default value
+ */
+ public void defer_testProcAsVirtualGroup9a(){
+ String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2112), "a" }), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Relies upon a default value of null for both parameters
+ *
+ * This is marked as defered since it is not desirable to support this behavior for a single default value
+ */
+ public void defer_testProcAsVirtualGroup9b(){
+ String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2112), null })
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * test for defect 22376
+ */
+ @Test public void testParameterPassing() throws Exception {
+ FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
+
+ FakeMetadataObject rs1 = FakeMetadataFactory.createResultSet("v1.rs1", v1, new String[] {"e1"}, new String[] { DataTypeManager.DefaultDataTypes.STRING }); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject rs1p1 = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
+
+ QueryNode n1 = new QueryNode("v1.vp1", "CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x = '1'; SELECT e1 FROM v1.vp2 where v1.vp2.in = VARIABLES.x; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vt1 = FakeMetadataFactory.createVirtualProcedure("v1.vp1", v1, Arrays.asList(new FakeMetadataObject[] { rs1p1 }), n1); //$NON-NLS-1$
+
+ FakeMetadataObject p1 = FakeMetadataFactory.createParameter("v1.vp2.in", 2, ParameterInfo.IN, DataTypeManager.DefaultDataTypes.STRING, null); //$NON-NLS-1$
+ QueryNode n2 = new QueryNode("v1.vp2", "CREATE VIRTUAL PROCEDURE BEGIN declare string VARIABLES.x; declare string VARIABLES.y; VARIABLES.x = '2'; VARIABLES.y = v1.vp2.in; select VARIABLES.y; end"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vt2 = FakeMetadataFactory.createVirtualProcedure("v1.vp2", v1, Arrays.asList(new FakeMetadataObject[] { rs1p1, p1 }), n2); //$NON-NLS-1$
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(v1);
+ store.addObject(rs1);
+ store.addObject(vt1);
+ store.addObject(vt2);
+ store.addObject(vt2);
+
+ String sql = "select * from (exec v1.vp1()) foo"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ };
+
+ FakeMetadataFacade metadata = new FakeMetadataFacade(store);
+
+ // Construct data manager with data
+ // Plan query
+ ProcessorPlan plan = TestProcedureProcessor.getProcedurePlan(sql, metadata);
+ // Run query
+ TestProcedureProcessor.helpTestProcess(plan, expected, new FakeDataManager());
+
+ }
+
+ //virtual group with procedure in transformation
+ @Test public void testCase6395ProcAsVirtualGroup9(){
+ String sql = "SELECT P.e2 as ve3, P.e1 as ve4 FROM pm1.vsp47 as P where param1=1 and param2='a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "FOO" }), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Case 6395 - This test case will now raise a QueryPlannerException. param2 is required
+ * and not nullable. This case is expected to fail because of 'param2 is null'
+ */
+ @Test public void testProcAsVirtualGroup2WithNull() throws Exception {
+ String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2 is null"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ try {
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.doProcess(plan, dataManager, expected, TestProcessor.createCommandContext());
+ fail("QueryPlannerException was expected."); //$NON-NLS-1$
+ } catch (QueryValidatorException e) {
+ assertEquals("The procedure parameter is not nullable, but is set to null: pm1.vsp26.param2",e.getMessage()); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Case 6395 - This case is expected to succeed. param1 and param2 are both required, but nulls
+ * are acceptable for both.
+ */
+ @Test public void testProcAsVirtualGroup2WithNull2() throws Exception {
+ String sql = "select * from pm1.vsp47 where param1 is null and param2 is null"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, new Integer(2112), null, null })
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Case 6395 - This will not throw an exception and the proc will not be invoked.
+ */
+ @Test public void testProcAsVirtualGroup2WithNull3() throws Exception {
+ String sql = "select e1 from (SELECT * FROM pm1.vsp26 as P where P.e1='a') x where param1=1 and param2 = commandpayload()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ /*
+ * The following are tests that were removed from the validator. We are no longer trying to validate a priori whether
+ * procedure input criteria is valid. This can be addressed later more generally when we do up front validation of
+ * access patterns and access patterns have a wider range of semantics.
+ *
+ @Test public void testProcInVirtualGroupDefect14609_1() throws Exception{
+ helpValidate("select ve3 from vm1.vgvp1 where ve1=1.1 and ve2='a'", new String[] {"ve1 = 1.1"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testProcInVirtualGroupDefect14609_2() throws Exception{
+ helpValidate("select ve3 from vm1.vgvp1 where convert(ve1, integer)=1 and ve2='a'", new String[] {"convert(ve1, integer) = 1" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testProcInVirtualGroupDefect14609_3() throws Exception{
+ helpValidate("select ve3 from vm1.vgvp1 where 1.1=ve1 and ve2='a'", new String[] {"1.1 = ve1" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testProcInVirtualGroupDefect14609_4() throws Exception{
+ helpValidate("select ve3 from vm1.vgvp1 where 1=convert(ve1, integer) and ve2='a'", new String[] {"1 = convert(ve1, integer)" }, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @Test public void testDefect15861() throws Exception{
+ helpValidate("select ve3 from vm1.vgvp1 where (ve1=1 or ve1=2) and ve2='a'", new String[] {"(ve1 = 1) OR (ve1 = 2)", "ve1 = 2"}, FakeMetadataFactory.example1Cached()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+
+ @Test public void testProcInVirtualGroup1_Defect20164() {
+ helpFailProcedure("select ve3 from vm1.vgvp2 where (ve1=1 and ve2='a') or ve3='c'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testProcInVirtualGroup2_Defect20164() {
+ helpFailProcedure("select ve3 from vm1.vgvp2 where ve1=1 or ve2='a'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testProcInVirtualGroup3_Defect20164() {
+ helpFailProcedure("select ve3 from vm1.vgvp2, pm1.g1 where ve1=pm1.g1.e2 and ve2='a'", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testProcInVirtualGroup4_Defect20164() {
+ helpValidate("select ve3 from vm1.vgvp2 where (ve1=1 and ve2='a') and (ve3='a' OR ve3='c')", new String[0], FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testProcInVirtualGroup5_Defect20164() {
+ helpFailProcedure("select ve3 from vm1.vgvp2 where ve1=1 and NOT(ve2='a')", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testProcInVirtualGroup6_Defect20164() {
+ helpValidate("select ve3 from vm1.vgvp2 where ve1=1 and ve2 is null", new String[0], FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }
+
+ @Test public void testProcInVirtualGroup7_Defect20164() {
+ helpFailProcedure("select ve3 from vm1.vgvp2 where ve1=1 and ve2 is not null", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+ }*/
+
+ /**
+ * Ensures that dependent procedures are processed 1 at a time so that projected input values
+ * are set correctly.
+ */
+ @Test public void testIssue119() throws Exception {
+ FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
+ FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
+
+ FakeMetadataObject in = FakeMetadataFactory.createParameter("v1.vp1.in1", 2, SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ FakeMetadataObject rs1 = FakeMetadataFactory.createResultSet("v1.vp1.rs1", v1, new String[] {"e1", "e2", "e3", "e4", "e5"}, new String[] { DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ FakeMetadataObject rs1p1 = FakeMetadataFactory.createParameter("ret", 1, SPParameter.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs1); //$NON-NLS-1$
+
+ QueryNode n1 = new QueryNode("v1.vp1", "CREATE VIRTUAL PROCEDURE BEGIN SELECT vp1.in1 e1, x.in1 e2, x.e1 e3, y.in1 e4, y.e1 e5 FROM pm1.sp119 x, pm1.sp119 y where x.in1 = vp1.in1 and y.in1 = x.e1; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vt1 = FakeMetadataFactory.createVirtualProcedure("v1.vp1", v1, Arrays.asList(new FakeMetadataObject[] { rs1p1, in }), n1); //$NON-NLS-1$
+
+ FakeMetadataObject in1 = FakeMetadataFactory.createParameter("pm1.sp119.in1", 2, SPParameter.IN, DataTypeManager.DefaultDataTypes.INTEGER, null); //$NON-NLS-1$
+ FakeMetadataObject rs3 = FakeMetadataFactory.createResultSet("pm1.sp119.rs1", pm1, new String[] { "e1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER }); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject rs3p1 = FakeMetadataFactory.createParameter("ret", 1, SPParameter.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs3); //$NON-NLS-1$
+ FakeMetadataObject sp1 = FakeMetadataFactory.createStoredProcedure("pm1.sp119", pm1, Arrays.asList(new FakeMetadataObject[] { rs3p1, in1 }), "pm1.sp119"); //$NON-NLS-1$ //$NON-NLS-2$
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(pm1);
+ store.addObject(v1);
+ store.addObject(rs1);
+ store.addObject(vt1);
+ store.addObject(sp1);
+
+ String sql = "select * from (exec v1.vp1(1)) foo order by e4, e5"; //$NON-NLS-1$
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(1, 1, 3, 3, 5),
+ Arrays.asList(1, 1, 3, 3, 8),
+ Arrays.asList(1, 1, 6, 6, 8),
+ Arrays.asList(1, 1, 6, 6, 11),
+ };
+
+ FakeMetadataFacade metadata = new FakeMetadataFacade(store);
+
+ // Construct data manager with data
+ // Plan query
+ ProcessorPlan plan = TestProcedureProcessor.getProcedurePlan(sql, metadata);
+ // Run query
+ HardcodedDataManager dataManager = new HardcodedDataManager() {
+ @Override
+ public TupleSource registerRequest(Object processorID,
+ Command command, String modelName,
+ String connectorBindingId, int nodeID)
+ throws TeiidComponentException {
+ if (command instanceof StoredProcedure) {
+ StoredProcedure proc = (StoredProcedure)command;
+ List<SPParameter> params = proc.getInputParameters();
+ assertEquals(1, params.size());
+ int value = (Integer)((Constant)params.get(0).getExpression()).getValue();
+ return new FakeTupleSource(command.getProjectedSymbols(), new List[] {
+ Arrays.asList(value+2), Arrays.asList(value+5)
+ });
+ }
+ return super.registerRequest(processorID, command, modelName,
+ connectorBindingId, nodeID);
+ }
+ };
+
+ TestProcedureProcessor.helpTestProcess(plan, expected, dataManager);
+
+ }
+
+ @Test public void testProcRelationalWithNoInputs() {
+ String sql = "select e1 from pm1.vsp2 order by e1 desc limit 1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList("c") //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestProcessor.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,7490 @@
+/*
+ * 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 java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.SQLException;
+import java.sql.Timestamp;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Calendar;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+
+import org.junit.Test;
+import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.XMLType;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.FakeFunctionMetadataSource;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.TestRuleRaiseNull;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.RuleChooseDependent;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.BindVariableVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorReport;
+
+
+public class TestProcessor {
+
+ // ################################## TEST HELPERS ################################
+
+ static Command helpParse(String sql) {
+ // parse
+ try {
+ return QueryParser.getQueryParser().parseCommand(sql);
+ } catch(TeiidException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ public static ProcessorPlan helpGetPlan(String sql, QueryMetadataInterface metadata) {
+ return helpGetPlan(sql, metadata, null);
+ }
+
+ public static ProcessorPlan helpGetPlan(String sql, QueryMetadataInterface metadata, String[] bindings) {
+ if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+
+ // attach bindings
+ if(bindings != null) {
+ try {
+ BindVariableVisitor.bindReferences(command, Arrays.asList(bindings), metadata);
+ } catch(Throwable e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ ProcessorPlan process = helpGetPlan(command, metadata);
+
+ return process;
+ }
+
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata) {
+ return helpGetPlan(command, metadata, new DefaultCapabilitiesFinder());
+ }
+
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) {
+ CommandContext context = new CommandContext();
+ context.setProcessorBatchSize(2000);
+ context.setConnectorBatchSize(2000);
+ return helpGetPlan(command, metadata, capFinder, context);
+ }
+
+ static ProcessorPlan helpGetPlan(Command command, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context) {
+ if(DEBUG) System.out.println("\n####################################\n" + command); //$NON-NLS-1$
+ AnalysisRecord analysisRecord = new AnalysisRecord(false, DEBUG);
+ try {
+ QueryResolver.resolveCommand(command, metadata);
+
+ ValidatorReport repo = Validator.validate(command, metadata);
+ Collection failures = new ArrayList();
+ repo.collectInvalidObjects(failures);
+ if (failures.size() > 0){
+ fail("Exception during validation (" + repo); //$NON-NLS-1$
+ }
+ command = QueryRewriter.rewrite(command, metadata, createCommandContext());
+ ProcessorPlan process = QueryOptimizer.optimizePlan(command, metadata, null, capFinder, analysisRecord, context);
+ if(DEBUG) System.out.println("\n" + process); //$NON-NLS-1$
+ //per defect 10022, clone this plan before processing, just to make sure
+ //a cloned plan with correlated subquery references (or any cloned plan) can be processed
+ process = process.clone();
+
+ assertNotNull("Output elements of process plan are null", process.getOutputElements()); //$NON-NLS-1$
+
+ return process;
+ } catch (TeiidComponentException e) {
+ throw new RuntimeException(e);
+ } catch (TeiidProcessingException e) {
+ throw new RuntimeException(e);
+ } finally {
+ if(DEBUG) {
+ System.out.println(analysisRecord.getDebugLog());
+ }
+ }
+ }
+
+ public static void helpProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults) {
+ CommandContext context = createCommandContext();
+ try {
+ helpProcess(plan, context, dataManager, expectedResults);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void helpProcess(ProcessorPlan plan, CommandContext context, ProcessorDataManager dataManager, List[] expectedResults) throws Exception {
+ ProcessorPlan clonePlan = plan.clone();
+
+ // Process twice to test reset and clone
+ doProcess(plan, dataManager, expectedResults, context);
+ plan.reset();
+ doProcess(plan, dataManager, expectedResults, context);
+
+ // Execute cloned of original plan
+ doProcess(clonePlan, dataManager, expectedResults, context);
+ }
+
+ private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager) {
+ helpProcessException(plan, dataManager, null);
+ }
+
+ private void helpProcessException(ProcessorPlan plan, ProcessorDataManager dataManager, String expectedErrorMessage) {
+ TupleBuffer tsId = null;
+ BufferManager bufferMgr = null;
+ try {
+ bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
+ CommandContext context = new CommandContext("0", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ processor.setNonBlocking(true);
+ BatchCollector collector = processor.createBatchCollector();
+ tsId = collector.collectTuples();
+ fail("Expected error during processing, but got none."); //$NON-NLS-1$
+ } catch(TeiidException e) {
+ // ignore - this is expected
+ if(expectedErrorMessage != null) {
+ assertEquals(expectedErrorMessage, e.getMessage());
+ }
+ } finally {
+ if (tsId != null) {
+ tsId.remove();
+ }
+ }
+ }
+
+ public static void doProcess(ProcessorPlan plan, ProcessorDataManager dataManager, List[] expectedResults, CommandContext context) throws Exception {
+ BufferManagerImpl bufferMgr = BufferManagerFactory.createBufferManager();
+ bufferMgr.setProcessorBatchSize(context.getProcessorBatchSize());
+ bufferMgr.setConnectorBatchSize(context.getProcessorBatchSize());
+ context.getNextRand(0);
+ TupleBuffer id = null;
+ try {
+ QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ processor.setNonBlocking(true);
+ BatchCollector collector = processor.createBatchCollector();
+ id = collector.collectTuples();
+ if ( expectedResults != null ) {
+ examineResults(expectedResults, bufferMgr, id);
+ }
+ } finally {
+ if (id != null) {
+ id.remove();
+ }
+ }
+ }
+
+ /**
+ * @param expectedResults
+ * @param bufferMgr
+ * @param tsID
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
+ * @since 4.3
+ */
+ static void examineResults(List[] expectedResults,BufferManager bufferMgr,TupleBuffer tsID)
+ throws TeiidComponentException,SQLException, TeiidProcessingException {
+
+ // Create QueryResults from TupleSource
+ TupleSource ts = tsID.createIndexedTupleSource();
+ int count = tsID.getRowCount();
+
+ if(DEBUG) {
+ System.out.println("\nResults:\n" + tsID.getSchema()); //$NON-NLS-1$
+ TupleSource ts2 = tsID.createIndexedTupleSource();
+ for(int j=0; j<count; j++) {
+ System.out.println("" + j + ": " + ts2.nextTuple()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ ts2.closeSource();
+ }
+
+ // Compare actual to expected row count
+ assertEquals("Did not get expected row count: ", expectedResults.length, count); //$NON-NLS-1$
+
+ // Walk results and compare
+ for(int i=0; i<count; i++) {
+ List record = ts.nextTuple();
+
+ //handle xml
+ if(record.size() == 1){
+ Object cellValue = record.get(0);
+ if(cellValue instanceof XMLType){
+ XMLType id = (XMLType)cellValue;
+ String actualDoc = id.getString();
+ record = new ArrayList(record);
+ record.set(0, actualDoc);
+ }
+ if (expectedResults[i].size() == 1) {
+ assertEquals("Row " + i + " does not match expected: ", expectedResults[i].get(0), record.get(0)); //$NON-NLS-1$ //$NON-NLS-2$
+ continue;
+ }
+ }
+
+ assertEquals("Row " + i + " does not match expected: ", expectedResults[i], record); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ ts.closeSource();
+ }
+
+ public static CommandContext createCommandContext() {
+ Properties props = new Properties();
+ props.setProperty("soap_host", "my.host.com"); //$NON-NLS-1$ //$NON-NLS-2$
+ props.setProperty("soap_port", "12345"); //$NON-NLS-1$ //$NON-NLS-2$
+ CommandContext context = new CommandContext("0", "test", "user", null, "myvdb", 1, props, DEBUG, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ context.setProcessorBatchSize(2000);
+ context.setConnectorBatchSize(2000);
+ context.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
+ return context;
+ }
+
+ public static void sampleData1(FakeDataManager dataMgr) {
+ try {
+ FakeDataStore.sampleData1(dataMgr);
+ } catch(Throwable e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleData2(FakeDataManager dataMgr) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ try {
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+ // Group pm1.g2
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g2"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(1), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(5), Boolean.TRUE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", new Integer(2), Boolean.FALSE, new Double(1.0) }), //$NON-NLS-1$
+ } );
+
+ // Group pm2.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ } );
+
+ // Group pm1.table1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm1.table1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleData2a(FakeDataManager dataMgr) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ try {
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+ // Group pm2.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(7), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ } );
+
+ // Group pm4.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm4.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "aa", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bb", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cc", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static void sampleData2b(FakeDataManager dataMgr) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ try {
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "aa ", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bb ", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cc ", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+ // Group pm2.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm2.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "b", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "e", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ } );
+
+ // Group pm4.g1
+ groupID = (FakeMetadataObject) metadata.getGroupID("pm4.g1"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { "aa ", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bb ", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cc ", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleData3(FakeDataManager dataMgr) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ try {
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementSymbols = new ArrayList(1);
+ ElementSymbol count = new ElementSymbol("Count"); //$NON-NLS-1$
+ count.setType(Integer.class);
+ elementSymbols.add(count);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ } );
+ }catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleDataStringTimestamps(FakeDataManager dataMgr) {
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ try {
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+ new List[] {
+ Arrays.asList(new Object[] { "Jan 01 2004 12:00:00", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "Dec 31 2004 12:00:00", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "Aug 01 2004 12:00:00", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ } );
+
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleDataBQT1(FakeDataManager dataMgr) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ try {
+ // Group bqt1.smalla
+
+ List[] tuples = new List[20];
+ for(int i=0; i<tuples.length; i++) {
+ tuples[i] = new ArrayList(17);
+ tuples[i].add(new Integer(i));
+ for(int j=0; j<16; j++) {
+ tuples[i].add(null);
+ }
+ }
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
+
+ // Group bqt2.mediumb
+ tuples = new List[20];
+ for(int i=0; i<tuples.length; i++) {
+ tuples[i] = new ArrayList(17);
+ tuples[i].add(new Integer(i));
+ for(int j=0; j<16; j++) {
+ tuples[i].add(null);
+ }
+ }
+
+ dataMgr.registerTuples(metadata, "bqt2.mediumb", tuples); //$NON-NLS-1$
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleDataBQT2(FakeDataManager dataMgr) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ try {
+ for(int i=0; i<groups.length; i++) {
+ String groupName = groups[i];
+
+ List[] tuples = new List[30];
+ for(int row=0; row<tuples.length; row++) {
+ tuples[row] = new ArrayList(17);
+ tuples[row].add(new Integer(row));
+ for(int col=0; col<16; col++) {
+ tuples[row].add(null);
+ }
+ }
+
+ dataMgr.registerTuples(metadata, groupName, tuples);
+ }
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Just want to register two rows of all the integral types to test AVG
+ * @param dataMgr
+ * @since 4.2
+ */
+ private void sampleDataBQT_defect11682(FakeDataManager dataMgr) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ try {
+ List[] tuples = new List[2];
+ for(int i=1; i<=tuples.length; i++) {
+ int index=i-1;
+ tuples[index] = new ArrayList(17);
+ tuples[index].add(new Integer(i)); //IntKey
+ tuples[index].add(null);
+ tuples[index].add(new Integer(i));
+ tuples[index].add(null);
+ tuples[index].add(new Float(i));
+ tuples[index].add(new Long(i));
+ tuples[index].add(new Double(i));
+ tuples[index].add(new Byte((byte)i));
+ tuples[index].add(null);
+ tuples[index].add(null);
+ tuples[index].add(null);
+ tuples[index].add(null);
+ tuples[index].add(null);
+ tuples[index].add(new Short((short)i));
+ tuples[index].add(new BigInteger(i+"")); //$NON-NLS-1$
+ tuples[index].add(new BigDecimal(i+".0")); //$NON-NLS-1$
+ tuples[index].add(null);
+ }
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void sampleDataBQTSmall(FakeDataManager dataMgr) {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ try {
+ List[] tuples = new List[1];
+ for(int i=0; i<tuples.length; i++) {
+ tuples[i] = new ArrayList(17);
+ tuples[i].add(new Integer(i));
+ for(int j=0; j<16; j++) {
+ tuples[i].add(null);
+ }
+ }
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", tuples); //$NON-NLS-1$
+
+ } catch(TeiidException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private List createRowWithTimestamp(String tsStr) {
+ Timestamp ts = Timestamp.valueOf(tsStr);
+ return Arrays.asList(new Object[] {
+ new Integer(0), "a", new Integer(1), "a", //$NON-NLS-1$ //$NON-NLS-2$
+ null, null, null, null, null, null, ts, null, null, null, null, null, null
+ });
+ }
+
+ private void sampleDataBQT_case1566(FakeDataManager dataMgr) throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ dataMgr.registerTuples(metadata, "bqt1.smalla", new List[] { //$NON-NLS-1$
+ createRowWithTimestamp("2002-01-01 10:00:00"), //$NON-NLS-1$
+ createRowWithTimestamp("2002-01-01 14:00:00"), //$NON-NLS-1$
+ createRowWithTimestamp("2002-01-02 10:00:00"), //$NON-NLS-1$
+ createRowWithTimestamp("2002-01-02 14:00:00"), //$NON-NLS-1$
+ createRowWithTimestamp("2002-01-02 19:00:00.01"), //$NON-NLS-1$
+ } );
+ }
+
+ static List getProcResultSetSymbols(List params){
+ List result = new ArrayList();
+ Iterator iter = params.iterator();
+ while(iter.hasNext()){
+ SPParameter param = (SPParameter)iter.next();
+ if(param.getResultSetColumns() != null){
+ result.addAll(param.getResultSetColumns());
+ }
+ }
+ iter = params.iterator();
+ while(iter.hasNext()){
+ SPParameter param = (SPParameter)iter.next();
+ if(param.getParameterType() == ParameterInfo.INOUT || param.getParameterType() == ParameterInfo.RETURN_VALUE) {
+ result.add(param.getParameterSymbol());
+ }
+ }
+ return result;
+ }
+
+ @Test public void test1() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test2() {
+ // Create query
+ String sql = "SELECT COUNT(*) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(6) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test3() {
+ // Create query
+ String sql = "SELECT COUNT(*), COUNT(e1), COUNT(distinct e1), COUNT(distinct e2), COUNT(distinct e3), COUNT(distinct e4) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(6), new Integer(5), new Integer(3), new Integer(4), new Integer(2), new Integer(4) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** see also integer average defect 11682 */
+ @Test public void test4() {
+ // Create query
+ String sql = "SELECT MIN(e2), MAX(e2), SUM(e2), AVG(e2), SUM(distinct e2), AVG(distinct e2) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), new Integer(3), new Long(7), new Double(1.1666666666666667), new Long(6), new Double(1.5) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test5() {
+ // Create query
+ String sql = "SELECT MIN(e4), MAX(e4), SUM(e4), AVG(e4), SUM(distinct e4), AVG(distinct e4) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Double(0.0), new Double(7.0), new Double(12.0), new Double(2.4), new Double(10.0), new Double(2.5) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test7() {
+ // Create query
+ String sql = "SELECT * FROM vm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test8() {
+ // Create query
+ String sql = "SELECT * FROM vm1.g2 order by 1, 2, 3"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test9() {
+ // Create query
+ String sql = "SELECT * FROM vm1.g4 order by e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "3" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void test10() {
+ // Create query
+ String sql = "SELECT e1 FROM vm1.g4 where e1 = 'a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testBooleanComparisonGT() {
+ // Create query
+ String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 > {b'false'}"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.TRUE }),
+ Arrays.asList(new Object[] { Boolean.TRUE })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testBooleanComparisonGE() {
+ // Create query
+ String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 >= {b'false'}"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.TRUE }),
+ Arrays.asList(new Object[] { Boolean.TRUE }),
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testBooleanComparisonLT() {
+ // Create query
+ String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 < {b'true'}"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testBooleanComparisonLE() {
+ // Create query
+ String sql = "SELECT pm1.g1.e3 FROM pm1.g1 WHERE e3 <= {b'true'}"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.TRUE }),
+ Arrays.asList(new Object[] { Boolean.TRUE }),
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ Arrays.asList(new Object[] { Boolean.FALSE })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testConcatOperator() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1 || e2 AS x FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a3" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a0" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Duplicates defect #4841: SELECT e1 a, e1 b FROM pm1.g1 order by a */
+ @Test public void testDefect4841_1() {
+ // Create query
+ String sql = "SELECT e1 a, e1 b FROM pm1.g1 order by a"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Duplicates defect #4841: SELECT e1 a, e1 b FROM pm1.g1 order by a, b desc */
+ @Test public void testDefect4841_2() {
+ // Create query
+ String sql = "SELECT e1 a, e1 b FROM pm1.g1 order by a"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Duplicates defect #5292: SELECT DISTINCT e1, e1 a FROM pm1.g1 */
+ @Test public void testDefect5292_1() {
+ // Create query
+ String sql = "SELECT DISTINCT e1, e1 a FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Duplicates defect #5292: SELECT DISTINCT e1, e1 a FROM pm1.g1 ORDER BY a */
+ @Test public void testDefect5292_2() {
+ // Create query
+ String sql = "SELECT DISTINCT e1, e1 a FROM pm1.g1 ORDER BY a"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Duplicates defect #5004: SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx' */
+ @Test public void testDefect5004() {
+ // Create query
+ String sql = "SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Test to ensure that multiple empty batches are handled by the grouping node as well
+ */
+ @Test public void testDefect5004a() throws Exception {
+ // Create query
+ String sql = "SELECT COUNT(*) FROM pm1.g1 WHERE e1='xxxx'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ CommandContext context = createCommandContext();
+ context.setProcessorBatchSize(2);
+ context.setConnectorBatchSize(2);
+ context.setMetadata(FakeMetadataFactory.example1Cached());
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
+
+ // Run query
+ helpProcess(plan, context, dataManager, expected);
+ }
+
+ /** SELECT COUNT(e2), MIN(e2), MAX(e2), SUM(e2), AVG(e2) FROM pm1.g1 WHERE e2=-999999 */
+ @Test public void test13() {
+ // Create query
+ String sql = "SELECT COUNT(e2), MIN(e2), MAX(e2), SUM(e2), AVG(e2) FROM pm1.g1 WHERE e2=-999999"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {new Integer(0), null, null, null, null})
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * This test uncovered a bug in the FakeDataManager; the element
+ * symbol in the atomic query criteria has a canonical name
+ * of "Y.e4", but the FakeDataManager sends a Map of ElementSymbols
+ * having the unaliased names. The first symbol cannot be found
+ * in the Map due to the implementation of Symbol.equals() being
+ * based entirely on the canonical name, which causes a NPE.
+ * (Alex says this wasn't previously a problem because aliased groups
+ * did not previously get pushed down to the source.)
+ */
+ @Test public void testCriteriaAliasedGroup() {
+ String sql = "select e1, e2 FROM pm2.g1 Y WHERE 2.0 = e4"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b", new Integer(0) }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT e1 FROM pm1.g1 WHERE 'abc' = 'xyz' */
+ @Test public void testCriteriaComparesUnequalConstants() {
+ // Create query
+ String sql = "SELECT e1 FROM pm1.g1 WHERE 'abc' = 'xyz'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
+ @Test public void testRightOuterJoin1() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { null, "d" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, "e" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 LEFT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
+ @Test public void testLeftOuterJoin1() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 LEFT OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 FULL OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1 */
+ @Test public void testFullOuterJoin1() throws Exception {
+ // Create query
+ String sql = "SELECT pm1.g1.e1, pm2.g1.e1 FROM pm1.g1 FULL OUTER JOIN pm2.g1 ON pm1.g1.e1=pm2.g1.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, "d" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, "e" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testFullOuterJoin2() throws Exception {
+ // Create query
+ String sql = "SELECT a.e4 c0, b.e4 c1 FROM pm1.g1 a FULL OUTER JOIN pm1.g1 b ON a.e4=b.e4 order by c0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { new Double(0), new Double(0) }),
+ Arrays.asList(new Object[] { new Double(2), new Double(2) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testFullOuterJoin3() throws Exception {
+ // Create query
+ String sql = "SELECT a.e4 c0, b.e4 c1 FROM pm1.g1 b FULL OUTER JOIN (select e4, 1 x from pm1.g1 union all select e4, 2 from pm1.g1) a ON a.e4=b.e4 and a.x = 2 order by c0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { new Double(0), new Double(0) }),
+ Arrays.asList(new Object[] { new Double(0), null }),
+ Arrays.asList(new Object[] { new Double(2), new Double(2) }),
+ Arrays.asList(new Object[] { new Double(2), null }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT x.e1, pm2.g1.e1 FROM (SELECT e1 FROM pm1.g1) AS x LEFT OUTER JOIN pm2.g1 ON x.e1=pm2.g1.e1 */
+ @Test public void testLeftOuterJoinWithInlineView() {
+ // Create query
+ String sql = "SELECT x.e1, pm2.g1.e1 FROM (SELECT e1 FROM pm1.g1) AS x LEFT OUTER JOIN pm2.g1 ON x.e1=pm2.g1.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT * FROM vm1.g5 ORDER BY expr */
+ @Test public void testDefect5273_1() {
+ // Create query
+ String sql = "SELECT expr FROM vm1.g5 ORDER BY expr"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT expr AS e FROM vm1.g5 ORDER BY e */
+ @Test public void testDefect5273_2() {
+ // Create query
+ String sql = "SELECT expr AS e FROM vm1.g5 ORDER BY e"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT e2 AS e FROM vm1.g5 ORDER BY e */
+ @Test public void testDefect5273_3() {
+ // Create query
+ String sql = "SELECT e2 AS e FROM vm1.g5 ORDER BY e"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(3) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT e AS f FROM vm1.g6 ORDER BY f */
+ @Test public void testDefect5273_4() {
+ // Create query
+ String sql = "SELECT e AS f FROM vm1.g6 ORDER BY f"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT e AS f FROM vm1.g7 ORDER BY f */
+ @Test public void testDefect5273_5() {
+ // Create query
+ String sql = "SELECT e AS f FROM vm1.g7 ORDER BY f"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a3" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c1" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT e AS f FROM vm1.g7 ORDER BY f */
+ @Test public void testDefect5273_6() {
+ // Create query
+ String sql = "SELECT e AS f FROM vm1.g8 ORDER BY f"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "aval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "bval" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "cval" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testFalseCriteria1() {
+ // Create query
+ String sql = "SELECT 5 FROM pm1.g1 WHERE 0=1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testFalseCriteria2() {
+ // Create query
+ String sql = "SELECT count(*) FROM pm1.g1 WHERE 0=1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testTempGroup() {
+ // Create query
+ String sql = "SELECT e1 FROM tm1.g1 WHERE e1 = 'a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSubquery1() {
+ // Create query
+ String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSubquerySimple() {
+ // Create query
+ String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCritInSubquery() {
+ // Create query
+ String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1 WHERE e1 = 'a') AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCritAboveSubquery() {
+ // Create query
+ String sql = "SELECT e1 FROM (SELECT e1 FROM pm1.g1) AS x WHERE e1 = 'a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSubqueryInJoinPredicate() {
+ // Create query
+ String sql = "SELECT x.e1 FROM (SELECT e1 FROM pm1.g1) AS x JOIN (SELECT e1 FROM pm1.g1) y ON x.e1=y.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSubqueryWithRenaming() {
+ // Create query
+ String sql = "SELECT x.a FROM (SELECT e1 AS a FROM pm1.g1) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNestedSubquery() {
+ // Create query
+ String sql = "SELECT x.a FROM (SELECT e1 AS a FROM (SELECT e1 FROM pm1.g1) AS y) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null }),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery IN clause criteria
+ */
+ @Test public void testSubqueryINClause() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery IN clause criteria with nulls
+ * in sample data
+ */
+ @Test public void testSubqueryINClauseWithNulls() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e4 IN (SELECT e4 FROM pm2.g1)"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery IN clause criteria with nulls
+ * in sample data
+ */
+ @Test public void testSubqueryINClauseWithNulls2() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e4 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a compound criteria of two subqueries in IN clauses
+ */
+ @Test public void testSubqueryINClauses() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1) AND e1 IN (SELECT e1 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a compound criteria of a subquery in IN clause and another type of
+ * criteria
+ */
+ @Test public void testSubqueryINClauseMixedCriteria() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1) AND e1 IN ('b')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a compound criteria of a subquery in IN clause and another type of
+ * criteria
+ */
+ @Test public void testSubqueryINClauseMixedCriteria2() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1) AND NOT (e1 = 'a')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests nesting of Subquery IN clause criteria
+ */
+ @Test public void testNestedSubqueryINClauses() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1 WHERE e1 IN (SELECT e1 FROM pm1.g1))"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSubqueryXML() {
+ // Create query
+ String sql = "SELECT * FROM (SELECT * FROM xmltest.doc1) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
+ "<root><node1><node2><node3/></node2></node1></root>" //$NON-NLS-1$
+ })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery EXISTS predicate criteria
+ */
+ @Test public void testSubqueryExistsPredicate() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE EXISTS (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery EXISTS predicate criteria
+ * where the subquery returns no rows
+ */
+ @Test public void testSubqueryExistsPredicate2() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE EXISTS (SELECT e2 FROM pm2.g1 WHERE e1 = 'ZZTop')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicate() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 = ANY (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicate2() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 = SOME (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicate3() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 = ALL (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicate4() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 <= ALL (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicate5() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 < SOME (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicate5a() {
+ String sql = "SELECT e1 FROM pm2.g1 WHERE e2 < SOME (SELECT e2 FROM pm1.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "e" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ * without predicate quantifier
+ */
+ @Test public void testSubqueryComparePredicate6() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 < (SELECT e2 FROM pm2.g1 WHERE e1 = 'e')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a single Subquery in compare predicate criteria
+ */
+ @Test public void testSubqueryComparePredicateNested() {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 < SOME (SELECT e2 FROM pm2.g1 WHERE EXISTS (SELECT e2 FROM pm2.g1))"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", new List[] { Arrays.asList(new Object[] { new Integer(0), "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Integer(1), "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), "c" }), //$NON-NLS-1$
+ });
+
+ dataManager.addData("SELECT pm2.g1.e2 FROM pm2.g1", new List[] { //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ });
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a scalar subquery in the SELECT clause
+ */
+ @Test public void testSubqueryScalar() {
+ String sql = "SELECT e1, (SELECT e2 FROM pm2.g1 WHERE e1 = 'b') FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a scalar subquery which returns no rows in the SELECT clause
+ */
+ @Test public void testSubqueryScalar2() {
+ String sql = "SELECT e1, (SELECT e2 FROM pm2.g1 WHERE e1 = 'a') FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Tests a scalar subquery which returns more than one rows
+ * causes the expected Exception
+ */
+ @Test public void testSubqueryScalarException() throws Exception {
+ String sql = "SELECT e1, (SELECT e2 FROM pm2.g1) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcessException(plan, dataManager);
+ }
+
+ @Test public void testSubqueryScalarInTransformation() {
+ String sql = "select * from vm1.g25"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), new Double(0.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSubqueryScalarInTransformation2() {
+ String sql = "select * from vm1.g25 where e5 = 0.0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), new Double(0.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), new Double(0.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery_CASE2022() {
+ String sql = "select * from BQT2_V WHERE BQT2_V.IntKey < 50"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT1(dataManager);
+ sampleDataBQT2(dataManager);
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.exampleBQTCached(), capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+ @Test public void testCorrelatedSubquery1() {
+ String sql = "Select e1, e2, e4 from pm1.g1 where e2 in (select e2 FROM pm2.g1 WHERE pm1.g1.e4 = pm2.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ /**
+ * There is a bug when the second query in a UNION ALL has a correlated subquery, and both
+ * the outer and inner query are selecting from the same virtual group, and aliasing them
+ * differently to distinguish between them. The generated atomic query has screwed up
+ * aliasing.
+ */
+ @Test public void testCorrelatedSubqueryCase3667() {
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ // Plan query
+ String sql = "Select e1, e2, e4 from pm2.g1 where 1=2 " + //$NON-NLS-1$
+ "UNION ALL Select e1, e2, e4 from vm1.g1 outg1 where outg1.e2 in (select ing1.e2 FROM vm1.g1 ing1 WHERE outg1.e4 = ing1.e4)";//$NON-NLS-1$
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "aString", new Integer(22), new Double(22.0) }), //$NON-NLS-1$
+ };
+
+ dataManager.addData("SELECT g_0.e1, g_0.e2, g_0.e4 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (SELECT g_1.e2 FROM pm1.g1 AS g_1 WHERE g_1.e4 = g_0.e4)", //$NON-NLS-1$
+ expected);
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** control query, this test passes */
+ @Test public void testCorrelatedSubqueryCase3667a() {
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Plan query
+ String sql = "Select e1, e2, e4 from vm1.g1 outg1 where outg1.e2 in (select ing1.e2 FROM vm1.g1 ing1 WHERE outg1.e4 = ing1.e4)";//$NON-NLS-1$
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "aString", new Integer(22), new Double(22.0) }), //$NON-NLS-1$
+ };
+
+ dataManager.addData("SELECT g_0.e1, g_0.e2, g_0.e4 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (SELECT g_1.e2 FROM pm1.g1 AS g_1 WHERE g_1.e4 = g_0.e4)", //$NON-NLS-1$
+ expected);
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery2() {
+ String sql = "Select e1, e2 from pm1.g1 where e2 in (select e2 FROM pm2.g1 WHERE pm1.g1.e4 = pm2.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testCorrelatedSubquery3() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 WHERE pm1.g1.e4 = pm2.g1.e4) from pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery3a() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 WHERE X.e4 = e4) from pm1.g1 X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery3b() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = e4) from pm1.g1 X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery3c() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from pm1.g1 X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery4() {
+ String sql = "Select e1, e2 from pm1.g1 X where e2 in (select e2 FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery4a() {
+ String sql = "Select e1, e2 from pm1.g1 X where e2 = some (select e2 FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery_defect9968() {
+ String sql = "Select e1, e2 from pm1.g1 X where e2 in (select max(X.e2) FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery_defect9968a() {
+ String sql = "Select e1, e2 from pm1.g1 X where e2 in (select ((X.e2)/2) as e FROM pm2.g1 WHERE X.e4 = pm2.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery_defect9968b() {
+ String sql = "Select e1, e2 from pm1.g1 X where e2 in (select (select e2 as e FROM pm2.g1 WHERE X.e4 = pm2.g1.e4) as e FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubquery_defect10021() {
+ String sql = "Select e1, e2 from table1 X where e4 in (select max(Y.e4) FROM table1 Y WHERE X.e4 = Y.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(2) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Note the subquery has a multi-column result - conceptually this is
+ * legal for the EXISTS predicate
+ */
+ @Test public void testCorrelatedSubquery5() {
+ String sql = "Select * from pm1.g1 where exists (select * FROM pm2.g1 WHERE pm1.g1.e1 = e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Count the # of parent rows for which no child rows exist
+ */
+ @Test public void testCorrelatedSubquery6() {
+ String sql = "Select count(*) from pm1.g1 where not (exists (select * FROM pm2.g1 WHERE pm1.g1.e1 = e1))"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { new Integer(2) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Select e2, e4, and the avg of e4 for each group of e1
+ */
+ @Test public void testCorrelatedSubquery7() {
+ String sql = "select e2, e4, (select avg(e4) FROM pm1.g1 Y WHERE X.e1 = e1) from pm1.g1 X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) }),
+ Arrays.asList(new Object[] { new Integer(1), new Double(1.0), null }),
+ Arrays.asList(new Object[] { new Integer(3), new Double(7.0), new Double(3.6666666666666665) }),
+ Arrays.asList(new Object[] { new Integer(1), null , null }),
+ Arrays.asList(new Object[] { new Integer(2), new Double(0.0), new Double(0.0) }),
+ Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Select e2, e4, and the avg of e4 for each group of e1
+ */
+ @Test public void testCorrelatedSubquery8() {
+ String sql = "select X.e2, X.e4, (select avg(Y.e4) FROM pm1.g1 Y WHERE X.e1 = Y.e1) from pm1.g1 X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) }),
+ Arrays.asList(new Object[] { new Integer(1), new Double(1.0), null }),
+ Arrays.asList(new Object[] { new Integer(3), new Double(7.0), new Double(3.6666666666666665) }),
+ Arrays.asList(new Object[] { new Integer(1), null , null }),
+ Arrays.asList(new Object[] { new Integer(2), new Double(0.0), new Double(0.0) }),
+ Arrays.asList(new Object[] { new Integer(0), new Double(2.0), new Double(3.6666666666666665) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer1() {
+ String sql = "Select e1, e2 from vm1.g1 X where e2 in (select e2 FROM vm1.g1 Y WHERE X.e4 = Y.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1) }),
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer2() {
+ String sql = "Select e1, e2 from vm1.g2 where e2 in (select e2 FROM vm1.g1 WHERE vm1.g2.e4 = vm1.g1.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer3() {
+ String sql = "Select e2 from vm1.g6 where e2 in (select e2 FROM vm1.g1 WHERE vm1.g6.e = e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer4() {
+ String sql = "Select e2 from vm1.g7 where e2 in (select e2 FROM vm1.g1 WHERE vm1.g7.e = e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer5() {
+ String sql = "Select e1 from vm1.g4 where not (e1 in (select e1 FROM vm1.g1 WHERE vm1.g4.e1 = e1)) order by e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "3" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer6() {
+ String sql = "Select e2 from vm1.g1 X where e2 in (select X.e2 FROM vm1.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer6a() {
+ String sql = "Select e2 from vm1.g1 where e2 in (select vm1.g1.e2 FROM vm1.g5)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer6b() {
+ String sql = "Select e2 from vm1.g1 where e2 in (select vm1.g1.e2 FROM vm1.g2)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer6c() {
+ String sql = "Select e2 from vm1.g7 where e2 in (select vm1.g7.e FROM vm1.g1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer6e() {
+ String sql = "Select e2 from vm1.g1 where e2 in (select vm1.g1.e2 FROM vm1.g2a)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryVirtualLayer7() {
+ String sql = "Select e2 from vm1.g7 where e2 in (select vm1.g7.e FROM vm1.g1 WHERE vm1.g7.e = e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[0];
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation() {
+ String sql = "Select * from vm1.g21"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation2() {
+ String sql = "Select * from vm1.g20"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation3() {
+ String sql = "Select * from vm1.g19 order by e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "3" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * User correlated subquery, and one of the virtual group transformations
+ * also has a correlated subquery
+ */
+ @Test public void testCorrelatedSubqueryInTransformation4() {
+ String sql = "Select * from vm1.g20 where exists (Select * from vm1.g19 where convert(vm1.g20.e2, string) = vm1.g19.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * User correlated subquery, and one of the virtual group transformations
+ * also has a correlated subquery
+ */
+ @Test public void testCorrelatedSubqueryInTransformation5() {
+ String sql = "Select * from vm1.g19 where exists (Select e2 from vm1.g20 where convert(e2, string) = vm1.g19.e1) order by e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "0" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "3" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation6() {
+ String sql = "Select * from vm1.g21 where e2 = some (Select e2 from pm1.g1 where e1 = vm1.g21.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "b", new Integer(1), Boolean.TRUE, null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation7() {
+ String sql = "Select * from vm1.g21 where exists (Select e2 from pm1.g2 where e4 = convert(vm1.g21.e2, double))"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation8() {
+ String sql = "Select * from vm1.g21 where exists (Select e2 from pm1.g1 where e4 = convert(vm1.g21.e2, double))"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation9() {
+ String sql = "Select * from vm1.g22"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
+
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation10() {
+ String sql = "Select * from vm1.g23"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation11() {
+ String sql = "Select * from vm1.g24"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }),
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation12() {
+ String sql = "Select * from vm1.g24 X where exists (Select * from vm1.g24 Y where X.e2 = Y.e2)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }),
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation13() {
+ String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g25 where pm1.g1.e4 = e5 and e4=0.0) as e5 from pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation14() {
+ String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g26 where pm1.g1.e4 = e5 and e4=0.0) as e5 from pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation15() {
+ String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g23 where vm1.g22.e4 = e5) as e5 from vm1.g22 where e1 = 'a'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Test selecting a virtual element (e5) which is defined by a scalar subquery in the virtual transformation */
+ @Test public void testCorrelatedSubqueryInTransformation15a() {
+ String sql = "Select e1, e2, e3, e4 from pm1.g1 where exists (select * from vm1.g26 where pm1.g1.e3 = e3)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueryInTransformation15b() {
+ String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g23 where vm1.g22.e4 = e5) as e5 from vm1.g22 where e1 = 'a' and exists (select * from vm1.g23 where vm1.g22.e3 = e3)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Test selecting a virtual element (e5) which is defined by a scalar subquery in the virtual transformation */
+ @Test public void testCorrelatedSubqueryInTransformation15c() {
+ String sql = "Select e1, e2, e3, e4 from pm1.g1 where exists (select e1, e2, e3, e4, e5 as e from vm1.g26 where pm1.g1.e3 = e3)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** Test selecting a virtual element (e5) which is defined by a scalar subquery in the virtual transformation */
+ @Test public void testCorrelatedSubqueryInTransformation15d() {
+ String sql = "Select e1, e2, e3, e4 from pm1.g1 where exists (select e1, e2, e3, e4, ((e4 + e5)/(e4 + 1)) as e from vm1.g26 where pm1.g1.e3 = e3)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+// Here is select * from vm1.g26
+// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }),
+// Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
+// Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }),
+// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }),
+// Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }),
+// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null })
+
+
+ @Test public void testCorrelatedSubqueryInTransformation16() {
+// String sql = "Select e1, e2, e3, e4, (select e4 from vm1.g23 where vm1.g22.e4 = e5) as e5 from vm1.g22 where e1 = 'a'"/* and exists (select * from vm1.g23 where vm1.g22.e3 = e3)"*/;
+ String sql = "select * from vm1.g26 where e5 = 0.0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[]{
+// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null }),
+// Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0), null }),
+// Arrays.asList(new Object[] { "a", new Integer(3), Boolean.TRUE, new Double(7.0), null }),
+// Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null, null }),
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0), new Double(0.0) }), //$NON-NLS-1$
+// Arrays.asList(new Object[] { "a", new Integer(0), Boolean.FALSE, new Double(2.0), null })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCorrelatedSubqueriesNested() {
+ String sql =
+ "Select e1, e2, e4 from pm1.g1 where e2 < all (" + //$NON-NLS-1$
+ "select e2 from pm1.g2 where pm1.g1.e1 = e1 and exists("+ //$NON-NLS-1$
+ "select e2 from pm2.g1 where pm1.g2.e4 = pm2.g1.e4))"; //$NON-NLS-1$
+ Command query = helpParse(sql);
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), new Double(2.0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(2), new Double(0.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(query, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** defect 15124 */
+ @Test public void testCorrelatedSubqueryAndInlineView() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from (select * from pm1.g1) as X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** defect 15124 */
+ @Test public void testCorrelatedSubqueryAndInlineView2() {
+ String sql = "Select e1 from (select * from pm1.g1) as X WHERE e2 IN (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** defect 15124 */
+ @Test public void testCorrelatedSubqueryAndInlineView3() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from (select * from pm1.g1 UNION ALL select * from pm1.g1) as X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** defect 15124 */
+ @Test public void testCorrelatedSubqueryAndInlineView4() {
+ String sql = "Select e1, (select e2 FROM pm2.g1 Y WHERE X.e4 = Y.e4) from (select pm1.g1.e1, (select pm1.g1.e2 from pm1.g1 Z where pm1.g1.e1 = Z.e1), pm1.g1.e3, pm1.g1.e4 from pm1.g1) as X"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", null }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXMLUnion_defect8373() {
+ // Create query
+ String sql = "SELECT * FROM xmltest.doc5"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
+ "<root><node1><node2>a</node2></node1><node1><node2/></node1><node1><node2>a</node2></node1><node1><node2>c</node2></node1><node1><node2>b</node2></node1><node1><node2>a</node2></node1><node1><node2>a</node2></node1><node1><node2/></node1><node1><node2>a</node2></node1><node1><node2>c</node2></node1><node1><node2>b</node2></node1><node1><node2>a</node2></node1></root>" //$NON-NLS-1$
+ })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery1() {
+ // Create query
+ String sql = "EXEC pm1.sq1()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1) }),
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery2() {
+ // Create query
+ String sql = "EXEC pm1.sq2(\'a\')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery3() {
+ // Create query
+ String sql = "select x.e1 from (EXEC pm1.sq1()) as x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null}),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery4() {
+ // Create query
+ String sql = "EXEC pm1.sq5('a')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery5() {
+ // Create query
+ String sql = "EXEC pm1.sp1()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, new Integer(1)}),
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery6() {
+ // Create query
+ String sql = "EXEC pm1.sqsp1()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null}),
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testStoredQuery7() {
+ // Create query
+ String sql = "EXEC pm1.sq17()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + //$NON-NLS-1$
+ "<root><node1><node2><node3/></node2></node1></root>" //$NON-NLS-1$
+ })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ // implict type conversion of parameter
+ @Test public void testStoredQuery8() {
+ // Create query
+ String sql = "EXEC pm1.sq5(5)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ // function for parameter
+ @Test public void testStoredQuery9() {
+ // Create query
+ String sql = "EXEC pm1.sq5(concat('a', ''))"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** named parameters */
+ @Test public void testStoredQuery10() {
+ // Create query
+ String sql = "EXEC pm1.sq3b(\"in\" = 'a', in3 = 'something')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testInsert() {
+ // Create query
+ String sql = "Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1)})
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData3(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA FULL OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20) */
+ @Test public void testDefect7770_FullOuter() {
+ // Create query
+ String sql = "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA FULL OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6), new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(7), new Integer(7) }),
+ Arrays.asList(new Object[] { new Integer(8), new Integer(8) }),
+ Arrays.asList(new Object[] { new Integer(9), new Integer(9) }),
+ Arrays.asList(new Object[] { new Integer(10), new Integer(10) }),
+ Arrays.asList(new Object[] { new Integer(11), new Integer(11) }),
+ Arrays.asList(new Object[] { new Integer(12), new Integer(12) }),
+ Arrays.asList(new Object[] { new Integer(13), new Integer(13) }),
+ Arrays.asList(new Object[] { new Integer(14), new Integer(14) }),
+ Arrays.asList(new Object[] { new Integer(15), new Integer(15) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20) */
+ @Test public void testDefect7770_RightOuter() {
+ // Create query
+ String sql = "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6), new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(7), new Integer(7) }),
+ Arrays.asList(new Object[] { new Integer(8), new Integer(8) }),
+ Arrays.asList(new Object[] { new Integer(9), new Integer(9) }),
+ Arrays.asList(new Object[] { new Integer(10), new Integer(10) }),
+ Arrays.asList(new Object[] { new Integer(11), new Integer(11) }),
+ Arrays.asList(new Object[] { new Integer(12), new Integer(12) }),
+ Arrays.asList(new Object[] { new Integer(13), new Integer(13) }),
+ Arrays.asList(new Object[] { new Integer(14), new Integer(14) }),
+ Arrays.asList(new Object[] { new Integer(15), new Integer(15) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20) */
+ @Test public void testDefect7770_LeftOuter() {
+ // Create query
+ String sql = "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey WHERE (BQT1.SmallA.IntKey >= 0) AND (BQT1.SmallA.IntKey <= 15) AND (BQT2.MediumB.IntKey >= 5) AND (BQT2.MediumB.IntKey <= 20)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6), new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(7), new Integer(7) }),
+ Arrays.asList(new Object[] { new Integer(8), new Integer(8) }),
+ Arrays.asList(new Object[] { new Integer(9), new Integer(9) }),
+ Arrays.asList(new Object[] { new Integer(10), new Integer(10) }),
+ Arrays.asList(new Object[] { new Integer(11), new Integer(11) }),
+ Arrays.asList(new Object[] { new Integer(12), new Integer(12) }),
+ Arrays.asList(new Object[] { new Integer(13), new Integer(13) }),
+ Arrays.asList(new Object[] { new Integer(14), new Integer(14) }),
+ Arrays.asList(new Object[] { new Integer(15), new Integer(15) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testReorder1() {
+ // Create query
+ String sql = "SELECT e1 AS x, {b'false'}, e2+e4, e3 FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", Boolean.FALSE, new Double(2.0), Boolean.FALSE }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { null, Boolean.FALSE, new Double(2.0), Boolean.FALSE }),
+ Arrays.asList(new Object[] { "a", Boolean.FALSE, new Double(10.0), Boolean.TRUE }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", Boolean.FALSE, null, Boolean.TRUE }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", Boolean.FALSE, new Double(2.0), Boolean.FALSE }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", Boolean.FALSE, new Double(2.0), Boolean.FALSE }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testTwoFullOuterJoins1() {
+ // Create query
+ String sql = "SELECT A.IntKey AS A_IntKey, B.IntKey AS B_IntKey, C.IntKey AS C_IntKey " + //$NON-NLS-1$
+ "FROM (BQT1.SmallA AS A FULL OUTER JOIN BQT2.SmallA AS B ON A.IntKey = B.IntKey) FULL OUTER JOIN BQT3.SmallA AS C ON B.IntKey = C.IntKey " + //$NON-NLS-1$
+ "WHERE (A.IntKey >= 0) AND (A.IntKey <= 15) " + //$NON-NLS-1$
+ "AND (B.IntKey >= 5) AND (B.IntKey <= 20) " + //$NON-NLS-1$
+ "AND (C.IntKey >= 10) AND (C.IntKey <= 30)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(10), new Integer(10), new Integer(10) }),
+ Arrays.asList(new Object[] { new Integer(11), new Integer(11), new Integer(11) }),
+ Arrays.asList(new Object[] { new Integer(12), new Integer(12), new Integer(12) }),
+ Arrays.asList(new Object[] { new Integer(13), new Integer(13), new Integer(13) }),
+ Arrays.asList(new Object[] { new Integer(14), new Integer(14), new Integer(14) }),
+ Arrays.asList(new Object[] { new Integer(15), new Integer(15), new Integer(15) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSelectDistinctOnBQT() {
+ // Create query
+ String sql = "SELECT DISTINCT IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(4) }),
+ Arrays.asList(new Object[] { new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(7) }),
+ Arrays.asList(new Object[] { new Integer(8) }),
+ Arrays.asList(new Object[] { new Integer(9) }),
+ Arrays.asList(new Object[] { new Integer(10) }),
+ Arrays.asList(new Object[] { new Integer(11) }),
+ Arrays.asList(new Object[] { new Integer(12) }),
+ Arrays.asList(new Object[] { new Integer(13) }),
+ Arrays.asList(new Object[] { new Integer(14) }),
+ Arrays.asList(new Object[] { new Integer(15) }),
+ Arrays.asList(new Object[] { new Integer(16) }),
+ Arrays.asList(new Object[] { new Integer(17) }),
+ Arrays.asList(new Object[] { new Integer(18) }),
+ Arrays.asList(new Object[] { new Integer(19) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSelectWithNoFrom() {
+ // Create query
+ String sql = "SELECT 5"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testBetween() {
+ // Create query
+ String sql = "SELECT * FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, new Integer(1), Boolean.FALSE, new Double(1.0) }),
+ Arrays.asList(new Object[] { "c", new Integer(1), Boolean.TRUE, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(2), Boolean.FALSE, new Double(0.0) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Test <code>QueryProcessor</code>'s ability to process a query containing
+ * a <code>CASE</code> expression in which a <code>BETWEEN</code>
+ * comparison is used in the queries <code>SELECT</code> statement.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
+ */
+ @Test public void testBetweenInCase() {
+ // Create query
+ final String sql = "SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(-1) }),
+ Arrays.asList(new Object[] { new Integer(-1) }),
+ Arrays.asList(new Object[] { new Integer(3) }),
+ Arrays.asList(new Object[] { new Integer(-1) }),
+ Arrays.asList(new Object[] { new Integer(-1) }),
+ Arrays.asList(new Object[] { new Integer(-1) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Test <code>QueryProcessor</code>'s ability to process a query containing
+ * an aggregate SUM with a <code>CASE</code> expression in which a
+ * <code>BETWEEN</code> comparison is used in the queries <code>SELECT</code>
+ * statement.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1
+ */
+ @Test public void testBetweenInCaseInSum() {
+ // Create query
+ final String sql = "SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(-2) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Test <code>QueryProcessor</code>'s ability to process a query containing
+ * an aggregate SUM with a <code>CASE</code> expression in which a
+ * <code>BETWEEN</code> comparison is used in the queries <code>SELECT</code>
+ * statement and a GROUP BY is specified.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END)
+ * FROM pm1.g1 GROUP BY e1 ORDER BY e1
+ */
+ @Test public void testBetweenInCaseInSumWithGroupBy() {
+ // Create query
+ final String sql = "SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1 GROUP BY e1 ORDER BY e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, new Long(-1) }),
+ Arrays.asList(new Object[] { "a", new Long(1) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Long(-1) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c", new Long(-1) }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Test <code>QueryProcessor</code>'s ability to process a query containing
+ * an aggregate COUNT with a <code>CASE</code> expression in which a
+ * <code>BETWEEN</code> comparison is used in the queries <code>SELECT</code>
+ * statement.
+ * <p>
+ * For example:
+ * <p>
+ * SELECT COUNT(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 END) FROM pm1.g1
+ */
+ @Test public void testBetweenInCaseInCount() {
+ // Create query
+ final String sql = "SELECT COUNT(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 END) FROM pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCase() {
+ // Create query
+ String sql = "SELECT e2, CASE e2 WHEN 1 THEN 2 ELSE 3 END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(3) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSelectNoFrom1() {
+ // Create query
+ String sql = "SELECT 1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSelectNoFrom2() {
+ // Create query
+ String sql = "SELECT 1, {b'true'}, 2.0 AS x, {d'2003-11-04'}"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), Boolean.TRUE, new Double(2.0), TimestampUtil.createDate(103, 10, 4) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCase1566() throws Exception {
+ // Create query
+ String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM bqt1.smalla) as y GROUP BY x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { java.sql.Date.valueOf("2002-01-01"), new Integer(2) }),
+ Arrays.asList(new Object[] { java.sql.Date.valueOf("2002-01-02"), new Integer(3) }) };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT_case1566(dataManager);
+
+ // Create capabilities
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ // Parse query
+ Command command = QueryParser.getQueryParser().parseCommand(sql);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.exampleBQTCached(), capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect10976(){
+ String sql = "SELECT * FROM vm1.g28"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "A", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "B", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "C", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect10976_2(){
+ String sql = "SELECT * FROM vm1.g29"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "A", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "B", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "C", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect10976_3(){
+ String sql = "SELECT * FROM vm1.g30"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect10976_4(){
+ String sql = "SELECT * FROM vm1.g31 order by x"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect10976_5(){
+ String sql = "SELECT * FROM vm1.g32"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect11236_MergeJoinWithFunctions() {
+ // Create query
+ String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 = (pm2.g1.e2+1)"; //$NON-NLS-1$
+ boolean pushDown = false;
+ boolean dependent = false;
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(2) })
+ };
+
+ helpTestMergeJoinWithExpression(sql, pushDown, dependent, expected);
+ }
+
+ @Test public void testMergeJoinWithFunctionsPushDown() {
+ // Create query
+ String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 = (pm2.g1.e2+1)"; //$NON-NLS-1$
+ boolean pushDown = true;
+ boolean dependent = false;
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(2) })
+ };
+
+ helpTestMergeJoinWithExpression(sql, pushDown, dependent, expected);
+ }
+
+ @Test public void testMergeJoinWithFunctionsPushDownDependent() {
+ // Create query
+ String sql = "SELECT pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm1.g1.e2 = (pm2.g1.e2+1) option makedep pm1.g1"; //$NON-NLS-1$
+ boolean pushDown = true;
+ boolean dependent = true;
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(2) })
+ };
+
+ helpTestMergeJoinWithExpression(sql, pushDown, dependent, expected);
+ }
+
+
+ /**
+ * @param sql
+ * @param pushDown
+ * @param expected
+ */
+ private void helpTestMergeJoinWithExpression(String sql,
+ boolean pushDown,
+ boolean dependent,
+ List[] expected) {
+ // Construct data manager with data
+ ProcessorDataManager dataManager = null;
+ if (!pushDown) {
+ FakeDataManager fakeDataManager = new FakeDataManager();
+ sampleData1(fakeDataManager);
+ dataManager = fakeDataManager;
+ } else {
+ HardcodedDataManager hardCoded = new HardcodedDataManager();
+ List[] results = new List[] {
+ Arrays.asList(new Object[] {new Integer(0), new Integer(1)}),
+ Arrays.asList(new Object[] {new Integer(0), new Integer(1)}),
+ Arrays.asList(new Object[] {new Integer(1), new Integer(2)}),
+ Arrays.asList(new Object[] {new Integer(1), new Integer(2)}),
+ Arrays.asList(new Object[] {new Integer(2), new Integer(3)}),
+ Arrays.asList(new Object[] {new Integer(3), new Integer(4)}),
+ };
+ hardCoded.addData("SELECT g_0.e2 AS c_0, (g_0.e2 + 1) AS c_1 FROM pm2.g1 AS g_0 ORDER BY c_1", results); //$NON-NLS-1$
+ if (!dependent) {
+ results = new List[] {
+ Arrays.asList(new Object[] {new Integer(0),}),
+ Arrays.asList(new Object[] {new Integer(0),}),
+ Arrays.asList(new Object[] {new Integer(1),}),
+ Arrays.asList(new Object[] {new Integer(1),}),
+ Arrays.asList(new Object[] {new Integer(2),}),
+ Arrays.asList(new Object[] {new Integer(3),}),
+ };
+ hardCoded.addData("SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", results); //$NON-NLS-1$
+ } else {
+ results = new List[] {
+ Arrays.asList(new Object[] {new Integer(1),}),
+ Arrays.asList(new Object[] {new Integer(2),}),
+ Arrays.asList(new Object[] {new Integer(1),}),
+ };
+ hardCoded.addData("SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (1, 2)", results); //$NON-NLS-1$
+ results = new List[] {
+ Arrays.asList(new Object[] {new Integer(3),}),
+ };
+ hardCoded.addData("SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e2 IN (3, 4)", results); //$NON-NLS-1$
+ }
+ dataManager = hardCoded;
+ }
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, pushDown);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, pushDown);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(2));
+ caps.setFunctionSupport("+", pushDown); //$NON-NLS-1$
+ finder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ finder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, finder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCase2() {
+ // Create query
+ String sql = "SELECT e2, CASE e2 WHEN 1 THEN 2 END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(2), null })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCase3() {
+ // Create query
+ String sql = "SELECT e2, CASE e2 WHEN 1 THEN 2 ELSE null END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(2), null })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** nested scalar subquery */
+ @Test public void testCase4() {
+ // Create query
+ String nestedExpression = "(SELECT e1 FROM pm1.g2 WHERE e2 = 3)"; //$NON-NLS-1$
+ String sql = "SELECT e2, CASE e2 WHEN 1 THEN " + nestedExpression + " ELSE null END FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(1), "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), null })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** nested correlated scalar subquery */
+ @Test public void testCase5() {
+ // Create query
+ String nestedExpression = "(SELECT e2 FROM pm1.g2 WHERE pm1.g1.e2 = (e4 + 2))"; //$NON-NLS-1$
+ String sql = "SELECT e2, CASE e2 WHEN " + nestedExpression + " THEN 1 ELSE null END FROM pm1.g1"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), null }),
+ Arrays.asList(new Object[] { new Integer(1), null }),
+ Arrays.asList(new Object[] { new Integer(3), null }),
+ Arrays.asList(new Object[] { new Integer(1), null }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(0), null })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * NOTE: this test depends on the ProcessorPlan being executed
+ * twice and reset in between, which currently is done in the
+ * helpProcess method
+ */
+ @Test public void testDefect12135(){
+ String sql = "SELECT pm1.g1.e1, pm1.g2.e1 FROM pm1.g1 LEFT OUTER JOIN pm1.g2 ON pm1.g1.e1=pm1.g2.e1"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect12081(){
+ String sql = "SELECT DISTINCT vm1.g1.e1, upper(vm1.g1.e1) as Nuge, pm1.g1.e1, upper(pm1.g1.e1) as Nuge FROM vm1.g1, pm1.g1"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "A", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "a", "A", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "a", "A", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "c", "C" }) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect12081_2(){
+ String sql = "SELECT DISTINCT vm1.g1b.e1, vm1.g1b.e1Upper, pm1.g1.e1, upper(pm1.g1.e1) as e1Upper FROM vm1.g1b, pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "A", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "a", "A", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "a", "A", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "c", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "c", "C" }) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect12081_3(){
+ String sql = "SELECT DISTINCT vm1.g1b.e1, vm1.g1b.e1Upper, pm1.g1.e1, vm1.g1b.e1Upper FROM vm1.g1b, pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "A", "a", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "a", "A", "b", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "a", "A", "c", "A" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "a", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "b", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "b", "B", "c", "B" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "a", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "b", "C" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { "c", "C", "c", "C" }) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Basically the same as above, but with a limit node between the dup removal and the project
+ */
+ @Test public void testDefect12081_4(){
+ String sql = "SELECT DISTINCT e1, e1 FROM pm1.g1 where e1 = 'a' LIMIT 1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "a"}), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect12719(){
+ String sql = "SELECT e1_, e2_, e2 FROM vm1.g34, pm1.g2 WHERE vm1.g34.e1_ = pm1.g2.e1 order by e1_, e2_"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0), new Integer(1) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0), new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0), new Integer(5) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0), new Integer(2) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), new Integer(0) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), new Integer(5) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1), new Integer(2) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", new Integer(3), new Integer(2) }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect13034() {
+ String sql = "SELECT CONCAT('http://', CONCAT(CASE WHEN (HOST IS NULL) OR (HOST = '') THEN 'soap_host' ELSE HOST END, CASE WHEN (PORT IS NULL) OR (PORT = '') THEN '/metamatrix-soap/services/DataService' ELSE CONCAT(':', CONCAT(PORT, '/metamatrix-soap/services/DataService')) END)) AS location " + //$NON-NLS-1$
+ "FROM (SELECT env('soap_host') AS HOST, env('soap_port') AS PORT) AS props"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "http://my.host.com:12345/metamatrix-soap/services/DataService" }), //$NON-NLS-1$
+ };
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, new FakeDataManager(), expected);
+
+ }
+
+ /** see also integer average defect 11682 */
+ @Test public void testIntAvgDefect11682() {
+ // Create query
+ String sql = "SELECT AVG(IntKey), AVG(IntNum), AVG(FloatNum), AVG(LongNum), AVG(DoubleNum), AVG(ByteNum), AVG(ShortValue), AVG(BigIntegerValue), AVG(BigDecimalValue) FROM BQT1.SmallA"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new Double(1.5), new BigDecimal("1.500000000"), new BigDecimal("1.500000000") }), //$NON-NLS-1$//$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT_defect11682(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonJoinCriteriaInFrom() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm2.g1 b ON a.e1=b.e1 AND b.e2 = 0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null, null }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonJoinCriteriaInWhere() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm2.g1 b ON a.e1=b.e1 WHERE b.e2 = 0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonJoinCriteriaInWhere2() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm1.g2 b ON a.e1=b.e1 WHERE (a.e2 + b.e2 = 1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "a", new Integer(1) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonJoinCriteriaInWhere3() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm1.g2 b ON a.e1=b.e1 WHERE (a.e2 = 0) OR (b.e2 = 0)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "a", new Integer(1) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonJoinCriteriaInFromNestedInVirtual() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN (SELECT c.e1, d.e2 FROM pm2.g1 c JOIN pm2.g1 d ON c.e1=d.e1 AND d.e2 >= 0) b ON a.e1=b.e1 AND b.e2 = 0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null, null }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonJoinCriteriaInFromUsingDependentJoin() {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a LEFT OUTER JOIN pm2.g1 b ON a.e1=b.e1 AND b.e2 = 0"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null, null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", "b", new Integer(0) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", null, null }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect13700() {
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(10) }),
+ };
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan("EXEC pm1.vsp36(5)", FakeMetadataFactory.example1Cached()); //$NON-NLS-1$
+
+ // Run query
+ helpProcess(plan, new FakeDataManager(), expected);
+
+ }
+
+ @Test public void testDefect13920() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, false);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, false);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ Command command = helpParse("SELECT e5, e2, e3, e4 FROM vm1.g1c WHERE e5 >= {ts'2004-08-01 00:00:00.0'}"); //$NON-NLS-1$
+ ProcessorPlan plan = helpGetPlan(command,
+ FakeMetadataFactory.example1Cached(), capFinder);
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataStringTimestamps(dataManager);
+
+ Calendar cal = Calendar.getInstance();
+ cal.set(2004, Calendar.DECEMBER, 31, 0, 0, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ Timestamp t1 = new Timestamp(cal.getTime().getTime());
+ cal.clear();
+ cal.set(2004, Calendar.AUGUST, 1, 0, 0, 0);
+ cal.set(Calendar.MILLISECOND, 0);
+ Timestamp t2 = new Timestamp(cal.getTime().getTime());
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { t1, new Integer(1), Boolean.TRUE, null }),
+ Arrays.asList(new Object[] { t2, new Integer(2), Boolean.FALSE, new Double(0.0) }),
+ };
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ /** RLM Case 2077
+ * @throws Exception */
+ @Test public void testComplexJoinExpressionsUsingDependentJoin() throws Exception {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm1.g1 a, pm2.g1 b where rtrim(a.e1)=(b.e1 || b.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "bb ", "b", new Integer(0) }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2b(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
+ caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ caps.setFunctionSupport("rtrim", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+
+ Command command = helpParse(sql);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder,context);
+
+ //Verify a dependent join (not merge join) was used
+ assertTrue(plan instanceof RelationalPlan);
+ RelationalPlan relationalPlan = (RelationalPlan)plan;
+ RelationalNode project = relationalPlan.getRootNode();
+ RelationalNode join = project.getChildren()[0];
+ assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
+
+ // Run query
+ helpProcess(plan, context, dataManager, expected);
+ }
+
+ /** RLM Case 2077
+ * @throws Exception */
+ @Test public void testComplexJoinExpressionsUsingDependentJoinWithAccessPattern() throws Exception {
+ String sql = "SELECT a.e1, b.e1, b.e2 FROM pm4.g1 a, pm2.g1 b where rtrim(a.e1)=(b.e1 || b.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "bb ", "b", new Integer(0) }) //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2b(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+ caps.setFunctionSupport("||", true); //$NON-NLS-1$
+ caps.setFunctionSupport("rtrim", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1();
+ FakeMetadataObject g1 = metadata.getStore().findObject("pm4.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
+ FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
+ g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
+
+ Command command = helpParse(sql);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
+
+ //Verify a dependent join (not merge join) was used
+ assertTrue(plan instanceof RelationalPlan);
+ RelationalPlan relationalPlan = (RelationalPlan)plan;
+ RelationalNode project = relationalPlan.getRootNode();
+ RelationalNode join = project.getChildren()[0];
+ assertTrue("Expected instance of JoinNode (for dep join) but got " + join.getClass(), join instanceof JoinNode); //$NON-NLS-1$
+
+ // Run query
+ helpProcess(plan, context, dataManager, expected);
+ }
+
+ @Test public void testPushingCriteriaUnderJoinButNotToSource() {
+ // Create query
+ String sql = "SELECT A.IntKey AS A_IntKey, B.IntKey AS B_IntKey, C.IntKey AS C_IntKey " + //$NON-NLS-1$
+ "FROM (BQT1.SmallA AS A FULL OUTER JOIN BQT2.SmallA AS B ON A.IntKey = B.IntKey) LEFT OUTER JOIN BQT3.SmallA AS C ON B.IntKey = C.IntKey " + //$NON-NLS-1$
+ "WHERE (sin(A.IntKey) >= 0) " + //$NON-NLS-1$
+ "AND (C.IntKey >= 10)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(13), new Integer(13), new Integer(13) }),
+ Arrays.asList(new Object[] { new Integer(14), new Integer(14), new Integer(14) }),
+ Arrays.asList(new Object[] { new Integer(15), new Integer(15), new Integer(15) }),
+ Arrays.asList(new Object[] { new Integer(19), new Integer(19), new Integer(19) }),
+ Arrays.asList(new Object[] { new Integer(20), new Integer(20), new Integer(20) }),
+ Arrays.asList(new Object[] { new Integer(21), new Integer(21), new Integer(21) }),
+ Arrays.asList(new Object[] { new Integer(26), new Integer(26), new Integer(26) }),
+ Arrays.asList(new Object[] { new Integer(27), new Integer(27), new Integer(27) }),
+ Arrays.asList(new Object[] { new Integer(28), new Integer(28), new Integer(28) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.exampleBQTCached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testPushdownLiteralInSelectUnderAggregate() {
+ String sql = "SELECT COUNT(*) FROM (SELECT '' AS y, a.IntKey FROM BQT1.SmallA a union all select '', b.intkey from bqt1.smallb b) AS x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(30) })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testPushdownLiteralInSelectWithOrderBy() {
+ String sql = "SELECT 1, concat('a', 'b' ) AS X FROM BQT1.SmallA where intkey = 0 " + //$NON-NLS-1$
+ "UNION ALL " + //$NON-NLS-1$
+ "select 2, 'Hello2' from BQT1.SmallA where intkey = 1 order by X desc"; //$NON-NLS-1$
+
+
+ // Create expected results - would expect these to be:
+ // 1, "ab"
+ // 2, "Hello2"
+ // but our fake tuple source is too dumb to return anything reasonable, so instead get:
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null, null }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQTSmall(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /** defect 15348
+ * @throws Exception */
+ @Test public void testPreparedStatementDefect15348() throws Exception{
+ String sql = "SELECT e1 from pm1.g1 where myrtrim(?)=e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+
+
+ Command command = helpParse(sql);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
+
+ // Collect reference, set value
+ Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
+ VariableContext vc = new VariableContext();
+ vc.setGlobalValue(ref.getContextSymbol(), "a "); //$NON-NLS-1$
+ context.setVariableContext(vc);
+ // Run query
+ helpProcess(plan, context, dataManager, expected);
+
+ }
+
+ /** defect 15348
+ * @throws Exception */
+ @Test public void testPreparedStatementDefect15348b() throws Exception{
+ String sql = "SELECT e1 from pm4.g1 where myrtrim(concat(?, 'a '))=e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "aa" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
+
+ FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
+
+
+ Command command = helpParse(sql);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
+
+ // Collect reference, set value
+ Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
+ VariableContext vc = new VariableContext();
+ vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
+ context.setVariableContext(vc);
+
+ // Run query
+ helpProcess(plan, context, dataManager, expected);
+
+ }
+
+ @Test public void testSourceDoesntSupportGroupAlias() {
+ String sql = "SELECT a.IntKey, b.IntKey FROM BQT1.SmallA a, BQT1.SmallB b WHERE a.IntKey = 5 AND A.IntKey = b.IntKey"; //$NON-NLS-1$
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set atomicQueries = TestOptimizer.getAtomicQueries(plan);
+ assertEquals("Expected one query to get pushed down", 1, atomicQueries.size()); //$NON-NLS-1$
+ String atomicSql = atomicQueries.iterator().next().toString();
+ String expectedSql = "SELECT BQT1.SmallA.IntKey, BQT1.SmallB.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) AND (BQT1.SmallA.IntKey = 5) AND (BQT1.SmallB.IntKey = 5)"; //$NON-NLS-1$
+ assertEquals(expectedSql, atomicSql);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(5)}),
+ };
+
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, expected);
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testSourceDoesntSupportGroupAliasOrCriteria() {
+ String sql = "SELECT a.IntKey, b.IntKey FROM BQT1.SmallA a, BQT1.SmallB b WHERE a.StringKey = '5' AND A.IntKey = b.IntKey"; //$NON-NLS-1$
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set atomicQueries = TestOptimizer.getAtomicQueries(plan);
+ assertEquals("Expected 2 queries to get pushed down", 2, atomicQueries.size()); //$NON-NLS-1$
+
+ String expectedSql = "SELECT BQT1.SmallA.StringKey, BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
+ String expectedSql2 = "SELECT BQT1.SmallB.IntKey FROM BQT1.SmallB"; //$NON-NLS-1$
+ Set expectedQueries = new HashSet();
+ expectedQueries.add(expectedSql);
+ expectedQueries.add(expectedSql2);
+ assertEquals(expectedQueries, atomicQueries);
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { "5", new Integer(5)}), //$NON-NLS-1$
+ };
+ List[] input2 = new List[] {Arrays.asList(new Object[] {new Integer(5)}),
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+ dataManager.addData(expectedSql2, input2);
+
+ List[] expected = new List[] {Arrays.asList(new Object[] {new Integer(5), new Integer(5)}),
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Same as testSourceDoesntSupportGroupAlias, but query is in an inline view and only
+ * the first column is selected.
+ *
+ * @since 4.2
+ */
+ @Test public void testSourceDoesntSupportGroupAliasInVirtual() {
+ String sql = "SELECT x FROM (SELECT a.IntKey as x, b.IntKey as y FROM BQT1.SmallA a, BQT1.SmallB b WHERE a.IntKey = 5 AND A.IntKey = b.IntKey) AS z, BQT2.SmallA WHERE y = IntKey"; //$NON-NLS-1$
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set atomicQueries = TestOptimizer.getAtomicQueries(plan);
+ assertEquals("Expected 2 queries to get pushed down", 2, atomicQueries.size()); //$NON-NLS-1$
+
+ String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) AND (BQT1.SmallA.IntKey = 5) AND (BQT1.SmallB.IntKey = 5)"; //$NON-NLS-1$
+ String expectedSql2 = "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA WHERE BQT2.SmallA.IntKey = 5"; //$NON-NLS-1$
+
+ Set expectedQueries = new HashSet();
+ expectedQueries.add(expectedSql);
+ expectedQueries.add(expectedSql2);
+ assertEquals(expectedQueries, atomicQueries);
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(5)}),
+ };
+ List[] input2 = new List[] {
+ Arrays.asList(new Object[] { new Integer(5)}),
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+ dataManager.addData(expectedSql2, input2);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5)}),
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCaseInGroupBy() {
+ String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set actualQueries = TestOptimizer.getAtomicQueries(plan);
+ String expectedSql = "SELECT SUM(X_1.c_1), X_1.c_0 FROM (SELECT CASE WHEN BQT1.SmallA.IntKey >= 5000 THEN '5000 +' ELSE '0-999' END AS c_0, BQT1.SmallA.IntKey AS c_1 FROM BQT1.SmallA) AS v_0 GROUP BY X_1.c_0"; //$NON-NLS-1$
+ assertEquals(1, actualQueries.size());
+ assertEquals(expectedSql, actualQueries.iterator().next().toString());
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(10)}),
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(5), new Integer(10)}),
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCaseInGroupByAndHavingCantPush() {
+ String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "HAVING case when IntKey>=5000 then '5000 +' else '0-999' end = '5000 +'"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false); // Can't push GROUP BY
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set actualQueries = TestOptimizer.getAtomicQueries(plan);
+ String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
+ assertEquals(1, actualQueries.size());
+ assertEquals(expectedSql, actualQueries.iterator().next().toString());
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { new Integer(2)}),
+ Arrays.asList(new Object[] { new Integer(4)}),
+ Arrays.asList(new Object[] { new Integer(10000)}),
+ Arrays.asList(new Object[] { new Integer(10002)}),
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(20002), "5000 +"}), //$NON-NLS-1$
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCaseInGroupByAndHavingCantPush2() {
+ String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end || 'x' " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ "HAVING length(case when IntKey>=5000 then '5000 +' else '0-999' end) > 5"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false); // Can't push GROUP BY
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set actualQueries = TestOptimizer.getAtomicQueries(plan);
+ String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
+ assertEquals(1, actualQueries.size());
+ assertEquals(expectedSql, actualQueries.iterator().next().toString());
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { new Integer(2)}),
+ Arrays.asList(new Object[] { new Integer(4)}),
+ Arrays.asList(new Object[] { new Integer(10000)}),
+ Arrays.asList(new Object[] { new Integer(10002)}),
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(20002), "5000 +x"}), //$NON-NLS-1$
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testCaseInGroupByAndHavingCantPush3() {
+ String sql = "SELECT s, c FROM (" + //$NON-NLS-1$
+ "SELECT sum (IntKey) s, case when IntKey>=5000 then '5000 +' else '0-999' end || 'x' c " + //$NON-NLS-1$
+ "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
+ ") AS x WHERE length(c) > 5 AND s = 20002"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false); // Can't push GROUP BY
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set actualQueries = TestOptimizer.getAtomicQueries(plan);
+ String expectedSql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA"; //$NON-NLS-1$
+ assertEquals(1, actualQueries.size());
+ assertEquals(expectedSql, actualQueries.iterator().next().toString());
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { new Integer(2)}),
+ Arrays.asList(new Object[] { new Integer(4)}),
+ Arrays.asList(new Object[] { new Integer(10000)}),
+ Arrays.asList(new Object[] { new Integer(10002)}),
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(20002), "5000 +x"}), //$NON-NLS-1$
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testFunctionOfAggregateCantPush() {
+ String sql = "SELECT StringKey || 'x', SUM(length(StringKey || 'x')) + 1 AS x FROM BQT1.SmallA GROUP BY StringKey || 'x' HAVING space(MAX(length((StringKey || 'x') || 'y'))) = ' '"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set actualQueries = TestOptimizer.getAtomicQueries(plan);
+ String expectedSql = "SELECT BQT1.SmallA.StringKey FROM BQT1.SmallA"; //$NON-NLS-1$
+ assertEquals(1, actualQueries.size());
+ assertEquals(expectedSql, actualQueries.iterator().next().toString());
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { "0"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "10"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "11"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "100"}), //$NON-NLS-1$
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "0x", new Long(3)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "1x", new Long(3)}), //$NON-NLS-1$
+ };
+ helpProcess(plan, dataManager, expected);
+ }
+
+
+ @Test public void testCase2634() {
+
+ String sql = "SELECT x, IntKey FROM (SELECT IntKey, 'a' AS x FROM BQT1.SmallA UNION ALL SELECT IntKey, 'b' AS x FROM BQT1.SmallB) as Z"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Set actualQueries = TestOptimizer.getAtomicQueries(plan);
+ String expectedSql = "SELECT 'a' AS c_0, BQT1.SmallA.IntKey AS c_1 FROM BQT1.SmallA UNION ALL SELECT 'b' AS c_0, BQT1.SmallB.IntKey AS c_1 FROM BQT1.SmallB"; //$NON-NLS-1$
+ assertEquals(1, actualQueries.size());
+ assertEquals(expectedSql, actualQueries.iterator().next().toString());
+
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1)}), //$NON-NLS-1$
+ };
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData(expectedSql, input1);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(1)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(0)}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", new Integer(1)}), //$NON-NLS-1$
+ };
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testQueryWithoutFromWithOrderBy() {
+
+ String sql = "select 'three' as x ORDER BY x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "three"} ), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testQueryWithoutFromWithOrderBy2() {
+
+ String sql = "select concat('three', ' sixteen') as x ORDER BY x"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "three sixteen"} ), //$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testQueryWithoutFromWithOrderBy3() {
+
+ String sql = "SELECT CONCAT('yy', 'z') as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
+ "CONCAT('21', '12') AS EXPR ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "yyz", "2112"} ), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testCase2507_3(){
+
+ String sql = "SELECT CONCAT('yy', 'z') AS c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
+ "CONCAT('21', '12') AS EXPR ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
+ caps.setFunctionSupport("concat", true); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[0] ,
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 0, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ // TEST PROCESSING
+
+ List[] expectedResults = new List[] {
+ Arrays.asList(new Object[] { "yyz", "2112"}), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT1(dataManager);
+
+ // Run query
+ helpProcess(plan, dataManager, expectedResults);
+
+ }
+
+ @Test public void testMultiGroupJoinCriteria() {
+
+ String sql = "SELECT X.NEWFIELD FROM " + //$NON-NLS-1$
+ "(SELECT SMALLA.STRINGNUM, " + //$NON-NLS-1$
+ "CASE WHEN SMALLA.STRINGNUM LIKE '1%' THEN SMALLA.INTKEY " + //$NON-NLS-1$
+ "WHEN SMALLA.STRINGNUM LIKE '2%' THEN SMALLB.INTNUM " + //$NON-NLS-1$
+ "WHEN SMALLA.STRINGNUM LIKE '3%' THEN MEDIUMA.INTKEY " + //$NON-NLS-1$
+ "END AS NEWFIELD " + //$NON-NLS-1$
+ "FROM BQT1.SMALLA, BQT1.SMALLB, BQT1.MEDIUMA " + //$NON-NLS-1$
+ "WHERE SMALLA.INTKEY = SMALLB.INTKEY AND SMALLA.INTKEY = MEDIUMA.INTKEY) AS X " + //$NON-NLS-1$
+ "WHERE X.NEWFIELD = -3"; //$NON-NLS-1$
+
+ String expectedAtomic1 = "SELECT BQT1.SMALLB.INTKEY, BQT1.SMALLB.INTNUM FROM BQT1.SMALLB"; //$NON-NLS-1$
+ String expectedAtomic2 = "SELECT BQT1.MEDIUMA.INTKEY FROM BQT1.MEDIUMA"; //$NON-NLS-1$
+ String expectedAtomic3 = "SELECT BQT1.SMALLA.INTKEY, BQT1.SMALLA.STRINGNUM FROM BQT1.SMALLA"; //$NON-NLS-1$
+
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql,
+ metadata,
+ null, capFinder,
+ new String[] {expectedAtomic1, expectedAtomic2, expectedAtomic3} ,
+ TestOptimizer.SHOULD_SUCCEED );
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // Join
+ 2, // MergeJoin
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ // TEST PROCESSING
+
+ List[] expectedResults = new List[] {
+ Arrays.asList(new Object[] { new Integer(-3) }),
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ List[] input1 = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(-4)}),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(-3)}),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(-2)}),
+ };
+ dataManager.addData(expectedAtomic1, input1);
+ List[] input2 = new List[] {
+ Arrays.asList(new Object[] { new Integer(1)}),
+ Arrays.asList(new Object[] { new Integer(2)}),
+ Arrays.asList(new Object[] { new Integer(3)}),
+ };
+ dataManager.addData(expectedAtomic2, input2);
+ List[] input3 = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new String("1")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), new String("2")}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(3), new String("3")}), //$NON-NLS-1$
+ };
+ dataManager.addData(expectedAtomic3, input3);
+
+ // Run query
+ helpProcess(plan, dataManager, expectedResults);
+
+ }
+
+ /**
+ * Cross-source join with group by on top but no aggregate functions - running some special cases
+ * where there are no "aggregate groups" (the groups of the aggregate expressions) because there
+ * are no aggregate expressions. In this case, need to switch the aggregate groups to be all the grouping
+ * columns because they are all being "grouped on".
+ *
+ * @since 4.3
+ */
+ @Test public void testDefect18360(){
+
+ String sql = "SELECT a.intkey, a.intnum FROM bqt1.smalla a join bqt2.mediumb b on a.stringkey = b.stringkey " + //$NON-NLS-1$
+ "group by a.intkey, a.intnum"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ capFinder.addCapabilities("BQT1", new BasicSourceCapabilities()); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", new BasicSourceCapabilities()); //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.exampleBQTCached(), capFinder);
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ List[] data1 = new List[] {
+ Arrays.asList(new Object[] { "1", new Integer(1), new Integer(5) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2", new Integer(2), new Integer(6) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "3", new Integer(3), new Integer(7) }), //$NON-NLS-1$
+ };
+ dataManager.addData("SELECT bqt1.smalla.stringkey, bqt1.smalla.intkey, bqt1.smalla.intnum FROM bqt1.smalla", data1); //$NON-NLS-1$
+
+ List[] data2 = new List[] {
+ Arrays.asList(new Object[] { "1" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "2" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "3" }), //$NON-NLS-1$
+ };
+ dataManager.addData("SELECT bqt2.mediumb.stringkey FROM bqt2.mediumb", data2); //$NON-NLS-1$
+
+ // Run query
+ List[] expectedResults = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(6) }),
+ Arrays.asList(new Object[] { new Integer(3), new Integer(7) }),
+ };
+ helpProcess(plan, dataManager, expectedResults);
+
+ }
+
+ @Test public void testDefect17407(){
+ String sql = "select pm1.g1.e1 from pm1.g1, g7 MAKEDEP WHERE pm1.g1.e2=g7.e2 order by e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null}),
+ Arrays.asList(new Object[] { null}),
+ Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}),//$NON-NLS-1$
+ Arrays.asList(new Object[] { "a"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b"}),//$NON-NLS-1$
+ Arrays.asList(new Object[] { "c"}),//$NON-NLS-1$
+ Arrays.asList(new Object[] { "c"}),//$NON-NLS-1$
+ };
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDecodeAsCriteria() {
+ // Create query
+ String sql = "SELECT x.foo, e2 FROM (select decodestring(e1, 'a,q,b,w') as foo, e2 from vm1.g1) as x where x.foo = 'w'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "w", new Integer(2) }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testInputParamInNestedExecParam() {
+ // Create query
+ String sql = "EXEC pm1.vsp48('a')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testVariableInExecParam() {
+ // Create query
+ String sql = "EXEC pm1.vsp49()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b", new Integer(2) }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testVariableInNestedExecParam() {
+ // Create query
+ String sql = "EXEC pm1.vsp50()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testVariableInNestedExecParamInLoop() {
+ // Create query
+ String sql = "EXEC pm1.vsp51()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "bb" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testVariableInNestedExecParamInAssignment() {
+ // Create query
+ String sql = "EXEC pm1.vsp52()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testInputParamInNestedExecParamInLoop() {
+ // Create query
+ String sql = "EXEC pm1.vsp53('b')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "bb" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testInputParamInNestedExecParamInAssignment() {
+ // Create query
+ String sql = "EXEC pm1.vsp54('c')"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testBitwiseAggregateProc() {
+ // Create query
+ String sql = "EXEC virt.agg()"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(19) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(1), "b", new Integer(4) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), "c", new Integer(3) }), //$NON-NLS-1$
+ };
+
+ // Plan query
+ FakeMetadataFacade metadata = FakeMetadataFactory.exampleBitwise();
+ ProcessorPlan plan = helpGetPlan(sql, metadata);
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBitwise(dataManager, metadata);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ private void sampleDataBitwise(FakeDataManager dataMgr, FakeMetadataFacade metadata) {
+ try {
+ // Group pm1.g1
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("phys.t"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(1) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(3) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(0), "a", new Integer(16) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(1), "b", new Integer(4) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), "c", new Integer(2) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Integer(2), "c", new Integer(1) }), //$NON-NLS-1$
+ } );
+
+ } catch(Throwable e) {
+ e.printStackTrace();
+ fail("Exception building test data (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ }
+
+ @Test public void testFunctionGroupByInJoinCriteria() {
+ // Create query
+ String sql = "SELECT lower(vm1.g1.e1) from vm1.g1, vm1.g2a where vm1.g1.e1 = vm1.g2a.e1 group by lower(vm1.g1.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ private FakeMetadataFacade createProjectErrorMetadata() {
+ FakeMetadataObject p1 = FakeMetadataFactory.createPhysicalModel("p1"); //$NON-NLS-1$
+ FakeMetadataObject t1 = FakeMetadataFactory.createPhysicalGroup("p1.t", p1); //$NON-NLS-1$
+ List e1 = FakeMetadataFactory.createElements(t1, new String[] {"a", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
+ QueryNode n1 = new QueryNode("v1.t1", "SELECT convert(a, integer) as c, b FROM p1.t"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vt1 = FakeMetadataFactory.createVirtualGroup("v1.t1", v1, n1); //$NON-NLS-1$
+ List vte1 = FakeMetadataFactory.createElements(vt1, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ QueryNode n2 = new QueryNode("v1.t2", "SELECT convert(a, integer) as c, b FROM p1.t"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vt2 = FakeMetadataFactory.createVirtualGroup("v1.t2", v1, n2); //$NON-NLS-1$
+ List vte2 = FakeMetadataFactory.createElements(vt2, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ QueryNode n3 = new QueryNode("v1.u1", "SELECT c, b FROM v1.t1 UNION ALL SELECT c, b FROM v1.t1"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject vu1 = FakeMetadataFactory.createVirtualGroup("v1.u1", v1, n3); //$NON-NLS-1$
+ List vtu1 = FakeMetadataFactory.createElements(vu1, new String[] {"c", "b" }, new String[] { "string", "string" }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(p1);
+ store.addObject(t1);
+ store.addObjects(e1);
+ store.addObject(v1);
+ store.addObject(vt1);
+ store.addObjects(vte1);
+ store.addObject(vt2);
+ store.addObjects(vte2);
+ store.addObject(vu1);
+ store.addObjects(vtu1);
+ return new FakeMetadataFacade(store);
+ }
+
+ @Test public void testProjectionErrorOverUnionWithConvert() {
+ // Create query
+ FakeMetadataFacade metadata = createProjectErrorMetadata();
+ String sql = "SELECT COUNT(*) FROM v1.u1"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("p1", caps); //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(2) }),
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT g_0.a FROM p1.t AS g_0", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1) })});
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testUpdatesInLoop() {
+ String sql = "update vm1.g39 set e2=3"; //$NON-NLS-1$
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(3) } )});
+ dataManager.addData("UPDATE pm1.g1 SET e2 = 3 WHERE pm1.g1.e2 = 3", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1) } )});
+
+ // Create expected results
+ List[] expected = new List[] { Arrays.asList(new Object[] { new Integer(1)})};
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testRand() {
+ // Create query
+ String sql = "SELECT RAND(E2) FROM pm1.g1 where pm1.g1.e2=3"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] {new Double(0.731057369148862)}),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /*
+ * Prior to case 3994 testInsertTempTableCreation1 worked, but testInsertTempTableCreation did not.
+ * Now they should both pass
+ *
+ */
+ @Test public void testInsertTempTableCreation() {
+ FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
+ QueryNode n1 = new QueryNode("v1.vp", "CREATE VIRTUAL PROCEDURE BEGIN insert into #temp (var1) values (1); select #temp.var1 from #temp; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject rs = FakeMetadataFactory.createResultSet("rs", v1, new String[] { "var1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject paramRS = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs); //$NON-NLS-1$
+ FakeMetadataObject vp = FakeMetadataFactory.createVirtualProcedure("v1.vp", v1, Arrays.asList(new Object[] {paramRS}), n1); //$NON-NLS-1$
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(v1);
+ store.addObject(vp);
+
+ ProcessorPlan plan = helpGetPlan("exec v1.vp()", new FakeMetadataFacade(store)); //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) })
+ };
+ helpProcess(plan, new FakeDataManager(), expected);
+ }
+
+ @Test public void testInsertTempTableCreation1() {
+ FakeMetadataObject v1 = FakeMetadataFactory.createVirtualModel("v1"); //$NON-NLS-1$
+ QueryNode n1 = new QueryNode("v1.vp", "CREATE VIRTUAL PROCEDURE BEGIN insert into #temp (var1) values (1); select 2 as var1 into #temp; select #temp.var1 from #temp; END"); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject rs = FakeMetadataFactory.createResultSet("rs", v1, new String[] { "var1" }, new String[] { DataTypeManager.DefaultDataTypes.INTEGER}); //$NON-NLS-1$ //$NON-NLS-2$
+ FakeMetadataObject paramRS = FakeMetadataFactory.createParameter("ret", 1, ParameterInfo.RESULT_SET, DataTypeManager.DefaultDataTypes.OBJECT, rs); //$NON-NLS-1$
+ FakeMetadataObject vp = FakeMetadataFactory.createVirtualProcedure("v1.vp", v1, Arrays.asList(new Object[] {paramRS}), n1); //$NON-NLS-1$
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(v1);
+ store.addObject(vp);
+
+ ProcessorPlan plan = helpGetPlan("exec v1.vp()", new FakeMetadataFacade(store)); //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(2) })
+ };
+ helpProcess(plan, new FakeDataManager(), expected);
+ }
+
+ @Test public void testCase4531() {
+ String sql = "select intkey, intnum from (select intnum as intkey, 1 as intnum from bqt1.smalla union all select intkey, intnum from bqt1.smalla union all select intkey, intnum from bqt2.smalla) x"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_UNION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, FakeMetadataFactory.exampleBQTCached(), capFinder);
+
+ // Run query
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT g_0.intkey, g_0.intnum FROM bqt2.smalla AS g_0", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) })});
+ dataManager.addData("SELECT g_1.intnum AS c_0, 1 AS c_1 FROM bqt1.smalla AS g_1 UNION ALL SELECT g_0.IntKey AS c_0, g_0.IntNum AS c_1 FROM bqt1.smalla AS g_0", //$NON-NLS-1$
+ new List[] { Arrays.asList(new Object[] { new Integer(1), new Integer(1) }),
+ Arrays.asList(new Object[] { new Integer(1), new Integer(1) })});
+ helpProcess(plan, dataManager, expected);
+ }
+
+ private void sampleDataBQT2a(FakeDataManager dataMgr) throws Exception {
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ String[] groups = new String[] {"bqt1.smalla", "bqt2.smalla", "bqt3.smalla" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ for(int groupIndex=0; groupIndex<groups.length; groupIndex++) {
+ String groupName = groups[groupIndex];
+
+ List[] tuples = new List[3];
+ for(int row=0; row<tuples.length; row++) {
+ tuples[row] = new ArrayList(17);
+ tuples[row].add(new Integer(row)); //IntKey
+ tuples[row].add(String.valueOf(row)); //StringKey
+ tuples[row].add(new Integer(row)); //IntNum
+ tuples[row].add(String.valueOf(row)); //StringNum
+ for(int col=0; col<10; col++) { //FloatNum, LongNum, DoubleNum, ByteNum, DateValue, TimeValue, TimestampValue, BooleanValue, CharValue, ShortValue
+ tuples[row].add(null);
+ }
+ tuples[row].add(new BigInteger(String.valueOf(row))); //BigIntegerValue
+ tuples[row].add(new BigDecimal(row)); //BigDecimalValue
+ tuples[row].add(null); //ObjectValue
+ }
+ dataMgr.registerTuples(metadata, groupName, tuples);
+ }
+ }
+
+ @Test public void testDefect15355() throws Exception {
+
+ String sql = "SELECT e1, e1 FROM pm1.g1 " //$NON-NLS-1$
+ +"UNION ALL " //$NON-NLS-1$
+ +"SELECT e1, (SELECT e1 FROM pm2.g1 WHERE pm2.g1.e2 = pm1.g2.e2) FROM pm1.g2"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", "a" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "c", "c" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "a", "e" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "b", null }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d", null }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testDefect15355b() throws Exception {
+
+ String sql = "SELECT StringKey, BigIntegerValue FROM BQT1.SmallA " //$NON-NLS-1$
+ +"UNION ALL " //$NON-NLS-1$
+ +"SELECT StringKey, (SELECT BigIntegerValue FROM BQT3.SmallA WHERE BQT3.SmallA.BigIntegerValue = BQT2.SmallA.StringNum) FROM BQT2.SmallA"; //$NON-NLS-1$
+
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "1", new BigInteger("1") }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "2", new BigInteger("2") }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "1", new BigInteger("1") }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "2", new BigInteger("2") }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355c() throws Exception {
+
+ String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355d() throws Exception {
+
+ String sql = "SELECT StringKey, BigIntegerValue FROM VQT.Defect15355a WHERE StringKey = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "0", new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355e() throws Exception {
+
+ String sql = "SELECT BigIntegerValue, StringKey FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0"), "0" }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355f() throws Exception {
+
+ String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355f2() throws Exception {
+
+ String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE StringKey LIKE '%0' AND StringKey LIKE '0%'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355g() throws Exception {
+
+ String sql = "SELECT BigIntegerValue AS a, BigIntegerValue AS b FROM VQT.Defect15355 WHERE StringKey = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0"), new BigInteger("0") }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355h() throws Exception {
+
+ String sql = "SELECT BigIntegerValue FROM VQT.Defect15355 WHERE BigIntegerValue = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testDefect15355i() throws Exception {
+
+ String sql = "SELECT BigIntegerValue FROM VQT.Defect15355b WHERE BigIntegerValue = '0'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2a(dataManager);
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
+ capFinder.addCapabilities("BQT3", caps); //$NON-NLS-1$
+
+ QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ /**
+ * The inner most A.e1 was mistakenly getting transformed into pm1.g3.e1
+ */
+ @Test public void testInnerCorrelatedReference() throws Exception {
+
+ String sql = "SELECT DISTINCT A.e1 FROM pm1.g3 AS A WHERE (A.e1 IN (SELECT A.e1 FROM pm1.g3))"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT DISTINCT g_0.e1 FROM pm1.g3 AS g_0 WHERE g_0.e1 IN (SELECT g_0.e1 FROM pm1.g3 AS g_1)", expected); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ // Plan query
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ Command command = helpParse(sql);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+
+ }
+
+ @Test public void testCase5413() throws Exception {
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ // Plan query
+ String sql = "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) = e1";//$NON-NLS-1$
+ QueryMetadataInterface metadata = FakeMetadataFactory.example1Cached();
+ Command command = TestProcessor.helpParse(sql);
+ CommandContext context = createCommandContext();
+ context.setMetadata(metadata);
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder, context);
+
+ // Run query
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+ Map valueMap = new HashMap();
+ valueMap.put(1, "b"); //$NON-NLS-1$ //$NON-NLS-2$
+ dataManager.defineCodeTable("pm1.g1", "e2", "e1", valueMap); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ dataManager.setThrowBlocked(true);
+
+ helpProcess(plan, context, dataManager, expected);
+ }
+
+ @Test public void testRaiseNullWithSelectInto() {
+ String sql = "select pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 into pm1.g2 from pm1.g1 where (1=0)"; //$NON-NLS-1$
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 1, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0)}),
+ };
+
+ helpProcess(plan, new FakeDataManager(), expected);
+
+ }
+
+ /*
+ * Test for Case6219
+ */
+ @Test public void testCase6219() {
+ String sql = "SELECT e1 FROM pm1.g1, (SELECT 'ACT' AS StateCode,'A' AS StateAbbrv UNION ALL SELECT 'NSW' AS StateCode, 'N' AS StateAbbrv) AS StateNames_Abbrvs WHERE (pm1.g1.e1 = StateCode) AND ((StateNames_Abbrvs.StateAbbrv || pm1.g1.e1) = 'VVIC')"; //$NON-NLS-1$
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 0, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 3, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+
+ List[] expected = new List[] {
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+
+ }
+
+ @Test public void testSortWithLimit() {
+ String sql = "select e1 from (select pm1.g1.e1, pm1.g1.e2 from pm1.g1 order by pm1.g1.e1, pm1.g1.e2 limit 1) x"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { null}),
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testSortWithLimit1() {
+ String sql = "select c from (select pm1.g1.e1 a, pm1.g1.e2 b, pm1.g1.e3 c from pm1.g1 order by b limit 1) x"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata);
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.FALSE}),
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ //note that the e1 column is not used in the source query
+ assertEquals("SELECT pm1.g1.e3, pm1.g1.e2 FROM pm1.g1", (String)manager.getQueries().iterator().next()); //$NON-NLS-1$
+ }
+
+ @Test public void testSortWithLimit2() {
+ String sql = "select a from (select max(e2) a from pm1.g1 group by e2 order by a limit 1) x where a = 0"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ /**
+ * A more direct test of 1, where the nested order by is unrelated
+ */
+ @Test public void testSortWithLimit3() {
+ String sql = "select c from (select pm1.g1.e3 c from pm1.g1 order by pm1.g1.e2 limit 1) x"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testSortWithLimit4() {
+ String sql = "select c from (select pm1.g1.e1 a, pm1.g1.e2 b, pm1.g1.e3 c from pm1.g1 order by b limit 1) x"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, false);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, new DefaultCapabilitiesFinder(caps));
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { Boolean.FALSE }),
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ assertEquals("SELECT g_0.e3 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_1", manager.getQueries().iterator().next()); //$NON-NLS-1$
+ }
+
+ @Test public void testCountWithHaving() {
+ String sql = "select e1, count(*) from pm1.g1 group by e1 having count(*) > 1"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" , new Integer(3)}), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testLimitZero() {
+ String sql = "select e1 from pm1.g1 limit 0"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ TestOptimizer.checkNodeTypes(plan, TestRuleRaiseNull.FULLY_NULL);
+
+ List[] expected = new List[] {
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testLimitZero1() {
+ String sql = "select distinct vm1.g1.e1, y.e1 from vm1.g1 left outer join (select 1 x, e1 from vm1.g2 limit 0) y on vm1.g1.e1 = y.e1 where vm1.g1.e1 = 'a'"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 0, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", null }), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testLimitZero2() {
+ String sql = "select vm1.g1.e1 from vm1.g1 union select e1 from pm1.g2 limit 0"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testLimitZero3() {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ String sql = "select e1 from pm1.g2 limit 0"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, capFinder);
+
+ List[] expected = new List[] {
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testUnionWithTypeConversion() {
+ String sql = "select pm1.g1.e1, pm1.g1.e2 from pm1.g1 where e1 = 'b' union select e2, e1 from pm1.g2 where e1 = 'b' order by e1, e2"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "2", "b" }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { "b", "2" }), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ /**
+ * Tests non-deterministic evaluation in the select clause.
+ *
+ * The evaluation of the rand function is delayed until processing time (which actually has predictable
+ * values since the test initializes the command context with the same seed)
+ *
+ * If this function were deterministic, it would be evaluated during rewrite to a single value.
+ */
+ @Test public void testNonDeterministicEvaluation() throws Exception {
+ String sql = "select e1, convert(rand()*1000, integer) as x from pm1.g1 where e1 = 'a'"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(240) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(637) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(550) }), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ /**
+ * here the rand function is deterministic and should yield a single value
+ */
+ @Test public void testDeterministicEvaluation() throws Exception {
+ String sql = "select e1, convert(rand(0)*1000, integer) as x from pm1.g1 where e1 = 'a'"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", new Integer(730) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(730) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", new Integer(730) }), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testEmptyAggregate() throws Exception {
+ String sql = "select count(e1) from pm1.g1 where 1 = 0"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) })
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testNullAggregate() throws Exception {
+ String sql = "select count(*), count(e1), sum(convert(e1, integer)) from pm1.g1 where e1 is null"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), new Integer(0), null })
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ /**
+ * here the presence of a group by causes no rows to be returned
+ */
+ @Test public void testNullAggregate1() throws Exception {
+ String sql = "select e1 from pm1.g1 where 1 = 0 group by e1"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testReferenceReplacementWithExpression() throws Exception {
+ String sql = "select e1, e2 from (select e1, convert(e2, string) e2 from pm1.g1) x where exists (select e3 from pm1.g2 where x.e2 = e1)"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {};
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ /**
+ * Here a merge join will be used since there is at least one equi join predicate.
+ * TODO: this can be optimized further
+ */
+ @Test public void testCase6193_1() throws Exception {
+ // Create query
+ String sql = "select a.INTKEY, b.intkey from bqt1.smalla a LEFT OUTER JOIN bqt2.SMALLA b on a.intkey=b.intkey and a.intkey=5 where a.intkey <10 "; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ capFinder.addCapabilities("BQT2", caps);
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), null }),
+ Arrays.asList(new Object[] { new Integer(1), null }),
+ Arrays.asList(new Object[] { new Integer(2), null }),
+ Arrays.asList(new Object[] { new Integer(3), null }),
+ Arrays.asList(new Object[] { new Integer(4), null }),
+ Arrays.asList(new Object[] { new Integer(5), new Integer(5) }),
+ Arrays.asList(new Object[] { new Integer(6), null }),
+ Arrays.asList(new Object[] { new Integer(7), null }),
+ Arrays.asList(new Object[] { new Integer(8), null }),
+ Arrays.asList(new Object[] { new Integer(9), null })
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataBQT2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
+ new String[] {"SELECT b.intkey FROM bqt2.SMALLA AS b", "SELECT a.intkey FROM bqt1.smalla AS a"}, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 1, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Here a merge join will be used since there is at least one equi join predicate.
+ */
+ @Test public void testCase6193_2() throws Exception {
+ // Create query
+ String sql = "select a.e2, b.e2 from pm1.g1 a LEFT OUTER JOIN pm1.g2 b on a.e4=b.e4 and (a.e2+b.e2)=4 order by a.e2"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0), null }),
+ Arrays.asList(new Object[] { new Integer(0), null }),
+ Arrays.asList(new Object[] { new Integer(1), null }),
+ Arrays.asList(new Object[] { new Integer(1), null }),
+ Arrays.asList(new Object[] { new Integer(2), new Integer(2) }),
+ Arrays.asList(new Object[] { new Integer(3), null }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT a.e4, a.e2 FROM pm1.g1 AS a", "SELECT b.e4, b.e2 FROM pm1.g2 AS b"}, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 1, // Sort
+ 0 // UnionAll
+ });
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Here a merge join will be used since there is at least one equi join predicate.
+ * The inner merge join is also a dependent join
+ */
+ @Test public void testCase6193_3() throws Exception {
+ // Create query
+ String sql = "select a.x, b.y from (select 4 x union select 1) a LEFT OUTER JOIN (select (a.e2 + b.e2) y from pm1.g1 a LEFT OUTER JOIN pm1.g2 b on a.e4=b.e4) b on (a.x = b.y)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(1), null }),
+ Arrays.asList(new Object[] { new Integer(4), new Integer(4) }),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
+ new String[] {"SELECT a.e4, a.e2 FROM pm1.g1 AS a", "SELECT b.e4, b.e2 FROM pm1.g2 AS b"}, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 4, // Project
+ 0, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+
+ TestOptimizer.checkDependentJoinCount(plan, 1);
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * A control test to ensure that y will still exist for sorting
+ */
+ @Test public void testOrderByWithDuplicateExpressions() throws Exception {
+ String sql = "select e1 as x, e1 as y from pm1.g1 order by y ASC"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata);
+
+ List[] expected = new List[] {
+ Arrays.asList(null, null),
+ Arrays.asList("a", "a"), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList("a", "a"), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList("a", "a"), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList("b", "b"), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList("c", "c"), //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ /**
+ * This is a control test. It should work regardless of whether the reference is aliased
+ * since accessnodes are now fully positional
+ */
+ @Test public void testPushdownNonAliasedSelectLiteral() throws Exception {
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ Command command = helpParse("select ?, e1 from pm1.g1"); //$NON-NLS-1$
+ ProcessorPlan plan = helpGetPlan(command, metadata, capFinder);
+
+ Reference ref = ReferenceCollectorVisitor.getReferences(command).iterator().next();
+ VariableContext vc = new VariableContext();
+ vc.setGlobalValue(ref.getContextSymbol(), "a"); //$NON-NLS-1$
+ CommandContext context = createCommandContext();
+ context.setVariableContext(vc);
+
+ List[] expected = new List[] {
+ Arrays.asList("a", "b"), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList("a", "c") //$NON-NLS-1$ //$NON-NLS-2$
+ };
+
+ HardcodedDataManager manager = new HardcodedDataManager();
+ manager.addData("SELECT 'a', pm1.g1.e1 FROM pm1.g1", expected); //$NON-NLS-1$
+
+ helpProcess(plan, context, manager, expected);
+ }
+
+ @Test public void testCase6486() {
+ // Create query
+ String sql = "select pm2.g1.e1 from pm1.g2, pm2.g1 where pm1.g2.e1=pm2.g1.e1 group by pm2.g1.e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "d"}) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonPushedOffset() throws Exception {
+ String sql = "SELECT e1 FROM pm1.g1 LIMIT 1, 5"; //$NON-NLS-1$
+
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = new BasicSourceCapabilities();
+ caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
+ capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b"}), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c"}), //$NON-NLS-1$
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData2(dataManager);
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, new String[] {"SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (5 + 1)"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testNonCorrelatedSubQueryExecution() throws Exception {
+ String sql = "SELECT e1 FROM pm1.g1 WHERE e2 IN (SELECT e2 FROM pm2.g1)"; //$NON-NLS-1$
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.setBlockOnce(true);
+ dataManager.addData("SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", new List[] { //$NON-NLS-1$
+ Arrays.asList(Integer.valueOf(1), "a"), //$NON-NLS-1$
+ Arrays.asList(Integer.valueOf(2), "b") //$NON-NLS-1$
+ });
+ dataManager.addData("SELECT pm2.g1.e2 FROM pm2.g1", new List[] { //$NON-NLS-1$
+ Arrays.asList(Integer.valueOf(2))
+ });
+
+ ProcessorPlan plan = helpGetPlan(sql, FakeMetadataFactory.example1Cached());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "b" }), //$NON-NLS-1$
+ };
+
+ doProcess(plan, dataManager, expected, createCommandContext());
+
+ //we expect 2 queries, 1 for the outer and 1 for the subquery
+ assertEquals(2, dataManager.getCommandHistory().size());
+ }
+
+ @Test public void testOrderByOutsideOfSelect() {
+ // Create query
+ String sql = "SELECT e1 FROM (select e1, e2 || e3 as e2 from pm1.g2) x order by e2"; //$NON-NLS-1$
+
+ //a, a, null, c, b, a
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList("a"),
+ Arrays.asList("a"),
+ Arrays.asList(new String[] {null}),
+ Arrays.asList("c"),
+ Arrays.asList("b"),
+ Arrays.asList("a"),
+ };
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testOrderByUnrelatedExpression() {
+ String sql = "SELECT e1, e2 + 1 from pm1.g2 order by e3 || e2 limit 1"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("a", 1),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached(), TestOptimizer.getGenericFinder());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Test a query that uses ambiguous alias names in the top level query and
+ * its sub-query and uses columns belonging to the alias as a parameter to a
+ * function.
+ * <p>
+ * For example, <code>SELECT CONVERT(A.e2, biginteger) AS e2 FROM (SELECT
+ * CONVERT(e2, long) AS e2 FROM pm1.g1 AS A) AS A</code>
+ * <p>
+ * The test is to ensure that A.e2 from the top level is not confused with
+ * e2 in the second level.
+ * <p>
+ * Related Defects: JBEDSP-1137
+ */
+ @Test public void testAliasReuseInFunctionInSubQuery() throws Exception {
+ // Create query
+ String sql = "SELECT CONVERT(A.e2, biginteger) AS e2 FROM (" + //$NON-NLS-1$
+ " SELECT CONVERT(e2, long) AS e2 FROM pm1.g1 AS A WHERE e1 = 'a'" + //$NON-NLS-1$
+ ") AS A"; //$NON-NLS-1$
+
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), metadata, TestOptimizer.getGenericFinder());
+
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new BigInteger("3") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new BigInteger("0") }), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ sampleData1(manager);
+ helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testOrderByDescAll() {
+ String sql = "SELECT distinct e1 from pm1.g2 order by e1 desc limit 1"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("c"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testImplicitAggregateWithInlineView() {
+ String sql = "SELECT * FROM (SELECT b.count, enterprise_id FROM (SELECT COUNT(*), 2 AS enterprise_id FROM (SELECT 'A Name' AS Name, 1 AS enterprise_id) c ) b ) a WHERE enterprise_id = 1"; //$NON-NLS-1$
+
+ List[] expected = new List[] {};
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ private static final boolean DEBUG = false;
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestQueryProcessor.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestQueryProcessor.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestQueryProcessor.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestQueryProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,142 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidException;
+import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.CommandContext;
+
+import junit.framework.TestCase;
+
+
+/**
+ */
+public class TestQueryProcessor extends TestCase {
+
+ /**
+ * Constructor for TestQueryProcessor.
+ * @param name
+ */
+ public TestQueryProcessor(String name) {
+ super(name);
+ }
+
+ public void helpTestProcessor(FakeProcessorPlan plan, long timeslice, List[] expectedResults) throws TeiidException {
+ BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
+ FakeDataManager dataManager = new FakeDataManager();
+
+ CommandContext context = new CommandContext("pid", "group", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
+ QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ BatchCollector collector = processor.createBatchCollector();
+ TupleBuffer tsID = null;
+ while(true) {
+ try {
+ tsID = collector.collectTuples();
+ break;
+ } catch(BlockedException e) {
+ }
+ }
+
+ // Compare # of rows in actual and expected
+ assertEquals("Did not get expected # of rows", expectedResults.length, tsID.getRowCount()); //$NON-NLS-1$
+
+ // Compare actual with expected results
+ TupleSource actual = tsID.createIndexedTupleSource();
+ if(expectedResults.length > 0) {
+ for(int i=0; i<expectedResults.length; i++) {
+ List actRecord = actual.nextTuple();
+ List expRecord = expectedResults[i];
+ assertEquals("Did not match row at row index " + i, expRecord, actRecord); //$NON-NLS-1$
+ }
+ }
+ tsID.remove();
+ }
+
+ public void testNoResults() throws Exception {
+ List elements = new ArrayList();
+ elements.add(new ElementSymbol("a")); //$NON-NLS-1$
+ FakeProcessorPlan plan = new FakeProcessorPlan(elements, null);
+ helpTestProcessor(plan, 1000, new List[0]);
+ }
+
+ public void testBlockNoResults() throws Exception {
+ List elements = new ArrayList();
+ elements.add(new ElementSymbol("a")); //$NON-NLS-1$
+
+ List batches = new ArrayList();
+ batches.add(BlockedException.INSTANCE);
+ TupleBatch batch = new TupleBatch(1, new List[0]);
+ batch.setTerminationFlag(true);
+ batches.add(batch);
+
+ FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
+ helpTestProcessor(plan, 1000, new List[0]);
+ }
+
+ public void testProcessWithOccasionalBlocks() throws Exception {
+ List elements = new ArrayList();
+ elements.add(new ElementSymbol("a")); //$NON-NLS-1$
+
+ HashSet blocked = new HashSet(Arrays.asList(new Integer[] { new Integer(0), new Integer(2), new Integer(7) }));
+ int numBatches = 10;
+ int batchRow = 1;
+ int rowsPerBatch = 50;
+ List[] expectedResults = new List[rowsPerBatch*(numBatches-blocked.size())];
+ List batches = new ArrayList();
+ for(int b=0; b<numBatches; b++) {
+ if(blocked.contains(new Integer(b))) {
+ batches.add(BlockedException.INSTANCE);
+ } else {
+ List[] rows = new List[rowsPerBatch];
+ for(int i=0; i<rowsPerBatch; i++) {
+ rows[i] = new ArrayList();
+ rows[i].add(new Integer(batchRow));
+ expectedResults[batchRow-1] = rows[i];
+ batchRow++;
+ }
+
+ TupleBatch batch = new TupleBatch(batchRow-rows.length, rows);
+ if(b == numBatches-1) {
+ batch.setTerminationFlag(true);
+ }
+ batches.add(batch);
+ }
+ }
+
+ FakeProcessorPlan plan = new FakeProcessorPlan(elements, batches);
+ helpTestProcessor(plan, 1000, expectedResults);
+ }
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestSQLXMLProcessing.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,175 @@
+/*
+ * 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.teiid.query.processor.TestProcessor.*;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+@SuppressWarnings("nls")
+public class TestSQLXMLProcessing {
+
+ @Test public void testXmlElementTextContent() throws Exception {
+ String sql = "SELECT xmlelement(foo, '<bar>', convert('<bar1/>', xml))"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<foo><bar><bar1/></foo>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ /**
+ * Repeat of the above test, but with a document declaration. Because of the way we do event filtering, we end
+ * up with a slightly different, but equivalent answer.
+ */
+ @Test public void testXmlElementTextContent1() throws Exception {
+ String sql = "SELECT xmlelement(foo, '<bar>', convert('<?xml version=\"1.0\" encoding=\"UTF-8\"?><bar1/>', xml))"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<foo><bar><bar1></bar1></foo>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXmlElement() {
+ String sql = "SELECT xmlelement(e1, e2) from pm1.g1 order by e1, e2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<e1>1</e1>"),
+ Arrays.asList("<e1>0</e1>"),
+ Arrays.asList("<e1>0</e1>"),
+ Arrays.asList("<e1>3</e1>"),
+ Arrays.asList("<e1>2</e1>"),
+ Arrays.asList("<e1>1</e1>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXmlElementWithConcat() {
+ String sql = "SELECT xmlelement(e1, e2, xmlconcat(xmlelement(x), xmlelement(y, e3))) from pm1.g1 order by e1, e2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<e1>1<x></x><y>false</y></e1>"),
+ Arrays.asList("<e1>0<x></x><y>false</y></e1>"),
+ Arrays.asList("<e1>0<x></x><y>false</y></e1>"),
+ Arrays.asList("<e1>3<x></x><y>true</y></e1>"),
+ Arrays.asList("<e1>2<x></x><y>false</y></e1>"),
+ Arrays.asList("<e1>1<x></x><y>true</y></e1>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXmlElementWithForest() {
+ String sql = "SELECT xmlelement(x, xmlforest(e1, e2, '1' as val)) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<x><e2>1</e2><val>1</val></x>"), //note e1 is not present, because it's null
+ Arrays.asList("<x><e1>a</e1><e2>0</e2><val>1</val></x>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXmlElementWithAttributes() {
+ String sql = "SELECT xmlelement(x, xmlattributes(e1, e2, '1' as val)) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<x e2=\"1\" val=\"1\"></x>"), //note e1 is not present, because it's null
+ Arrays.asList("<x e1=\"a\" e2=\"0\" val=\"1\"></x>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXmlElementWithPi() {
+ String sql = "SELECT xmlelement(x, xmlpi(name e1, ' 1'))"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<x><?e1 1?></x>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+ @Test public void testXmlElementWithNamespaces() {
+ String sql = "SELECT xmlelement(x, xmlnamespaces(no default, 'http://foo' as x, 'http://foo1' as y), xmlattributes(e1), e2) from pm1.g1 order by e1, e2 limit 2"; //$NON-NLS-1$
+
+ List[] expected = new List[] {
+ Arrays.asList("<x xmlns=\"\" xmlns:x=\"http://foo\" xmlns:y=\"http://foo1\">1</x>"), //note e1 is not present, because it's null
+ Arrays.asList("<x xmlns=\"\" xmlns:x=\"http://foo\" xmlns:y=\"http://foo1\" e1=\"a\">0</x>"),
+ };
+
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleData1(dataManager);
+
+ ProcessorPlan plan = helpGetPlan(helpParse(sql), FakeMetadataFactory.example1Cached());
+
+ helpProcess(plan, dataManager, expected);
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestSQLXMLProcessing.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestSecurityFunctions.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSecurityFunctions.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,95 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.eval.SecurityFunctionEvaluator;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
+
+import junit.framework.TestCase;
+
+
+public class TestSecurityFunctions extends TestCase {
+
+ /**
+ * hasRole should be true without a service
+ */
+ public void testHasRoleWithoutService() throws Exception {
+
+ String sql = "select pm1.g1.e2 from pm1.g1 where true = hasRole('data', pm1.g1.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Integer(0) }),
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List[] { //$NON-NLS-1$
+ Arrays.asList(new Object[] { "fooRole", new Integer(0) }), //$NON-NLS-1$
+ });
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached());
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
+
+ public void testHasRoleWithService() throws Exception {
+
+ String sql = "select pm1.g1.e2 from pm1.g1 where true = hasRole('data', pm1.g1.e1)"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] { };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+
+ dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", new List[] { //$NON-NLS-1$
+ Arrays.asList(new Object[] { "fooRole", new Integer(0) }), //$NON-NLS-1$
+ });
+
+ CommandContext context = new CommandContext();
+ context.setSecurityFunctionEvaluator(new SecurityFunctionEvaluator() {
+ public boolean hasRole(String roleType,
+ String roleName) throws TeiidComponentException {
+ return false;
+ }});
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, FakeMetadataFactory.example1Cached(), new DefaultCapabilitiesFinder(), context);
+
+ // Run query
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestSetProcessing.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestSetProcessing.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,87 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.junit.Test;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestSetProcessing {
+
+ @Test public void testExcept() throws Exception {
+ String sql = "select e1, e2 from pm1.g2 except select e1, 1 from pm1.g2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] {"SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] {"a", 0}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {"a", 3}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {"b", 2}), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ TestProcessor.sampleData1(manager);
+ TestProcessor.helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testIntersect() throws Exception {
+ String sql = "select e1, e2 from pm1.g2 intersect select e1, 1 from pm1.g2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(), new String[] {"SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] {null, 1}),
+ Arrays.asList(new Object[] {"c", 1}), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ TestProcessor.sampleData1(manager);
+ TestProcessor.helpProcess(plan, manager, expected);
+ }
+
+ @Test public void testIntersectExcept() {
+ String sql = "select e1, e2 from pm1.g2 except select e1, 1 from pm1.g2 intersect select 'a', e2 from pm1.g2"; //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1, 1 FROM pm1.g2 AS g_0", "SELECT g_0.e1, g_0.e2 FROM pm1.g2 AS g_0", "SELECT 'a', g_0.e2 FROM pm1.g2 AS g_0"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ List<?>[] expected = new List[] {
+ Arrays.asList(new Object[] {null, 1}),
+ Arrays.asList(new Object[] {"a", 0}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {"a", 3}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {"b", 2}), //$NON-NLS-1$
+ Arrays.asList(new Object[] {"c", 1}), //$NON-NLS-1$
+ };
+
+ FakeDataManager manager = new FakeDataManager();
+ TestProcessor.sampleData1(manager);
+ TestProcessor.helpProcess(plan, manager, expected);
+ }
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestTempTables.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,94 @@
+/*
+ * 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 java.util.Arrays;
+import java.util.List;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.processor.TempTableDataManager;
+import org.teiid.query.tempdata.TempTableStoreImpl;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
+
+public class TestTempTables {
+
+ private TempMetadataAdapter metadata;
+ private TempTableDataManager dataManager;
+
+ private void execute(String sql, List[] expectedResults) throws Exception {
+ TestProcessor.doProcess(TestProcessor.helpGetPlan(sql, metadata), dataManager, expectedResults, TestProcessor.createCommandContext());
+ }
+
+ @Before public void setUp() throws TeiidComponentException {
+ TempTableStoreImpl tempStore = new TempTableStoreImpl(BufferManagerFactory.getStandaloneBufferManager(), "1", null); //$NON-NLS-1$
+ metadata = new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), tempStore.getMetadataStore());
+ FakeDataManager fdm = new FakeDataManager();
+ TestProcessor.sampleData1(fdm);
+ dataManager = new TempTableDataManager(fdm, tempStore);
+ }
+
+ @Test public void testInsertWithQueryExpression() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) select e2, e1 from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ }
+
+ @Test public void testOutofOrderInsert() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select e1, e2 from x", new List[] {Arrays.asList("one", 1)}); //$NON-NLS-1$
+ }
+
+ @Test public void testUpdate() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("insert into x (e2, e1) values (1, 'one')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("update x set e1 = e2 where e2 > 1", new List[] {Arrays.asList(2)}); //$NON-NLS-1$
+ execute("select e1 from x where e2 > 0 order by e1", new List[] { //$NON-NLS-1$
+ Arrays.asList((String)null),
+ Arrays.asList("2"), //$NON-NLS-1$
+ Arrays.asList("3"), //$NON-NLS-1$
+ Arrays.asList("c"), //$NON-NLS-1$
+ Arrays.asList("one")}); //$NON-NLS-1$
+ }
+
+ @Test public void testDelete() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("delete from x where ascii(e1) > e2", new List[] {Arrays.asList(5)}); //$NON-NLS-1$
+ execute("select e1 from x order by e1", new List[] {Arrays.asList((String)null)}); //$NON-NLS-1$
+ }
+
+ @Test public void testDelete1() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("select e1, e2 into x from pm1.g1", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("delete from x", new List[] {Arrays.asList(6)}); //$NON-NLS-1$
+ execute("select e1 from x order by e1", new List[] {}); //$NON-NLS-1$
+ }
+
+}
Property changes on: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/TestVirtualDepJoin.java)
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java (rev 0)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestVirtualDepJoin.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -0,0 +1,774 @@
+/*
+ * 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 java.math.BigDecimal;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.common.buffer.impl.MemoryStorageManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.TimestampUtil;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.validator.TestValidator;
+
+
+public class TestVirtualDepJoin {
+
+ /**
+ * @param usAcctsElem
+ * @param is
+ * @param is2
+ * @param object
+ * @param object2
+ * @since 4.3
+ */
+ private static void setStats(List elementObjects,
+ int[] ndvs,
+ int[] nnvs,
+ String[] mins,
+ String[] maxs) {
+
+ Iterator iter = elementObjects.iterator();
+ for(int i=0; iter.hasNext(); i++) {
+ FakeMetadataObject obj = (FakeMetadataObject) iter.next();
+ if(ndvs != null) {
+ obj.putProperty(FakeMetadataObject.Props.DISTINCT_VALUES, new Integer(ndvs[i]));
+ }
+ if(nnvs != null) {
+ obj.putProperty(FakeMetadataObject.Props.NULL_VALUES, new Integer(nnvs[i]));
+ }
+ if(mins != null) {
+ obj.putProperty(FakeMetadataObject.Props.MIN_VALUE, mins[i]);
+ }
+ if(maxs != null) {
+ obj.putProperty(FakeMetadataObject.Props.MAX_VALUE, maxs[i]);
+ }
+
+ }
+ }
+
+ public static FakeMetadataFacade exampleVirtualDepJoin() {
+ FakeMetadataObject us = FakeMetadataFactory.createPhysicalModel("US"); //$NON-NLS-1$
+ us.putProperty(FakeMetadataObject.Props.MAX_SET_SIZE, new Integer(0));
+ FakeMetadataObject usAccts = FakeMetadataFactory.createPhysicalGroup("US.Accounts", us); //$NON-NLS-1$
+ usAccts.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1000000));
+ List usAcctsElem = FakeMetadataFactory.createElements(usAccts,
+ new String[] { "customer", "account", "txn", "txnid", "pennies" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.INTEGER });
+ setStats(usAcctsElem,
+ new int[] { 1000, 1250, 4, 1000000, 800000}, // NDV per column
+ new int[] { 0, 0, 0, 0, 0}, // NNV per column
+ new String[] {"0", null, null, null, "-10"}, // min per column - use defaults //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] {"1000", null, null, null, "-5"} // max per column - use defaults //$NON-NLS-1$ //$NON-NLS-2$
+ );
+
+ FakeMetadataObject europe = FakeMetadataFactory.createPhysicalModel("Europe"); //$NON-NLS-1$
+ europe.putProperty(FakeMetadataObject.Props.MAX_SET_SIZE, new Integer(0));
+ FakeMetadataObject euAccts = FakeMetadataFactory.createPhysicalGroup("Europe.CustAccts", europe); //$NON-NLS-1$
+ euAccts.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1000000));
+ List euAcctsElem = FakeMetadataFactory.createElements(euAccts,
+ new String[] { "id", "accid", "type", "amount" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.SHORT, DataTypeManager.DefaultDataTypes.BIG_DECIMAL });
+ setStats(euAcctsElem,
+ new int[] { 10000, 1000000, 4, 1000000, 750000}, // NDV per column
+ new int[] { 0, 0, 0, 0, 0}, // NNV per column
+ null, // min per column - use defaults
+ null // max per column - use defaults
+ );
+
+ FakeMetadataObject cust = FakeMetadataFactory.createPhysicalModel("CustomerMaster"); //$NON-NLS-1$
+ cust.putProperty(FakeMetadataObject.Props.MAX_SET_SIZE, new Integer(0));
+ FakeMetadataObject customers = FakeMetadataFactory.createPhysicalGroup("CustomerMaster.Customers", cust); //$NON-NLS-1$
+ customers.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1000));
+ List customersElem = FakeMetadataFactory.createElements(customers,
+ new String[] { "id", "first", "last", "birthday" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.DATE });
+ setStats(customersElem,
+ new int[] { 1000, 800, 800, 365}, // NDV per column
+ new int[] { 0, 0, 0, 0}, // NNV per column
+ null, // min per column - use defaults
+ null // max per column - use defaults
+ );
+ FakeMetadataObject locations = FakeMetadataFactory.createPhysicalGroup("CustomerMaster.Locations", cust); //$NON-NLS-1$
+ locations.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(1200));
+ List locationsElem = FakeMetadataFactory.createElements(locations,
+ new String[] { "id", "location" }, //$NON-NLS-1$ //$NON-NLS-2$
+ new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.STRING });
+ setStats(locationsElem,
+ new int[] { 1000, 2}, // NDV per column
+ new int[] { 0, 0, 0, 0}, // NNV per column
+ null, // min per column - use defaults
+ null // max per column - use defaults
+ );
+
+ FakeMetadataObject vAccts = FakeMetadataFactory.createVirtualModel("Accounts"); //$NON-NLS-1$
+ QueryNode accountsPlan = new QueryNode("Accounts.Accounts", //$NON-NLS-1$
+ "SELECT customer as customer_id, convert(account, long) as account_id, convert(txnid, long) as transaction_id, case txn when 'DEP' then 1 when 'TFR' then 2 when 'WD' then 3 else -1 end as txn_type, (pennies + convert('0.00', bigdecimal)) / 100 as amount, 'US' as source FROM US.Accounts where txn != 'X'" + //$NON-NLS-1$
+ "UNION ALL " + //$NON-NLS-1$
+ "SELECT id, convert(accid / 10000, long), mod(accid, 10000), convert(type, integer), amount, 'EU' from Europe.CustAccts"); //$NON-NLS-1$
+ FakeMetadataObject accounts = FakeMetadataFactory.createVirtualGroup("Accounts.Accounts", vAccts, accountsPlan); //$NON-NLS-1$
+ List accountsElem = FakeMetadataFactory.createElements(accounts,
+ new String[] { "customer_id", "account_id", "transaction_id", "txn_type", "amount", "source" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.DefaultDataTypes.STRING });
+
+ FakeMetadataObject master = FakeMetadataFactory.createVirtualModel("Master"); //$NON-NLS-1$
+ QueryNode masterPlan = new QueryNode("Master.Transactions", //$NON-NLS-1$
+ "select id as CustomerID, First, Last, a.account_id as AccountID, transaction_id as TransactionID, txn_type AS TxnCode, Amount from CustomerMaster.Customers c, Accounts.Accounts a where c.id=a.customer_id"); //$NON-NLS-1$
+ FakeMetadataObject transactions = FakeMetadataFactory.createVirtualGroup("Master.Transactions", master, masterPlan); //$NON-NLS-1$
+ List transactionsElem = FakeMetadataFactory.createElements(transactions,
+ new String[] { "CustomerID", "First", "Last", "AccountID", "TransactionID", "TxnCode", "Amount" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+ new String[] { DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.LONG, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BIG_DECIMAL });
+
+ FakeMetadataStore store = new FakeMetadataStore();
+ store.addObject(us);
+ store.addObject(usAccts);
+ store.addObjects(usAcctsElem);
+
+ store.addObject(europe);
+ store.addObject(euAccts);
+ store.addObjects(euAcctsElem);
+
+ store.addObject(cust);
+ store.addObject(customers);
+ store.addObjects(customersElem);
+ store.addObject(locations);
+ store.addObjects(locationsElem);
+
+ store.addObject(vAccts);
+ store.addObject(accounts);
+ store.addObjects(accountsElem);
+
+ store.addObject(master);
+ store.addObject(transactions);
+ store.addObjects(transactionsElem);
+
+ return new FakeMetadataFacade(store);
+ }
+
+ @Test public void testVirtualDepJoinNoValues() throws Exception {
+ // Create query
+ String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first=-9999 group by c.id, first, last"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+
+ // Plan query
+ CommandContext context = TestProcessor.createCommandContext();
+
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ finder.addCapabilities("Europe", caps);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
+
+ TestOptimizer.checkDependentJoinCount(plan, 1);
+ // Run query
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+
+ // Second query *will not be run* as no values were passed and dependent side has always false criteria
+ // So, the list should contain only the first query
+ assertEquals(3, dataManager.getQueries().size());
+ }
+
+ public void helpTestVirtualDepJoinSourceSelection(boolean setPushdown) throws Exception {
+ // Create query
+ String sql = "select c.id as CustomerID, First, Last, a.account_id as AccountID, transaction_id as TransactionID, txn_type AS TxnCode, Amount, source from (CustomerMaster.Customers c join CustomerMaster.Locations l on c.id=l.id) join Accounts.Accounts a on c.id=a.customer_id and l.location=a.source where c.first='Miles' option makenotdep c, l"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20"), "EU" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00"), "EU" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00"), "US" }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+
+ // Plan query
+ CommandContext context = TestProcessor.createCommandContext();
+
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, setPushdown);
+ finder.addCapabilities("US", caps); //$NON-NLS-1$
+ finder.addCapabilities("Europe", caps);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
+
+ // Check plan contents
+ int selectCount = !setPushdown ? 2 : 0;
+ int accessCount = setPushdown ? 2 : 4;
+ int depAccessCount = 4 - accessCount;
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ accessCount, // Access
+ depAccessCount, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 3, // Project
+ selectCount, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+
+ // Run query
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+ }
+
+ @Test public void testVirtualDepJoinSourceSelectionPushdown() throws Exception {
+ helpTestVirtualDepJoinSourceSelection(true);
+ }
+
+ @Test public void testVirtualDepJoinSourceSelectionNoPushdown() throws Exception {
+ helpTestVirtualDepJoinSourceSelection(false);
+ }
+
+ @Test public void testVirtualDepJoinPartialPushdown() throws Exception {
+ // Create query
+ String sql = "SELECT * from Master.Transactions where last = 'Davis'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+
+ // Plan query
+ CommandContext context = TestProcessor.createCommandContext();
+
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
+ BasicSourceCapabilities caps2 = TestOptimizer.getTypicalCapabilities();
+ caps2.setCapabilitySupport(Capability.CRITERIA_IN, false);
+ finder.addCapabilities("US", caps1); //$NON-NLS-1$
+ finder.addCapabilities("Europe", caps2);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps1);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 3, // Project
+ 1, // Select
+ 0, // Sort
+ 1 // UnionAll
+ });
+
+ TestOptimizer.checkDependentJoinCount(plan, 1);
+ // Run query
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+ }
+
+ @Test public void testVirtualDepJoinOverAggregates() throws Exception {
+ // Create query
+ String sql = "select first, last, sum(amount) from Europe.CustAccts e join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "Miles", "Davis", new BigDecimal("1007.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+
+ // Plan query
+ CommandContext context = TestProcessor.createCommandContext();
+
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ finder.addCapabilities("Europe", caps);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 3, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ TestOptimizer.checkDependentJoinCount(plan, 1);
+ // Run query
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+
+ List<String> expectedQueries = new ArrayList<String>(6);
+ for (int i = 0; i < 3; i++) {
+ expectedQueries.add("SELECT DISTINCT g_0.id AS c_0, g_0.first AS c_1, g_0.last AS c_2 FROM CustomerMaster.Customers AS g_0 WHERE g_0.first = 'Miles' ORDER BY c_0"); //$NON-NLS-1$
+ expectedQueries.add("SELECT DISTINCT g_0.id AS c_0, g_0.amount AS c_1 FROM Europe.CustAccts AS g_0 WHERE g_0.id = 100 ORDER BY c_0"); //$NON-NLS-1$
+ }
+
+ assertEquals(expectedQueries, dataManager.getQueries());
+ }
+
+ @Test public void testVirtualDepJoinSelects() throws Exception {
+ helpTestVirtualDepJoin(false);
+ }
+
+ @Test public void testVirtualDepJoinPushdown() throws Exception {
+ helpTestVirtualDepJoin(true);
+ }
+
+ @Test public void testVirtualDepMultipleDependentBatches() throws Exception {
+ helpTestMultipleBatches(true);
+ }
+
+ @Test public void testVirtualDepMultipleDependentBatchesNonUnique() throws Exception {
+ helpTestMultipleBatches(false);
+ }
+
+ private void helpTestMultipleBatches(boolean unique) throws Exception,
+ TeiidComponentException,
+ TeiidException,
+ SQLException {
+ // Create query
+ String sql = "SELECT * from Master.Transactions where last = 'Davis' order by CustomerID, TransactionID"; //$NON-NLS-1$
+
+ List expected = new LinkedList();
+
+
+ // Create expected results
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ if (!unique) {
+ expected.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(16000), new Long(207), new Integer(3), new BigDecimal("12.34") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(16000), new Long(299), new Integer(3), new BigDecimal("950.34") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(550), new Long(1004), new Integer(3), new BigDecimal("542.20") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", new Long(550), new Long(1005), new Integer(1), new BigDecimal("99.99") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(620), new Long(1006), new Integer(1), new BigDecimal("10000.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(620), new Long(1007), new Integer(2), new BigDecimal("0.75") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ expected.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", new Long(630), new Long(1008), new Integer(2), new BigDecimal("62.00") })); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+ overrideVirtualDepJoinData(dataManager, metadata, unique);
+
+ // Plan query
+ CommandContext context = TestProcessor.createCommandContext();
+
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
+ finder.addCapabilities("US", caps); //$NON-NLS-1$
+ finder.addCapabilities("Europe", caps);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
+
+ // Run query
+ BufferManager bufferMgr = createCustomBufferMgr(2);
+ QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataManager);
+ processor.setNonBlocking(true);
+ BatchCollector collector = processor.createBatchCollector();
+ TupleBuffer id = collector.collectTuples();
+
+ TestProcessor.examineResults((List[])expected.toArray(new List[expected.size()]), bufferMgr, id);
+ }
+
+ private BufferManager createCustomBufferMgr(int batchSize) throws TeiidComponentException {
+ BufferManagerImpl bufferMgr = new BufferManagerImpl();
+ bufferMgr.setConnectorBatchSize(batchSize);
+ bufferMgr.setProcessorBatchSize(batchSize);
+ bufferMgr.initialize();
+
+ // Add unmanaged memory storage manager
+ bufferMgr.setStorageManager(new MemoryStorageManager());
+
+ return bufferMgr;
+ }
+
+ public void helpTestVirtualDepJoin(boolean pushCriteria) throws Exception {
+ // Create query
+ String sql = "SELECT * from Master.Transactions where last = 'Davis'"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(123), new Integer(1), new BigDecimal("100.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(127), new Integer(2), new BigDecimal("250.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15000), new Long(128), new Integer(3), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(134), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(15001), new Long(201), new Integer(1), new BigDecimal("10.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1002), new Integer(1), new BigDecimal("7.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", new Long(540), new Long(1003), new Integer(2), new BigDecimal("1000.00") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+
+ // Plan query
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.CRITERIA_IN, pushCriteria);
+ finder.addCapabilities("US", caps); //$NON-NLS-1$
+ finder.addCapabilities("Europe", caps);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder);
+
+ // Run query
+ CommandContext context = TestProcessor.createCommandContext();
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+ }
+
+ private void sampleDataVirtualDepJoin(FakeDataManager dataMgr, FakeMetadataFacade metadata) throws Exception {
+ dataMgr.setBlockOnce();
+ // Group US.Accounts
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("US.Accounts"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { new Long(100), new Integer(15000), "DEP", new Integer(123), new Integer(10000) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(100), new Integer(15000), "TFR", new Integer(127), new Integer(25000) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(100), new Integer(15000), "WD", new Integer(128), new Integer(100000) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(100), new Integer(15001), "DEP", new Integer(134), new Integer(1000) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(100), new Integer(15001), "DEP", new Integer(201), new Integer(1000) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), new Integer(16000), "WD", new Integer(207), new Integer(1234) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), new Integer(16000), "WD", new Integer(299), new Integer(95034) }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), new Integer(16000), "X", new Integer(301), new Integer(5000) }), //$NON-NLS-1$
+ } );
+
+ // Group Europe.CustAccts
+ groupID = (FakeMetadataObject) metadata.getGroupID("Europe.CustAccts"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols,
+
+ new List[] {
+ Arrays.asList(new Object[] { new Long(100), new Long(5401002), new Short((short)1), new BigDecimal("7.20") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(100), new Long(5401003), new Short((short)2), new BigDecimal("1000.00") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), new Long(5501004), new Short((short)3), new BigDecimal("542.20") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), new Long(5501005), new Short((short)1), new BigDecimal("99.99") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(300), new Long(6201006), new Short((short)1), new BigDecimal("10000.00") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(300), new Long(6201007), new Short((short)2), new BigDecimal("0.75") }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(300), new Long(6301008), new Short((short)2), new BigDecimal("62.00") }), //$NON-NLS-1$
+ } );
+
+ // Group CustomerMaster.Customers
+ groupID = (FakeMetadataObject) metadata.getGroupID("CustomerMaster.Customers"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ TimestampUtil ts = new TimestampUtil();
+ dataMgr.registerTuples(groupID, elementSymbols,
+ new List[] {
+ Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", ts.createDate(1926, 4, 25) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Long(200), "John", "Coltrane", ts.createDate(1926, 8, 23) }), //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(new Object[] { new Long(300), "Thelonious", "Monk", ts.createDate(1917, 9, 10) }), //$NON-NLS-1$ //$NON-NLS-2$
+ } );
+
+ // Group CustomerMaster.Locations
+ groupID = (FakeMetadataObject) metadata.getGroupID("CustomerMaster.Locations"); //$NON-NLS-1$
+ elementIDs = metadata.getElementIDsInGroupID(groupID);
+ elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ dataMgr.registerTuples(groupID, elementSymbols,
+ new List[] {
+ Arrays.asList(new Object[] { new Long(100), "US" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(100), "EU" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), "US" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(200), "EU" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { new Long(300), "EU" }), //$NON-NLS-1$
+ } );
+ }
+
+ private void overrideVirtualDepJoinData(FakeDataManager dataMgr, FakeMetadataFacade metadata, boolean unique) throws Exception {
+ // Group CustomerMaster.Customers
+ FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("CustomerMaster.Customers"); //$NON-NLS-1$
+ List elementIDs = metadata.getElementIDsInGroupID(groupID);
+ List elementSymbols = FakeDataStore.createElements(elementIDs);
+
+ TimestampUtil ts = new TimestampUtil();
+
+ List data = new LinkedList();
+
+ data.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", ts.createDate(1926, 4, 25) })); //$NON-NLS-1$ //$NON-NLS-2$
+ if (!unique) {
+ data.add(Arrays.asList(new Object[] { new Long(100), "Miles", "Davis", ts.createDate(1926, 4, 25) })); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ data.add(Arrays.asList(new Object[] { new Long(200), "CloneA", "Davis", ts.createDate(1926, 4, 26) })); //$NON-NLS-1$ //$NON-NLS-2$
+ data.add(Arrays.asList(new Object[] { new Long(300), "CloneB", "Davis", ts.createDate(1926, 4, 27) })); //$NON-NLS-1$ //$NON-NLS-2$
+ data.add(Arrays.asList(new Object[] { new Long(400), "CloneC", "Davis", ts.createDate(1926, 4, 28) })); //$NON-NLS-1$ //$NON-NLS-2$
+
+ dataMgr.registerTuples(
+ groupID,
+ elementSymbols, (List[])data.toArray(new List[data.size()]));
+ }
+
+ @Test public void testVirtualAccessVirtualDep() throws Exception {
+ String sql = "SELECT a.e0, b.e2 FROM vTest.vGroup a inner join vTest.vGroup b on (a.e0 = b.e2 and a.e1 = b.e2) where b.e0=1 and b.e1='2'"; //$NON-NLS-1$
+
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ finder.addCapabilities("test", caps); //$NON-NLS-1$
+
+ ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, finder,
+ new String[] {"SELECT g_0.e2 AS c_0 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2') ORDER BY c_0", //$NON-NLS-1$
+ "SELECT g_0.e0 AS c_0, g_0.e1 AS c_1, g_0.e0 AS c_2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 IN (<dependent values>)) AND (g_0.e1 IN (<dependent values>)) ORDER BY c_2, c_1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 1, // Access
+ 1, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+ }
+
+ /**
+ * Here the virtual makenotdep hint causes us to throw an exception
+ *
+ */
+ @Test public void testVirtualAccessVirtualDep2() {
+ String sql = "SELECT a.e0, b.e2 FROM vTest.vGroup a makenotdep inner join vTest.vGroup b on (a.e0 = b.e2 and a.e1 = b.e2) where b.e0=1 and b.e1='2'"; //$NON-NLS-1$
+
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setFunctionSupport("convert", true); //$NON-NLS-1$
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ finder.addCapabilities("test", caps); //$NON-NLS-1$
+
+ TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, finder,
+ new String[] {}, TestOptimizer.SHOULD_FAIL);
+
+ }
+
+ /**
+ * same as testVirtualDepJoinOverAggregate, but the makenotdep hint prevents the
+ * dependent join from happening
+ */
+ @Test public void testVirtualDepJoinOverAggregates2() throws Exception {
+ // Create query
+ String sql = "select first, last, sum(amount) from Europe.CustAccts e makenotdep join CustomerMaster.Customers c on c.id=e.id where c.first='Miles' group by c.id, first, last"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "Miles", "Davis", new BigDecimal("1007.20") }), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = exampleVirtualDepJoin();
+ FakeDataManager dataManager = new FakeDataManager();
+ sampleDataVirtualDepJoin(dataManager, metadata);
+
+ // Plan query
+ CommandContext context = TestProcessor.createCommandContext();
+
+ Command command = TestProcessor.helpParse(sql);
+ FakeCapabilitiesFinder finder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
+ finder.addCapabilities("Europe", caps);//$NON-NLS-1$
+ finder.addCapabilities("CustomerMaster", caps);//$NON-NLS-1$
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, exampleVirtualDepJoin(), finder, context);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 2, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 0, // DupRemove
+ 3, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 1, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 0, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ TestOptimizer.checkDependentJoinCount(plan, 0);
+ // Run query
+ TestProcessor.helpProcess(plan, context, dataManager, expected);
+ }
+
+
+ @Test public void testVirtualMakeDepHint() throws Exception {
+ // Create query
+ String sql = "select distinct pm1.g1.e1 from (pm1.g1 inner join pm1.g2 on g1.e1 = g2.e1) makedep inner join pm2.g1 on pm2.g1.e1 = pm1.g1.e1 where pm2.g1.e3 = 1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a" }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "c" }), //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Plan query
+ ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
+
+ TestOptimizer.checkNodeTypes(plan, new int[] {
+ 3, // Access
+ 0, // DependentAccess
+ 0, // DependentSelect
+ 0, // DependentProject
+ 1, // DupRemove
+ 0, // Grouping
+ 0, // NestedLoopJoinStrategy
+ 2, // MergeJoinStrategy
+ 0, // Null
+ 0, // PlanExecution
+ 1, // Project
+ 2, // Select
+ 0, // Sort
+ 0 // UnionAll
+ });
+
+ TestOptimizer.checkDependentJoinCount(plan, 1);
+ // Run query
+ TestProcessor.helpProcess(plan, new CommandContext(), dataManager, expected);
+ }
+
+
+}
Copied: trunk/engine/src/test/java/org/teiid/query/processor/batch (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/batch)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/batch/TestBatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/batch/TestBatchedUpdatePlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/batch/TestBatchedUpdatePlan.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,16 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.batch;
+package org.teiid.query.processor.batch;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.query.processor.FakeProcessorPlan;
+import org.teiid.query.processor.batch.BatchedUpdatePlan;
+
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.processor.FakeProcessorPlan;
/**
Copied: trunk/engine/src/test/java/org/teiid/query/processor/dynamic (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/dynamic/SimpleQueryProcessorFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/SimpleQueryProcessorFactory.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/dynamic/SimpleQueryProcessorFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,26 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.dynamic;
+package org.teiid.query.processor.dynamic;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
+
public class SimpleQueryProcessorFactory implements QueryProcessor.ProcessorFactory {
private QueryMetadataInterface metadata;
@@ -60,7 +61,7 @@
@Override
public QueryProcessor createQueryProcessor(String sql, String recursionGroup, CommandContext commandContext)
- throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ throws TeiidProcessingException, TeiidComponentException {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
command = QueryRewriter.rewrite(command, metadata, commandContext);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/dynamic/TestSqlEval.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/dynamic/TestSqlEval.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/dynamic/TestSqlEval.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,30 +20,31 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.dynamic;
+package org.teiid.query.processor.dynamic;
import java.util.Collections;
import javax.xml.transform.Source;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.types.StandardXMLTranslator;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.FakeDataStore;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.processor.xquery.SqlEval;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.types.StandardXMLTranslator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.FakeDataStore;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.processor.xquery.SqlEval;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
/**
Copied: trunk/engine/src/test/java/org/teiid/query/processor/eval (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/eval)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/eval/TestCriteriaEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestCriteriaEvaluator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/eval/TestCriteriaEvaluator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.eval;
+package org.teiid.query.processor.eval;
import static org.junit.Assert.*;
@@ -34,32 +34,32 @@
import java.util.Map;
import org.junit.Test;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.sql.lang.CollectionValueIterator;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.sql.lang.CollectionValueIterator;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.util.CommandContext;
public class TestCriteriaEvaluator {
// ################################## TEST HELPERS ################################
- private void helpTestMatch(String value, String pattern, char escape, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ private void helpTestMatch(String value, String pattern, char escape, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
MatchCriteria crit = new MatchCriteria(new Constant(value), new Constant(pattern), escape);
crit.setNegated(negated);
boolean actualMatch = Evaluator.evaluate(crit);
@@ -67,11 +67,11 @@
assertEquals("Match criteria test failed for value=[" + value + "], pattern=[" + pattern + "], hasEscape=" + (escape != MatchCriteria.NULL_ESCAPE_CHAR) + ": ", expectedMatch, actualMatch); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- private void helpTestMatch(String value, String pattern, char escape, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ private void helpTestMatch(String value, String pattern, char escape, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
helpTestMatch(value, pattern, escape, false, expectedMatch);
}
- private void helpTestIsNull(String value, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ private void helpTestIsNull(String value, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
IsNullCriteria criteria = new IsNullCriteria(new Constant(value));
criteria.setNegated(negated);
@@ -79,11 +79,11 @@
assertEquals("Result did not match expected value", expectedMatch, result); //$NON-NLS-1$
}
- private void helpTestSetCriteria(int value, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ private void helpTestSetCriteria(int value, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
helpTestSetCriteria(new Integer(value), negated, expectedMatch);
}
- private void helpTestSetCriteria(Integer value, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ private void helpTestSetCriteria(Integer value, boolean negated, boolean expectedMatch) throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
Collection constants = new ArrayList(2);
constants.add(new Constant(new Integer(1000)));
constants.add(new Constant(new Integer(5000)));
@@ -93,7 +93,7 @@
assertEquals("Result did not match expected value", expectedMatch, result); //$NON-NLS-1$
}
- private void helpTestCompareSubqueryCriteria(Criteria crit, boolean expectedResult, final Collection values) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException{
+ private void helpTestCompareSubqueryCriteria(Criteria crit, boolean expectedResult, final Collection values) throws CriteriaEvaluationException, BlockedException, TeiidComponentException{
Map elementMap = new HashMap();
ElementSymbol e1 = new ElementSymbol("e1"); //$NON-NLS-1$
@@ -105,8 +105,8 @@
@Override
protected ValueIterator evaluateSubquery(
SubqueryContainer container, List tuple)
- throws MetaMatrixProcessingException, BlockedException,
- MetaMatrixComponentException {
+ throws TeiidProcessingException, BlockedException,
+ TeiidComponentException {
return new CollectionValueIterator(values);
}
}.evaluate(crit, tuple));
Modified: trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/eval/TestExpressionEvaluator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.eval;
+package org.teiid.query.processor.eval;
import java.io.Serializable;
import java.util.ArrayList;
@@ -30,33 +30,34 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.sql.lang.CollectionValueIterator;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.TestCaseExpression;
+import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.CollectionValueIterator;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.TestCaseExpression;
-import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -74,12 +75,12 @@
try {
Object actualValue = helpEval(expr, elementList, valueList, dataMgr, context, expectedValue);
assertEquals("Did not get expected result", expectedValue, actualValue); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Received unexpected exception: " + e.getFullMessage()); //$NON-NLS-1$
}
}
- public Object helpEval(Expression expr, SingleElementSymbol[] elementList, Object[] valueList, ProcessorDataManager dataMgr, CommandContext context, Object expectedValue) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ public Object helpEval(Expression expr, SingleElementSymbol[] elementList, Object[] valueList, ProcessorDataManager dataMgr, CommandContext context, Object expectedValue) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
Map elements = new HashMap();
if (elementList != null) {
for(int i=0; i<elementList.length; i++) {
@@ -185,7 +186,7 @@
try {
helpEval(e2, elements, values, null, null, null);
fail("Exception expected"); //$NON-NLS-1$
- } catch (MetaMatrixComponentException e){
+ } catch (TeiidComponentException e){
//this should be a componentexception, since it is unexpected
assertEquals(e.getMessage(), "Error Code:ERR.015.006.0033 Message:Unable to evaluate e2: No value was available"); //$NON-NLS-1$
}
@@ -271,15 +272,15 @@
private void helpTestWithValueIterator(ScalarSubquery expr,
List<?> values, Object expected)
throws BlockedException,
- MetaMatrixComponentException, ExpressionEvaluationException {
+ TeiidComponentException, ExpressionEvaluationException {
final CollectionValueIterator valueIter = new CollectionValueIterator(values);
CommandContext cc = new CommandContext();
assertEquals(expected, new Evaluator(Collections.emptyMap(), null, cc) {
@Override
protected ValueIterator evaluateSubquery(
SubqueryContainer container, List tuple)
- throws MetaMatrixProcessingException, BlockedException,
- MetaMatrixComponentException {
+ throws TeiidProcessingException, BlockedException,
+ TeiidComponentException {
return valueIter;
}
}.evaluate(expr, null) );
Copied: trunk/engine/src/test/java/org/teiid/query/processor/proc (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/proc)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/proc/TestProcedureProcessor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/proc/TestProcedureProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
import static org.junit.Assert.*;
-import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -32,47 +31,39 @@
import java.util.Map;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.processor.xml.TestXMLPlanningEnhancements;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorFailure;
+import org.teiid.query.validator.ValidatorReport;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.BatchCollector;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.processor.xml.TestXMLPlanningEnhancements;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorFailure;
-import com.metamatrix.query.validator.ValidatorReport;
public class TestProcedureProcessor {
@@ -104,97 +95,41 @@
}
}
- static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr, QueryMetadataInterface metadata) throws SQLException, MetaMatrixCoreException {
- // Process twice, testing reset and clone method of Processor plan
- for (int i=1; i<=2; i++) {
-
- CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
- context.getNextRand(0);
- context.setProcessDebug(DEBUG);
- context.setMetadata(metadata);
-
- BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
-
- QueryProcessor processor = new QueryProcessor(procPlan, context, bufferMgr, dataMgr);
- processor.setNonBlocking(true);
- BatchCollector collector = processor.createBatchCollector();
- TupleBuffer tsID = collector.collectTuples();
-
- // Create QueryResults from TupleSource
- TupleSource ts = tsID.createIndexedTupleSource();
- int count = tsID.getRowCount();
-
- if(DEBUG) {
- System.out.println("\nResults:\n" + tsID.getSchema()); //$NON-NLS-1$
- TupleSource ts2 = tsID.createIndexedTupleSource();
- for(int j=0; j<count; j++) {
- System.out.println("" + j + ": " + ts2.nextTuple()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- ts2.closeSource();
- }
-
- if (shouldFail) {
- fail("Expected processing to fail"); //$NON-NLS-1$
- }
-
- if (expectedResults == null) {
- assertEquals("Incorrect number of rows: ", 1, count); //$NON-NLS-1$
- List tuple = ts.nextTuple();
- assertEquals("Incorrect number of columns: ", 1, tuple.size()); //$NON-NLS-1$
-
- Integer rowCount = (Integer) tuple.get(0);
- assertEquals("Rows updated mismatch: ", rowsUpdated, rowCount.intValue()); //$NON-NLS-1$
- }
-
- if (expectedResults != null) {
- //Walk results and compare
- ts = tsID.createIndexedTupleSource();
- assertEquals("Incorrect number of rows: ", expectedResults.length, count); //$NON-NLS-1$
- for(int j=0; j<count; j++) {
- List record = ts.nextTuple();
-
- //handle xml
- if(record.size() == 1 && expectedResults[j].size() == 1){
- Object cellValue = record.get(0);
- if(cellValue instanceof XMLType){
- XMLType id = (XMLType)cellValue;
- String actualDoc = id.getString();
- TestXMLProcessor.compareDocuments((String)expectedResults[j].get(0), actualDoc);
- continue;
- }
- }
- assertEquals("Row " + j + " does not match expected: ", expectedResults[j], record); //$NON-NLS-1$ //$NON-NLS-2$
- }
- ts.closeSource();
- }
-
- //reset and clone after 1st run
- if (i==1) {
- procPlan.reset();
- procPlan = procPlan.clone();
- }
+ static void helpTestProcess(ProcessorPlan procPlan, int rowsUpdated, List[] expectedResults, boolean shouldFail, ProcessorDataManager dataMgr, QueryMetadataInterface metadata) throws Exception {
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
+ context.getNextRand(0);
+ context.setProcessDebug(DEBUG);
+ context.setMetadata(metadata);
+
+ if (expectedResults == null) {
+ expectedResults = new List[] {Arrays.asList(rowsUpdated)};
}
+
+ TestProcessor.helpProcess(procPlan, context, dataMgr, expectedResults);
+ if (shouldFail) {
+ fail("Expected processing to fail"); //$NON-NLS-1$
+ }
}
private void helpTestProcessFailure(boolean optimistic, ProcessorPlan procPlan,
- FakeDataManager dataMgr, String failMessage) throws SQLException, MetaMatrixCoreException {
+ FakeDataManager dataMgr, String failMessage) throws Exception {
try {
helpTestProcess(optimistic, procPlan, new List[] {}, dataMgr, true);
- } catch(MetaMatrixException ex) {
+ } catch(TeiidException ex) {
assertEquals(failMessage, ex.getMessage());
}
}
- public static void helpTestProcess(ProcessorPlan procPlan, List[] expectedResults, ProcessorDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
+ public static void helpTestProcess(ProcessorPlan procPlan, List[] expectedResults, ProcessorDataManager dataMgr) throws Exception {
helpTestProcess(false, procPlan, expectedResults, dataMgr, false);
}
- private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws SQLException, MetaMatrixCoreException {
+ private void helpTestProcess(ProcessorPlan procPlan, int expectedRows, FakeDataManager dataMgr) throws Exception {
helpTestProcess(procPlan, expectedRows, null, false, dataMgr, null);
}
static void helpTestProcess(boolean optimistic, ProcessorPlan procPlan, List[] expectedResults,
- ProcessorDataManager dataMgr, boolean shouldFail) throws SQLException, MetaMatrixCoreException {
+ ProcessorDataManager dataMgr, boolean shouldFail) throws Exception {
helpTestProcess(procPlan, 0, expectedResults, shouldFail, dataMgr, null);
}
@@ -210,7 +145,7 @@
return elements;
}
- private FakeDataManager exampleDataManager(FakeMetadataFacade metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ private FakeDataManager exampleDataManager(FakeMetadataFacade metadata) throws QueryMetadataException, TeiidComponentException {
FakeDataManager dataMgr = new FakeDataManager();
FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
@@ -244,7 +179,7 @@
return dataMgr;
}
- private FakeDataManager exampleDataManager2(FakeMetadataFacade metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ private FakeDataManager exampleDataManager2(FakeMetadataFacade metadata) throws QueryMetadataException, TeiidComponentException {
FakeDataManager dataMgr = new FakeDataManager();
FakeMetadataObject groupID = (FakeMetadataObject) metadata.getGroupID("pm1.g1"); //$NON-NLS-1$
@@ -306,7 +241,7 @@
return dataMgr;
}
- private FakeDataManager exampleDataManagerPm5(FakeMetadataFacade metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ private FakeDataManager exampleDataManagerPm5(FakeMetadataFacade metadata) throws QueryMetadataException, TeiidComponentException {
FakeDataManager dataMgr = new FakeDataManager();
// Group stock.items
@@ -928,7 +863,11 @@
Arrays.asList(new Object[] { "Second"}), //$NON-NLS-1$
Arrays.asList(new Object[] { "Third"}), //$NON-NLS-1$
Arrays.asList(new Object[] { "Fourth"})}; //$NON-NLS-1$
- helpTestProcess(plan, expected, dataMgr);
+ CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
+ context.setMetadata(metadata);
+ context.setProcessorBatchSize(1); //ensure that the final temp result set will not be deleted prematurely
+
+ TestProcessor.helpProcess(plan, context, dataMgr, expected);
}
@Test public void testVirtualProcedure17() throws Exception {
@@ -2372,40 +2311,40 @@
FakeMetadataFacade metadata = TestXMLProcessor.exampleMetadataCached();
FakeDataManager dataMgr = TestXMLProcessor.exampleDataManagerNested(metadata);
String expectedDoc =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + //$NON-NLS-1$
- "<Catalogs>\r\n" + //$NON-NLS-1$
- " <Catalog>\r\n" + //$NON-NLS-1$
- " <Items>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"001\">\r\n" + //$NON-NLS-1$
- " <Name>Lamp</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>5</Quantity>\r\n" + //$NON-NLS-1$
- " <Suppliers>\r\n" + //$NON-NLS-1$
- " <Supplier SupplierID=\"52\">\r\n" + //$NON-NLS-1$
- " <Name>Biff's Stuff</Name>\r\n" + //$NON-NLS-1$
- " <Zip>22222</Zip>\r\n" + //$NON-NLS-1$
- " <Orders>\r\n" + //$NON-NLS-1$
- " <Order OrderID=\"2\">\r\n" + //$NON-NLS-1$
- " <OrderDate>12/31/01</OrderDate>\r\n" + //$NON-NLS-1$
- " <OrderQuantity>87</OrderQuantity>\r\n" + //$NON-NLS-1$
- " <OrderStatus>complete</OrderStatus>\r\n" + //$NON-NLS-1$
- " </Order>\r\n" + //$NON-NLS-1$
- " </Orders>\r\n" + //$NON-NLS-1$
- " </Supplier>\r\n" + //$NON-NLS-1$
- " </Suppliers>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"002\">\r\n" + //$NON-NLS-1$
- " <Name>Screwdriver</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>100</Quantity>\r\n" + //$NON-NLS-1$
- " <Suppliers/>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " <Item ItemID=\"003\">\r\n" + //$NON-NLS-1$
- " <Name>Goat</Name>\r\n" + //$NON-NLS-1$
- " <Quantity>4</Quantity>\r\n" + //$NON-NLS-1$
- " <Suppliers/>\r\n" + //$NON-NLS-1$
- " </Item>\r\n" + //$NON-NLS-1$
- " </Items>\r\n" + //$NON-NLS-1$
- " </Catalog>\r\n" + //$NON-NLS-1$
- "</Catalogs>\r\n\r\n"; //$NON-NLS-1$
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //$NON-NLS-1$
+ "<Catalogs>\n" + //$NON-NLS-1$
+ " <Catalog>\n" + //$NON-NLS-1$
+ " <Items>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"001\">\n" + //$NON-NLS-1$
+ " <Name>Lamp</Name>\n" + //$NON-NLS-1$
+ " <Quantity>5</Quantity>\n" + //$NON-NLS-1$
+ " <Suppliers>\n" + //$NON-NLS-1$
+ " <Supplier SupplierID=\"52\">\n" + //$NON-NLS-1$
+ " <Name>Biff's Stuff</Name>\n" + //$NON-NLS-1$
+ " <Zip>22222</Zip>\n" + //$NON-NLS-1$
+ " <Orders>\n" + //$NON-NLS-1$
+ " <Order OrderID=\"2\">\n" + //$NON-NLS-1$
+ " <OrderDate>12/31/01</OrderDate>\n" + //$NON-NLS-1$
+ " <OrderQuantity>87</OrderQuantity>\n" + //$NON-NLS-1$
+ " <OrderStatus>complete</OrderStatus>\n" + //$NON-NLS-1$
+ " </Order>\n" + //$NON-NLS-1$
+ " </Orders>\n" + //$NON-NLS-1$
+ " </Supplier>\n" + //$NON-NLS-1$
+ " </Suppliers>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"002\">\n" + //$NON-NLS-1$
+ " <Name>Screwdriver</Name>\n" + //$NON-NLS-1$
+ " <Quantity>100</Quantity>\n" + //$NON-NLS-1$
+ " <Suppliers/>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " <Item ItemID=\"003\">\n" + //$NON-NLS-1$
+ " <Name>Goat</Name>\n" + //$NON-NLS-1$
+ " <Quantity>4</Quantity>\n" + //$NON-NLS-1$
+ " <Suppliers/>\n" + //$NON-NLS-1$
+ " </Item>\n" + //$NON-NLS-1$
+ " </Items>\n" + //$NON-NLS-1$
+ " </Catalog>\n" + //$NON-NLS-1$
+ "</Catalogs>"; //$NON-NLS-1$
FakeMetadataObject pm1 = metadata.getStore().findObject("xmltest",FakeMetadataObject.MODEL); //$NON-NLS-1$
Copied: trunk/engine/src/test/java/org/teiid/query/processor/relational (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/relational)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/BlockingFakeRelationalNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/BlockingFakeRelationalNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/BlockingFakeRelationalNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.*;
+import org.teiid.common.buffer.*;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
public class BlockingFakeRelationalNode extends FakeRelationalNode {
private int count = 1;
@@ -59,7 +60,7 @@
this.returnPeriod = returnPeriod;
}
- public TupleBatch nextBatchDirect() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (count++%returnPeriod != 0) {
throw BlockedException.INSTANCE;
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/FakeRelationalNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/FakeRelationalNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/FakeRelationalNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.*;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.*;
+import org.teiid.common.buffer.*;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.relational.RelationalNode;
+
/**
*/
public class FakeRelationalNode extends RelationalNode {
@@ -66,10 +68,10 @@
}
/**
- * @throws MetaMatrixProcessingException
+ * @throws TeiidProcessingException
* @see com.metamatrix.query.processor.relational.x.RelationalNode#nextBatch()
*/
- public TupleBatch nextBatchDirect() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if(data != null) {
if(currentRow < data.length) {
int endRow = Math.min(data.length, currentRow+getBatchSize());
@@ -115,7 +117,7 @@
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#getBatchSize()
+ * @see org.teiid.query.processor.relational.RelationalNode#getBatchSize()
* @since 4.2
*/
protected int getBatchSize() {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/NodeTestUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/NodeTestUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/NodeTestUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.buffer.impl.MemoryStorageManager;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.common.buffer.impl.MemoryStorageManager;
+import org.teiid.core.TeiidComponentException;
+
/**
* @since 4.2
*/
@@ -54,7 +55,7 @@
static BufferManager createBufferManager(BufferManagerImpl bufferManager) {
try {
bufferManager.initialize();
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new RuntimeException(e);
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestAccessNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestAccessNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,29 +20,32 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Arrays;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.RelationalNodeUtil;
+import org.teiid.query.resolver.TestResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SetClauseList;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.resolver.TestResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestBatchedUpdateNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestBatchedUpdateNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import static org.junit.Assert.*;
@@ -31,20 +31,21 @@
import org.junit.Test;
import org.mockito.Mockito;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.batch.TestBatchedUpdatePlanner;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.BatchedUpdateNode;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.batch.TestBatchedUpdatePlanner;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
/**
@@ -210,8 +211,8 @@
private FakePDM(int numExecutedCommands) {
this.numExecutedCommands = numExecutedCommands;
}
- public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,MetaMatrixComponentException {return null;}
- public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws MetaMatrixComponentException {
+ public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,TeiidComponentException {return null;}
+ public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws TeiidComponentException {
assertEquals("myProcessorID", processorID); //$NON-NLS-1$
assertEquals("myModelName", modelName); //$NON-NLS-1$
assertEquals(1, nodeID);
@@ -233,7 +234,7 @@
}
public void closeSource() {}
public List getSchema() {return null;}
- public List nextTuple() throws MetaMatrixComponentException {
+ public List nextTuple() throws TeiidComponentException {
if (first) {
first = false;
throw BlockedException.INSTANCE;
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDependentCriteriaProcessor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestDependentCriteriaProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,23 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Arrays;
import java.util.List;
import static org.junit.Assert.*;
import org.junit.Test;
+import org.teiid.query.processor.relational.DependentAccessNode;
+import org.teiid.query.processor.relational.DependentCriteriaProcessor;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.query.processor.relational.DependentAccessNode;
-import com.metamatrix.query.processor.relational.DependentCriteriaProcessor;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.util.CommandContext;
public class TestDependentCriteriaProcessor {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestDuplicateFilter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestDuplicateFilter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestDuplicateFilter.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,16 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.aggregate.Count;
+import org.teiid.query.processor.relational.DuplicateFilter;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.aggregate.Count;
/**
*/
@@ -43,7 +45,7 @@
super(arg0);
}
- public void helpTestDuplicateFilter(Object[] input, Class dataType, int expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestDuplicateFilter(Object[] input, Class dataType, int expected) throws TeiidComponentException, TeiidProcessingException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
DuplicateFilter filter = new DuplicateFilter(new Count(), mgr, "test"); //$NON-NLS-1$
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestGroupingNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import static org.junit.Assert.*;
@@ -32,29 +32,32 @@
import java.util.Map;
import org.junit.Test;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.aggregate.AggregateFunction;
+import org.teiid.query.function.aggregate.NullFilter;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.FakeTupleSource;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.DuplicateFilter;
+import org.teiid.query.processor.relational.GroupingNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.function.aggregate.AggregateFunction;
-import com.metamatrix.query.function.aggregate.NullFilter;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.FakeTupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.util.CommandContext;
public class TestGroupingNode {
@@ -88,9 +91,9 @@
private void helpProcess(BufferManager mgr,
GroupingNode node,
CommandContext context,
- List[] expected, ProcessorDataManager dataMgr) throws MetaMatrixComponentException,
+ List[] expected, ProcessorDataManager dataMgr) throws TeiidComponentException,
BlockedException,
- MetaMatrixProcessingException {
+ TeiidProcessingException {
TupleSource dataSource = createTupleSource1();
helpProcess(mgr, node, context, expected, dataSource, dataMgr);
}
@@ -99,9 +102,9 @@
GroupingNode node,
CommandContext context,
List[] expected,
- TupleSource dataSource, ProcessorDataManager dataMgr) throws MetaMatrixComponentException,
+ TupleSource dataSource, ProcessorDataManager dataMgr) throws TeiidComponentException,
BlockedException,
- MetaMatrixProcessingException {
+ TeiidProcessingException {
RelationalNode dataNode = new FakeRelationalNode(0, dataSource, mgr.getProcessorBatchSize());
dataNode.setElements(dataSource.getSchema());
node.addChild(dataNode);
@@ -200,8 +203,8 @@
// Same as test2, but uses processor batch size smaller than number of groups
@Test public void test3() throws Exception {
- BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- ((BufferManagerImpl)mgr).setProcessorBatchSize(5);
+ BufferManagerImpl mgr = BufferManagerFactory.createBufferManager();
+ mgr.setProcessorBatchSize(5);
GroupingNode node = getExampleGroupingNode();
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -298,8 +301,8 @@
}
private void helpTestLookupFunctionInAggregate(int batchSize) throws Exception {
- BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
- ((BufferManagerImpl)mgr).setProcessorBatchSize(batchSize);
+ BufferManagerImpl mgr = BufferManagerFactory.createBufferManager();
+ mgr.setProcessorBatchSize(batchSize);
// Set up
GroupingNode node = new GroupingNode(1);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestJoinNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import static org.junit.Assert.assertEquals;
@@ -32,24 +32,30 @@
import org.junit.Before;
import org.junit.Test;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.JoinStrategy;
+import org.teiid.query.processor.relational.MergeJoinStrategy;
+import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
+import org.teiid.query.processor.relational.PartitionedSortJoin;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.util.CommandContext;
public class TestJoinNode {
private static final int NO_CRITERIA = 0;
@@ -212,7 +218,7 @@
}
}
- public void helpTestJoin() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestJoin() throws TeiidComponentException, TeiidProcessingException {
for (int batchSize : new int[] {1, 10, leftTuples.length, 100}) {
helpCreateJoin();
if (batchSize == 0) {
@@ -230,7 +236,7 @@
}
}
- public void helpTestJoinDirect(List[] expectedResults, int batchSize) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestJoinDirect(List[] expectedResults, int batchSize) throws TeiidComponentException, TeiidProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, batchSize);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestLimitNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestLimitNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestLimitNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Arrays;
import java.util.List;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.query.processor.relational.LimitNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.sql.symbol.Constant;
+
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.sql.symbol.Constant;
/**
* @since 4.3
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectIntoNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectIntoNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,30 +20,33 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.FakeTupleSource;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.ProjectIntoNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.tempdata.TempTableStoreImpl;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.processor.FakeTupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.query.util.CommandContext;
/**
@@ -127,8 +130,8 @@
this.expectedBatchSize = expectedBatchSize;
this.exceptionOnClose = exceptionOnClose;
}
- public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,MetaMatrixComponentException {return null;}
- public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws MetaMatrixComponentException, ExpressionEvaluationException {
+ public Object lookupCodeValue(CommandContext context,String codeTableName,String returnElementName,String keyElementName,Object keyValue) throws BlockedException,TeiidComponentException {return null;}
+ public TupleSource registerRequest(Object processorID,Command command,String modelName,String connectorBindingId, int nodeID) throws TeiidComponentException, ExpressionEvaluationException {
callCount++;
int batchSize = 1;
@@ -188,7 +191,7 @@
}
public void closeSource() {}
public List getSchema() {return null;}
- public List nextTuple() throws MetaMatrixComponentException {
+ public List nextTuple() throws TeiidComponentException {
if (currentRow % 100 == 0 && block) {
block = false;
throw BlockedException.INSTANCE;
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestProjectNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,26 +28,28 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -61,7 +63,7 @@
super(arg0);
}
- public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) throws MetaMatrixComponentException {
+ public ProjectNode helpSetupProject(List elements, List[] data, List childElements, ProcessorDataManager dataMgr) throws TeiidComponentException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -78,7 +80,7 @@
return projectNode;
}
- public void helpTestProject(List elements, List[] data, List childElements, List[] expected, ProcessorDataManager dataMgr) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestProject(List elements, List[] data, List childElements, List[] expected, ProcessorDataManager dataMgr) throws TeiidComponentException, TeiidProcessingException {
ProjectNode projectNode = helpSetupProject(elements, data, childElements, dataMgr);
projectNode.open();
@@ -101,7 +103,7 @@
}
}
- public void helpTestProjectFails(List elements, List[] data, List childElements, String expectedError) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestProjectFails(List elements, List[] data, List childElements, String expectedError) throws TeiidComponentException, TeiidProcessingException {
ProjectNode projectNode = helpSetupProject(elements, data, childElements, null);
try {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalNodeStatistics.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalNodeStatistics.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,20 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.processor.relational.RelationalNodeStatistics;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.CommandContext;
/**
* @since 4.2
@@ -57,7 +59,7 @@
assertTrue("The batch timer did not yield an end time", testnodeStatistics.getBatchEndTime()!= 0); //$NON-NLS-1$
}
- public void testStatsCollection() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testStatsCollection() throws TeiidComponentException, TeiidProcessingException {
List[] data = createData(1000);
FakeRelationalNode fakeNode = this.createFakeNode(data);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalPlan.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestRelationalPlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestRelationalPlan.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.TupleBatch;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSelectNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,28 +28,30 @@
import java.util.List;
import java.util.Map;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.SelectNode;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -63,11 +65,11 @@
super(arg0);
}
- public void helpTestSelect(List elements, Criteria criteria, List[] data, List childElements, ProcessorDataManager dataMgr, List[] expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestSelect(List elements, Criteria criteria, List[] data, List childElements, ProcessorDataManager dataMgr, List[] expected) throws TeiidComponentException, TeiidProcessingException {
helpTestSelect(elements, criteria, childElements, dataMgr, expected, new FakeRelationalNode(2, data));
}
- public void helpTestSelect(List elements, Criteria criteria, List childElements, ProcessorDataManager dataMgr, List[] expected, RelationalNode child) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestSelect(List elements, Criteria criteria, List childElements, ProcessorDataManager dataMgr, List[] expected, RelationalNode child) throws TeiidComponentException, TeiidProcessingException {
BufferManager mgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -100,7 +102,7 @@
/**
* Ensures that a final empty batch is reindexed so that the batch iterator works correctly
*/
- public void testEmptyBatchIndexing() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testEmptyBatchIndexing() throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -122,7 +124,7 @@
@Override
protected TupleBatch nextBatchDirect() throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
if (i++ == 0) {
return new TupleBatch(1, new List[] {Arrays.asList(1), Arrays.asList(1)});
}
@@ -136,7 +138,7 @@
helpTestSelect(elements, crit, childElements, null, new List[0], child);
}
- public void testNoRows() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testNoRows() throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -158,7 +160,7 @@
}
- public void testSimpleSelect() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testSimpleSelect() throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -193,7 +195,7 @@
}
- public void testSelectWithLookup() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testSelectWithLookup() throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestSortNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import static org.junit.Assert.*;
@@ -30,27 +30,30 @@
import java.util.TreeSet;
import org.junit.Test;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.processor.relational.ListNestedSortComparator;
+import org.teiid.query.processor.relational.SortNode;
+import org.teiid.query.processor.relational.SortUtility;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.CommandContext;
public class TestSortNode {
public static final int BATCH_SIZE = 100;
- private void helpTestSort(List elements, List[] data, List sortElements, List sortTypes, List[] expected, Mode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void helpTestSort(List elements, List[] data, List sortElements, List sortTypes, List[] expected, Mode mode) throws TeiidComponentException, TeiidProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(100, BATCH_SIZE, BATCH_SIZE);
CommandContext context = new CommandContext ("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/relational/TestUnionAllNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/relational/TestUnionAllNode.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,22 +20,25 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -49,7 +52,7 @@
super(arg0);
}
- public void helpTestUnion(RelationalNode[] children, RelationalNode union, List[] expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestUnion(RelationalNode[] children, RelationalNode union, List[] expected) throws TeiidComponentException, TeiidProcessingException {
BufferManager mgr = NodeTestUtil.getTestBufferManager(1, 2);
CommandContext context = new CommandContext("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -87,7 +90,7 @@
assertEquals("Didn't match expected counts", expected.length, currentRow-1); //$NON-NLS-1$
}
- public void testNoRows() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testNoRows() throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -113,7 +116,7 @@
helpTestUnion(new RelationalNode[] {leftNode, rightNode}, union, new List[0]);
}
- public void helpTestUnionConfigs(int sources, int blockModIndex, int rowsPerSource, int batchSize, List[] expected) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void helpTestUnionConfigs(int sources, int blockModIndex, int rowsPerSource, int batchSize, List[] expected) throws TeiidComponentException, TeiidProcessingException {
ElementSymbol es1 = new ElementSymbol("e1"); //$NON-NLS-1$
es1.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -148,7 +151,7 @@
helpTestUnion(nodes, union, expected);
}
- public void testBasicUnion() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testBasicUnion() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(0) }),
@@ -161,7 +164,7 @@
}
- public void testBasicUnionMultipleSources() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testBasicUnionMultipleSources() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(0) }),
@@ -178,7 +181,7 @@
helpTestUnionConfigs(5, -1, 2, 50, expected);
}
- public void testMultipleSourcesHalfBlockingNodes() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testMultipleSourcesHalfBlockingNodes() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(1) }),
Arrays.asList(new Object[] { new Integer(0) }),
@@ -190,7 +193,7 @@
helpTestUnionConfigs(5, 2, 1, 50, expected);
}
- public void testMultipleSourcesAllBlockingNodes() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testMultipleSourcesAllBlockingNodes() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(1) }),
@@ -202,7 +205,7 @@
helpTestUnionConfigs(5, 1, 1, 50, expected);
}
- public void testMultipleSourceMultiBatchAllBlocking() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void testMultipleSourceMultiBatchAllBlocking() throws TeiidComponentException, TeiidProcessingException {
List expected[] = new List[] {
Arrays.asList(new Object[] { new Integer(0) }),
Arrays.asList(new Object[] { new Integer(1) }),
Copied: trunk/engine/src/test/java/org/teiid/query/processor/xml (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/xml)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/FakePlanExecutor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/FakePlanExecutor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/FakePlanExecutor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.processor.FakeTupleSource;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.FakeTupleSource;
+import org.teiid.query.processor.xml.PlanExecutor;
+
class FakePlanExecutor implements PlanExecutor{
String resultName;
FakeTupleSource tupleSource;
@@ -47,23 +49,23 @@
this.schema = schema;
this.tupleSource = new FakeTupleSource(schema, rows);
}
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
}
- public List currentRow() throws MetaMatrixComponentException {
+ public List currentRow() throws TeiidComponentException {
return this.currentRow;
}
- public void execute(Map values) throws MetaMatrixComponentException, BlockedException {
+ public void execute(Map values) throws TeiidComponentException, BlockedException {
tupleSource.openSource();
}
- public List nextRow() throws MetaMatrixComponentException {
+ public List nextRow() throws TeiidComponentException {
currentRow = tupleSource.nextTuple();
return currentRow;
}
- public List getOutputElements() throws MetaMatrixComponentException {
+ public List getOutputElements() throws TeiidComponentException {
return this.schema;
}
}
\ No newline at end of file
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/FakeXMLProcessorEnvironment.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/FakeXMLProcessorEnvironment.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.processor.xml.PlanExecutor;
+import org.teiid.query.processor.xml.XMLProcessorEnvironment;
+
/**
*/
public class FakeXMLProcessorEnvironment extends XMLProcessorEnvironment {
@@ -45,7 +48,7 @@
}
public PlanExecutor createResultExecutor(final String resultSetName, ResultSetInfo info)
- throws MetaMatrixComponentException{
+ throws TeiidComponentException{
return new FakePlanExecutor(resultSetName, (List)schemaMap.get(resultSetName), (List[])dataMap.get(resultSetName));
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/NoOpInstruction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/NoOpInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/NoOpInstruction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.xml.ProcessorInstruction;
+import org.teiid.query.processor.xml.XMLContext;
+import org.teiid.query.processor.xml.XMLProcessorEnvironment;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BlockedException;
/**
*/
@@ -42,7 +45,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException {
+ throws BlockedException, TeiidComponentException {
env.incrementCurrentProgramCounter();
return context;
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestAddNodeInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestAddNodeInstruction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,19 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Properties;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.processor.xml.AddNodeInstruction;
+import org.teiid.query.processor.xml.DocumentInProgress;
+import org.teiid.query.processor.xml.NodeDescriptor;
+import org.teiid.query.processor.xml.ProcessorInstruction;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.SAXDocumentInProgress;
+import org.teiid.query.processor.xml.XMLContext;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
/**
* Unit tests {@link AddNodeInstruction} class
@@ -381,7 +389,7 @@
* Take instruction, make a Program out of it, instantiate a
* FakeEnvironment and XMLPlan, process instruction, and return result
* doc
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private String helpGetDocument(AddNodeInstruction addNodeInstruction) throws Exception{
return helpGetDocument(addNodeInstruction, null);
@@ -391,7 +399,7 @@
* Take instruction, make a Program out of it, instantiate a
* FakeEnvironment and XMLPlan, process instruction, and return result
* doc
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private String helpGetDocument(ProcessorInstruction addNodeInstruction, Properties namespaceDeclarations) throws Exception{
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestElement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestElement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestElement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.io.CharArrayWriter;
import java.util.Properties;
@@ -29,10 +29,13 @@
import javax.xml.transform.sax.TransformerHandler;
import javax.xml.transform.stream.StreamResult;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.processor.xml.Element;
+import org.teiid.query.processor.xml.NodeDescriptor;
+
import junit.framework.TestCase;
import net.sf.saxon.TransformerFactoryImpl;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
public class TestElement extends TestCase{
private CharArrayWriter streamResultHolder;
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestInstructions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestInstructions.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestInstructions.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,39 +20,55 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.processor.xml.AddNodeInstruction;
+import org.teiid.query.processor.xml.Condition;
+import org.teiid.query.processor.xml.CriteriaCondition;
+import org.teiid.query.processor.xml.EndDocumentInstruction;
+import org.teiid.query.processor.xml.ExecSqlInstruction;
+import org.teiid.query.processor.xml.IfInstruction;
+import org.teiid.query.processor.xml.InitializeDocumentInstruction;
+import org.teiid.query.processor.xml.MoveCursorInstruction;
+import org.teiid.query.processor.xml.MoveDocInstruction;
+import org.teiid.query.processor.xml.NodeDescriptor;
+import org.teiid.query.processor.xml.ProcessorInstruction;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.WhileInstruction;
+import org.teiid.query.processor.xml.XMLPlan;
+import org.teiid.query.processor.xml.XMLProcessorEnvironment;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.util.CommandContext;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -112,7 +128,7 @@
return new FakeMetadataFacade(store);
}
- private Command helpGetCommand(String sql, FakeMetadataFacade metadata) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private Command helpGetCommand(String sql, FakeMetadataFacade metadata) throws TeiidComponentException, TeiidProcessingException {
// parse
QueryParser parser = new QueryParser();
Command command = parser.parseCommand(sql);
@@ -123,7 +139,7 @@
return command;
}
- private Criteria helpGetCriteria(String sql, FakeMetadataFacade metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ private Criteria helpGetCriteria(String sql, FakeMetadataFacade metadata) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryParser parser = new QueryParser();
Criteria crit = parser.parseCriteria(sql);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestProcessorEnvironment.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestProcessorEnvironment.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestProcessorEnvironment.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
+import org.teiid.query.processor.xml.InitializeDocumentInstruction;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.XMLContext;
+
import junit.framework.TestCase;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestSAXDocumentInProgress.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSAXDocumentInProgress.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.processor.xml.NodeDescriptor;
+import org.teiid.query.processor.xml.SAXDocumentInProgress;
+
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
public class TestSAXDocumentInProgress extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestSourceNodeGenaratorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestSourceNodeGenaratorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,24 +20,25 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.List;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingException;
+import org.teiid.query.mapping.xml.MappingLoader;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.optimizer.xml.SourceNodeGenaratorVisitor;
+
import junit.framework.TestCase;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingBaseNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingException;
-import com.metamatrix.query.mapping.xml.MappingLoader;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.optimizer.xml.SourceNodeGenaratorVisitor;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLContext.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLContext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLContext.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.xml.XMLContext;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestXMLContext extends TestCase {
@@ -71,7 +73,7 @@
try {
currentRow = context.getCurrentRow(resultSetName);
fail("must have failed because the results are removed."); //$NON-NLS-1$
- }catch(MetaMatrixComponentException e) {
+ }catch(TeiidComponentException e) {
}
}
@@ -108,7 +110,7 @@
try {
parentContext.getCurrentRow(results2);
fail("should fail to get child contexts results from parent.."); //$NON-NLS-1$
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
}
// note that we only using the current context which is the "child"
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLPlanningEnhancements.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLPlanningEnhancements.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,31 +20,34 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.relational.rules.RuleChooseDependent;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.xml.ExecSqlInstruction;
+import org.teiid.query.processor.xml.ExecStagingTableInstruction;
+import org.teiid.query.processor.xml.XMLPlan;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.relational.rules.RuleChooseDependent;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
public class TestXMLPlanningEnhancements extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLProcessor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import static org.junit.Assert.*;
@@ -35,52 +35,54 @@
import java.util.StringTokenizer;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCommentNode;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.Namespace;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.xml.TestXMLPlanner;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.xml.ExecStagingTableInstruction;
+import org.teiid.query.processor.xml.XMLPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingChoiceNode;
-import com.metamatrix.query.mapping.xml.MappingCommentNode;
-import com.metamatrix.query.mapping.xml.MappingCriteriaNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSequenceNode;
-import com.metamatrix.query.mapping.xml.Namespace;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.xml.TestXMLPlanner;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.BatchCollector;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.util.CommandContext;
/**
* Tests XML processing, which involves XMLPlanner making a ProcessorPlan
@@ -2923,7 +2925,7 @@
return dataMgr;
}
- public static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public static Command helpGetCommand(String sql, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException {
QueryParser parser = new QueryParser();
Command command = parser.parseCommand(sql);
QueryResolver.resolveCommand(command, metadata);
@@ -2932,7 +2934,7 @@
}
static ProcessorPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr) throws Exception{
- return helpTestProcess(sql, expectedDoc, metadata, dataMgr, true, MetaMatrixComponentException.class, null);
+ return helpTestProcess(sql, expectedDoc, metadata, dataMgr, true, TeiidComponentException.class, null);
}
static ProcessorPlan helpTestProcess(String sql, String expectedDoc, FakeMetadataFacade metadata, FakeDataManager dataMgr, final boolean shouldSucceed, Class expectedException, final String shouldFailMsg) throws Exception{
@@ -3043,8 +3045,8 @@
}
private void helpTestProcess(String[] expectedDocs, FakeDataManager dataMgr,
- ProcessorPlan plan) throws MetaMatrixComponentException,
- MetaMatrixProcessingException, SQLException {
+ ProcessorPlan plan) throws TeiidComponentException,
+ TeiidProcessingException, SQLException {
BufferManager bufferMgr = BufferManagerFactory.getStandaloneBufferManager();
CommandContext context = new CommandContext("pID", null, null, null, 1); //$NON-NLS-1$
context.setProcessDebug(DEBUG);
@@ -5841,7 +5843,7 @@
@Test public void test2b() throws Exception {
FakeMetadataFacade metadata = exampleMetadataCached();
FakeDataManager dataMgr = exampleDataManager(metadata);
- helpTestProcess("SELECT * FROM xmltest.doc2b", null, metadata, dataMgr, false, MetaMatrixComponentException.class, "Should have failed on default"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestProcess("SELECT * FROM xmltest.doc2b", null, metadata, dataMgr, false, TeiidComponentException.class, "Should have failed on default"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void test2c() throws Exception {
@@ -6059,10 +6061,10 @@
QueryProcessor processor = new QueryProcessor(plan, context, bufferMgr, dataMgr);
processor.setNonBlocking(true);
BatchCollector collector = processor.createBatchCollector();
- MetaMatrixComponentException failOnDefaultException = null;
+ TeiidComponentException failOnDefaultException = null;
try{
collector.collectTuples();
- } catch (MetaMatrixComponentException e){
+ } catch (TeiidComponentException e){
failOnDefaultException = e;
}
@@ -6472,7 +6474,7 @@
@Test public void testRecursive4Exception() throws Exception {
FakeMetadataFacade metadata = exampleMetadataCached();
FakeDataManager dataMgr = exampleDataManagerNested(metadata);
- helpTestProcess("SELECT * FROM xmltest.doc15", null, metadata, dataMgr, false, MetaMatrixComponentException.class, "Query processing should have failed on recursion limit."); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestProcess("SELECT * FROM xmltest.doc15", null, metadata, dataMgr, false, TeiidComponentException.class, "Query processing should have failed on recursion limit."); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -10059,7 +10061,7 @@
caps.setFunctionSupport("convert", true); //$NON-NLS-1$
CapabilitiesFinder capFinder = new DefaultCapabilitiesFinder(caps);
- helpTestProcess("SELECT * FROM xmltest.doc12260", expectedDoc, metadata, dataMgr, true, MetaMatrixComponentException.class, null, capFinder); //$NON-NLS-1$
+ helpTestProcess("SELECT * FROM xmltest.doc12260", expectedDoc, metadata, dataMgr, true, TeiidComponentException.class, null, capFinder); //$NON-NLS-1$
}
@Test public void testDefect8373() throws Exception{
@@ -10615,7 +10617,7 @@
FakeMetadataFacade metadata = exampleMetadataCached();
FakeDataManager dataMgr = exampleDataManagerNested(metadata);
- helpTestProcess("SELECT * FROM xmltest.doc8 WHERE rowlimitexception(supplier) = 2", null, metadata, dataMgr, false, MetaMatrixProcessingException.class, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestProcess("SELECT * FROM xmltest.doc8 WHERE rowlimitexception(supplier) = 2", null, metadata, dataMgr, false, TeiidProcessingException.class, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
/** Two row limits on the same mapping class should be harmless as long as the row limits are identical. */
@@ -10679,7 +10681,7 @@
FakeMetadataFacade metadata = exampleMetadataCached();
FakeDataManager dataMgr = exampleDataManagerNested(metadata);
- helpTestProcess("SELECT * FROM xmltest.doc8 WHERE rowlimitexception(supplier) = 2 AND rowlimitexception(supplierid) = 2", null, metadata, dataMgr, false, MetaMatrixProcessingException.class, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestProcess("SELECT * FROM xmltest.doc8 WHERE rowlimitexception(supplier) = 2 AND rowlimitexception(supplierid) = 2", null, metadata, dataMgr, false, TeiidProcessingException.class, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
/** compound criteria */
@@ -10719,7 +10721,7 @@
FakeMetadataFacade metadata = exampleMetadataCached();
FakeDataManager dataMgr = exampleDataManagerNested(metadata);
- helpTestProcess("SELECT * FROM xmltest.doc8 WHERE ItemID='002' AND rowlimitexception(supplier) = 2", null, metadata, dataMgr, false, MetaMatrixProcessingException.class, ""); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestProcess("SELECT * FROM xmltest.doc8 WHERE ItemID='002' AND rowlimitexception(supplier) = 2", null, metadata, dataMgr, false, TeiidProcessingException.class, ""); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testCase2951MaxRows4() throws Exception {
@@ -11903,7 +11905,7 @@
try {
helpTestProcess("SELECT * FROM xmltest.docBounded", expectedDoc, metadata, dataMgr); //$NON-NLS-1$
fail("should have failed the document restrictions."); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
// pass
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLValueTranslator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/TestXMLValueTranslator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/TestXMLValueTranslator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.math.BigInteger;
import java.sql.Timestamp;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.processor.xml.XMLValueTranslator;
+import org.teiid.query.unittest.TimestampUtil;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.unittest.TimestampUtil;
public class TestXMLValueTranslator extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xml/XMLProgramUtil.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xml/XMLProgramUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xml/XMLProgramUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
+import org.teiid.query.processor.xml.Condition;
+import org.teiid.query.processor.xml.IfInstruction;
+import org.teiid.query.processor.xml.ProcessorInstruction;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.RecurseProgramCondition;
+import org.teiid.query.processor.xml.WhileInstruction;
+
/**
*
*/
Copied: trunk/engine/src/test/java/org/teiid/query/processor/xquery (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/processor/xquery)
Modified: trunk/engine/src/test/java/org/teiid/query/processor/xquery/TestXQueryProcessor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/processor/xquery/TestXQueryProcessor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/processor/xquery/TestXQueryProcessor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,26 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xquery;
+package org.teiid.query.processor.xquery;
import java.util.Arrays;
import java.util.List;
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.FakeDataStore;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.processor.dynamic.SimpleQueryProcessorFactory;
-import com.metamatrix.query.processor.xml.TestXMLProcessor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
+import org.teiid.query.processor.FakeDataManager;
+import org.teiid.query.processor.FakeDataStore;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.processor.dynamic.SimpleQueryProcessorFactory;
+import org.teiid.query.processor.xml.TestXMLProcessor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.util.CommandContext;
+
/**
* Tests processing XQueries
*/
@@ -53,7 +53,7 @@
helpProcess(xquery, new List[] {Arrays.asList(expectedResult)}, dataMgr, metadata);
}
- private void helpTest(String sql, List[] expected) throws MetaMatrixComponentException {
+ private void helpTest(String sql, List[] expected) throws Exception {
FakeDataManager dataManager = new FakeDataManager();
TestProcessor.sampleData1(dataManager);
FakeMetadataFacade metadata = FakeMetadataFactory.exampleXQueryTransformations();
@@ -63,7 +63,7 @@
private void helpProcess(String sql, List[] expected,
FakeDataManager dataManager, FakeMetadataFacade metadata)
- throws MetaMatrixComponentException {
+ throws Exception {
ProcessorPlan plan = TestProcessor.helpGetPlan(sql, metadata);
CommandContext cc = TestProcessor.createCommandContext();
cc.setQueryProcessorFactory(new SimpleQueryProcessorFactory(BufferManagerFactory.getStandaloneBufferManager(), dataManager, new DefaultCapabilitiesFinder(), null, metadata));
Copied: trunk/engine/src/test/java/org/teiid/query/resolver (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/resolver)
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/CheckNoTempMetadataIDsVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/CheckNoTempMetadataIDsVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/CheckNoTempMetadataIDsVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import java.util.*;
-import java.util.ArrayList;
-import java.util.Collection;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.symbol.*;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.*;
+
/**
* Used to verify that all symbols in a LanguageObject were resolved
* with respect to runtime metadata - also that they aren't resolved
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/CheckSymbolsAreResolvedVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/CheckSymbolsAreResolvedVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/CheckSymbolsAreResolvedVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import java.util.ArrayList;
import java.util.Collection;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.symbol.*;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.symbol.*;
+
/**
* Used to verify that all symbols in a LanguageObject were resolved
* with respect to runtime metadata
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestAccessPattern.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestAccessPattern.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestAccessPattern.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.query.resolver.util.AccessPattern;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.resolver.util.AccessPattern;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
import junit.framework.TestCase;
public class TestAccessPattern extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestFunctionResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestFunctionResolving.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestFunctionResolving.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,23 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import static org.junit.Assert.*;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.unittest.FakeMetadataFactory;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestFunctionResolving {
@@ -120,14 +120,14 @@
}
private Function helpResolveFunction(String sql) throws QueryParserException,
- QueryResolverException, MetaMatrixComponentException {
+ QueryResolverException, TeiidComponentException {
Function func = getFunction(sql);
assertEquals(DataTypeManager.DefaultDataClasses.STRING, func.getType());
return func;
}
private Function getFunction(String sql) throws QueryParserException,
- MetaMatrixComponentException, QueryResolverException {
+ TeiidComponentException, QueryResolverException {
Function func = (Function)QueryParser.getQueryParser().parseExpression(sql);
ResolverVisitor.resolveLanguageObject(func, FakeMetadataFactory.example1Cached());
return func;
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestProcedureResolving.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestProcedureResolving.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import static org.junit.Assert.*;
@@ -30,37 +30,39 @@
import java.util.Map;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.ProcedureContainerResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
public class TestProcedureResolving {
@@ -93,7 +95,7 @@
if (msg != null) {
assertEquals(msg, ex.getMessage());
}
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new RuntimeException(e);
} catch (QueryParserException e) {
throw new RuntimeException(e);
@@ -101,7 +103,7 @@
}
public static Map getProcedureExternalMetadata(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Map externalMetadata = new HashMap();
//TODO: it doesn't seem like these should be in the
@@ -156,14 +158,14 @@
assertNull(tempIDs.get("LOOPCURSOR2")); //$NON-NLS-1$
}
- private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ private CreateUpdateProcedureCommand helpResolveUpdateProcedure(String procedure, String userUpdateStr, String procedureType) throws QueryParserException, QueryResolverException, TeiidComponentException {
QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
return resolveProcedure(userUpdateStr, metadata);
}
private CreateUpdateProcedureCommand resolveProcedure(String userUpdateStr,
QueryMetadataInterface metadata) throws QueryParserException,
- QueryResolverException, MetaMatrixComponentException,
+ QueryResolverException, TeiidComponentException,
QueryMetadataException {
ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
QueryResolver.resolveCommand(userCommand, metadata);
@@ -171,7 +173,7 @@
return (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
}
- private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, MetaMatrixComponentException {
+ private void helpResolveException(String userUpdateStr, QueryMetadataInterface metadata, String msg) throws QueryParserException, TeiidComponentException {
try {
helpResolve(userUpdateStr, metadata);
} catch (QueryResolverException e) {
@@ -179,7 +181,7 @@
}
}
- private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ private CreateUpdateProcedureCommand helpResolve(String userUpdateStr, QueryMetadataInterface metadata) throws QueryParserException, QueryResolverException, TeiidComponentException {
return resolveProcedure(userUpdateStr, metadata);
}
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import static org.junit.Assert.*;
@@ -39,61 +39,62 @@
import org.junit.Before;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.BindVariableVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.unittest.TimestampUtil;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.util.BindVariableVisitor;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.FunctionCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.unittest.TimestampUtil;
public class TestResolver {
@@ -108,7 +109,7 @@
static Command helpParse(String sql) {
try {
return QueryParser.getQueryParser().parseCommand(sql);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
}
@@ -170,7 +171,7 @@
// resolve
try {
QueryResolver.resolveCommand(command, queryMetadataInterface, analysis);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
@@ -191,7 +192,7 @@
QueryResolver.resolveCommand(command, metadata);
} catch(QueryResolverException e) {
exception = e;
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
assertNotNull("Expected a QueryResolverException but got none.", exception); //$NON-NLS-1$
@@ -204,14 +205,14 @@
try {
criteria = QueryParser.getQueryParser().parseCriteria(sql);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
// resolve
try {
QueryResolver.resolveCriteria(criteria, metadata);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
e.printStackTrace();
fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -232,7 +233,7 @@
if(bindings != null) {
try {
BindVariableVisitor.bindReferences(command, bindings, metadata);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Exception during binding (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
}
@@ -240,7 +241,7 @@
// resolve
try {
QueryResolver.resolveCommand(command, metadata);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -269,7 +270,7 @@
if(expectedExceptionMessage != null){
assertEquals(expectedExceptionMessage, e.getMessage());
}
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
throw new RuntimeException(e);
}
}
@@ -325,7 +326,7 @@
}
}
- private void helpTestIsXMLQuery(String sql, boolean isXML) throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+ private void helpTestIsXMLQuery(String sql, boolean isXML) throws QueryResolverException, QueryMetadataException, TeiidComponentException {
// parse
Query query = (Query) helpParse(sql);
@@ -1578,7 +1579,7 @@
actual = QueryParser.getQueryParser().parseCriteria("bqt1.smalla.shortvalue IN (1, 2)"); //$NON-NLS-1$
expected = QueryParser.getQueryParser().parseCriteria("convert(bqt1.smalla.shortvalue, integer) IN (1, 2)"); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Exception during parsing (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -1586,7 +1587,7 @@
try {
QueryResolver.resolveCriteria(expected, FakeMetadataFactory.exampleBQTCached());
QueryResolver.resolveCriteria(actual, FakeMetadataFactory.exampleBQTCached());
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Exception during resolution (" + e.getClass().getName() + "): " + e.getMessage()); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -2723,7 +2724,7 @@
assertEquals( sExpected, sActual );
}
- @Test public void testCase6319() throws QueryResolverException, MetaMatrixComponentException {
+ @Test public void testCase6319() throws QueryResolverException, TeiidComponentException {
String sql = "select floatnum from bqt1.smalla group by floatnum having sum(floatnum) between 51.0 and 100.0 "; //$NON-NLS-1$
Query query = (Query)helpParse(sql);
QueryResolver.resolveCommand(query, FakeMetadataFactory.exampleBQTCached());
Modified: trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/resolver/TestXMLResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/resolver/TestXMLResolver.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,29 +20,31 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver;
+package org.teiid.query.resolver;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.ElementSymbolOptimizer;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.ElementSymbolOptimizer;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestXMLResolver extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/rewriter (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/rewriter)
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestOrderByRewrite.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestOrderByRewrite.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,38 +20,39 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.rewriter;
+package org.teiid.query.rewriter;
-import static com.metamatrix.query.rewriter.TestQueryRewriter.*;
import static org.junit.Assert.*;
+import static org.teiid.query.rewriter.TestQueryRewriter.*;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.junit.Test;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
/**
* Converted from older resolver tests
*/
public class TestOrderByRewrite {
- private static Command getCommand(String sql) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private static Command getCommand(String sql) throws TeiidComponentException, TeiidProcessingException {
Command command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, FakeMetadataFactory.example1Cached());
Modified: trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/rewriter/TestQueryRewriter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.rewriter;
+package org.teiid.query.rewriter;
import static org.junit.Assert.*;
@@ -33,49 +33,50 @@
import org.junit.Ignore;
import org.junit.Test;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ContextProperties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.TimestampWithTimezone;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ContextProperties;
@SuppressWarnings("nls")
public class TestQueryRewriter {
@@ -93,7 +94,7 @@
QueryResolver.resolveCriteria(crit, metadata);
return crit;
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
}
@@ -106,7 +107,7 @@
}
}
- private Criteria helpTestRewriteCriteria(String original, String expected, boolean rewrite) throws QueryMetadataException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private Criteria helpTestRewriteCriteria(String original, String expected, boolean rewrite) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
Criteria expectedCrit = parseCriteria(expected, metadata);
if (rewrite) {
@@ -124,13 +125,13 @@
try {
actual = QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
assertEquals("Did not rewrite correctly: ", expectedCrit, actual); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
return actual;
}
- private Expression helpTestRewriteExpression(String original, String expected, QueryMetadataInterface metadata) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private Expression helpTestRewriteExpression(String original, String expected, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException {
Expression actualExp = QueryParser.getQueryParser().parseExpression(original);
ResolverVisitor.resolveLanguageObject(actualExp, metadata);
CommandContext context = new CommandContext();
@@ -144,15 +145,15 @@
return actualExp;
}
- private String getRewritenProcedure(String procedure, String userUpdateStr, String procedureType) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private String getRewritenProcedure(String procedure, String userUpdateStr, String procedureType) throws TeiidComponentException, TeiidProcessingException {
QueryMetadataInterface metadata = FakeMetadataFactory.exampleUpdateProc(procedureType, procedure);
return getRewritenProcedure(userUpdateStr, metadata);
}
private String getRewritenProcedure(String userUpdateStr,
- QueryMetadataInterface metadata) throws MetaMatrixComponentException,
- QueryMetadataException, MetaMatrixProcessingException {
+ QueryMetadataInterface metadata) throws TeiidComponentException,
+ QueryMetadataException, TeiidProcessingException {
ProcedureContainer userCommand = (ProcedureContainer)QueryParser.getQueryParser().parseCommand(userUpdateStr);
QueryResolver.resolveCommand(userCommand, metadata);
CreateUpdateProcedureCommand proc = (CreateUpdateProcedureCommand)QueryResolver.expandCommand(userCommand, metadata, null);
@@ -164,12 +165,12 @@
static Command helpTestRewriteCommand(String original, String expected) {
try {
return helpTestRewriteCommand(original, expected, FakeMetadataFactory.example1Cached());
- } catch(MetaMatrixException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch(TeiidException e) {
+ throw new TeiidRuntimeException(e);
}
}
- static Command helpTestRewriteCommand(String original, String expected, QueryMetadataInterface metadata) throws MetaMatrixException {
+ static Command helpTestRewriteCommand(String original, String expected, QueryMetadataInterface metadata) throws TeiidException {
Command command = QueryParser.getQueryParser().parseCommand(original);
QueryResolver.resolveCommand(command, metadata);
Command rewriteCommand = QueryRewriter.rewrite(command, metadata, null);
@@ -416,7 +417,7 @@
try {
QueryRewriter.rewriteCriteria(origCrit, null, null, null);
fail("Expected failure"); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
assertEquals("Error Code:ERR.015.001.0003 Message:Error simplifying criteria: PARSEDATE(pm3.g1.e1, '''') = {d'2003-05-01'}", e.getMessage()); //$NON-NLS-1$
}
}
@@ -1532,7 +1533,7 @@
try {
QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
fail("Expected QueryValidatorException due to divide by 0"); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
// looks like message is being wrapped with another exception with same message
assertEquals("Error Code:ERR.015.001.0003 Message:Unable to evaluate (5 / 0): Error Code:ERR.015.001.0003 Message:Error while evaluating function /", e.getMessage()); //$NON-NLS-1$
}
@@ -1546,7 +1547,7 @@
try {
QueryRewriter.rewriteCriteria(origCrit, null, null, metadata);
fail("Expected QueryValidatorException due to invalid string"); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
assertEquals("Error Code:ERR.015.001.0003 Message:Unable to evaluate convert('x', integer): Error Code:ERR.015.001.0003 Message:Error while evaluating function convert", e.getMessage()); //$NON-NLS-1$
}
}
@@ -1970,7 +1971,7 @@
new Class[] { DataTypeManager.DefaultDataClasses.STRING});
}
- private void verifyProjectedTypesOnUnionBranches(String unionQuery, Class<?>[] types) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void verifyProjectedTypesOnUnionBranches(String unionQuery, Class<?>[] types) throws TeiidComponentException, TeiidProcessingException {
SetQuery union = (SetQuery)QueryParser.getQueryParser().parseCommand(unionQuery);
QueryResolver.resolveCommand(union, FakeMetadataFactory.example1Cached());
@@ -2089,11 +2090,11 @@
* THEN e2 ELSE -1 END) FROM pm1.g1
* </table>
*
- * @see com.metamatrix.query.rewriter.QueryRewriter
- * @see com.metamatrix.query.sql.lang.BetweenCriteria
- * @see com.metamatrix.query.sql.lang.CompoundCriteria
- * @see com.metamatrix.query.sql.symbol.AggregateSymbol
- * @see com.metamatrix.query.sql.symbol.SearchedCaseExpression
+ * @see org.teiid.query.rewriter.QueryRewriter
+ * @see org.teiid.query.sql.lang.BetweenCriteria
+ * @see org.teiid.query.sql.lang.CompoundCriteria
+ * @see org.teiid.query.sql.symbol.AggregateSymbol
+ * @see org.teiid.query.sql.symbol.SearchedCaseExpression
*/
@Test public void testAggregateWithBetweenInCaseInSelect() {
// Define a list of aggregates to test against
@@ -2135,10 +2136,10 @@
* ELSE -1 END FROM pm1.g1
* </table>
*
- * @see com.metamatrix.query.rewriter.QueryRewriter
- * @see com.metamatrix.query.sql.lang.BetweenCriteria
- * @see com.metamatrix.query.sql.lang.CompoundCriteria
- * @see com.metamatrix.query.sql.symbol.SearchedCaseExpression
+ * @see org.teiid.query.rewriter.QueryRewriter
+ * @see org.teiid.query.sql.lang.BetweenCriteria
+ * @see org.teiid.query.sql.lang.CompoundCriteria
+ * @see org.teiid.query.sql.symbol.SearchedCaseExpression
*/
@Test public void testBetweenInCaseInSelect() {
String sqlBefore = "SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1"; //$NON-NLS-1$
@@ -2167,10 +2168,10 @@
* (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END
* </table>
*
- * @see com.metamatrix.query.rewriter.QueryRewriter
- * @see com.metamatrix.query.sql.lang.BetweenCriteria
- * @see com.metamatrix.query.sql.lang.CompoundCriteria
- * @see com.metamatrix.query.sql.symbol.SearchedCaseExpression
+ * @see org.teiid.query.rewriter.QueryRewriter
+ * @see org.teiid.query.sql.lang.BetweenCriteria
+ * @see org.teiid.query.sql.lang.CompoundCriteria
+ * @see org.teiid.query.sql.symbol.SearchedCaseExpression
*/
@Test public void testBetweenInCase() {
String sqlBefore = "SELECT * FROM pm1.g1 WHERE e3 = CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END"; //$NON-NLS-1$
Copied: trunk/engine/src/test/java/org/teiid/query/sql/lang (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/sql/lang)
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestAliasSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestAliasSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestAliasSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
public class TestAliasSymbol extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestBetweenCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestBetweenCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestBetweenCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
public class TestBetweenCriteria extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCompoundCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestCompoundCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCompoundCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
* @author amiller
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCreate.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestCreate.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCreate.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,16 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestCreate extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Arrays;
import java.util.Collection;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
import junit.framework.*;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDependentSetCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDependentSetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDependentSetCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDrop.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDrop.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDrop.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.*;
+
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
public class TestDrop extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDynamicCommand.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestDynamicCommand.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestDynamicCommand.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,19 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.SetClauseList;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
* Test for DynamicCommand
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestExpressionSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestExpressionSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestExpressionSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestIsNullCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestIsNullCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestIsNullCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
public class TestIsNullCriteria extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestJDBCExecutionHelper.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJDBCExecutionHelper.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
@@ -32,8 +32,8 @@
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.Literal;
import org.teiid.connector.language.Select;
+import org.teiid.core.types.DataTypeManager;
-import com.metamatrix.common.types.DataTypeManager;
public class TestJDBCExecutionHelper extends TestCase{
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJoinPredicate.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestJoinPredicate.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestJoinPredicate.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -19,16 +19,24 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
/**
* Test the <code>JoinPredicate</code> implementation to verify it is producing
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestLimit.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestLimit.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestLimit.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,10 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Reference;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Reference;
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestMatchCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestMatchCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
public class TestMatchCriteria extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestOption.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestOption.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestOption.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Arrays;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.Option;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestQuery.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestQuery.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestQuery.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,18 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.List;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.ClobType;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.BlobType;
-import com.metamatrix.common.types.ClobType;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestQuery extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSelect.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestSelect.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSelect.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
public class TestSelect extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSetCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestSetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSetCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.*;
+
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
public class TestSetCriteria extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSetQuery.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestSetQuery.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSetQuery.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestSetQuery extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSubqueryFromClause.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestSubqueryFromClause.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSubqueryFromClause.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestSubqueryFromClause extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSubquerySetCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/lang/TestSubquerySetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/lang/TestSubquerySetCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestSubquerySetCriteria extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/sql/proc (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/sql/proc)
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestAssignmentStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestAssignmentStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestAssignmentStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,21 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.Arrays;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestBlock.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBlock.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestBlock.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.List;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.Statement;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestBlock extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestBreakStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestBreakStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestBreakStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,10 +22,13 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.BreakStatement;
+import org.teiid.query.sql.proc.ContinueStatement;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestBreakStatement extends TestCase{
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCommandStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCommandStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCommandStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.proc.CommandStatement;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.*;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestContinueStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestContinueStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestContinueStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,11 +22,14 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.BreakStatement;
+import org.teiid.query.sql.proc.ContinueStatement;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* @author LLiang
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCreateUpdateProcedureCommand.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCreateUpdateProcedureCommand.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,21 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCriteriaSelector.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestCriteriaSelector.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestCriteriaSelector.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.*;
+
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.symbol.*;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.*;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestDeclareStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestDeclareStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestDeclareStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestHasCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestHasCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestHasCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,10 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.HasCriteria;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestIfStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestIfStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestIfStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.IfStatement;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.lang.*;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestLoopStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestLoopStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestLoopStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,16 +22,19 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestLoopStatement extends TestCase{
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestRaiseErrorStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestRaiseErrorStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestRaiseErrorStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.RaiseErrorStatement;
+import org.teiid.query.sql.symbol.Constant;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.symbol.Constant;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestTranslateCriteria.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestTranslateCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestTranslateCriteria.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,10 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.proc.TranslateCriteria;
+
import junit.framework.*;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*
Modified: trunk/engine/src/test/java/org/teiid/query/sql/proc/TestWhileStatement.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/proc/TestWhileStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/proc/TestWhileStatement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,12 +22,15 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.WhileStatement;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.sql.lang.Criteria;
public class TestWhileStatement extends TestCase{
Copied: trunk/engine/src/test/java/org/teiid/query/sql/symbol (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/sql/symbol)
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestAggregateSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestAggregateSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import junit.framework.TestCase;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestAggregateSymbol extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestCaseExpression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestCaseExpression.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.ArgCheck;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.query.sql.symbol.AbstractCaseExpression;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+
import junit.framework.TestCase;
public class TestCaseExpression extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestConstant.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestConstant.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,12 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.symbol.Constant;
+
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestConstant extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestElementSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestElementSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestElementSymbol extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestFunction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestFunction.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+
import junit.framework.TestCase;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestFunction extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestGroupSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestGroupSymbol.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,9 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
import junit.framework.TestCase;
Modified: trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/symbol/TestSearchedCaseExpression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/symbol/TestSearchedCaseExpression.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,14 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.lang.CompareCriteria;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+
import junit.framework.TestCase;
public class TestSearchedCaseExpression extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/sql/util (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/sql/util)
Modified: trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestElementSymbolOptimizer.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/util/TestElementSymbolOptimizer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,24 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.*;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.ElementSymbolOptimizer;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import junit.framework.*;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
/**
*/
@@ -51,7 +53,7 @@
super(name);
}
- public Command helpResolve(String sql, QueryMetadataInterface metadata, Map externalMetadata) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ public Command helpResolve(String sql, QueryMetadataInterface metadata, Map externalMetadata) throws QueryParserException, QueryResolverException, TeiidComponentException {
Command command = QueryParser.getQueryParser().parseCommand(sql);
final boolean USE_METADATA_COMMANDS = true;
@@ -61,12 +63,12 @@
}
- public void helpTestOptimize(String sql, QueryMetadataInterface metadata, String expected) throws QueryMetadataException, MetaMatrixComponentException, QueryParserException, QueryResolverException {
+ public void helpTestOptimize(String sql, QueryMetadataInterface metadata, String expected) throws QueryMetadataException, TeiidComponentException, QueryParserException, QueryResolverException {
this.helpTestOptimize(sql, metadata, expected, Collections.EMPTY_MAP);
}
- public void helpTestOptimize(String sql, QueryMetadataInterface metadata, String expected, Map externalMetadata) throws QueryMetadataException, MetaMatrixComponentException, QueryParserException, QueryResolverException {
+ public void helpTestOptimize(String sql, QueryMetadataInterface metadata, String expected, Map externalMetadata) throws QueryMetadataException, TeiidComponentException, QueryParserException, QueryResolverException {
Command command = helpResolve(sql, metadata, externalMetadata);
ElementSymbolOptimizer.optimizeElements(command, metadata);
String actual = command.toString();
@@ -125,7 +127,7 @@
"SELECT 1, 'xyz'"); //$NON-NLS-1$
}
- public void helpTestFullyQualify(String sql, QueryMetadataInterface metadata, String expected) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ public void helpTestFullyQualify(String sql, QueryMetadataInterface metadata, String expected) throws QueryParserException, QueryResolverException, TeiidComponentException {
Command command = helpResolve(sql, metadata, Collections.EMPTY_MAP);
ElementSymbolOptimizer.fullyQualifyElements(command);
String actual = command.toString();
Modified: trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/util/TestUpdateProcedureGenerator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/util/TestUpdateProcedureGenerator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,27 +20,28 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.Arrays;
import java.util.List;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.util.UpdateProcedureGenerator;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
/**
@@ -65,7 +66,7 @@
assertEquals("Didn't get expected generated procedure", expectedProc, actualProc.toString()); //$NON-NLS-1$
QueryParser.getQueryParser().parseCommand(actualProc.toString());
}
- } catch (MetaMatrixException e) {
+ } catch (TeiidException e) {
throw new RuntimeException(e);
}
}
Copied: trunk/engine/src/test/java/org/teiid/query/sql/visitor (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/sql/visitor)
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestAggregateSymbolCollectorVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestAggregateSymbolCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestAggregateSymbolCollectorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
public class TestAggregateSymbolCollectorVisitor extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestDeepGroupCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestDeepGroupCollectorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,17 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.Collection;
import java.util.Iterator;
+import org.teiid.core.TeiidException;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+
import junit.framework.TestCase;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class TestDeepGroupCollectorVisitor extends TestCase {
public TestDeepGroupCollectorVisitor(String name) {
@@ -42,7 +44,7 @@
try {
QueryParser parser = new QueryParser();
obj = parser.parseCommand(sql);
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
fail("Unexpected exception while parsing: " + e.getFullMessage()); //$NON-NLS-1$
}
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestEvaluatableVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestEvaluatableVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestEvaluatableVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,13 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import org.junit.Test;
+import org.teiid.query.resolver.TestResolver;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import static org.junit.Assert.*;
-import com.metamatrix.query.resolver.TestResolver;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestEvaluatableVisitor {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestExpressionMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestExpressionMappingVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import static org.junit.Assert.*;
@@ -32,21 +32,22 @@
import org.junit.Test;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.TestCaseExpression;
+import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
import org.teiid.resource.cci.SourceSystemFunctions;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.TestCaseExpression;
-import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
public class TestExpressionMappingVisitor {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestGroupCollectorVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestGroupCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestGroupCollectorVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,18 +28,20 @@
import java.util.List;
import java.util.Set;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+
import junit.framework.TestCase;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
*/
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestSQLStringVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestSQLStringVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -29,71 +29,72 @@
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.RaiseErrorStatement;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.TestCaseExpression;
+import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.unittest.FakeMetadataFactory;
import junit.framework.TestCase;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.RaiseErrorStatement;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.TestCaseExpression;
-import com.metamatrix.query.sql.symbol.TestSearchedCaseExpression;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class TestSQLStringVisitor extends TestCase {
Modified: trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/sql/visitor/TestStaticSymbolMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/sql/visitor/TestStaticSymbolMappingVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.HashMap;
@@ -28,36 +28,40 @@
import java.util.List;
import java.util.Map;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.StaticSymbolMappingVisitor;
+
import junit.framework.TestCase;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Symbol;
public class TestStaticSymbolMappingVisitor extends TestCase {
Copied: trunk/engine/src/test/java/org/teiid/query/unittest (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/unittest)
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFacade.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.unittest;
+package org.teiid.query.unittest;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,27 +29,27 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.metadata.BasicQueryMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingBaseNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.metadata.BasicQueryMetadata;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
public class FakeMetadataFacade extends BasicQueryMetadata {
@@ -71,7 +71,7 @@
}
public Object getElementID(String elementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Assertion.isNotNull(elementName);
@@ -83,7 +83,7 @@
}
public Object getGroupID(String groupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Assertion.isNotNull(groupName);
@@ -95,7 +95,7 @@
}
public Collection getGroupsForPartialName(String partialGroupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(partialGroupName == null) {
throw new QueryMetadataException("Group name cannot be null"); //$NON-NLS-1$
@@ -121,7 +121,7 @@
}
public Object getModelID(Object groupOrElementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupOrElementID);
FakeMetadataObject obj = (FakeMetadataObject) groupOrElementID;
@@ -129,34 +129,34 @@
}
public String getInsertPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject obj = (FakeMetadataObject) groupID;
return (String) obj.getProperty(FakeMetadataObject.Props.INSERT_PROCEDURE);
}
public String getUpdatePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject obj = (FakeMetadataObject) groupID;
return (String) obj.getProperty(FakeMetadataObject.Props.UPDATE_PROCEDURE);
}
public String getDeletePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject obj = (FakeMetadataObject) groupID;
return (String) obj.getProperty(FakeMetadataObject.Props.DELETE_PROCEDURE);
}
public String getFullName(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, metadataID);
return ((FakeMetadataObject)metadataID).getName();
}
public List getElementIDsInGroupID(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
List ids = store.findObjects(FakeMetadataObject.ELEMENT, FakeMetadataObject.Props.GROUP, groupID);
Collections.sort(ids);
@@ -164,34 +164,34 @@
}
public Object getGroupIDForElementID(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
return element.getProperty(FakeMetadataObject.Props.GROUP);
}
public String getElementType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
return (String) element.getProperty(FakeMetadataObject.Props.TYPE);
}
public Object getDefaultValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
return ((FakeMetadataObject)elementID).getDefaultValue();
}
public boolean isVirtualGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
return Boolean.TRUE.equals(group.getProperty(FakeMetadataObject.Props.IS_VIRTUAL));
}
public boolean isVirtualModel(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, modelID);
FakeMetadataObject model = (FakeMetadataObject) modelID;
return ((Boolean)model.getProperty(FakeMetadataObject.Props.IS_VIRTUAL)).booleanValue();
@@ -199,7 +199,7 @@
}
public QueryNode getVirtualPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
QueryNode queryNode = (QueryNode) group.getProperty(FakeMetadataObject.Props.PLAN);
@@ -210,7 +210,7 @@
}
public boolean modelSupports(Object modelID, int supportConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, modelID);
switch(supportConstant) {
default:
@@ -219,7 +219,7 @@
}
public boolean groupSupports(Object groupID, int groupConstant)
- throws MetaMatrixComponentException,QueryMetadataException {
+ throws TeiidComponentException,QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
Boolean supports = null;
@@ -234,7 +234,7 @@
}
public boolean elementSupports(Object elementID, int elementConstant)
- throws MetaMatrixComponentException,QueryMetadataException {
+ throws TeiidComponentException,QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
Boolean supports = null;
@@ -286,7 +286,7 @@
}
public int getMaxSetSize(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, modelID);
FakeMetadataObject model = (FakeMetadataObject) modelID;
Integer maxSetSize = (Integer) model.getProperty(FakeMetadataObject.Props.MAX_SET_SIZE);
@@ -297,7 +297,7 @@
}
public String getFullElementName(String fullGroupName, String shortElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Assertion.isNotNull(fullGroupName);
Assertion.isNotNull(shortElementName);
@@ -306,7 +306,7 @@
}
public String getShortElementName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Assertion.isNotNull(fullElementName);
@@ -318,7 +318,7 @@
}
public String getGroupName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Assertion.isNotNull(fullElementName);
@@ -331,7 +331,7 @@
public StoredProcedureInfo getStoredProcedureInfoForProcedure(String fullyQualifiedProcedureName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Assertion.isNotNull(fullyQualifiedProcedureName);
@@ -390,58 +390,58 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
*/
public Collection getIndexesInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return getTypeOfKeysInGroup(groupID, FakeMetadataObject.TYPE_INDEX);
}
public Collection getUniqueKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return getTypeOfKeysInGroup(groupID, FakeMetadataObject.TYPE_PRIMARY_KEY);
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getForeignKeysInGroup(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getForeignKeysInGroup(java.lang.Object)
*/
public Collection getForeignKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return getTypeOfKeysInGroup(groupID, FakeMetadataObject.TYPE_FOREIGN_KEY);
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getPrimaryKeyIDForForeignKeyID(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getPrimaryKeyIDForForeignKeyID(java.lang.Object)
*/
public Object getPrimaryKeyIDForForeignKeyID(Object foreignKeyID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, foreignKeyID);
FakeMetadataObject keyObj = (FakeMetadataObject) foreignKeyID;
return keyObj.getProperty(FakeMetadataObject.Props.REFERENCED_KEY);
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
*/
public List getElementIDsInIndex(Object index)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, index);
FakeMetadataObject keyObj = (FakeMetadataObject) index;
return (List)keyObj.getProperty(FakeMetadataObject.Props.KEY_ELEMENTS);
}
public List getElementIDsInKey(Object keyID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, keyID);
FakeMetadataObject keyObj = (FakeMetadataObject) keyID;
return (List)keyObj.getProperty(FakeMetadataObject.Props.KEY_ELEMENTS);
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(Object)
*/
public Collection getAccessPatternsInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return getTypeOfKeysInGroup(groupID, FakeMetadataObject.TYPE_ACCESS_PATTERN);
}
@@ -469,17 +469,17 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(Object)
*/
public List getElementIDsInAccessPattern(Object accessPattern)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, accessPattern);
FakeMetadataObject accessPatternObj = (FakeMetadataObject) accessPattern;
return (List)accessPatternObj.getProperty(FakeMetadataObject.Props.KEY_ELEMENTS);
}
public MappingNode getMappingNode(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
MappingDocument doc = (MappingDocument)group.getProperty(FakeMetadataObject.Props.PLAN);
@@ -487,7 +487,7 @@
return doc;
}
- public boolean isXMLGroup(Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isXMLGroup(Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
Object plan = group.getProperty(FakeMetadataObject.Props.PLAN);
@@ -497,11 +497,11 @@
return (plan instanceof MappingNode);
}
- public String getVirtualDatabaseName() throws MetaMatrixComponentException, QueryMetadataException {
+ public String getVirtualDatabaseName() throws TeiidComponentException, QueryMetadataException {
return "myvdb"; //$NON-NLS-1$
}
- public boolean isTemporaryTable(Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isTemporaryTable(Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
Boolean isTemp = (Boolean)group.getProperty(FakeMetadataObject.Props.TEMP);
@@ -512,7 +512,7 @@
}
public Collection getXMLTempGroups(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
MappingDocument mappingDoc = (MappingDocument)((FakeMetadataObject)groupID).getProperty(FakeMetadataObject.Props.PLAN);
@@ -537,7 +537,7 @@
private List resolveGroups(List groupNames)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if(groupNames != null && !groupNames.isEmpty()) {
ArrayList tempGroups = new ArrayList();
@@ -550,10 +550,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getCardinality(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getCardinality(java.lang.Object)
*/
public int getCardinality(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
Integer cardinality = (Integer)((FakeMetadataObject)groupID).getProperty(FakeMetadataObject.Props.CARDINALITY);
if (cardinality != null){
@@ -562,18 +562,18 @@
return QueryMetadataInterface.UNKNOWN_CARDINALITY;
}
- public String getNameInSource(Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getNameInSource(Object metadataID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, metadataID);
return (String)((FakeMetadataObject)metadataID).getProperty(FakeMetadataObject.Props.NAME_IN_SOURCE);
}
public Properties getExtensionProperties(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, metadataID);
return ((FakeMetadataObject)metadataID).getExtensionProps();
}
- public int getElementLength(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getElementLength(Object elementID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
return Integer.parseInt((String) element.getProperty(FakeMetadataObject.Props.LENGTH));
@@ -582,13 +582,13 @@
/**
* Return position of element in group or result set. Position returned is 1-based!
*/
- public int getPosition(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPosition(Object elementID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
return ((Integer) element.getProperty(FakeMetadataObject.Props.INDEX)).intValue() + 1;
}
- public int getPrecision(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPrecision(Object elementID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
String precision = (String) element.getProperty(FakeMetadataObject.Props.PRECISION);
@@ -598,7 +598,7 @@
return Integer.parseInt(precision);
}
- public int getRadix(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getRadix(Object elementID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
String radix = (String) element.getProperty(FakeMetadataObject.Props.RADIX);
@@ -608,7 +608,7 @@
return Integer.parseInt(radix);
}
- public int getScale(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getScale(Object elementID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
String scale = (String) element.getProperty(FakeMetadataObject.Props.SCALE);
@@ -619,7 +619,7 @@
}
- public String getNativeType(Object elementID) throws MetaMatrixComponentException,
+ public String getNativeType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
@@ -630,21 +630,21 @@
return nativeType;
}
- public boolean hasMaterialization(Object groupID) throws MetaMatrixComponentException,
+ public boolean hasMaterialization(Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject)groupID;
return group.getProperty(FakeMetadataObject.Props.MAT_GROUP) != null;
}
- public Object getMaterialization(Object groupID) throws MetaMatrixComponentException,
+ public Object getMaterialization(Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
return group.getProperty(FakeMetadataObject.Props.MAT_GROUP);
}
- public Object getMaterializationStage(Object groupID) throws MetaMatrixComponentException,
+ public Object getMaterializationStage(Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
@@ -652,21 +652,21 @@
return group.getProperty(FakeMetadataObject.Props.MAT_STAGE);
}
- public Object getMaximumValue(Object elementID) throws MetaMatrixComponentException,
+ public Object getMaximumValue(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
return element.getProperty(FakeMetadataObject.Props.MAX_VALUE);
}
- public Object getMinimumValue(Object elementID) throws MetaMatrixComponentException,
+ public Object getMinimumValue(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
return element.getProperty(FakeMetadataObject.Props.MIN_VALUE);
}
- public int getDistinctValues(Object elementID) throws MetaMatrixComponentException,
+ public int getDistinctValues(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject)elementID;
@@ -677,7 +677,7 @@
return -1;
}
- public int getNullValues(Object elementID) throws MetaMatrixComponentException,
+ public int getNullValues(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject)elementID;
@@ -688,7 +688,7 @@
return -1;
}
- public List getXMLSchemas(Object groupID) throws MetaMatrixComponentException,
+ public List getXMLSchemas(Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, groupID);
FakeMetadataObject group = (FakeMetadataObject) groupID;
@@ -701,23 +701,23 @@
return FakeMetadataObject.PROCEDURE.equals(element.getType());
}
- public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ public byte[] getBinaryVDBResource(String resourcePath) throws TeiidComponentException, QueryMetadataException {
return "ResourceContents".getBytes(); //$NON-NLS-1$
}
- public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getCharacterVDBResource(String resourcePath) throws TeiidComponentException, QueryMetadataException {
return "ResourceContents"; //$NON-NLS-1$
}
- public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
+ public String[] getVDBResourcePaths() throws TeiidComponentException, QueryMetadataException {
return new String[] {"my/resource/path"}; //$NON-NLS-1$
}
/**
- * @see com.metamatrix.query.metadata.BasicQueryMetadata#getModeledType(java.lang.Object)
+ * @see org.teiid.query.metadata.BasicQueryMetadata#getModeledType(java.lang.Object)
* @since 5.0
*/
- public String getModeledType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
@@ -726,10 +726,10 @@
}
/**
- * @see com.metamatrix.query.metadata.BasicQueryMetadata#getModeledBaseType(java.lang.Object)
+ * @see org.teiid.query.metadata.BasicQueryMetadata#getModeledBaseType(java.lang.Object)
* @since 5.0
*/
- public String getModeledBaseType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledBaseType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
@@ -738,10 +738,10 @@
}
/**
- * @see com.metamatrix.query.metadata.BasicQueryMetadata#getModeledPrimitiveType(java.lang.Object)
+ * @see org.teiid.query.metadata.BasicQueryMetadata#getModeledPrimitiveType(java.lang.Object)
* @since 5.0
*/
- public String getModeledPrimitiveType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledPrimitiveType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, elementID);
FakeMetadataObject element = (FakeMetadataObject) elementID;
@@ -750,7 +750,7 @@
@Override
public Object addToMetadataCache(Object metadataID, String key, Object value)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, metadataID);
FakeMetadataObject object = (FakeMetadataObject) metadataID;
synchronized (object) {
@@ -762,7 +762,7 @@
@Override
public Object getFromMetadataCache(Object metadataID, String key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(FakeMetadataObject.class, metadataID);
FakeMetadataObject object = (FakeMetadataObject) metadataID;
synchronized (object) {
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataFactory.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.unittest;
+package org.teiid.query.unittest;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,21 +33,21 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingSequenceNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
public class FakeMetadataFactory {
@@ -64,7 +64,7 @@
return RealMetadataFactory.exampleBQTCached();
}
- public static void setCardinality(String group, int cardinality, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ public static void setCardinality(String group, int cardinality, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
if (metadata instanceof TransformationMetadata) {
Table t = (Table)metadata.getGroupID(group);
t.setCardinality(cardinality);
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataObject.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataObject.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.unittest;
+package org.teiid.query.unittest;
import java.io.Serializable;
import java.util.HashMap;
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataStore.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/FakeMetadataStore.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/FakeMetadataStore.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.unittest;
+package org.teiid.query.unittest;
import java.util.*;
Modified: trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/unittest/RealMetadataFactory.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.unittest;
+package org.teiid.query.unittest;
import java.util.ArrayList;
import java.util.Arrays;
@@ -39,12 +39,12 @@
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.sql.lang.SPParameter;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.sql.lang.SPParameter;
public class RealMetadataFactory {
Copied: trunk/engine/src/test/java/org/teiid/query/util (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/util)
Modified: trunk/engine/src/test/java/org/teiid/query/util/TestPermutation.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/util/TestPermutation.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/util/TestPermutation.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.util;
+package org.teiid.query.util;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.NoSuchElementException;
-import com.metamatrix.query.util.Permutation;
+import org.teiid.query.util.Permutation;
+
import junit.framework.TestCase;
/**
Copied: trunk/engine/src/test/java/org/teiid/query/validator (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/validator)
Modified: trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/validator/TestValidator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/validator/TestValidator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import static org.junit.Assert.*;
@@ -36,40 +36,42 @@
import java.util.Set;
import org.junit.Test;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.unittest.FakeMetadataFacade;
+import org.teiid.query.unittest.FakeMetadataFactory;
+import org.teiid.query.unittest.FakeMetadataObject;
+import org.teiid.query.unittest.FakeMetadataStore;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorReport;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
@SuppressWarnings("nls")
public class TestValidator {
public static Map getStoredProcedureExternalMetadata(GroupSymbol virtualProc, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Map externalMetadata = new HashMap();
@@ -328,7 +330,7 @@
command = QueryParser.getQueryParser().parseCommand(sql);
QueryResolver.resolveCommand(command, externalMetadata, metadata, AnalysisRecord.createNonRecordingRecord());
} catch(Exception e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
return command;
@@ -365,8 +367,8 @@
assertEquals("Expected and actual sets of strings are not the same: ", expectedStrings, actualStrings); //$NON-NLS-1$
}
return report;
- } catch(MetaMatrixException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch(TeiidException e) {
+ throw new TeiidRuntimeException(e);
}
}
@@ -387,8 +389,8 @@
if(actualObjs.size() > 0) {
fail("Expected no failures but got some: " + report.getFailureMessage()); //$NON-NLS-1$
}
- } catch(MetaMatrixException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch(TeiidException e) {
+ throw new TeiidRuntimeException(e);
}
}
@@ -406,7 +408,7 @@
Collection actualObjs = new ArrayList();
report.collectInvalidObjects(actualObjs);
assertTrue("Expected some failures but got none for procedure = " + procedure, !actualObjs.isEmpty()); //$NON-NLS-1$
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
throw new RuntimeException(e);
}
}
Copied: trunk/engine/src/test/java/org/teiid/query/xquery (from rev 2112, trunk/engine/src/test/java/com/metamatrix/query/xquery)
Modified: trunk/engine/src/test/java/org/teiid/query/xquery/HardcodedSqlEval.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/xquery/HardcodedSqlEval.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/xquery/HardcodedSqlEval.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.xquery;
+package org.teiid.query.xquery;
import java.io.StringReader;
import java.util.Map;
@@ -28,13 +28,15 @@
import javax.xml.transform.Source;
import javax.xml.transform.stream.StreamSource;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.common.buffer.BlockedException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.xquery.XQuerySQLEvaluator;
+
/**
*/
public class HardcodedSqlEval implements XQuerySQLEvaluator {
@@ -46,7 +48,7 @@
}
public Source executeSQL(String sql)
- throws QueryParserException, MetaMatrixProcessingException, MetaMatrixComponentException {
+ throws QueryParserException, TeiidProcessingException, TeiidComponentException {
if (this.result != null) {
return new StreamSource(new StringReader(result));
}
@@ -54,15 +56,15 @@
}
/**
- * @see com.metamatrix.query.xquery.XQuerySQLEvaluator#close()
+ * @see org.teiid.query.xquery.XQuerySQLEvaluator#close()
*/
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
}
@Override
public Object getParameterValue(String key)
throws ExpressionEvaluationException, BlockedException,
- MetaMatrixComponentException {
+ TeiidComponentException {
return params.get(key);
}
Modified: trunk/engine/src/test/java/org/teiid/query/xquery/TestXQueryEngine.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/xquery/TestXQueryEngine.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/query/xquery/TestXQueryEngine.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.xquery;
+package org.teiid.query.xquery;
import java.io.File;
import java.io.IOException;
@@ -35,13 +35,15 @@
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.output.XMLOutputter;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.XMLTranslator;
+import org.teiid.core.util.FileUtil;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.query.xquery.XQueryExpression;
+import org.teiid.query.xquery.XQuerySQLEvaluator;
+import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.XMLTranslator;
-import com.metamatrix.core.util.FileUtil;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.xquery.saxon.SaxonXQueryExpression;
/**
* Test XQueryEngine and XQueryExpression implementations
@@ -77,7 +79,7 @@
try {
expr.evaluateXQuery(sqlEval);
fail("expected failure"); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
assertEquals(expectedFailure, e.getClass());
}
}
@@ -146,7 +148,7 @@
"}\n" + //$NON-NLS-1$
"</friends>"; //$NON-NLS-1$
- helpTestEngineFails(xquery, MetaMatrixProcessingException.class, new HardcodedSqlEval(xmlOutputter.outputString(doc)));
+ helpTestEngineFails(xquery, TeiidProcessingException.class, new HardcodedSqlEval(xmlOutputter.outputString(doc)));
}
public void testDocArgReadingFileURI() throws Exception {
Copied: trunk/engine/src/test/java/org/teiid/vdb/runtime (from rev 2112, trunk/engine/src/test/java/com/metamatrix/vdb/runtime)
Modified: trunk/engine/src/test/java/org/teiid/vdb/runtime/TestVDBKey.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/vdb/runtime/TestVDBKey.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/test/java/org/teiid/vdb/runtime/TestVDBKey.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.vdb.runtime;
+package org.teiid.vdb.runtime;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.vdb.runtime.VDBKey;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.vdb.runtime.VDBKey;
+
import junit.framework.TestCase;
public class TestVDBKey extends TestCase {
Copied: trunk/engine/src/test/resources/org (from rev 2113, trunk/engine/src/test/resources/com)
Copied: trunk/engine/src/test/resources/org/teiid (from rev 2113, trunk/engine/src/test/resources/com/metamatrix)
Deleted: trunk/engine/src/test/resources/org/teiid/query/mapping/xml/testExample.xml
===================================================================
--- trunk/engine/src/test/resources/com/metamatrix/query/mapping/xml/testExample.xml 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/engine/src/test/resources/org/teiid/query/mapping/xml/testExample.xml 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-
- 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.
-
--->
-<xmlMapping>
- <mappingNode>
- <name>root</name>
- <documentEncoding>UTF-16</documentEncoding>
- <formattedDocument>true</formattedDocument>
- <mappingNode>
- <name>element</name>
- <source>source</source>
- <mappingNode>
- <name>data</name>
- </mappingNode>
- <mappingNode>
- <name>recursionRoot</name>
- <isRecursive>true</isRecursive>
- <recursionCriteria>xxxx</recursionCriteria>
- <recursionLimit>1001</recursionLimit>
- <recursionLimitException>true</recursionLimitException>
- <recursionRootMappingClass>source</recursionRootMappingClass>
- <mappingNode>
- <name>data</name>
- </mappingNode>
- </mappingNode>
- </mappingNode>
- </mappingNode>
-</xmlMapping>
-
-
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/AdminObjectBuilder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -39,11 +39,11 @@
import org.jboss.metatype.api.values.MetaValueFactory;
import org.jboss.metatype.api.values.SimpleValue;
import org.teiid.adminapi.impl.TranslatorMetaData;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.jboss.IntegrationPlugin;
import org.teiid.templates.TranslatorMetadataICF;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.MetaMatrixRuntimeException;
public class AdminObjectBuilder {
@@ -96,9 +96,9 @@
}
return clazz.cast(t);
} catch (InstantiationException e) {
- throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
} catch (IllegalAccessException e) {
- throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
}
}
@@ -116,9 +116,9 @@
}
return clazz.cast(t);
} catch (InstantiationException e) {
- throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
} catch (IllegalAccessException e) {
- throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, IntegrationPlugin.Util.getString("class_not_found", clazz.getName())); //$NON-NLS-1$
}
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/jboss-integration/src/main/java/org/teiid/adminapi/jboss/ManagedUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -55,9 +55,9 @@
import org.jboss.metatype.api.values.SimpleValueSupport;
import org.jboss.profileservice.spi.DeploymentOption;
import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.jboss.IntegrationPlugin;
-import com.metamatrix.core.MetaMatrixRuntimeException;
public class ManagedUtil {
@@ -102,7 +102,7 @@
SimpleValue simple = (SimpleValue)v1;
return simple.getValue().toString();
}
- throw new MetaMatrixRuntimeException("Failed to convert value to string value"); //$NON-NLS-1$
+ throw new TeiidRuntimeException("Failed to convert value to string value"); //$NON-NLS-1$
}
return null;
}
@@ -189,7 +189,7 @@
try {
return new SimpleValueSupport(st, SimpleDateFormat.getInstance().parse(value));
} catch (ParseException e) {
- throw new MetaMatrixRuntimeException(e, IntegrationPlugin.Util.getString("failed_to_convert", type.getClassName())); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, IntegrationPlugin.Util.getString("failed_to_convert", type.getClassName())); //$NON-NLS-1$
}
} else if (SimpleMetaType.DOUBLE.equals(st)) {
return new SimpleValueSupport(st, Double.valueOf(value));
@@ -215,7 +215,7 @@
return new SimpleValueSupport(st,value);
}
}
- throw new MetaMatrixRuntimeException(IntegrationPlugin.Util.getString("failed_to_convert", type.getClassName())); //$NON-NLS-1$
+ throw new TeiidRuntimeException(IntegrationPlugin.Util.getString("failed_to_convert", type.getClassName())); //$NON-NLS-1$
}
public static void deployArchive(DeploymentManager deploymentManager, String fileName, final InputStream resource, boolean deployExploded) throws AdminProcessingException {
@@ -275,7 +275,7 @@
}
});
} catch (MalformedURLException e2) {
- throw new MetaMatrixRuntimeException(e2);
+ throw new TeiidRuntimeException(e2);
}
}
@@ -312,6 +312,6 @@
return mo.invoke(args);
}
}
- throw new MetaMatrixRuntimeException(IntegrationPlugin.Util.getString("no_operation", operation)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(IntegrationPlugin.Util.getString("no_operation", operation)); //$NON-NLS-1$
}
}
Modified: trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java
===================================================================
--- trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/IntegrationPlugin.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -23,8 +23,9 @@
import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
+
public class IntegrationPlugin {
private static final String PLUGIN_ID = "org.teiid.jboss" ; //$NON-NLS-1$
private static final String BUNDLE_NAME = PLUGIN_ID + ".i18n"; //$NON-NLS-1$
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 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/jboss-integration/src/main/java/org/teiid/jboss/deployers/RuntimeEngineDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -52,12 +52,19 @@
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
import org.teiid.client.util.ExceptionUtil;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.deployers.VDBRepository;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.transaction.TransactionServerImpl;
+import org.teiid.dqp.service.BufferService;
+import org.teiid.dqp.service.SessionService;
+import org.teiid.dqp.service.SessionServiceException;
+import org.teiid.dqp.service.TransactionService;
import org.teiid.jboss.IntegrationPlugin;
import org.teiid.logging.Log4jListener;
import org.teiid.logging.LogConstants;
@@ -70,13 +77,6 @@
import org.teiid.transport.SocketConfiguration;
import org.teiid.transport.SocketListener;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.SessionService;
-import com.metamatrix.dqp.service.SessionServiceException;
-import com.metamatrix.dqp.service.TransactionService;
@ManagementObject(isRuntime=true, componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class RuntimeEngineDeployer extends DQPConfiguration implements DQPManagement, Serializable , ClientServiceRegistry {
@@ -141,7 +141,7 @@
try {
this.dqpCore.stop();
- } catch(MetaMatrixRuntimeException e) {
+ } catch(TeiidRuntimeException e) {
// this bean is already shutdown
}
@@ -166,7 +166,7 @@
try {
this.admin = AdminProvider.getLocal();
} catch (AdminComponentException e) {
- throw new MetaMatrixRuntimeException(e.getCause());
+ throw new TeiidRuntimeException(e.getCause());
}
}
@@ -270,7 +270,7 @@
public boolean cancelRequest(String sessionId, long requestId) throws AdminException {
try {
return this.dqpCore.cancelRequest(sessionId, requestId);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new AdminComponentException(e);
}
}
Modified: trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestManagedUtil.java
===================================================================
--- trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestManagedUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/jboss-integration/src/test/java/org/teiid/adminapi/jboss/TestManagedUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,8 +28,8 @@
import java.net.URL;
import org.junit.Test;
+import org.teiid.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.ObjectConverterUtil;
public class TestManagedUtil {
Modified: trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/BlocksIndexInput.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,8 +20,8 @@
import org.teiid.core.index.IDocument;
import org.teiid.core.index.IEntryResult;
import org.teiid.core.index.IQueryResult;
+import org.teiid.core.util.LRUCache;
-import com.metamatrix.core.util.LRUCache;
/**
* This input is used for reading indexes saved using a BlocksIndexOutput.
Modified: trunk/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/internal/core/index/VirtualRandomAccessFile.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,8 +25,8 @@
import java.io.IOException;
import org.jboss.virtual.VirtualFile;
+import org.teiid.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.ObjectConverterUtil;
public class VirtualRandomAccessFile {
File indexFile;
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -42,6 +42,7 @@
import org.jboss.virtual.spi.VirtualFileHandler;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.ColumnSet;
@@ -53,19 +54,18 @@
import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.id.UUID;
import org.teiid.core.index.IEntryResult;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.StringUtil;
import org.teiid.internal.core.index.Index;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.metadata.VdbConstants;
import org.teiid.metadata.TransformationMetadata.Resource;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.id.UUID;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.core.vdb.VdbConstants;
/**
* Loads MetadataRecords from index files.
@@ -73,6 +73,9 @@
public class IndexMetadataFactory {
private Index[] indexes;
+ private RecordFactory recordFactory = new RecordFactory();
+ private Map<String, String> annotationCache = new HashMap<String, String>();
+ private Map<String, LinkedHashMap<String, String>> extensionCache = new HashMap<String, LinkedHashMap<String,String>>();
private Map<String, Datatype> datatypeCache;
private Map<String, KeyRecord> primaryKeyCache = new HashMap<String, KeyRecord>();
private Map<String, Table> tableCache = new HashMap<String, Table>();
@@ -119,7 +122,13 @@
tmp.add(index);
}
this.indexes = tmp.toArray(new Index[tmp.size()]);
+ getAnnotationCache();
+ getExtensionCache();
getDatatypeCache();
+ List<KeyRecord> keys = findMetadataRecords(MetadataConstants.RECORD_TYPE.PRIMARY_KEY, null, false);
+ for (KeyRecord keyRecord : keys) {
+ this.primaryKeyCache.put(keyRecord.getUUID(), keyRecord);
+ }
getModels();
getTables();
getProcedures();
@@ -131,6 +140,52 @@
return store;
}
+ private void getExtensionCache() {
+ IEntryResult[] properties = queryIndex(MetadataConstants.RECORD_TYPE.PROPERTY, null, false);
+
+ for (IEntryResult iEntryResult : properties) {
+ final String str = new String(iEntryResult.getWord());
+ final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+
+ // The tokens are the standard header values
+ int tokenIndex = 2;
+
+ String uuid = (String)tokens.get(1);
+ LinkedHashMap<String, String> result = this.extensionCache.get(uuid);
+ if (result == null) {
+ result = new LinkedHashMap<String, String>();
+ this.extensionCache.put(uuid, result);
+ }
+ result.put( (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
+ }
+ }
+
+ private void getAnnotationCache() {
+ IEntryResult[] results = queryIndex(MetadataConstants.RECORD_TYPE.ANNOTATION, null, false);
+
+ for (IEntryResult iEntryResult : results) {
+ final String str = new String(iEntryResult.getWord());
+ final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
+
+ // Extract the index version information from the record
+ int indexVersion = recordFactory.getIndexVersion(iEntryResult.getWord());
+
+
+ String uuid = (String)tokens.get(2);
+
+ // The tokens are the standard header values
+ int tokenIndex = 6;
+
+ if(recordFactory.includeAnnotationProperties(indexVersion)) {
+ // The next token are the properties, ignore it not going to be read any way
+ tokenIndex++;
+ }
+
+ // The next token is the description
+ this.annotationCache.put(uuid, (String)tokens.get(tokenIndex++));
+ }
+ }
+
public void addIndexFile(VirtualFile f) {
this.indexFiles.add(f);
}
@@ -289,12 +344,11 @@
}
private KeyRecord getPrimaryKey(String uuid) {
- KeyRecord pk = this.primaryKeyCache.get(uuid);
- if (pk == null) {
- pk = (KeyRecord)this.getRecordByType(uuid, MetadataConstants.RECORD_TYPE.PRIMARY_KEY);
- this.primaryKeyCache.put(uuid, pk);
- }
- return pk;
+ KeyRecord key = this.primaryKeyCache.get(uuid);
+ if (key == null) {
+ throw new TeiidRuntimeException(uuid+" PrimaryKey "+TransformationMetadata.NOT_EXISTS_MESSAGE); //$NON-NLS-1$
+ }
+ return key;
}
public Map<String, Datatype> getDatatypeCache() {
@@ -331,11 +385,11 @@
if(resultSize == 0) {
if (mustExist) {
// there should be only one for the UUID
- throw new MetaMatrixRuntimeException(entityName+TransformationMetadata.NOT_EXISTS_MESSAGE);
+ throw new TeiidRuntimeException(entityName+TransformationMetadata.NOT_EXISTS_MESSAGE);
}
return null;
}
- throw new MetaMatrixRuntimeException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.0", entityName)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("TransformationMetadata.0", entityName)); //$NON-NLS-1$
}
public void getProcedures() {
@@ -416,20 +470,13 @@
private List<AbstractMetadataRecord> loadRecords(
IEntryResult[] results) {
- List<AbstractMetadataRecord> records = RecordFactory.getMetadataRecord(results);
+ List<AbstractMetadataRecord> records = recordFactory.getMetadataRecord(results);
for (AbstractMetadataRecord metadataRecord : records) {
String uuid = metadataRecord.getUUID();
- String prefixString = getUUIDMatchPattern(MetadataConstants.RECORD_TYPE.ANNOTATION, uuid, false);
- IEntryResult[] annotations = queryIndex(MetadataConstants.RECORD_TYPE.ANNOTATION, prefixString.toCharArray(), false, true, true);
- if (annotations.length > 0) {
- metadataRecord.setAnnotation(RecordFactory.createAnnotationRecord(annotations[0].getWord()));
- }
-
- prefixString = String.valueOf(MetadataConstants.RECORD_TYPE.PROPERTY) + IndexConstants.RECORD_STRING.RECORD_DELIMITER + uuid.trim() + IndexConstants.RECORD_STRING.RECORD_DELIMITER;
- IEntryResult[] properties = queryIndex(MetadataConstants.RECORD_TYPE.PROPERTY, prefixString.toCharArray(), true, true, true);
- metadataRecord.setProperties(RecordFactory.createPropertyRecord(properties));
+ metadataRecord.setAnnotation(this.annotationCache.get(uuid));
+ metadataRecord.setProperties(this.extensionCache.get(uuid));
}
return records;
}
@@ -582,8 +629,8 @@
try {
return SimpleIndexUtil.queryIndex(search, pattern, isPrefix, isCaseSensitive, returnFirstMatch);
- } catch (MetaMatrixCoreException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch (TeiidException e) {
+ throw new TeiidRuntimeException(e);
}
}
}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/MetadataConstants.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,7 +22,7 @@
package org.teiid.metadata.index;
-import com.metamatrix.core.util.StringUtil;
+import org.teiid.core.util.StringUtil;
/**
* MetadataConstants are all the constant values used to identify all the valid values for a multi-value attribute.
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RecordFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,7 +25,6 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
-import java.util.LinkedHashMap;
import java.util.List;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
@@ -34,20 +33,20 @@
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.ForeignKey;
import org.teiid.connector.metadata.runtime.KeyRecord;
-import org.teiid.connector.metadata.runtime.Schema;
-import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.Procedure;
+import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.connector.metadata.runtime.Datatype.Variety;
+import org.teiid.core.id.UUID;
import org.teiid.core.index.IEntryResult;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.StringUtil;
import org.teiid.internal.core.index.EntryResult;
import org.teiid.internal.core.index.IIndexConstants;
-import com.metamatrix.core.id.UUID;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.StringUtil;
/**
* RuntimeAdapter
@@ -136,11 +135,9 @@
* The version number that is encoded with all newly created index records
*/
public static final int CURRENT_INDEX_VERSION = PROCEDURE_UPDATE_COUNT_VERSION;
-
- // ==================================================================================
- // P U B L I C M E T H O D S
- // ==================================================================================
+ private int version = NONVERSIONED_RECORD_INDEX_VERSION;
+
/**
* Return a collection of {@link com.metamatrix.modeler.core.metadata.runtime.MetadataRecord}
* instances for the result obtained from executing <code>queryEntriesMatching</code>
@@ -148,7 +145,7 @@
* @param queryResult
* @param container Container reference to be set on the record
*/
- public static List<AbstractMetadataRecord> getMetadataRecord(final IEntryResult[] queryResult) {
+ public List<AbstractMetadataRecord> getMetadataRecord(final IEntryResult[] queryResult) {
final List records = new ArrayList(queryResult.length);
for (int i = 0; i < queryResult.length; i++) {
final AbstractMetadataRecord record = getMetadataRecord(queryResult[i].getWord());
@@ -164,7 +161,7 @@
* instances for specified IEntryResult.
* @param entryResult
*/
- private static AbstractMetadataRecord getMetadataRecord(final char[] record) {
+ private AbstractMetadataRecord getMetadataRecord(final char[] record) {
if (record == null || record.length == 0) {
return null;
}
@@ -204,8 +201,6 @@
public static IEntryResult joinEntryResults(final IEntryResult result,
final IEntryResult[] continuationResults,
final int blockSize) {
- Assertion.isNotNull(result);
-
// If the IEntryResult is not continued on another record, return the original
char[] baseResult = result.getWord();
if (baseResult.length < blockSize || baseResult[blockSize-1] != MetadataConstants.RECORD_TYPE.RECORD_CONTINUATION) {
@@ -285,8 +280,6 @@
* @param result
*/
public static String extractUUIDString(final IEntryResult result) {
- Assertion.isNotNull(result);
-
char[] word = result.getWord();
String baseStr = new String(word);
int beginIndex = baseStr.indexOf(UUID.PROTOCOL);
@@ -309,7 +302,7 @@
/**
* Create a ModelRecord instance from the specified index record
*/
- public static Schema createModelRecord(final char[] record) {
+ public Schema createModelRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
final Schema model = new Schema();
@@ -342,7 +335,7 @@
/**
* Create a TransformationRecord instance from the specified index record
*/
- public static TransformationRecordImpl createTransformationRecord(final char[] record) {
+ public TransformationRecordImpl createTransformationRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
final TransformationRecordImpl transform = new TransformationRecordImpl();
@@ -394,7 +387,7 @@
/**
* Create a TableRecord instance from the specified index record
*/
- public static Table createTableRecord(final char[] record) {
+ public Table createTableRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
final Table table = new Table();
@@ -466,7 +459,7 @@
/**
* Create a ColumnRecord instance from the specified index record
*/
- public static Column createColumnRecord(final char[] record) {
+ public Column createColumnRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
final Column column = new Column();
@@ -553,7 +546,7 @@
/**
* Create a ColumnSetRecord instance from the specified index record
*/
- public static ColumnSet createColumnSetRecord(final char[] record, ColumnSet columnSet) {
+ public ColumnSet createColumnSetRecord(final char[] record, ColumnSet columnSet) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
@@ -583,7 +576,7 @@
/**
* Create a ForeignKeyRecord instance from the specified index record
*/
- public static ForeignKey createForeignKeyRecord(final char[] record) {
+ public ForeignKey createForeignKeyRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
final ForeignKey fkRecord = new ForeignKey();
@@ -613,7 +606,7 @@
/**
* Create a DatatypeRecord instance from the specified index record
*/
- public static Datatype createDatatypeRecord(final char[] record) {
+ public Datatype createDatatypeRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
final Datatype dt = new Datatype();
@@ -696,7 +689,7 @@
/**
* Create a ProcedureRecord instance from the specified index record
*/
- public static Procedure createProcedureRecord(final char[] record) {
+ public Procedure createProcedureRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
@@ -752,7 +745,7 @@
* Create a ProcedureParameterRecord instance from the specified index record
* header|defaultValue|dataType|length|radix|scale|nullType|precision|paramType|footer|
*/
- public static ProcedureParameter createProcedureParameterRecord(final char[] record) {
+ public ProcedureParameter createProcedureParameterRecord(final char[] record) {
final String str = new String(record);
final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
@@ -820,50 +813,6 @@
return paramRd;
}
-
- /**
- * Create a AnnotationRecord instance from the specified index record
- */
- public static String createAnnotationRecord(final char[] record) {
- final String str = new String(record);
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
-
- // Extract the index version information from the record
- int indexVersion = getIndexVersion(record);
-
- // The tokens are the standard header values
- int tokenIndex = 6;
-
- if(includeAnnotationProperties(indexVersion)) {
- // The next token are the properties, ignore it not going to be read any way
- tokenIndex++;
- }
-
- // The next token is the description
- return (String)tokens.get(tokenIndex++);
- }
-
- /**
- * Create a PropertyRecord instance from the specified index record
- */
- public static LinkedHashMap<String, String> createPropertyRecord(IEntryResult[] records) {
- if (records == null || records.length == 0) {
- return null;
- }
- LinkedHashMap<String, String> result = new LinkedHashMap<String, String>();
-
- for (IEntryResult iEntryResult : records) {
- final String str = new String(iEntryResult.getWord());
- final List tokens = StringUtil.split(str,String.valueOf(IndexConstants.RECORD_STRING.RECORD_DELIMITER));
-
- // The tokens are the standard header values
- int tokenIndex = 2;
-
- result.put( (String)tokens.get(tokenIndex++), (String)tokens.get(tokenIndex++));
- }
-
- return result;
- }
/**
* Search for and return the version number associated with this record.
@@ -872,38 +821,38 @@
* @param record
* @since 4.2
*/
- private static int getIndexVersion(final char[] record) {
- Assertion.isNotNull(record);
- int endIndex = record.length;
- int beginIndex = (endIndex - 6 > 0 ? endIndex - 6 : 1);
- int version = NONVERSIONED_RECORD_INDEX_VERSION;
- for (int i = beginIndex; i < endIndex; i++) {
- if (record[i] == IndexConstants.RECORD_STRING.INDEX_VERSION_MARKER) {
- char versionPart1 = record[i+1];
- char versionPart2 = record[i+2];
- if (Character.isDigit(versionPart1) && Character.isDigit(versionPart2)){
- version = Character.digit(versionPart1, 10) * 10 + Character.digit(versionPart2, 10);
- }
- }
- }
+ int getIndexVersion(final char[] record) {
+ if (version == NONVERSIONED_RECORD_INDEX_VERSION) {
+ int endIndex = record.length;
+ int beginIndex = (endIndex - 6 > 0 ? endIndex - 6 : 1);
+ for (int i = beginIndex; i < endIndex; i++) {
+ if (record[i] == IndexConstants.RECORD_STRING.INDEX_VERSION_MARKER) {
+ char versionPart1 = record[i+1];
+ char versionPart2 = record[i+2];
+ if (Character.isDigit(versionPart1) && Character.isDigit(versionPart2)){
+ version = Character.digit(versionPart1, 10) * 10 + Character.digit(versionPart2, 10);
+ }
+ }
+ }
+ }
return version;
}
- public static String getObjectValue(final String str) {
+ public String getObjectValue(final String str) {
if (str != null && str.length() == 1 && str.charAt(0) == IndexConstants.RECORD_STRING.SPACE) {
return null;
}
return str;
}
- public static boolean getBooleanValue(final char b) {
+ public boolean getBooleanValue(final char b) {
if (b == IndexConstants.RECORD_STRING.TRUE) {
return true;
}
return false;
}
- public static List<String> getIDs(final String values, final int indexVersionNumber) {
+ public List<String> getIDs(final String values, final int indexVersionNumber) {
if (StringUtil.isEmpty(values)) {
return Collections.EMPTY_LIST;
}
@@ -922,16 +871,16 @@
return result;
}
- public static List getStrings(final String values, final int indexVersionNumber) {
+ public List<String> getStrings(final String values, final int indexVersionNumber) {
if (StringUtil.isEmpty(values)) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
if (values.length() == 1 && values.charAt(0) == IndexConstants.RECORD_STRING.SPACE) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
final char listDelimiter = getListDelimiter(indexVersionNumber);
final List tokens = StringUtil.split(values,String.valueOf(listDelimiter));
- final List result = new ArrayList(tokens.size());
+ final List<String> result = new ArrayList<String>(tokens.size());
for (Iterator iter = tokens.iterator(); iter.hasNext();) {
String token = (String)iter.next();
if (token != null) {
@@ -941,63 +890,63 @@
return result;
}
- public static char getListDelimiter(final int indexVersionNumber) {
+ public char getListDelimiter(final int indexVersionNumber) {
if (indexVersionNumber < DELIMITER_INDEX_VERSION) {
return IndexConstants.RECORD_STRING.LIST_DELIMITER_OLD;
}
return IndexConstants.RECORD_STRING.LIST_DELIMITER;
}
- public static boolean includeMaterializationFlag(final int indexVersionNumber) {
+ public boolean includeMaterializationFlag(final int indexVersionNumber) {
if (indexVersionNumber < TABLE_MATERIALIZATION_INDEX_VERSION) {
return false;
}
return true;
}
- public static boolean includeMaterializedTables(final int indexVersionNumber) {
+ public boolean includeMaterializedTables(final int indexVersionNumber) {
if (indexVersionNumber < TABLE_MATERIALIZATION_INDEX_VERSION) {
return false;
}
return true;
}
- public static boolean includeColumnNativeType(final int indexVersionNumber) {
+ public boolean includeColumnNativeType(final int indexVersionNumber) {
if (indexVersionNumber < COLUMN_NATIVE_TYPE_INDEX_VERSION) {
return false;
}
return true;
}
- public static boolean includeColumnNullDistinctValues(final int indexVersionNumber) {
+ public boolean includeColumnNullDistinctValues(final int indexVersionNumber) {
if (indexVersionNumber < COLUMN_NULL_DISTINCT_INDEX_VERSION) {
return false;
}
return true;
}
- public static boolean includePrimitiveTypeIdValue(final int indexVersionNumber) {
+ public boolean includePrimitiveTypeIdValue(final int indexVersionNumber) {
if (indexVersionNumber < PRIMITIVE_TYPE_ID_INDEX_VERSION) {
return false;
}
return true;
}
- public static boolean includeInputParameterFlag(final int indexVersionNumber) {
+ public boolean includeInputParameterFlag(final int indexVersionNumber) {
if (indexVersionNumber < COLUMN_INPUT_PARAMETER_FLAG_INDEX_VERSION) {
return false;
}
return true;
}
- public static boolean includeAnnotationProperties(final int indexVersionNumber) {
+ public boolean includeAnnotationProperties(final int indexVersionNumber) {
if (indexVersionNumber < ANNOTATION_TAGS_INDEX_VERSION) {
return true;
}
return false;
}
- public static boolean includeTransformationUUID(final int indexVersionNumber) {
+ public boolean includeTransformationUUID(final int indexVersionNumber) {
if (indexVersionNumber < TRANSFORMATION_UUID_INDEX_VERSION) {
return false;
}
@@ -1008,10 +957,6 @@
return (indexVersionNumber >= PROCEDURE_UPDATE_COUNT_VERSION);
}
- public static int getCurrentIndexVersionNumber() {
- return CURRENT_INDEX_VERSION;
- }
-
// ==================================================================================
// P R I V A T E M E T H O D S
// ==================================================================================
@@ -1023,7 +968,7 @@
* The order of the fields in the index file header must also
* be the order of the arguments in method signature.
*/
- private static void setRecordHeaderValues(final AbstractMetadataRecord record, final String recordType,
+ private void setRecordHeaderValues(final AbstractMetadataRecord record, final String recordType,
final String upperName, final String objectID, String fullName,
final String nameInSource,
final String parentObjectID) {
@@ -1054,7 +999,7 @@
* The order of the fields in the index file header must also
* be the order of the arguments in method signature.
*/
- private static void setRecordFooterValues(final AbstractMetadataRecord record, final List tokens, int tokenIndex) {
+ private void setRecordFooterValues(final AbstractMetadataRecord record, final List tokens, int tokenIndex) {
if (record instanceof TransformationRecordImpl) {
((TransformationRecordImpl)record).setResourcePath(getOptionalToken(tokens, tokenIndex));
}
@@ -1066,7 +1011,7 @@
getOptionalToken(tokens, tokenIndex++);
}
- public static String getOptionalToken( final List tokens, int tokenIndex) {
+ public String getOptionalToken( final List tokens, int tokenIndex) {
if(tokens.size() > tokenIndex) {
return (String) tokens.get(tokenIndex);
}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/RuntimeMetadataPlugin.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,8 +24,9 @@
import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
+
/**
* CommonPlugin
* <p>Used here in <code>metadata.runtime</code> to have access to the new
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/SimpleIndexUtil.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,11 +26,11 @@
import java.util.ArrayList;
import java.util.List;
+import org.teiid.core.TeiidException;
import org.teiid.core.index.IEntryResult;
+import org.teiid.core.util.ArgCheck;
import org.teiid.internal.core.index.Index;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ArgCheck;
/**
* IndexUtil
@@ -60,7 +60,7 @@
* @return results
* @throws MetamatrixCoreException
*/
- public static IEntryResult[] queryIndex(final Index[] indexes, final char[] pattern, final boolean isPrefix, final boolean isCaseSensitive, final boolean returnFirstMatch) throws MetaMatrixCoreException {
+ public static IEntryResult[] queryIndex(final Index[] indexes, final char[] pattern, final boolean isPrefix, final boolean isCaseSensitive, final boolean returnFirstMatch) throws TeiidException {
final List<IEntryResult> queryResult = new ArrayList<IEntryResult>();
try {
@@ -104,7 +104,7 @@
}
}
} catch(IOException e) {
- throw new MetaMatrixCoreException(e);
+ throw new TeiidException(e);
}
return queryResult.toArray(new IEntryResult[queryResult.size()]);
Modified: trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java
===================================================================
--- trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/test/java/com/metamatrix/cdk/api/TranslationUtility.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,19 +26,19 @@
import java.net.URL;
import java.util.Collection;
+import org.teiid.cdk.CommandBuilder;
import org.teiid.connector.language.Command;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.metadata.BasicQueryMetadataWrapper;
+import org.teiid.query.metadata.QueryMetadataInterface;
-import com.metamatrix.cdk.CommandBuilder;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionTree;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.function.UDFSource;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.metadata.BasicQueryMetadataWrapper;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
/**
* <p>This translation utility can be used to translate sql strings into
Modified: trunk/metadata/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java
===================================================================
--- trunk/metadata/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/test/java/com/metamatrix/cdk/unittest/FakeTranslationFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,8 +22,9 @@
package com.metamatrix.cdk.unittest;
+import org.teiid.query.unittest.FakeMetadataFactory;
+
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
public class FakeTranslationFactory {
Modified: trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
--- trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,16 +32,16 @@
import java.util.Collection;
import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.FileUtils;
+import org.teiid.core.util.LRUCache;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.function.metadata.FunctionMetadataReader;
+import org.teiid.query.function.metadata.FunctionMethod;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.function.metadata.FunctionMetadataReader;
-import com.metamatrix.query.function.metadata.FunctionMethod;
@SuppressWarnings("nls")
public class VDBMetadataFactory {
@@ -52,7 +52,7 @@
try {
return getVDBMetadata(new File(vdbFile).toURI().toURL(), null);
} catch (IOException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
@@ -61,7 +61,7 @@
IndexMetadataFactory imf = loadMetadata(Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB));
return imf.getMetadataStore();
} catch (Exception e) {
- throw new MetaMatrixRuntimeException("System VDB not found");
+ throw new TeiidRuntimeException("System VDB not found");
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -33,10 +33,10 @@
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.metadata.TransformationMetadata.Resource;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.vdb.runtime.VDBKey;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.vdb.runtime.VDBKey;
public class CompositeVDB {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/DynamicVDBDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,10 +29,10 @@
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.CoreConstants;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import com.metamatrix.core.CoreConstants;
public class DynamicVDBDeployer extends AbstractVFSParsingDeployer<VDBMetaData> {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/ExtendedPropertyMetadata.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/ExtendedPropertyMetadata.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/ExtendedPropertyMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -23,8 +23,9 @@
import java.util.ArrayList;
-import com.metamatrix.core.MetaMatrixRuntimeException;
+import org.teiid.core.TeiidRuntimeException;
+
/**
* This is used with ra.xml properties file to extend the metadata on the properties.
*/
@@ -55,7 +56,7 @@
}
if (!encodedData.endsWith("}")) { //$NON-NLS-1$
- throw new MetaMatrixRuntimeException("The description field = "+encodedData+" does not end with \"}\""); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new TeiidRuntimeException("The description field = "+encodedData+" does not end with \"}\""); //$NON-NLS-1$ //$NON-NLS-2$
}
encodedData = encodedData.substring(1, encodedData.length()-1);
Modified: trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/ObjectSerializer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,11 +30,11 @@
import org.jboss.deployers.vfs.spi.structure.VFSDeploymentUnit;
import org.jboss.logging.Logger;
+import org.teiid.core.util.FileUtils;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.runtime.RuntimePlugin;
-import com.metamatrix.core.util.FileUtils;
public class ObjectSerializer {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/SystemVDBDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,12 +25,12 @@
import java.net.URISyntaxException;
import java.net.URL;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.metadata.index.RuntimeMetadataPlugin;
import org.teiid.runtime.RuntimePlugin;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.MetaMatrixRuntimeException;
public class SystemVDBDeployer {
private VDBRepository vdbRepository;
@@ -40,13 +40,13 @@
try {
URL url = Thread.currentThread().getContextClassLoader().getResource(CoreConstants.SYSTEM_VDB);
if (url == null) {
- throw new MetaMatrixRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(RuntimeMetadataPlugin.Util.getString("system_vdb_not_found")); //$NON-NLS-1$
}
this.vdbRepository.setSystemStore(new IndexMetadataFactory(url).getMetadataStore());
} catch (URISyntaxException e) {
- throw new MetaMatrixRuntimeException(e, RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
} catch (IOException e) {
- throw new MetaMatrixRuntimeException(e, RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("failed_to_deployed", CoreConstants.SYSTEM_VDB)); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/TranslatorDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,6 +32,8 @@
import org.jboss.deployers.structure.spi.DeploymentUnit;
import org.jboss.managed.api.annotation.ManagementProperty;
import org.teiid.adminapi.impl.TranslatorMetaData;
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.ReflectionHelper;
import org.teiid.dqp.internal.datamgr.impl.TranslatorRepository;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -39,8 +41,6 @@
import org.teiid.resource.cci.TranslatorProperty;
import org.teiid.runtime.RuntimePlugin;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.core.util.ReflectionHelper;
/**
* Deployer for the Translator
@@ -104,7 +104,7 @@
executionFactory.start();
return executionFactory;
- } catch (MetaMatrixCoreException e) {
+ } catch (TeiidException e) {
throw new DeploymentException(e);
} catch (ResourceException e) {
throw new DeploymentException(e);
Modified: trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/UDFMetaData.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,10 +28,10 @@
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.virtual.VirtualFile;
+import org.teiid.query.function.metadata.FunctionMetadataReader;
+import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.runtime.RuntimePlugin;
-import com.metamatrix.query.function.metadata.FunctionMetadataReader;
-import com.metamatrix.query.function.metadata.FunctionMethod;
@ManagementObject
public class UDFMetaData {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -36,6 +36,8 @@
import org.teiid.adminapi.impl.SourceMappingMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.util.FileUtils;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
@@ -48,8 +50,6 @@
import org.teiid.resource.cci.ExecutionFactory;
import org.teiid.runtime.RuntimePlugin;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.util.FileUtils;
public class VDBDeployer extends AbstractSimpleRealDeployer<VDBMetaData> {
private VDBRepository vdbRepository;
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBParserDeployer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -44,15 +44,15 @@
import org.teiid.adminapi.Model;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.CoreConstants;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.metadata.VdbConstants;
import org.teiid.metadata.index.IndexConstants;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.runtime.RuntimePlugin;
import org.xml.sax.SAXException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.vdb.VdbConstants;
/**
* This file loads the "vdb.xml" file inside a ".vdb" file, along with all the metadata in the .INDEX files
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -37,11 +37,11 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.metadata.TransformationMetadata.Resource;
import org.teiid.runtime.RuntimePlugin;
+import org.teiid.vdb.runtime.VDBKey;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.vdb.runtime.VDBKey;
/**
* Repository for VDBs
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VDBStructure.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,8 +28,8 @@
import org.jboss.deployers.vfs.spi.structure.StructureContext;
import org.jboss.virtual.VirtualFile;
import org.jboss.virtual.plugins.context.jar.JarUtils;
+import org.teiid.metadata.VdbConstants;
-import com.metamatrix.core.vdb.VdbConstants;
public class VDBStructure extends AbstractVFSStructureDeployer{
Modified: trunk/runtime/src/main/java/org/teiid/deployers/VirtualDatabaseException.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/VirtualDatabaseException.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/deployers/VirtualDatabaseException.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,11 +22,11 @@
package org.teiid.deployers;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import org.teiid.core.TeiidProcessingException;
/**
* The base exception from which all Runtime Metadata Exceptions extend.
*/
-public class VirtualDatabaseException extends MetaMatrixProcessingException {
+public class VirtualDatabaseException extends TeiidProcessingException {
public static final String NO_MODELS = "1"; //$NON-NLS-1$
public static final String MODEL_NON_DEPLOYABLE_STATE = "2"; //$NON-NLS-1$
Modified: trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/runtime/RuntimePlugin.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -23,8 +23,9 @@
import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
+
public class RuntimePlugin {
private static final String PLUGIN_ID = "org.teiid.runtime" ; //$NON-NLS-1$
private static final String BUNDLE_NAME = PLUGIN_ID + ".i18n"; //$NON-NLS-1$
Modified: trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/services/BufferServiceImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,18 +30,18 @@
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
+import org.teiid.cache.CacheFactory;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.common.buffer.impl.FileStorageManager;
+import org.teiid.common.buffer.impl.MemoryStorageManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.FileUtils;
import org.teiid.dqp.internal.cache.DQPContextCache;
+import org.teiid.dqp.service.BufferService;
import org.teiid.runtime.RuntimePlugin;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.buffer.impl.FileStorageManager;
-import com.metamatrix.common.buffer.impl.MemoryStorageManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.dqp.service.BufferService;
/**
* Implement the BufferService for the DQP Embedded component. This implementation
@@ -104,10 +104,10 @@
this.bufferMgr.setStorageManager(new MemoryStorageManager());
}
- } catch(MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e, RuntimePlugin.Util.getString("LocalBufferService.Failed_initializing_buffer_manager._8")); //$NON-NLS-1$
+ } catch(TeiidComponentException e) {
+ throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("LocalBufferService.Failed_initializing_buffer_manager._8")); //$NON-NLS-1$
} catch(IOException e) {
- throw new MetaMatrixRuntimeException(e, RuntimePlugin.Util.getString("LocalBufferService.Failed_initializing_buffer_manager._8")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(e, RuntimePlugin.Util.getString("LocalBufferService.Failed_initializing_buffer_manager._8")); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/services/SessionServiceImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -44,9 +44,12 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.security.InvalidSessionException;
import org.teiid.client.security.SessionToken;
+import org.teiid.core.util.ArgCheck;
import org.teiid.deployers.VDBRepository;
import org.teiid.deployers.VirtualDatabaseException;
import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.service.SessionService;
+import org.teiid.dqp.service.SessionServiceException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.net.ServerConnection;
@@ -55,9 +58,6 @@
import org.teiid.security.Credentials;
import org.teiid.security.SecurityHelper;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.dqp.service.SessionService;
-import com.metamatrix.dqp.service.SessionServiceException;
/**
* This class serves as the primary implementation of the Session Service.
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientInstance.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientInstance.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,11 +24,11 @@
import java.io.Serializable;
+import org.teiid.core.crypto.Cryptor;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.net.CommunicationException;
import org.teiid.net.socket.Message;
-import com.metamatrix.common.util.crypto.Cryptor;
/**
* Represents a ClientConnection from the server's point of view. This interface
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistry.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,9 +22,9 @@
package org.teiid.transport;
+import org.teiid.core.ComponentNotFoundException;
import org.teiid.security.SecurityHelper;
-import com.metamatrix.api.exception.ComponentNotFoundException;
public interface ClientServiceRegistry {
Modified: trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/ClientServiceRegistryImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,11 +24,11 @@
import java.util.HashMap;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.util.ReflectionHelper;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.security.SecurityHelper;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.core.util.ReflectionHelper;
public class ClientServiceRegistryImpl implements ClientServiceRegistry {
Modified: trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/LocalServerConnection.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -38,14 +38,14 @@
import org.teiid.client.security.LogonException;
import org.teiid.client.security.LogonResult;
import org.teiid.client.util.ExceptionUtil;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.NetPlugin;
import org.teiid.net.ServerConnection;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
public class LocalServerConnection implements ServerConnection {
private static final String TEIID_RUNTIME = "teiid/engine-deployer"; //$NON-NLS-1$
@@ -66,7 +66,7 @@
InitialContext ic = new InitialContext();
return (ClientServiceRegistry)ic.lookup(TEIID_RUNTIME);
} catch (NamingException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
@@ -78,7 +78,7 @@
// Propagate the original message as it contains the message we want
// to give to the user
throw new ConnectionException(e, e.getMessage());
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
if (e.getCause() instanceof CommunicationException) {
throw (CommunicationException)e.getCause();
}
@@ -91,7 +91,7 @@
public Object invoke(Object arg0, final Method arg1, final Object[] arg2) throws Throwable {
if (!isOpen()) {
- throw ExceptionUtil.convertException(arg1, new MetaMatrixComponentException(NetPlugin.Util.getString("LocalTransportHandler.Transport_shutdown"))); //$NON-NLS-1$
+ throw ExceptionUtil.convertException(arg1, new TeiidComponentException(NetPlugin.Util.getString("LocalTransportHandler.Transport_shutdown"))); //$NON-NLS-1$
}
try {
final T service = csr.getClientService(iface);
Modified: trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/LogonImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -33,17 +33,17 @@
import org.teiid.client.security.LogonResult;
import org.teiid.client.security.SessionToken;
import org.teiid.client.util.ResultsFuture;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidComponentException;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.service.SessionService;
+import org.teiid.dqp.service.SessionServiceException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.net.TeiidURL;
import org.teiid.security.Credentials;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.dqp.service.SessionService;
-import com.metamatrix.dqp.service.SessionServiceException;
public class LogonImpl implements ILogon {
@@ -97,7 +97,7 @@
return ResultsFuture.NULL_FUTURE;
}
- public ResultsFuture<?> ping() throws InvalidSessionException,MetaMatrixComponentException {
+ public ResultsFuture<?> ping() throws InvalidSessionException,TeiidComponentException {
// ping is double used to alert the aliveness of the client, as well as check the server instance is
// alive by socket server instance, so that they can be cached.
String id = DQPWorkContext.getWorkContext().getSessionId();
@@ -109,12 +109,12 @@
}
@Override
- public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, MetaMatrixComponentException {
+ public void assertIdentity(SessionToken checkSession) throws InvalidSessionException, TeiidComponentException {
SessionMetadata sessionInfo = null;
try {
sessionInfo = this.service.validateSession(checkSession.getSessionID());
} catch (SessionServiceException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
if (sessionInfo == null) {
Modified: trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/ObjectDecoder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -39,15 +39,15 @@
import org.jboss.netty.handler.codec.serialization.CompatibleObjectDecoder;
import org.jboss.netty.handler.codec.serialization.CompatibleObjectEncoder;
import org.jboss.netty.handler.codec.serialization.ObjectEncoder;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.InputStreamFactory.StreamFactoryReference;
+import org.teiid.core.util.ExternalizeUtil;
import org.teiid.netty.handler.codec.serialization.CompactObjectInputStream;
import org.teiid.netty.handler.codec.serialization.ObjectEncoderOutputStream;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.common.types.InputStreamFactory;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.InputStreamFactory.StreamFactoryReference;
-import com.metamatrix.core.util.ExternalizeUtil;
/**
* A decoder which deserializes the received {@link ChannelBuffer}s into Java
Modified: trunk/runtime/src/main/java/org/teiid/transport/ObjectEncoder.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ObjectEncoder.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/ObjectEncoder.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -40,10 +40,10 @@
import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.handler.stream.ChunkedInput;
import org.jboss.netty.handler.stream.ChunkedStream;
+import org.teiid.core.util.ExternalizeUtil;
import org.teiid.netty.handler.codec.serialization.CompactObjectOutputStream;
import org.teiid.netty.handler.codec.serialization.ObjectDecoderInputStream;
-import com.metamatrix.core.util.ExternalizeUtil;
/**
* An encoder which serializes a Java object into a {@link ChannelBuffer}.
Modified: trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/SSLAwareChannelHandler.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -51,12 +51,12 @@
import org.jboss.netty.channel.SimpleChannelHandler;
import org.jboss.netty.handler.ssl.SslHandler;
import org.jboss.netty.handler.stream.ChunkedWriteHandler;
+import org.teiid.common.buffer.StorageManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.net.NetPlugin;
import org.teiid.net.socket.ObjectChannel;
-import com.metamatrix.common.buffer.StorageManager;
/**
* Main class for creating Netty Nio Channels
Modified: trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,9 +30,9 @@
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLEngine;
+import org.teiid.core.util.Assertion;
import org.teiid.net.socket.SocketUtil;
-import com.metamatrix.core.util.Assertion;
public class SSLConfiguration {
Modified: trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/ServerWorkItem.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -33,7 +33,11 @@
import javax.crypto.SealedObject;
import org.teiid.adminapi.AdminProcessingException;
+import org.teiid.client.util.ExceptionHolder;
import org.teiid.client.util.ResultsFuture;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.crypto.CryptoException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.net.socket.Message;
@@ -41,10 +45,6 @@
import org.teiid.runtime.RuntimePlugin;
import org.teiid.transport.ClientServiceRegistryImpl.ClientService;
-import com.metamatrix.api.exception.ExceptionHolder;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
public class ServerWorkItem implements Runnable {
@@ -121,7 +121,7 @@
try {
result.setContents(socketClientInstance.getCryptor().sealObject(result.getContents()));
} catch (CryptoException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
socketClientInstance.send(result, messageKey);
@@ -134,7 +134,7 @@
// Case 5558: Differentiate between system level errors and
// processing errors. Only log system level errors as errors,
// log the processing errors as warnings only
- if (e instanceof MetaMatrixProcessingException) {
+ if (e instanceof TeiidProcessingException) {
logProcessingException(e, context);
} else if (e instanceof AdminProcessingException) {
logProcessingException(e, context);
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketClientInstance.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,6 +27,10 @@
import java.net.SocketAddress;
import org.teiid.client.security.ILogon;
+import org.teiid.core.crypto.CryptoException;
+import org.teiid.core.crypto.Cryptor;
+import org.teiid.core.crypto.DhKeyGenerator;
+import org.teiid.core.crypto.NullCryptor;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
@@ -37,10 +41,6 @@
import org.teiid.net.socket.Message;
import org.teiid.net.socket.ObjectChannel;
-import com.metamatrix.common.util.crypto.CryptoException;
-import com.metamatrix.common.util.crypto.Cryptor;
-import com.metamatrix.common.util.crypto.DhKeyGenerator;
-import com.metamatrix.common.util.crypto.NullCryptor;
/**
* Sockets implementation of the communication framework class representing the server's view of a client connection.
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketConfiguration.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,8 +28,8 @@
import org.jboss.managed.api.annotation.ManagementObject;
import org.jboss.managed.api.annotation.ManagementProperties;
import org.jboss.managed.api.annotation.ManagementProperty;
+import org.teiid.core.TeiidRuntimeException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
@ManagementObject(componentType=@ManagementComponent(type="teiid",subtype="dqp"), properties=ManagementProperties.EXPLICIT)
public class SocketConfiguration {
@@ -82,7 +82,7 @@
this.hostName = InetAddress.getLocalHost().getHostName();
}
} catch (UnknownHostException e) {
- throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+ throw new TeiidRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
}
}
@@ -128,7 +128,7 @@
}
return addr;
} catch (UnknownHostException e) {
- throw new MetaMatrixRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
+ throw new TeiidRuntimeException("Failed to resolve the bind address"); //$NON-NLS-1$
}
}
Modified: trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/main/java/org/teiid/transport/SocketListener.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,6 +30,9 @@
import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.ChannelFactory;
import org.jboss.netty.channel.socket.nio.NioServerSocketChannelFactory;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.core.util.ApplicationInfo;
+import org.teiid.core.util.NamedThreadFactory;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
@@ -37,9 +40,6 @@
import org.teiid.runtime.RuntimePlugin;
import org.teiid.transport.ChannelListener.ChannelListenerFactory;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.core.util.NamedThreadFactory;
/**
* Server-side class to listen for new connection requests and create a SocketClientConnection for each connection request.
Modified: trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java
===================================================================
--- trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/test/java/com/metamatrix/dqp/service/buffer/TestLocalBufferService.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -22,13 +22,13 @@
package com.metamatrix.dqp.service.buffer;
+import org.teiid.common.buffer.impl.BufferManagerImpl;
+import org.teiid.common.buffer.impl.FileStorageManager;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.services.BufferServiceImpl;
import junit.framework.TestCase;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.buffer.impl.FileStorageManager;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestLocalBufferService extends TestCase {
Modified: trunk/runtime/src/test/java/org/teiid/deployers/TestObjectSerializer.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/deployers/TestObjectSerializer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/test/java/org/teiid/deployers/TestObjectSerializer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,8 +27,8 @@
import java.io.File;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestObjectSerializer {
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -38,6 +38,11 @@
import org.teiid.client.security.ILogon;
import org.teiid.client.security.LogonException;
import org.teiid.client.security.LogonResult;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.crypto.NullCryptor;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.dqp.service.SessionService;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
import org.teiid.net.TeiidURL;
@@ -47,11 +52,6 @@
import org.teiid.net.socket.UrlServerDiscovery;
import org.teiid.transport.TestSocketRemoting.FakeService;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.dqp.service.SessionService;
@SuppressWarnings("nls")
public class TestCommSockets {
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestLogonImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,9 +32,9 @@
import org.teiid.client.security.LogonResult;
import org.teiid.client.security.SessionToken;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.service.SessionService;
import org.teiid.net.TeiidURL;
-import com.metamatrix.dqp.service.SessionService;
public class TestLogonImpl extends TestCase {
Modified: trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java
===================================================================
--- trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/runtime/src/test/java/org/teiid/transport/TestSocketRemoting.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -43,6 +43,11 @@
import org.teiid.client.security.SessionToken;
import org.teiid.client.util.ResultsFuture;
import org.teiid.client.util.ResultsReceiver;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.crypto.Cryptor;
+import org.teiid.core.crypto.NullCryptor;
+import org.teiid.core.util.ObjectConverterUtil;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.net.CommunicationException;
import org.teiid.net.ConnectionException;
@@ -55,11 +60,6 @@
import org.teiid.net.socket.SocketServerInstanceImpl;
import org.teiid.net.socket.UrlServerDiscovery;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.util.crypto.Cryptor;
-import com.metamatrix.common.util.crypto.NullCryptor;
-import com.metamatrix.core.util.ObjectConverterUtil;
public class TestSocketRemoting {
@@ -67,7 +67,7 @@
ResultsFuture<Integer> asynchResult();
- String exceptionMethod() throws MetaMatrixProcessingException;
+ String exceptionMethod() throws TeiidProcessingException;
int lobMethod(InputStream is, Reader r) throws IOException;
@@ -83,8 +83,8 @@
return result;
}
- public String exceptionMethod() throws MetaMatrixProcessingException {
- throw new MetaMatrixProcessingException();
+ public String exceptionMethod() throws TeiidProcessingException {
+ throw new TeiidProcessingException();
}
@Override
@@ -166,25 +166,25 @@
public ResultsFuture<?> logoff()
throws InvalidSessionException {
ResultsFuture<?> result = new ResultsFuture<Void>();
- result.getResultsReceiver().exceptionOccurred(new MetaMatrixComponentException("some exception")); //$NON-NLS-1$
+ result.getResultsReceiver().exceptionOccurred(new TeiidComponentException("some exception")); //$NON-NLS-1$
return result;
}
public LogonResult logon(Properties connectionProperties)
- throws LogonException, MetaMatrixComponentException {
+ throws LogonException, TeiidComponentException {
return new LogonResult();
}
// tests asynch where we don't care about the result
public ResultsFuture<?> ping() throws InvalidSessionException,
- MetaMatrixComponentException {
+ TeiidComponentException {
return null;
}
@Override
public void assertIdentity(SessionToken sessionId)
throws InvalidSessionException,
- MetaMatrixComponentException {
+ TeiidComponentException {
}
}, "foo"); //$NON-NLS-1$
@@ -199,7 +199,7 @@
result.get(0, TimeUnit.MICROSECONDS);
fail("exception expected"); //$NON-NLS-1$
} catch (ExecutionException e) {
- assertTrue(e.getCause() instanceof MetaMatrixComponentException);
+ assertTrue(e.getCause() instanceof TeiidComponentException);
}
FakeService service = connection.getService(FakeService.class);
Future<Integer> asynchInteger = service.asynchResult();
@@ -207,7 +207,7 @@
try {
service.exceptionMethod();
fail("exception expected"); //$NON-NLS-1$
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
}
DQP dqp = connection.getService(DQP.class);
Modified: trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java
===================================================================
--- trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/com/metamatrix/cdk/api/TestTranslationUtility.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,8 +28,8 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.UnitTestUtil;
public class TestTranslationUtility extends TestCase {
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestElement.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,9 +32,9 @@
import org.teiid.connector.language.Select;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
import org.teiid.connector.metadata.runtime.Column.SearchType;
+import org.teiid.core.util.UnitTestUtil;
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestGroup.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,9 +29,9 @@
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Select;
+import org.teiid.core.util.UnitTestUtil;
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestMetadataObject.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,9 +31,9 @@
import org.teiid.connector.language.DerivedColumn;
import org.teiid.connector.language.NamedTable;
import org.teiid.connector.language.Select;
+import org.teiid.core.util.UnitTestUtil;
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestParams.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,9 +31,9 @@
import org.teiid.connector.language.Call;
import org.teiid.connector.language.Argument.Direction;
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
+import org.teiid.core.util.UnitTestUtil;
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.core.util.UnitTestUtil;
/**
Modified: trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/metadata/runtime/TestProcedure.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,9 +28,9 @@
import junit.framework.TestCase;
import org.teiid.connector.language.Call;
+import org.teiid.core.util.UnitTestUtil;
import com.metamatrix.cdk.api.TranslationUtility;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
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 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/connector/visitor/util/TestSQLStringVisitor.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -68,10 +68,10 @@
import org.teiid.dqp.internal.datamgr.language.TestSubqueryInCriteriaImpl;
import org.teiid.dqp.internal.datamgr.language.TestUpdateImpl;
import org.teiid.dqp.internal.datamgr.language.TstLanguageBridgeFactory;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.JoinType;
import com.metamatrix.cdk.unittest.FakeTranslationFactory;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
public class TestSQLStringVisitor {
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/BaseQueryTest.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/BaseQueryTest.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/BaseQueryTest.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,20 +25,20 @@
import junit.framework.TestCase;
+import org.teiid.dqp.message.RequestID;
import org.teiid.metadata.TransformationMetadata;
import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.TestProcessor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
/**
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestTPCR.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,18 +25,18 @@
import java.util.Arrays;
import java.util.List;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.dqp.internal.datamgr.impl.CapabilitiesConverter;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.TestOptimizer;
+import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.processor.HardcodedDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.unittest.TimestampUtil;
import org.teiid.translator.jdbc.oracle.OracleCapabilities;
import org.teiid.translator.jdbc.sqlserver.SQLServerCapabilities;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.processor.HardcodedDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.TimestampUtil;
public class TestTPCR extends BaseQueryTest {
Modified: trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/dqp/internal/process/TestXMLTypeTranslations.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,18 +31,18 @@
import org.mockito.Mockito;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.dqp.message.RequestID;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.HardcodedDataManager;
+import org.teiid.query.unittest.TimestampUtil;
import org.teiid.resource.cci.SourceSystemFunctions;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.HardcodedDataManager;
-import com.metamatrix.query.unittest.TimestampUtil;
public class TestXMLTypeTranslations extends BaseQueryTest {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractMMQueryTestCase.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractMMQueryTestCase.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/AbstractMMQueryTestCase.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -31,9 +31,9 @@
import java.sql.SQLException;
import java.util.Stack;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.TeiidDriver;
-import com.metamatrix.core.util.UnitTestUtil;
/**
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,6 +32,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.DQP;
import org.teiid.client.security.ILogon;
+import org.teiid.common.queue.FakeWorkManager;
import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.deployers.MetadataStoreGroup;
@@ -41,8 +42,11 @@
import org.teiid.dqp.internal.datamgr.impl.FakeTransactionService;
import org.teiid.dqp.internal.process.DQPConfiguration;
import org.teiid.dqp.internal.process.DQPCore;
+import org.teiid.dqp.service.FakeBufferService;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.resource.ConnectorException;
import org.teiid.services.SessionServiceImpl;
import org.teiid.transport.ClientServiceRegistry;
@@ -50,10 +54,6 @@
import org.teiid.transport.LocalServerConnection;
import org.teiid.transport.LogonImpl;
-import com.metamatrix.common.queue.FakeWorkManager;
-import com.metamatrix.dqp.service.FakeBufferService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
public class FakeServer extends ClientServiceRegistryImpl {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestCase3473.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,8 +28,8 @@
import org.junit.Before;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestMMDatabaseMetaData.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -46,11 +46,11 @@
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.util.ApplicationInfo;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.util.ResultSetUtil;
-import com.metamatrix.common.util.ApplicationInfo;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.util.UnitTestUtil;
/**
*/
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestQueryPlans.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,8 +30,8 @@
import org.junit.Before;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestQueryPlans {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestResultsCache.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -30,8 +30,8 @@
import org.junit.Before;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestResultsCache {
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestVDBMerge.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -1,8 +1,8 @@
package org.teiid.jdbc;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestVDBMerge extends AbstractMMQueryTestCase {
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestPartsDatabaseMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,10 +29,10 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.FakeServer;
import org.teiid.jdbc.TestMMDatabaseMetaData;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* Test the DatabaseMetadata results using the Parts VDB.
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestResultSetMetadata.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -27,10 +27,10 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
import org.teiid.jdbc.FakeServer;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestResultSetMetadata extends AbstractMMQueryTestCase {
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestSystemVirtualModel.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,10 +25,10 @@
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
import org.teiid.jdbc.FakeServer;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* Exercises each virtual table in the system model.
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestVirtualDocWithVirtualProc.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -25,10 +25,10 @@
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
import org.teiid.jdbc.FakeServer;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* Tests xml virtual documents which are built on top of virtual
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ClassFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,10 +24,10 @@
import java.util.ArrayList;
import java.util.Collection;
+import org.teiid.core.util.ReflectionHelper;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.core.util.ReflectionHelper;
/**
* @author vanhalbert
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/QueryScenario.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,14 +29,14 @@
import java.util.List;
import java.util.Properties;
+import org.teiid.core.util.FileUtils;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.test.client.TestProperties.RESULT_MODES;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.util.FileUtils;
/**
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/TestClient.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -28,6 +28,9 @@
import java.util.Properties;
import org.junit.Assert;
+import org.teiid.core.util.FileUtils;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.StringUtil;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.TestLogger;
@@ -37,9 +40,6 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.StringUtil;
/**
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/ListNestedSortComparator.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -24,10 +24,11 @@
import java.util.List;
-import com.metamatrix.core.util.ArgCheck;
+import org.teiid.core.util.ArgCheck;
+
/**
* This class can be used for comparing lists of elements, when the fields to
* be sorted on and the comparison mechanism are dynamically specified. <p>
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/QueryResults.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,14 +32,15 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
/**
* This class encapsulates results associated with a query.
* <p>
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLExpectedResults.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -41,6 +41,7 @@
import java.util.Properties;
import org.jdom.JDOMException;
+import org.teiid.core.util.StringUtil;
import org.teiid.test.client.ClassFactory;
import org.teiid.test.client.ExpectedResults;
import org.teiid.test.client.QueryScenario;
@@ -53,7 +54,6 @@
import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
-import com.metamatrix.core.util.StringUtil;
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLGenerateResults.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -42,14 +42,14 @@
import org.jdom.JDOMException;
import org.jdom.output.XMLOutputter;
import org.junit.Assert;
+import org.teiid.core.util.FileUtils;
+import org.teiid.core.util.StringUtil;
+import org.teiid.internal.core.xml.JdomHelper;
import org.teiid.test.client.ResultsGenerator;
import org.teiid.test.client.TestProperties;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.util.TestResultSetUtil;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.internal.core.xml.JdomHelper;
public class XMLGenerateResults implements ResultsGenerator {
private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryReader.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -32,6 +32,8 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.core.util.FileUtils;
+import org.teiid.core.util.StringUtil;
import org.teiid.test.client.QueryTest;
import org.teiid.test.client.QueryReader;
import org.teiid.test.framework.ConfigPropertyLoader;
@@ -40,8 +42,6 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.core.util.FileUtils;
-import com.metamatrix.core.util.StringUtil;
public class XMLQueryReader implements QueryReader {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/ctc/XMLQueryVisitationStrategy.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -42,6 +42,10 @@
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.internal.core.xml.SAXBuilderHelper;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.test.client.QuerySQL;
import org.teiid.test.client.QueryTest;
import org.teiid.test.client.ctc.QueryResults.ColumnInfo;
@@ -49,10 +53,6 @@
import org.teiid.test.framework.exception.TransactionRuntimeException;
import org.teiid.test.util.StringUtil;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.internal.core.xml.SAXBuilderHelper;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ExpectedResultsImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -29,13 +29,13 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.core.util.SqlUtil;
import org.teiid.test.client.ExpectedResults;
import org.teiid.test.client.ctc.ResultsHolder;
import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.util.TestResultSetUtil;
-import com.metamatrix.common.util.SqlUtil;
public class ExpectedResultsImpl implements ExpectedResults {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/client/impl/ResultsGeneratorImpl.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -34,12 +34,12 @@
import java.util.Properties;
import org.junit.Assert;
+import org.teiid.core.util.FileUtils;
import org.teiid.test.client.ResultsGenerator;
import org.teiid.test.client.TestProperties;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.util.TestResultSetUtil;
-import com.metamatrix.core.util.FileUtils;
public class ResultsGeneratorImpl implements ResultsGenerator {
private static final SimpleDateFormat FILE_NAME_DATE_FORMATER = new SimpleDateFormat(
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/ConfigPropertyLoader.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -4,11 +4,11 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.test.framework.datasource.DataSourceFactory;
import org.teiid.test.framework.datasource.DataStore;
import org.teiid.test.util.PropUtils;
-import com.metamatrix.common.util.PropertiesUtils;
/**
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/TransactionContainer.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -4,9 +4,9 @@
*/
package org.teiid.test.framework;
+import org.teiid.core.util.StringUtil;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.core.util.StringUtil;
public abstract class TransactionContainer {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/ConnectionStrategy.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -20,6 +20,7 @@
import org.teiid.adminapi.AdminFactory;
import org.teiid.adminapi.Model;
import org.teiid.adminapi.VDB;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.jdbc.ConnectionImpl;
import org.teiid.jdbc.JDBCURL;
import org.teiid.test.framework.ConfigPropertyLoader;
@@ -31,7 +32,6 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
public abstract class ConnectionStrategy {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/connection/DataSourceConnection.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -12,6 +12,7 @@
import javax.sql.XAConnection;
import javax.sql.XADataSource;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.jdbc.BaseDataSource;
import org.teiid.jdbc.TeiidDataSource;
import org.teiid.test.framework.TestLogger;
@@ -19,7 +20,6 @@
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
public class DataSourceConnection extends ConnectionStrategy {
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceFactory.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -9,14 +9,14 @@
import java.util.Properties;
import java.util.Set;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.core.util.StringUtil;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
-import com.metamatrix.core.util.StringUtil;
/**
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/datasource/DataSourceMgr.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -12,13 +12,13 @@
import java.util.Map;
import java.util.Properties;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.ConfigPropertyNames;
import org.teiid.test.framework.TestLogger;
import org.teiid.test.framework.exception.QueryTestFailedException;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
/**
* The DataSourceMgr is responsible for loading and managing the datasources
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/framework/exception/QueryTestFailedException.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -6,9 +6,10 @@
import java.io.Serializable;
import java.util.List;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.MetaMatrixExceptionUtil;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.ExceptionUtil;
+
/**
*/
@@ -91,7 +92,7 @@
/**
* Construct an instance with a linked exception specified. If the exception is a MetaMatrixException or a
- * {@link MetaMatrixRuntimeException}, then the code will be set to the exception's code.
+ * {@link TeiidRuntimeException}, then the code will be set to the exception's code.
* @param e An exception to chain to this exception
*/
public QueryTestFailedException(final Throwable e) {
@@ -106,7 +107,7 @@
/**
* Construct an instance with the linked exception and error message specified. If the message is actually a key, the error
* message will be retrieved from a resource bundle the key, and code will be set to that key. Otherwise, if the specified
- * exception is a MetaMatrixException or a {@link MetaMatrixRuntimeException}, the code will be set to the exception's code.
+ * exception is a MetaMatrixException or a {@link TeiidRuntimeException}, the code will be set to the exception's code.
* @param e The exception to chain to this exception
* @param message The error message or a resource bundle key
*/
@@ -186,7 +187,7 @@
* @see #getFormattedMessage
*/
public String getFullMessage() {
- return MetaMatrixExceptionUtil.getLinkedMessages(this, 0 );
+ return ExceptionUtil.getLinkedMessages(this, 0 );
}
/* (non-Javadoc)
Modified: trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java
===================================================================
--- trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/main/java/org/teiid/test/util/PropUtils.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -5,10 +5,10 @@
import java.io.InputStream;
import java.util.Properties;
+import org.teiid.core.util.PropertiesUtils;
import org.teiid.test.framework.ConfigPropertyLoader;
import org.teiid.test.framework.exception.TransactionRuntimeException;
-import com.metamatrix.common.util.PropertiesUtils;
public class PropUtils {
Modified: trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/test/java/org/teiid/adminapi/jboss/TestConnectorBindings.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -34,9 +34,9 @@
import org.teiid.adminapi.Transaction;
import org.teiid.adminapi.Translator;
import org.teiid.adminapi.VDB;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.UnitTestUtil;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.UnitTestUtil;
@SuppressWarnings("nls")
public class TestConnectorBindings extends BaseConnection {
Modified: trunk/test-integration/db/src/test/java/org/teiid/dynamicvdb/TestVDBLessExecution.java
===================================================================
--- trunk/test-integration/db/src/test/java/org/teiid/dynamicvdb/TestVDBLessExecution.java 2010-05-11 22:01:58 UTC (rev 2117)
+++ trunk/test-integration/db/src/test/java/org/teiid/dynamicvdb/TestVDBLessExecution.java 2010-05-11 22:15:35 UTC (rev 2118)
@@ -26,9 +26,9 @@
import java.sql.DatabaseMetaData;
import org.junit.Test;
+import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
-import com.metamatrix.core.util.UnitTestUtil;
/**
* Test the DatabaseMetadata results using the Parts VDB.
15 years, 11 months
teiid SVN: r2117 - in trunk/engine/src: main/java/com/metamatrix/vdb and 86 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2010-05-11 18:01:58 -0400 (Tue, 11 May 2010)
New Revision: 2117
Added:
trunk/engine/src/main/java/org/teiid/api/
trunk/engine/src/main/java/org/teiid/api/exception/
trunk/engine/src/main/java/org/teiid/api/exception/query/
trunk/engine/src/main/java/org/teiid/cache/Cache.java
trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java
trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java
trunk/engine/src/main/java/org/teiid/cache/CacheListener.java
trunk/engine/src/main/java/org/teiid/common/
trunk/engine/src/main/java/org/teiid/common/buffer/
trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java
trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java
trunk/engine/src/main/java/org/teiid/common/buffer/IndexedTupleSource.java
trunk/engine/src/main/java/org/teiid/common/buffer/StorageManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
trunk/engine/src/main/java/org/teiid/common/buffer/TupleSource.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/
trunk/engine/src/main/java/org/teiid/dqp/DQPPlugin.java
trunk/engine/src/main/java/org/teiid/dqp/message/
trunk/engine/src/main/java/org/teiid/dqp/service/
trunk/engine/src/main/java/org/teiid/internal/
trunk/engine/src/main/java/org/teiid/internal/core/
trunk/engine/src/main/java/org/teiid/internal/core/xml/
trunk/engine/src/main/java/org/teiid/metadata/VdbConstants.java
trunk/engine/src/main/java/org/teiid/query/
trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java
trunk/engine/src/main/java/org/teiid/query/analysis/
trunk/engine/src/main/java/org/teiid/query/eval/
trunk/engine/src/main/java/org/teiid/query/execution/
trunk/engine/src/main/java/org/teiid/query/function/
trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java
trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/
trunk/engine/src/main/java/org/teiid/query/function/metadata/
trunk/engine/src/main/java/org/teiid/query/function/source/
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
trunk/engine/src/main/java/org/teiid/query/mapping/
trunk/engine/src/main/java/org/teiid/query/mapping/relational/
trunk/engine/src/main/java/org/teiid/query/mapping/xml/
trunk/engine/src/main/java/org/teiid/query/metadata/
trunk/engine/src/main/java/org/teiid/query/optimizer/
trunk/engine/src/main/java/org/teiid/query/optimizer/CommandPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java
trunk/engine/src/main/java/org/teiid/query/optimizer/batch/
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/
trunk/engine/src/main/java/org/teiid/query/optimizer/proc/
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/OptimizerRule.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanHints.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RuleStack.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/
trunk/engine/src/main/java/org/teiid/query/optimizer/xquery/
trunk/engine/src/main/java/org/teiid/query/parser/
trunk/engine/src/main/java/org/teiid/query/processor/
trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java
trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
trunk/engine/src/main/java/org/teiid/query/processor/CollectionTupleSource.java
trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java
trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/TempTableDataManager.java
trunk/engine/src/main/java/org/teiid/query/processor/batch/
trunk/engine/src/main/java/org/teiid/query/processor/proc/
trunk/engine/src/main/java/org/teiid/query/processor/program/
trunk/engine/src/main/java/org/teiid/query/processor/relational/
trunk/engine/src/main/java/org/teiid/query/processor/xml/
trunk/engine/src/main/java/org/teiid/query/processor/xquery/
trunk/engine/src/main/java/org/teiid/query/report/
trunk/engine/src/main/java/org/teiid/query/resolver/
trunk/engine/src/main/java/org/teiid/query/resolver/CommandResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/
trunk/engine/src/main/java/org/teiid/query/resolver/util/
trunk/engine/src/main/java/org/teiid/query/rewriter/
trunk/engine/src/main/java/org/teiid/query/sql/
trunk/engine/src/main/java/org/teiid/query/sql/LanguageObject.java
trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/
trunk/engine/src/main/java/org/teiid/query/sql/navigator/
trunk/engine/src/main/java/org/teiid/query/sql/proc/
trunk/engine/src/main/java/org/teiid/query/sql/symbol/
trunk/engine/src/main/java/org/teiid/query/sql/util/
trunk/engine/src/main/java/org/teiid/query/sql/visitor/
trunk/engine/src/main/java/org/teiid/query/tempdata/
trunk/engine/src/main/java/org/teiid/query/util/
trunk/engine/src/main/java/org/teiid/query/validator/
trunk/engine/src/main/java/org/teiid/query/xquery/
trunk/engine/src/main/java/org/teiid/query/xquery/XQueryExpression.java
trunk/engine/src/main/java/org/teiid/query/xquery/XQuerySQLEvaluator.java
trunk/engine/src/main/java/org/teiid/query/xquery/saxon/
trunk/engine/src/main/java/org/teiid/vdb/
trunk/engine/src/main/java/org/teiid/vdb/runtime/
trunk/engine/src/main/javacc/org/
trunk/engine/src/main/javacc/org/teiid/
trunk/engine/src/main/resources/org/teiid/dqp/
trunk/engine/src/main/resources/org/teiid/query/
Removed:
trunk/engine/src/main/java/com/metamatrix/query/xquery/XQueryExpression.java
trunk/engine/src/main/java/com/metamatrix/query/xquery/XQuerySQLEvaluator.java
trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/
trunk/engine/src/main/java/com/metamatrix/vdb/runtime/
trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
trunk/engine/src/main/javacc/com/
trunk/engine/src/main/javacc/org/metamatrix/
trunk/engine/src/main/resources/com/
trunk/engine/src/main/resources/org/teiid/adminapi/
trunk/engine/src/test/java/com/metamatrix/cache/
trunk/engine/src/test/java/com/metamatrix/cdk/
trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBatch.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java
trunk/engine/src/test/java/com/metamatrix/common/buffer/impl/
trunk/engine/src/test/java/com/metamatrix/common/log/
trunk/engine/src/test/java/com/metamatrix/common/queue/
trunk/engine/src/test/java/com/metamatrix/dqp/message/
trunk/engine/src/test/java/com/metamatrix/dqp/service/
trunk/engine/src/test/java/com/metamatrix/internal/core/xml/
trunk/engine/src/test/java/com/metamatrix/query/analysis/
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionMetadataReader.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java
trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java
trunk/engine/src/test/java/com/metamatrix/query/function/metadata/
trunk/engine/src/test/java/com/metamatrix/query/function/source/
trunk/engine/src/test/java/com/metamatrix/query/mapping/xml/
trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/InlineViewCase.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAnsiJoinPushdown.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestComparableMetadataPushdown.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestExpressionsInGroupBy.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinPushdownRestrictions.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestPartitionedJoinPlanning.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRemoveSorts.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSortOptimization.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestUnionPlanning.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/batch/
trunk/engine/src/test/java/com/metamatrix/query/optimizer/capabilities/
trunk/engine/src/test/java/com/metamatrix/query/optimizer/proc/
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestRuleStack.java
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/plantree/
trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/rules/
trunk/engine/src/test/java/com/metamatrix/query/optimizer/xml/
Modified:
trunk/engine/src/main/java/org/teiid/api/exception/query/CriteriaEvaluationException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/ExpressionEvaluationException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/FunctionExecutionException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/FunctionMetadataException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/InvalidFunctionException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryMetadataException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryPlannerException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryProcessingException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryResolverException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/QueryValidatorException.java
trunk/engine/src/main/java/org/teiid/api/exception/query/UnresolvedSymbolDescription.java
trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/FileStorageManager.java
trunk/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestID.java
trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java
trunk/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java
trunk/engine/src/main/java/org/teiid/dqp/message/RequestID.java
trunk/engine/src/main/java/org/teiid/dqp/service/BufferService.java
trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java
trunk/engine/src/main/java/org/teiid/dqp/service/SessionServiceException.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
trunk/engine/src/main/java/org/teiid/internal/core/xml/JdomHelper.java
trunk/engine/src/main/java/org/teiid/internal/core/xml/SAXBuilderHelper.java
trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
trunk/engine/src/main/java/org/teiid/query/eval/SecurityFunctionEvaluator.java
trunk/engine/src/main/java/org/teiid/query/execution/QueryExecPlugin.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/AggregateFunction.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/Avg.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/ConstantFunction.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/Count.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/Max.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/Min.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/NullFilter.java
trunk/engine/src/main/java/org/teiid/query/function/aggregate/Sum.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionCategoryConstants.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java
trunk/engine/src/main/java/org/teiid/query/function/source/SecuritySystemFunctions.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/InterceptingVisitor.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingAllNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingChoiceNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingCommentNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingDocument.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingException.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingInterceptor.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeLogger.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingSequenceNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingSourceNode.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/Namespace.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/Navigator.java
trunk/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java
trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
trunk/engine/src/main/java/org/teiid/query/metadata/StoredProcedureInfo.java
trunk/engine/src/main/java/org/teiid/query/metadata/SupportConstants.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java
trunk/engine/src/main/java/org/teiid/query/optimizer/batch/BatchedUpdatePlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/CapabilitiesFinder.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/DefaultCapabilitiesFinder.java
trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
trunk/engine/src/main/java/org/teiid/query/optimizer/proc/ProcedurePlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeConstants.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeFactory.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAccessPatternValidation.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCalculateCost.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleConstants.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlaceAccess.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanProcedures.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanUnions.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushNonJoinCriteria.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleValidateWhereAll.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ContextReplacerVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/CriteriaPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/HandleNillableVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/QueryUtil.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ReferenceBindingReplacerVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodeGenaratorVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/TagBuilderVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLNodeMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLStagaingQueryPlanner.java
trunk/engine/src/main/java/org/teiid/query/optimizer/xquery/XQueryPlanner.java
trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java
trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/batch/BatchedUpdatePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/AssignmentInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/BreakInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ContinueInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/RepeatedInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/proc/WhileInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java
trunk/engine/src/main/java/org/teiid/query/processor/program/ProgramInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentAccessNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureAccessNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureCriteriaProcessor.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureExecutionNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentValueSource.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/DuplicateFilter.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/InsertPlanExecutionNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/LimitNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/NullNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeStatistics.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareEvaluator.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/TupleSourceValueIterator.java
trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/AbortProcessingInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/AddCommentInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/AddNodeInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/BlockInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/Condition.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/CriteriaCondition.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/DefaultCondition.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/Element.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/EndBlockInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/EndDocumentInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/ExecSqlInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/ExecStagingTableInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/IfInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/MoveCursorInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/MoveDocInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/NodeDescriptor.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/PlanExecutor.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/ProcessorInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/Program.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/ProgramUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/WhileInstruction.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java
trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLValueTranslator.java
trunk/engine/src/main/java/org/teiid/query/processor/xquery/SqlEval.java
trunk/engine/src/main/java/org/teiid/query/processor/xquery/TupleInputSource.java
trunk/engine/src/main/java/org/teiid/query/processor/xquery/TupleXMLReader.java
trunk/engine/src/main/java/org/teiid/query/processor/xquery/XQueryPlan.java
trunk/engine/src/main/java/org/teiid/query/report/ActivityReport.java
trunk/engine/src/main/java/org/teiid/query/report/ReportItem.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/BatchedUpdateResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/DeleteResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/SetQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/TempTableResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/command/XQueryResolver.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/AccessPattern.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/BindVariableVisitor.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/AbstractCompareCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/AbstractSetCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/AtomicCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/BetweenCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/CollectionValueIterator.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/CompareCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/CompoundCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Create.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/DependentSetCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Drop.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/ExistsCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/GroupBy.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/GroupContext.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Into.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/IsNullCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/JoinType.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Limit.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/LogicalCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/NotCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/OrderBy.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/OrderByItem.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/PredicateCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Select.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SetClause.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SetClauseList.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SetCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryContainer.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/TranslatableProcedureContainer.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
trunk/engine/src/main/java/org/teiid/query/sql/lang/XQuery.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/AbstractNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/DeepPostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/DeepPreOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrderNavigator.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/BreakStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/ContinueStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/CriteriaSelector.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/HasCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/IfStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/LoopStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/TranslateCriteria.java
trunk/engine/src/main/java/org/teiid/query/sql/proc/WhileStatement.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AbstractCaseExpression.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AliasSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/CaseExpression.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ContextReference.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Expression.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ExpressionSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/MultipleElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/SearchedCaseExpression.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/SelectSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLElement.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java
trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLNamespaces.java
trunk/engine/src/main/java/org/teiid/query/sql/util/ElementSymbolOptimizer.java
trunk/engine/src/main/java/org/teiid/query/sql/util/SymbolMap.java
trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java
trunk/engine/src/main/java/org/teiid/query/sql/util/ValueIterator.java
trunk/engine/src/main/java/org/teiid/query/sql/util/ValueIteratorSource.java
trunk/engine/src/main/java/org/teiid/query/sql/util/VariableContext.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/CommandCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/CorrelatedReferenceCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ElementCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/FunctionCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/GroupCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/GroupsUsedByElementsVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/PredicateCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ReferenceCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/StaticSymbolMappingVisitor.java
trunk/engine/src/main/java/org/teiid/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStoreImpl.java
trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java
trunk/engine/src/main/java/org/teiid/query/util/ErrorMessageKeys.java
trunk/engine/src/main/java/org/teiid/query/util/Permutation.java
trunk/engine/src/main/java/org/teiid/query/util/XMLFormatConstants.java
trunk/engine/src/main/java/org/teiid/query/validator/AbstractValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/Validator.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidatorFailure.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidatorReport.java
trunk/engine/src/main/java/org/teiid/query/xquery/saxon/DocFunctionURIResolver.java
trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
trunk/engine/src/main/java/org/teiid/vdb/runtime/VDBKey.java
trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
Log:
TEIID-918 changing package to org.teiid and removing metamatrix from class names
Deleted: trunk/engine/src/main/java/com/metamatrix/query/xquery/XQueryExpression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/xquery/XQueryExpression.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/com/metamatrix/query/xquery/XQueryExpression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,70 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.xquery;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.types.XMLTranslator;
-
-/**
- * An XQueryExpression - the object representation of
- * a compiled XQuery. Must be thread-safe and immutable.
- */
-public interface XQueryExpression {
-
- /**
- * Return the compiled XQueryExpression - the result of this
- * call should be used as a parameter to the
- * {@link #getDocumentNames getDocumentNames} and
- * {@link #evaluateXQuery evaluateXQuery} methods.
- * A null return value is interpreted to mean that XQueries
- * are not supported by this engine at all.
- * @param xQueryString the original XQuery String
- * @throws MetaMatrixProcessingException if xQueryString is
- * invalid and fails to compile
- */
- public void compileXQuery(String xQueryString)
- throws MetaMatrixProcessingException;
-
-
- /**
- * Evaluate the XQuery and return results. A null return
- * value is interpreted to mean that XQueries are not supported
- * by this engine.
- * @param compiledXQuery compiled XQueryExpression
- * @throws MetaMatrixProcessingException if xQueryString is
- * invalid and fails to compile
- */
- public XMLTranslator evaluateXQuery(XQuerySQLEvaluator sqlEval)
- throws MetaMatrixProcessingException, MetaMatrixComponentException;
-
-
- /**
- * This method sets whether the documents should be returned in compact
- * format (no extraneous whitespace). Non-compact format is more human-readable
- * (and bigger). Additional formats may be possible in future.
- * @param xmlFormat A string giving the format in which xml results need to be returned
- */
- public void setXMLFormat(String xmlFormat);
-
-}
Deleted: trunk/engine/src/main/java/com/metamatrix/query/xquery/XQuerySQLEvaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/xquery/XQuerySQLEvaluator.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/com/metamatrix/query/xquery/XQuerySQLEvaluator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,54 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.xquery;
-
-import javax.xml.transform.Source;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.common.buffer.BlockedException;
-
-
-/**
- * @since 4.3
- */
-public interface XQuerySQLEvaluator {
-
- /**
- * Execute a SQL string that returns an XML result
- * @param sql SQL string, typically an EXEC against an xml service or virtual document
- * @throws QueryParserException If sql parameter is not sql
- * @throws MetaMatrixProcessingException If execution of the sql fails due to a bad query
- * @throws MetaMatrixComponentException If execution of the sql fails due to an internal failure
- */
- Source executeSQL(String sql) throws QueryParserException, MetaMatrixProcessingException, MetaMatrixComponentException;
-
- /**
- * Closes any resources opened during the evaluation
- */
- void close() throws MetaMatrixComponentException ;
-
- Object getParameterValue(String key) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException;
-}
Copied: trunk/engine/src/main/java/org/teiid/api/exception/query (from rev 2112, trunk/engine/src/main/java/com/metamatrix/api/exception/query)
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/CriteriaEvaluationException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/CriteriaEvaluationException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/CriteriaEvaluationException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import org.teiid.core.TeiidProcessingException;
/**
* This exception is thrown when an error occurs while evaluating a SQL criteria.
*/
-public class CriteriaEvaluationException extends MetaMatrixProcessingException {
+public class CriteriaEvaluationException extends TeiidProcessingException {
/**
* No-arg constructor required by Externalizable semantics.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/ExpressionEvaluationException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/ExpressionEvaluationException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/ExpressionEvaluationException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import org.teiid.core.TeiidProcessingException;
/**
* This exception is thrown when an error occurs while evaluating a SQL expression.
*/
-public class ExpressionEvaluationException extends MetaMatrixProcessingException {
+public class ExpressionEvaluationException extends TeiidProcessingException {
/**
* No-arg constructor required by Externalizable semantics.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/FunctionExecutionException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionExecutionException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/FunctionExecutionException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
/**
* During processing, an invalid function was detected.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/FunctionMetadataException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/FunctionMetadataException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/FunctionMetadataException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
/**
* Detected invalid function metadata during validation.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/InvalidFunctionException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/InvalidFunctionException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/InvalidFunctionException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
/**
* During processing, an invalid function was detected.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryMetadataException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryMetadataException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryMetadataException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
+import org.teiid.core.TeiidComponentException;
/**
* This exception is thrown when an error occurs while retrieving metadata
@@ -30,7 +30,7 @@
*
* TODO: this isn't really a component exception all of the time. missing entries in metadata are fine during resolving.
*/
-public class QueryMetadataException extends MetaMatrixComponentException {
+public class QueryMetadataException extends TeiidComponentException {
/**
* No-arg constructor required by Externalizable semantics.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryParserException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryParserException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
/**
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryPlannerException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryPlannerException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryPlannerException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
/**
* This exception is thrown when an error occurs while planning the query. This
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryProcessingException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryProcessingException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryProcessingException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import org.teiid.core.TeiidProcessingException;
/**
* This exception is thrown when an error occurs while retrieving metadata
* from a query component metadata facade.
*/
-public class QueryProcessingException extends MetaMatrixProcessingException {
+public class QueryProcessingException extends TeiidProcessingException {
/**
* No-arg constructor required by Externalizable semantics.
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryResolverException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryResolverException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryResolverException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
import java.util.*;
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/QueryValidatorException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/QueryValidatorException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/QueryValidatorException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
/**
* This exception is thrown if an error is discovered while validating the query. Validation
Modified: trunk/engine/src/main/java/org/teiid/api/exception/query/UnresolvedSymbolDescription.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/api/exception/query/UnresolvedSymbolDescription.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/api/exception/query/UnresolvedSymbolDescription.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.api.exception.query;
+package org.teiid.api.exception.query;
import java.io.Serializable;
Copied: trunk/engine/src/main/java/org/teiid/cache/Cache.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/cache/Cache.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/Cache.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/Cache.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,160 @@
+/*
+ * 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.cache;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+
+/**
+ * Abstraction over cache providers
+ */
+public interface Cache<K, V> {
+
+ public enum Type { REGISTRY("Registry"), //$NON-NLS-1$
+ SESSION("Session"), //$NON-NLS-1$
+ SESSION_MONITOR("Session-Monitor"), //$NON-NLS-1$
+ AUTHORIZATION_POLICY("Authorization-Policy"), //$NON-NLS-1$
+ AUTHORIZATION_PRINCIPAL("Auhtorization-Principal"), //$NON-NLS-1$
+ RESULTSET("ResultSet"), //$NON-NLS-1$
+ VDBMETADATA("VdbMetadata"), //$NON-NLS-1$
+ VDBMODELS("VdbModels"), //$NON-NLS-1$
+ SCOPED_CACHE("Scoped-Cache"); //$NON-NLS-1$
+
+ private String location;
+
+ Type(String location){
+ this.location = location;
+ }
+
+ public String location() {
+ return this.location;
+ }
+ }
+
+ /**
+ * Retrieves the value for the given Key
+ *
+ * @param key key under which value is to be retrieved.
+ * @return returns data held under specified key in cache
+ */
+ V get(K key);
+
+ /**
+ * Associates the specified value with the specified key this cache.
+ * If the cache previously contained a mapping for this key, the old value is replaced by the specified value.
+ *
+ * @param key key with which the specified value is to be associated.
+ * @param value value to be associated with the specified key.
+ * @return previous value associated with specified key, or <code>null</code> if there was no mapping for key.
+ * A <code>null</code> return can also indicate that the key previously associated <code>null</code> with the specified key,
+ * if the implementation supports null values.
+ */
+ V put(K key, V value);
+
+ /**
+ * Removes the value for this key from a Cache.
+ * Returns the value to which the Key previously associated , or
+ * <code>null</code> if the Key contained no mapping.
+ *
+ * @param key key whose mapping is to be removed
+ * @return previous value associated with specified Node's key
+ */
+ V remove(K key);
+
+ /**
+ * Size of the cache
+ * @return number of items in this cache
+ */
+ int size();
+
+
+ /**
+ * Returns a {@link Set} containing the data in this Cache
+ *
+ * @return a {@link Set} containing the data in this Cache. If there is no data,
+ * an empty {@link Set} is returned. The {@link Set} returned is always immutable.
+ */
+ Set<K> keySet();
+
+ /**
+ * Removes all the keys and their values from the Cache
+ */
+ void clear();
+
+ /**
+ * Listener to get the updates on this Cache
+ * @param listener
+ */
+ void addListener(CacheListener listener);
+
+ /**
+ * Remove Listener to stop the updates on this Cache
+ * @param listener
+ */
+ void removeListener();
+
+ /**
+ * Returns a {@link Collection} containing the data in this Cache
+ *
+ * @return a {@link Collection} containing the data in this Cache. If there is no data,
+ * an empty {@link Collection} is returned.
+ */
+ Collection<V> values();
+
+
+ /**
+ * Add a child node to the current cache node
+ * @param name - name of the child
+ * @return Cache instance.
+ */
+ Cache addChild(String name);
+
+ /**
+ * Get the child cache node from the current node
+ * @param name
+ * @return null if not found
+ */
+ Cache getChild(String name);
+
+ /**
+ * Destroys the child from the current node; no-op if node not found
+ * @param name
+ * @return true if removed; false otherwise
+ */
+ boolean removeChild(String name);
+
+
+ /**
+ * Get child nodes under this cache node. If none found empty set is returned
+ * @return
+ */
+ List<Cache> getChildren();
+
+ /**
+ * Name of the cache node
+ * @return
+ */
+ String getName();
+}
Copied: trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/cache/CacheConfiguration.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheConfiguration.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,56 @@
+/*
+ * 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.cache;
+
+public class CacheConfiguration {
+
+ public static CacheConfiguration DEFAULT = new CacheConfiguration(Policy.LRU, 60*60, 100); // 1 hours with 100 nodes.
+
+ public enum Policy {
+ LRU, // Least Recently Used
+ FIFO, // First in First Out
+ LFU; // Least frequently Used
+ }
+
+ private Policy policy;
+ private int maxage;
+ private int maxnodes;
+
+ public CacheConfiguration(Policy policy, int maxAgeInSeconds, int maxNodes) {
+ this.policy = policy;
+ this.maxage = maxAgeInSeconds;
+ this.maxnodes = maxNodes;
+ }
+
+ public Policy getPolicy() {
+ return this.policy;
+ }
+
+ public int getMaxAgeInSeconds(){
+ return maxage;
+ }
+
+ public int getMaxNodes() {
+ return this.maxnodes;
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/cache/CacheFactory.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,39 @@
+/*
+ * 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.cache;
+
+public interface CacheFactory {
+
+ /**
+ * Create / Get the cache for the give type use
+ * @param type cache type
+ * @param config configuration setup for the cache
+ * @return
+ */
+ <K,V> Cache<K, V> get(Cache.Type type, CacheConfiguration config);
+
+ /**
+ * Destroy the cache factory and any caches underneath.
+ */
+ void destroy();
+}
Copied: trunk/engine/src/main/java/org/teiid/cache/CacheListener.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/cache/CacheListener.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/CacheListener.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/cache/CacheListener.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,30 @@
+/*
+ * 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.cache;
+
+/**
+ * Listener for the cache events like add,update delete
+ */
+public interface CacheListener {
+ void cacheChanged();
+}
Modified: trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/cache/DefaultCacheFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -29,13 +29,10 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.cache.Cache;
-import com.metamatrix.cache.CacheConfiguration;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.cache.CacheListener;
-import com.metamatrix.cache.Cache.Type;
-import com.metamatrix.core.MetaMatrixRuntimeException;
+import org.teiid.cache.Cache.Type;
+import org.teiid.core.TeiidRuntimeException;
+
public class DefaultCacheFactory implements CacheFactory, Serializable {
private static final long serialVersionUID = -5541424157695857527L;
@@ -53,7 +50,7 @@
Cache node = cacheRoot.addChild(type.location());
return node;
}
- throw new MetaMatrixRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
+ throw new TeiidRuntimeException("Cache system has been shutdown"); //$NON-NLS-1$
}
class DefaultCache<K, V> implements Cache<K, V>, Serializable {
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/BatchManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,41 @@
+/*
+ * 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.common.buffer;
+
+import org.teiid.core.TeiidComponentException;
+
+public interface BatchManager {
+
+ public interface ManagedBatch {
+
+ TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException;
+
+ void remove();
+
+ }
+
+ ManagedBatch createManagedBatch(TupleBatch batch) throws TeiidComponentException;
+
+ void remove();
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/common/buffer/BatchManager.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/BlockedException.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BlockedException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,43 @@
+/*
+ * 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.common.buffer;
+
+import org.teiid.core.TeiidComponentException;
+
+/**
+ * This exception is thrown if the buffer manager blocks waiting on input during
+ * processing. This is an indication that more data will be available, but is
+ * not currently available.
+ */
+public class BlockedException extends TeiidComponentException {
+
+ public static final BlockedException INSTANCE = new BlockedException();
+
+ /**
+ * No-arg costructor required by Externalizable semantics
+ */
+ public BlockedException() {
+ super();
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/BufferManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/BufferManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,117 @@
+/*
+ * 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.common.buffer;
+
+import java.util.List;
+
+import org.teiid.core.TeiidComponentException;
+
+
+/**
+ * The buffer manager controls how memory is used and how data flows through
+ * the system. It uses {@link StorageManager storage managers}
+ * to retrieve data, store data, and
+ * transfer data. The buffer manager has algorithms that tell it when and
+ * how to store data. The buffer manager should also be aware of memory
+ * management issues.
+ */
+public interface BufferManager extends StorageManager {
+
+ public enum TupleSourceType {
+ /**
+ * Indicates that a tuple source is use during query processing as a
+ * temporary results.
+ */
+ PROCESSOR,
+ /**
+ * Indicates that a tuple source represents a query's final results.
+ */
+ FINAL
+ }
+
+ public enum BufferReserveMode {
+ WAIT,
+ FORCE,
+ NO_WAIT
+ }
+
+ public static int DEFAULT_CONNECTOR_BATCH_SIZE = 1024;
+ public static int DEFAULT_PROCESSOR_BATCH_SIZE = 512;
+ public static int DEFAULT_MAX_PROCESSING_BATCHES = 128;
+
+ /**
+ * This is the maximum number of batch columns used for processing.
+ * See {@link #reserveBuffers(int, boolean)}
+ */
+ public static int DEFAULT_RESERVE_BUFFERS = 16384;
+
+ /**
+ * Get the batch size to use during query processing.
+ * @return Batch size (# of rows)
+ */
+ int getProcessorBatchSize();
+
+ /**
+ * Get the batch size to use when reading data from a connector.
+ * @return Batch size (# of rows)
+ */
+ int getConnectorBatchSize();
+
+ TupleBuffer createTupleBuffer(List elements, String groupName, TupleSourceType tupleSourceType)
+ throws TeiidComponentException;
+
+ /**
+ * Return the maximum number of batches that can be temporarily held potentially
+ * across even a blocked exception.
+ * @return
+ */
+ int getMaxProcessingBatchColumns();
+
+ /**
+ * Creates a new {@link FileStore}. See {@link FileStore#setCleanupReference(Object)} to
+ * automatically cleanup the underlying resources.
+ * @param name
+ * @return
+ */
+ FileStore createFileStore(String name);
+
+ /**
+ * Reserve up to count buffers for use.
+ * @param count
+ * @param mode
+ * @return
+ */
+ int reserveBuffers(int count, BufferReserveMode mode);
+
+ /**
+ * Releases the buffers reserved by a call to {@link BufferManager#reserveBuffers(int, boolean)}
+ * @param count
+ */
+ void releaseBuffers(int count);
+
+ /**
+ * Get the size estimate for the given schema.
+ */
+ int getSchemaSize(List elements);
+
+}
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/FileStore.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,245 @@
+/*
+ * 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.common.buffer;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.lang.ref.PhantomReference;
+import java.lang.ref.ReferenceQueue;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.IdentityHashMap;
+import java.util.Set;
+
+import org.teiid.core.TeiidComponentException;
+
+
+public abstract class FileStore {
+
+ private static ReferenceQueue<Object> QUEUE = new ReferenceQueue<Object>();
+ private static final Set<PhantomReference<Object>> REFERENCES = Collections.newSetFromMap(new IdentityHashMap<PhantomReference<Object>, Boolean>());
+
+ /**
+ * A customized buffered stream with an exposed buffer
+ */
+ public final class FileStoreOutputStream extends OutputStream {
+
+ private byte[] buffer;
+ private int count;
+ private boolean bytesWritten;
+
+ public FileStoreOutputStream(int size) {
+ this.buffer = new byte[size];
+ }
+
+ @Override
+ public void write(int b) throws IOException {
+ write(new byte[b], 0, 1);
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ if (len > buffer.length) {
+ flushBuffer();
+ writeDirect(b, off, len);
+ return;
+ }
+ int bufferedLength = Math.min(len, buffer.length - count);
+ if (count < buffer.length) {
+ System.arraycopy(b, off, buffer, count, bufferedLength);
+ count += bufferedLength;
+ if (bufferedLength == len) {
+ return;
+ }
+ }
+ flushBuffer();
+ System.arraycopy(b, off + bufferedLength, buffer, count, len - bufferedLength);
+ count += len - bufferedLength;
+ }
+
+ private void writeDirect(byte[] b, int off, int len) throws IOException {
+ try {
+ FileStore.this.write(b, off, len);
+ bytesWritten = true;
+ } catch (TeiidComponentException e) {
+ throw new IOException(e);
+ }
+ }
+
+ public void flushBuffer() throws IOException {
+ if (count > 0) {
+ writeDirect(buffer, 0, count);
+ count = 0;
+ }
+ }
+
+ public boolean bytesWritten() {
+ return bytesWritten;
+ }
+
+ public byte toByteArray()[] {
+ return Arrays.copyOf(buffer, count);
+ }
+
+ @Override
+ public void close() throws IOException {
+ if (bytesWritten) {
+ flushBuffer();
+ }
+ }
+
+ }
+
+ static class CleanupReference extends PhantomReference<Object> {
+
+ private FileStore store;
+
+ public CleanupReference(Object referent, FileStore store) {
+ super(referent, QUEUE);
+ this.store = store;
+ }
+
+ public void cleanup() {
+ try {
+ this.store.remove();
+ } finally {
+ this.clear();
+ }
+ }
+ }
+
+ private boolean removed;
+ private long len;
+
+ public void setCleanupReference(Object o) {
+ REFERENCES.add(new CleanupReference(o, this));
+ for (int i = 0; i < 10; i++) {
+ CleanupReference ref = (CleanupReference)QUEUE.poll();
+ if (ref == null) {
+ break;
+ }
+ ref.cleanup();
+ REFERENCES.remove(ref);
+ }
+ }
+
+ public synchronized long getLength() {
+ return len;
+ }
+
+ public int read(long fileOffset, byte[] b, int offSet, int length)
+ throws TeiidComponentException {
+ if (removed) {
+ throw new TeiidComponentException("already removed"); //$NON-NLS-1$
+ }
+ return readDirect(fileOffset, b, offSet, length);
+ }
+
+ protected abstract int readDirect(long fileOffset, byte[] b, int offSet, int length)
+ throws TeiidComponentException;
+
+ public void readFully(long fileOffset, byte[] b, int offSet, int length) throws TeiidComponentException {
+ int n = 0;
+ do {
+ int count = this.read(fileOffset + n, b, offSet + n, length - n);
+ if (count < 0) {
+ throw new TeiidComponentException("not enough bytes available"); //$NON-NLS-1$
+ }
+ n += count;
+ } while (n < length);
+ }
+
+ public void write(byte[] bytes) throws TeiidComponentException {
+ write(bytes, 0, bytes.length);
+ }
+
+ public synchronized long write(byte[] bytes, int offset, int length) throws TeiidComponentException {
+ if (removed) {
+ throw new TeiidComponentException("already removed"); //$NON-NLS-1$
+ }
+ writeDirect(bytes, offset, length);
+ long result = len;
+ len += length;
+ return result;
+ }
+
+ protected abstract void writeDirect(byte[] bytes, int offset, int length) throws TeiidComponentException;
+
+ public void remove() {
+ if (!this.removed) {
+ this.removed = true;
+ this.removeDirect();
+ }
+ }
+
+ protected abstract void removeDirect();
+
+ public InputStream createInputStream(final long start) {
+ return new InputStream() {
+ private long offset = start;
+
+ @Override
+ public int read() throws IOException {
+ throw new UnsupportedOperationException("buffered reading must be used"); //$NON-NLS-1$
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ try {
+ int bytes = FileStore.this.read(offset, b, off, len);
+ if (bytes != -1) {
+ this.offset += bytes;
+ }
+ return bytes;
+ } catch (TeiidComponentException e) {
+ throw new IOException(e);
+ }
+ }
+ };
+ }
+
+ public OutputStream createOutputStream() {
+ return new OutputStream() {
+
+ @Override
+ public void write(int b) throws IOException {
+ throw new UnsupportedOperationException("buffered reading must be used"); //$NON-NLS-1$
+ }
+
+ @Override
+ public void write(byte[] b, int off, int len) throws IOException {
+ try {
+ FileStore.this.write(b, off, len);
+ } catch (TeiidComponentException e) {
+ throw new IOException(e);
+ }
+ }
+ };
+ }
+
+ public FileStoreOutputStream createOutputStream(int maxMemorySize) {
+ return new FileStoreOutputStream(maxMemorySize);
+ }
+
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/common/buffer/FileStore.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/IndexedTupleSource.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/IndexedTupleSource.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/IndexedTupleSource.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/IndexedTupleSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,60 @@
+/*
+ * 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.common.buffer;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
+public interface IndexedTupleSource extends TupleSource {
+
+ /**
+ * @return true if there are more tuples
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
+ */
+ boolean hasNext() throws TeiidComponentException, TeiidProcessingException;
+
+ /**
+ * Save the current position that can be restored with a call to {@link #reset()}
+ */
+ void mark();
+
+ /**
+ * Restore the previous mark and set the mark back to the first position.
+ */
+ void reset();
+
+ /**
+ * Set the tuple source position
+ * @param position
+ */
+ void setPosition(int position);
+
+ /**
+ * Get the current position. The position is 1 based and reports the position of the
+ * tuple that will be retrieved with a call to {@link TupleSource#nextTuple()}
+ * @return
+ */
+ int getCurrentIndex();
+
+}
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/StorageManager.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/StorageManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/StorageManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/StorageManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,33 @@
+/*
+ * 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.common.buffer;
+
+import org.teiid.core.TeiidComponentException;
+
+public interface StorageManager {
+
+ void initialize() throws TeiidComponentException;
+
+ FileStore createFileStore(String name);
+
+}
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBatch.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBatch.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,184 @@
+/*
+ * 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.common.buffer;
+
+import java.io.Externalizable;
+import java.io.IOException;
+import java.io.ObjectInput;
+import java.io.ObjectOutput;
+import java.util.List;
+
+import org.teiid.client.BatchSerializer;
+
+
+/**
+ * Represents a set of indexed tuples. The {@link #getBeginRow beginning row}
+ * is the first row contained in this batch; if it equals "1" then it is the
+ * first row of the tuple source, otherwise this is a batch of intermediate
+ * tuples. The {@link #getEndRow ending row} is the last row contained in
+ * this tuple batch; it is equal to the beginning row plus the
+ * {@link #getRowCount number of rows} contained in this batch, minus one.
+ * This object is immutable and Serializable;
+ */
+public class TupleBatch implements Externalizable {
+
+ private static final long serialVersionUID = 6304443387337336957L;
+
+ private int rowOffset;
+ private List[] tuples;
+
+ // Optional state
+ private boolean terminationFlag = false;
+
+ /**
+ * Contains ordered data types of each of the columns in the batch. Although it is not serialized,
+ * this array is a serialization aid and must be set before serialization and deserialization using
+ * the setDataTypes method.
+ */
+ private transient String[] types;
+
+ /** Required to honor Externalizable contract */
+ public TupleBatch() {
+ }
+
+ /**
+ * Constructor
+ * @param beginRow indicates the row of the tuple source which is the
+ * first row contained in this batch
+ * @param tuples array of List objects, each of which is
+ * a single tuple
+ */
+ public TupleBatch(int beginRow, List[] tuples) {
+ this.rowOffset = beginRow;
+ this.tuples = tuples;
+ }
+
+ /**
+ * Constructor
+ * @param beginRow indicates the row of the tuple source which is the
+ * first row contained in this batch
+ * @param listOfTupleLists List containing List objects, each of which is
+ * a single tuple
+ */
+ public TupleBatch(int beginRow, List listOfTupleLists) {
+ this.rowOffset = beginRow;
+ this.tuples = (List[]) listOfTupleLists.toArray(new List[listOfTupleLists.size()]);
+ }
+
+ /**
+ * Return the number of the first row of the tuple source that is
+ * contained in this batch (one-based).
+ * @return the first row contained in this tuple batch
+ */
+ public int getBeginRow() {
+ return rowOffset;
+ }
+
+ /**
+ * Return number of the last row of the tuple source that is contained in
+ * this batch (one-based).
+ * @return the last row contained in this tuple batch
+ */
+ public int getEndRow() {
+ return rowOffset + tuples.length - 1;
+ }
+
+ /**
+ * Return the number of rows contained in this tuple batch
+ * @return the number of rows contained in this tuple batch
+ */
+ public int getRowCount() {
+ return tuples.length;
+ }
+
+ /**
+ * Return the tuple at the given index (one-based).
+ * @return the tuple at the given index
+ */
+ public List getTuple(int rowIndex) {
+ return tuples[rowIndex-rowOffset];
+ }
+
+ /**
+ * Get all tuples
+ * @return All tuples
+ */
+ public List[] getAllTuples() {
+ return tuples;
+ }
+
+ /**
+ * Check whether this batch is the last in a series of batches.
+ * @return True if this batch is last
+ */
+ public boolean getTerminationFlag() {
+ return this.terminationFlag;
+ }
+
+ /**
+ * Set whether this batch is the last in a series of batches.
+ * @param terminationFlag True if last
+ */
+ public void setTerminationFlag(boolean terminationFlag) {
+ this.terminationFlag = terminationFlag;
+ }
+
+ public String[] getDataTypes() {
+ return types;
+ }
+
+ public void setDataTypes(String[] types) {
+ this.types = types;
+ }
+
+ public boolean containsRow(int row) {
+ return rowOffset <= row && getEndRow() >= row;
+ }
+
+ /**
+ * Return a String describing this object
+ * @param String representation of this TupleBatch
+ */
+ public String toString() {
+ StringBuffer s = new StringBuffer();
+ s.append("TupleBatch; beginning row="); //$NON-NLS-1$
+ s.append(rowOffset);
+ s.append(", number of rows="); //$NON-NLS-1$
+ s.append(tuples.length);
+ s.append(", lastBatch="); //$NON-NLS-1$
+ s.append(this.terminationFlag);
+ return s.toString();
+ }
+
+ public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
+ rowOffset = in.readInt();
+ terminationFlag = in.readBoolean();
+ tuples = BatchSerializer.readBatch(in, types);
+ }
+ public void writeExternal(ObjectOutput out) throws IOException {
+ out.writeInt(rowOffset);
+ out.writeBoolean(terminationFlag);
+ BatchSerializer.writeBatch(out, types, tuples);
+ }
+}
+
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleBuffer.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,419 @@
+/*
+ * 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.common.buffer;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.query.sql.symbol.Expression;
+
+
+public class TupleBuffer {
+
+ class TupleSourceImpl implements IndexedTupleSource {
+ private int currentRow = 1;
+ private int mark = 1;
+ private List<?> currentTuple;
+ private TupleBatch batch;
+
+ @Override
+ public int getCurrentIndex() {
+ return this.currentRow;
+ }
+
+ @Override
+ public List getSchema(){
+ return schema;
+ }
+
+ @Override
+ public List<?> nextTuple()
+ throws TeiidComponentException{
+ List<?> result = null;
+ if (currentTuple != null){
+ result = currentTuple;
+ currentTuple = null;
+ } else {
+ result = getCurrentTuple();
+ }
+ if (result != null) {
+ currentRow++;
+ }
+ return result;
+ }
+
+ private List<?> getCurrentTuple() throws TeiidComponentException,
+ BlockedException {
+ if (currentRow <= rowCount) {
+ //if (forwardOnly) {
+ if (batch == null || !batch.containsRow(currentRow)) {
+ batch = getBatch(currentRow);
+ }
+ return batch.getTuple(currentRow);
+ //}
+ //TODO: determine if we should directly hold a soft reference here
+ //return getRow(currentRow);
+ }
+ batch = null;
+ if(isFinal) {
+ return null;
+ }
+ throw BlockedException.INSTANCE;
+ }
+
+ @Override
+ public void closeSource() {
+ batch = null;
+ mark = 1;
+ reset();
+ }
+
+ @Override
+ public boolean hasNext() throws TeiidComponentException {
+ if (this.currentTuple != null) {
+ return true;
+ }
+
+ this.currentTuple = getCurrentTuple();
+ return this.currentTuple != null;
+ }
+
+ @Override
+ public void reset() {
+ this.setPosition(mark);
+ this.mark = 1;
+ }
+
+ @Override
+ public void mark() {
+ this.mark = currentRow;
+ }
+
+ @Override
+ public void setPosition(int position) {
+ if (this.currentRow != position) {
+ this.currentRow = position;
+ this.currentTuple = null;
+ }
+ }
+
+ @Override
+ public int available() {
+ return rowCount - currentRow + 1;
+ }
+ }
+
+ /**
+ * Gets the data type names for each of the input expressions, in order.
+ * @param expressions List of Expressions
+ * @return
+ * @since 4.2
+ */
+ public static String[] getTypeNames(List expressions) {
+ if (expressions == null) {
+ return null;
+ }
+ String[] types = new String[expressions.size()];
+ for (ListIterator i = expressions.listIterator(); i.hasNext();) {
+ Expression expr = (Expression)i.next();
+ types[i.previousIndex()] = DataTypeManager.getDataTypeName(expr.getType());
+ }
+ return types;
+ }
+
+ private static final AtomicLong LOB_ID = new AtomicLong();
+
+ //construction state
+ private BatchManager manager;
+ private String tupleSourceID;
+ private List<?> schema;
+ private String[] types;
+ private int batchSize;
+
+ private int rowCount;
+ private boolean isFinal;
+ private TreeMap<Integer, BatchManager.ManagedBatch> batches = new TreeMap<Integer, BatchManager.ManagedBatch>();
+ private ArrayList<List<?>> batchBuffer;
+ private boolean removed;
+ private boolean forwardOnly;
+
+ //lob management
+ private Map<String, Streamable<?>> lobReferences; //references to contained lobs
+ private boolean lobs = true;
+
+ public TupleBuffer(BatchManager manager, String id, List<?> schema, int batchSize) {
+ this.manager = manager;
+ this.tupleSourceID = id;
+ this.schema = schema;
+ this.types = getTypeNames(schema);
+ this.batchSize = batchSize;
+ if (types != null) {
+ int i = 0;
+ for (i = 0; i < types.length; i++) {
+ if (DataTypeManager.isLOB(types[i]) || types[i] == DataTypeManager.DefaultDataTypes.OBJECT) {
+ break;
+ }
+ }
+ if (i == types.length) {
+ lobs = false;
+ }
+ }
+ }
+
+ public void addTuple(List<?> tuple) throws TeiidComponentException {
+ if (lobs) {
+ correctLobReferences(new List[] {tuple});
+ }
+ this.rowCount++;
+ if (batchBuffer == null) {
+ batchBuffer = new ArrayList<List<?>>(batchSize/4);
+ }
+ batchBuffer.add(tuple);
+ if (batchBuffer.size() == batchSize) {
+ saveBatch(false, false);
+ }
+ }
+
+ /**
+ * Adds the given batch preserving row offsets.
+ * @param batch
+ * @throws TeiidComponentException
+ */
+ public void addTupleBatch(TupleBatch batch, boolean save) throws TeiidComponentException {
+ setRowCount(batch.getBeginRow() - 1);
+ if (save) {
+ for (List<?> tuple : batch.getAllTuples()) {
+ addTuple(tuple);
+ }
+ }
+ }
+
+ public void setRowCount(int rowCount)
+ throws TeiidComponentException {
+ assert this.rowCount <= rowCount;
+ if (this.rowCount != rowCount) {
+ saveBatch(false, true);
+ this.rowCount = rowCount;
+ }
+ }
+
+ public void purge() {
+ if (this.batchBuffer != null) {
+ this.batchBuffer.clear();
+ }
+ for (BatchManager.ManagedBatch batch : this.batches.values()) {
+ batch.remove();
+ }
+ this.batches.clear();
+ }
+
+ /**
+ * Force the persistence of any rows held in memory.
+ * @throws TeiidComponentException
+ */
+ public void saveBatch() throws TeiidComponentException {
+ this.saveBatch(false, false);
+ }
+
+ void saveBatch(boolean finalBatch, boolean force) throws TeiidComponentException {
+ Assertion.assertTrue(!this.isRemoved());
+ if (batchBuffer == null || batchBuffer.isEmpty() || (!force && batchBuffer.size() < Math.max(1, batchSize / 32))) {
+ return;
+ }
+ TupleBatch writeBatch = new TupleBatch(rowCount - batchBuffer.size() + 1, batchBuffer);
+ if (finalBatch) {
+ writeBatch.setTerminationFlag(true);
+ }
+ writeBatch.setDataTypes(types);
+ BatchManager.ManagedBatch mbatch = manager.createManagedBatch(writeBatch);
+ this.batches.put(writeBatch.getBeginRow(), mbatch);
+ batchBuffer = null;
+ }
+
+ public void close() throws TeiidComponentException {
+ saveBatch(true, false);
+ this.isFinal = true;
+ }
+
+ /**
+ * Get the batch containing the given row.
+ * NOTE: the returned batch may be empty or may begin with a row other
+ * than the one specified.
+ * @param row
+ * @return
+ * @throws TeiidComponentException
+ */
+ public TupleBatch getBatch(int row) throws TeiidComponentException {
+ TupleBatch result = null;
+ if (row > rowCount) {
+ result = new TupleBatch(rowCount + 1, new List[] {});
+ } else if (this.batchBuffer != null && row > rowCount - this.batchBuffer.size()) {
+ result = new TupleBatch(rowCount - this.batchBuffer.size() + 1, batchBuffer);
+ if (forwardOnly) {
+ this.batchBuffer = null;
+ }
+ } else {
+ if (this.batchBuffer != null && !this.batchBuffer.isEmpty()) {
+ //this is just a sanity check to ensure we're not holding too many
+ //hard references to batches.
+ saveBatch(isFinal, false);
+ }
+ Map.Entry<Integer, BatchManager.ManagedBatch> entry = batches.floorEntry(row);
+ Assertion.isNotNull(entry);
+ BatchManager.ManagedBatch batch = entry.getValue();
+ result = batch.getBatch(!forwardOnly, types);
+ if (lobs && result.getDataTypes() == null) {
+ correctLobReferences(result.getAllTuples());
+ }
+ result.setDataTypes(types);
+ if (forwardOnly) {
+ batches.remove(entry.getKey());
+ }
+ }
+ if (isFinal && result.getEndRow() == rowCount) {
+ result.setTerminationFlag(true);
+ }
+ return result;
+ }
+
+ public void remove() {
+ if (!removed) {
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, "Removing TupleBuffer:", this.tupleSourceID); //$NON-NLS-1$
+ }
+ this.batchBuffer = null;
+ purge();
+ this.manager.remove();
+ removed = true;
+ }
+ }
+
+ public int getRowCount() {
+ return rowCount;
+ }
+
+ public boolean isFinal() {
+ return isFinal;
+ }
+
+ public void setFinal(boolean isFinal) {
+ this.isFinal = isFinal;
+ }
+
+ public List<?> getSchema() {
+ return schema;
+ }
+
+ public int getBatchSize() {
+ return batchSize;
+ }
+
+ public void setBatchSize(int batchSize) {
+ this.batchSize = batchSize;
+ }
+
+ public Streamable<?> getLobReference(String id) throws TeiidComponentException {
+ Streamable<?> lob = null;
+ if (this.lobReferences != null) {
+ lob = this.lobReferences.get(id);
+ }
+ if (lob == null) {
+ throw new TeiidComponentException(DQPPlugin.Util.getString("ProcessWorker.wrongdata")); //$NON-NLS-1$
+ }
+ return lob;
+ }
+
+ /**
+ * If a tuple batch is being added with Lobs, then references to
+ * the lobs will be held on the {@link TupleSourceInfo}
+ * @param batch
+ * @throws TeiidComponentException
+ */
+ @SuppressWarnings("unchecked")
+ private void correctLobReferences(List[] rows) throws TeiidComponentException {
+ int columns = schema.size();
+ // walk through the results and find all the lobs
+ for (int row = 0; row < rows.length; row++) {
+ for (int col = 0; col < columns; col++) {
+ Object anObj = rows[row].get(col);
+
+ if (!(anObj instanceof Streamable<?>)) {
+ continue;
+ }
+ Streamable lob = (Streamable)anObj;
+ String id = lob.getReferenceStreamId();
+ if (id == null) {
+ id = String.valueOf(LOB_ID.getAndIncrement());
+ lob.setReferenceStreamId(id);
+ }
+ if (this.lobReferences == null) {
+ this.lobReferences = Collections.synchronizedMap(new HashMap<String, Streamable<?>>());
+ }
+ this.lobReferences.put(id, lob);
+ if (lob.getReference() == null) {
+ lob.setReference(getLobReference(lob.getReferenceStreamId()).getReference());
+ }
+ }
+ }
+ }
+
+ public void setForwardOnly(boolean forwardOnly) {
+ this.forwardOnly = forwardOnly;
+ }
+
+ /**
+ * Create a new iterator for this buffer
+ * @return
+ */
+ public IndexedTupleSource createIndexedTupleSource() {
+ return new TupleSourceImpl();
+ }
+
+ @Override
+ public String toString() {
+ return this.tupleSourceID;
+ }
+
+ public boolean isRemoved() {
+ return removed;
+ }
+
+ public boolean isForwardOnly() {
+ return forwardOnly;
+ }
+
+}
Property changes on: trunk/engine/src/main/java/org/teiid/common/buffer/TupleBuffer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/TupleSource.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/TupleSource.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/common/buffer/TupleSource.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/TupleSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,67 @@
+/*
+ * 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.common.buffer;
+
+import java.util.List;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
+
+/**
+ * <p>A cursored source of tuples. The implementation will likely be closely
+ * bound to a {@link BufferManager} implementation - it will work with it
+ * to use {@link TupleBatch TupleBatches} behind the scenes.</p>
+ */
+public interface TupleSource {
+
+ /**
+ * Returns the List of ElementSymbol describing the Tuple Source
+ * @return the List of elements describing the Tuple Source
+ */
+ List<SingleElementSymbol> getSchema();
+
+ /**
+ * Returns the next tuple
+ * @return the next tuple (a List object), or <code>null</code> if
+ * there are no more tuples.
+ * @throws TeiidComponentException indicating a non-business
+ * exception such as a communication exception, or other such
+ * nondeterministic exception
+ */
+ List<?> nextTuple()
+ throws TeiidComponentException, TeiidProcessingException;
+
+ /**
+ * Closes the Tuple Source.
+ */
+ void closeSource();
+
+ /**
+ * Returns an estimate of the number of rows that can be read without blocking.
+ * @return
+ */
+ int available();
+
+}
Copied: trunk/engine/src/main/java/org/teiid/common/buffer/impl (from rev 2112, trunk/engine/src/main/java/com/metamatrix/common/buffer/impl)
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/BufferManagerImpl.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/BufferManagerImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.buffer.impl;
+package org.teiid.common.buffer.impl;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
@@ -43,29 +43,29 @@
import javax.xml.transform.Source;
+import org.teiid.common.buffer.BatchManager;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.BatchManager.ManagedBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.SourceTransform;
+import org.teiid.core.types.StandardXMLTranslator;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.Assertion;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.processor.xml.XMLUtil;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BatchManager;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.BatchManager.ManagedBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.InputStreamFactory;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.SourceTransform;
-import com.metamatrix.common.types.StandardXMLTranslator;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.xml.XMLUtil;
/**
* <p>Default implementation of BufferManager.</p>
@@ -151,7 +151,7 @@
}
@Override
- public TupleBatch getBatch(boolean cache, String[] types) throws MetaMatrixComponentException {
+ public TupleBatch getBatch(boolean cache, String[] types) throws TeiidComponentException {
int reads = readAttempts.incrementAndGet();
LogManager.logTrace(LogConstants.CTX_BUFFER_MGR, id, "getting batch", reads, "reference hits", referenceHit.get()); //$NON-NLS-1$ //$NON-NLS-2$
synchronized (activeBatches) {
@@ -203,14 +203,14 @@
}
return batch;
} catch(IOException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", id)); //$NON-NLS-1$
+ throw new TeiidComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", id)); //$NON-NLS-1$
} catch (ClassNotFoundException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", id)); //$NON-NLS-1$
+ throw new TeiidComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", id)); //$NON-NLS-1$
}
}
}
- public synchronized void persist() throws MetaMatrixComponentException {
+ public synchronized void persist() throws TeiidComponentException {
try {
TupleBatch batch = activeBatch;
if (batch != null) {
@@ -229,7 +229,7 @@
this.batchReference = new WeakReference<TupleBatch>(batch);
}
} catch (IOException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
} finally {
persistent = true;
activeBatch = null;
@@ -334,7 +334,7 @@
@Override
public ManagedBatch createManagedBatch(TupleBatch batch)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
if (this.store == null) {
this.store = createFileStore(newID);
this.store.setCleanupReference(this);
@@ -365,7 +365,7 @@
}
@Override
- public void initialize() throws MetaMatrixComponentException {
+ public void initialize() throws TeiidComponentException {
//TODO: remove me - connectors should be able to do this statefully
DataTypeManager.addSourceTransform(Source.class, new SourceTransform<Source, XMLType>() {
@Override
@@ -377,10 +377,10 @@
SQLXMLImpl sqlxml;
try {
sqlxml = XMLUtil.saveToBufferManager(BufferManagerImpl.this, sxt, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (MetaMatrixProcessingException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidProcessingException e) {
+ throw new TeiidRuntimeException(e);
}
return new XMLType(sqlxml);
}
@@ -411,7 +411,7 @@
try {
batchesFreed.await(100, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
waitCount++;
}
@@ -464,7 +464,7 @@
}
try {
mb.persist();
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
LogManager.logDetail(LogConstants.CTX_BUFFER_MGR, e, "Error persisting batch, attempts to read that batch later will result in an exception"); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/FileStorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/FileStorageManager.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/FileStorageManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.buffer.impl;
+package org.teiid.common.buffer.impl;
import java.io.File;
import java.io.FileNotFoundException;
@@ -31,14 +31,14 @@
import java.util.Map;
import java.util.TreeMap;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.Assertion;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.execution.QueryExecPlugin;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.execution.QueryExecPlugin;
/**
* Implements file storage that automatically splits large files and limits the number of open files.
@@ -101,7 +101,7 @@
/**
* Concurrent reads are possible, but only after writing is complete.
*/
- public int readDirect(long fileOffset, byte[] b, int offSet, int length) throws MetaMatrixComponentException {
+ public int readDirect(long fileOffset, byte[] b, int offSet, int length) throws TeiidComponentException {
Map.Entry<Long, FileInfo> entry = storageFiles.floorEntry(fileOffset);
Assertion.isNotNull(entry);
FileInfo fileInfo = entry.getValue();
@@ -111,7 +111,7 @@
fileAccess.seek(fileOffset - entry.getKey());
return fileAccess.read(b, offSet, length);
} catch (IOException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
+ throw new TeiidComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
} finally {
fileInfo.close();
}
@@ -121,7 +121,7 @@
/**
* Concurrent writes are prevented by FileStore, but in general should not happen since processing is single threaded.
*/
- public void writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
+ public void writeDirect(byte[] bytes, int offset, int length) throws TeiidComponentException {
Map.Entry<Long, FileInfo> entry = this.storageFiles.lastEntry();
boolean createNew = false;
FileInfo fileInfo = null;
@@ -149,7 +149,7 @@
fileAccess.seek(pointer);
fileAccess.write(bytes, offset, length);
} catch(IOException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
+ throw new TeiidComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_reading", fileInfo.file.getAbsoluteFile())); //$NON-NLS-1$
} finally {
fileInfo.close();
}
@@ -189,19 +189,19 @@
/**
* Initialize
*/
- public void initialize() throws MetaMatrixComponentException {
+ public void initialize() throws TeiidComponentException {
if(this.directory == null) {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.no_directory")); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.no_directory")); //$NON-NLS-1$
}
dirFile = new File(this.directory);
if(dirFile.exists()) {
if(! dirFile.isDirectory()) {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.not_a_directory", dirFile.getAbsoluteFile())); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.not_a_directory", dirFile.getAbsoluteFile())); //$NON-NLS-1$
}
} else if(! dirFile.mkdirs()) {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.error_creating", dirFile.getAbsoluteFile())); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("FileStoreageManager.error_creating", dirFile.getAbsoluteFile())); //$NON-NLS-1$
}
}
@@ -221,7 +221,7 @@
this.directory = directory;
}
- File createFile(String name, int fileNumber) throws MetaMatrixComponentException {
+ File createFile(String name, int fileNumber) throws TeiidComponentException {
try {
File storageFile = File.createTempFile(FILE_PREFIX + name + "_" + String.valueOf(fileNumber) + "_", null, this.dirFile); //$NON-NLS-1$ //$NON-NLS-2$
if (LogManager.isMessageToBeRecorded(org.teiid.logging.LogConstants.CTX_BUFFER_MGR, MessageLevel.DETAIL)) {
@@ -229,7 +229,7 @@
}
return storageFile;
} catch(IOException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_creating", name + "_" + fileNumber)); //$NON-NLS-1$ //$NON-NLS-2$
+ throw new TeiidComponentException(e, QueryExecPlugin.Util.getString("FileStoreageManager.error_creating", name + "_" + fileNumber)); //$NON-NLS-1$ //$NON-NLS-2$
}
}
Modified: trunk/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/common/buffer/impl/MemoryStorageManager.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/common/buffer/impl/MemoryStorageManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.common.buffer.impl;
+package org.teiid.common.buffer.impl;
import java.nio.ByteBuffer;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.StorageManager;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.StorageManager;
+import org.teiid.core.TeiidComponentException;
+
public class MemoryStorageManager implements StorageManager {
public void initialize() {
@@ -39,7 +40,7 @@
private ByteBuffer buffer = ByteBuffer.allocate(1 << 16);
@Override
- public void writeDirect(byte[] bytes, int offset, int length) throws MetaMatrixComponentException {
+ public void writeDirect(byte[] bytes, int offset, int length) throws TeiidComponentException {
if (getLength() + length > buffer.capacity()) {
ByteBuffer newBuffer = ByteBuffer.allocate(buffer.capacity() * 2 + length);
newBuffer.put(buffer);
@@ -56,7 +57,7 @@
@Override
public synchronized int readDirect(long fileOffset, byte[] b, int offset, int length)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
if (fileOffset >= getLength()) {
return -1;
}
Copied: trunk/engine/src/main/java/org/teiid/dqp/DQPPlugin.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/dqp/DQPPlugin.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/DQPPlugin.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/dqp/DQPPlugin.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,39 @@
+/*
+ * 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.dqp;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+
+/**
+ * DQPPlugin
+ */
+public class DQPPlugin {
+
+ public static final String PLUGIN_ID = DQPPlugin.class.getPackage().getName();
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
+ PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
+
+}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/cache/DQPContextCache.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -23,13 +23,13 @@
import java.io.Serializable;
+import org.teiid.cache.Cache;
+import org.teiid.cache.CacheConfiguration;
+import org.teiid.cache.CacheFactory;
+import org.teiid.cache.CacheConfiguration.Policy;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import com.metamatrix.cache.Cache;
-import com.metamatrix.cache.CacheConfiguration;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.cache.CacheConfiguration.Policy;
public class DQPContextCache implements Serializable{
private static final long serialVersionUID = 6958846566556640186L;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/CapabilitiesConverter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -25,11 +25,11 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.resource.cci.ConnectorCapabilities;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
/**
* Utility to convert a ConnectorCapabilities class into a Map of
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -35,33 +35,33 @@
import javax.naming.InitialContext;
import javax.naming.NamingException;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.connector.metadata.runtime.Datatype;
import org.teiid.connector.metadata.runtime.MetadataFactory;
import org.teiid.connector.metadata.runtime.MetadataStore;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWorkItem.PermitMode;
import org.teiid.dqp.internal.process.AbstractWorkItem;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.service.BufferService;
import org.teiid.logging.CommandLogMessage;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Scope;
+import org.teiid.query.sql.lang.Command;
import org.teiid.resource.ConnectorException;
import org.teiid.resource.cci.ConnectorCapabilities;
import org.teiid.resource.cci.ExecutionContext;
import org.teiid.resource.cci.ExecutionFactory;
import org.teiid.resource.cci.MetadataProvider;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Scope;
-import com.metamatrix.query.sql.lang.Command;
/**
* The <code>ConnectorManager</code> manages a {@link org.teiid.resource.adapter.BasicExecutionFactory Connector}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWork.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,10 +22,10 @@
package org.teiid.dqp.internal.datamgr.impl;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.dqp.message.AtomicResultsMessage;
import org.teiid.resource.ConnectorException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
/**
* Represents a connector execution in batched form.
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ConnectorWorkItem.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -28,15 +28,31 @@
import java.util.concurrent.atomic.AtomicBoolean;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBuffer;
import org.teiid.connector.language.Call;
import org.teiid.connector.language.QueryExpression;
import org.teiid.connector.metadata.runtime.RuntimeMetadata;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.datamgr.language.LanguageBridgeFactory;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
import org.teiid.dqp.internal.process.AbstractWorkItem;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.AtomicResultsMessage;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.resource.ConnectorException;
import org.teiid.resource.cci.DataNotAvailableException;
import org.teiid.resource.cci.Execution;
@@ -45,22 +61,6 @@
import org.teiid.resource.cci.ResultSetExecution;
import org.teiid.resource.cci.UpdateExecution;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
public class ConnectorWorkItem implements ConnectorWork {
@@ -203,7 +203,7 @@
String msg = DQPPlugin.Util.getString("ConnectorWorker.process_failed", this.id); //$NON-NLS-1$
if (isCancelled.get()) {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, msg);
- } else if (t instanceof ConnectorException || t instanceof MetaMatrixProcessingException) {
+ } else if (t instanceof ConnectorException || t instanceof TeiidProcessingException) {
LogManager.logWarning(LogConstants.CTX_CONNECTOR, t, msg);
} else {
LogManager.logError(LogConstants.CTX_CONNECTOR, t, msg);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ExecutionContextImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -30,15 +30,15 @@
import javax.security.auth.Subject;
+import org.teiid.cache.Cache;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.resource.cci.CacheScope;
import org.teiid.resource.cci.ExecutionContext;
-import com.metamatrix.cache.Cache;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.dqp.DQPPlugin;
/**
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/impl/ProcedureBatchHandler.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -33,10 +33,10 @@
import org.teiid.connector.language.Argument;
import org.teiid.connector.language.Call;
import org.teiid.connector.language.Argument.Direction;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.resource.ConnectorException;
import org.teiid.resource.cci.ProcedureExecution;
-import com.metamatrix.dqp.DQPPlugin;
class ProcedureBatchHandler {
private Call proc;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/language/LanguageBridgeFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -26,6 +26,7 @@
import java.util.Iterator;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.connector.language.AggregateFunction;
import org.teiid.connector.language.AndOr;
@@ -60,56 +61,55 @@
import org.teiid.connector.language.SubqueryComparison.Quantifier;
import org.teiid.connector.metadata.runtime.Procedure;
import org.teiid.connector.metadata.runtime.ProcedureParameter;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
import org.teiid.dqp.internal.datamgr.metadata.RuntimeMetadataImpl;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.SetClause;
+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.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.resource.ConnectorException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
public class LanguageBridgeFactory {
private RuntimeMetadataImpl metadataFactory = null;
@@ -586,7 +586,7 @@
try {
proc = this.metadataFactory.getProcedure(sp.getGroup().getName());
} catch (ConnectorException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
Class<?> returnType = null;
@@ -640,9 +640,9 @@
try {
group.setMetadataObject(metadataFactory.getGroup(symbol.getMetadataID()));
} catch (QueryMetadataException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
return group;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/datamgr/metadata/RuntimeMetadataImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -24,15 +24,15 @@
*/
package org.teiid.dqp.internal.datamgr.metadata;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.metadata.runtime.*;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.sql.lang.SPParameter;
import org.teiid.resource.ConnectorException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.sql.lang.SPParameter;
/**
*/
@@ -51,7 +51,7 @@
return getElement(metadataId);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new ConnectorException(e);
}
}
@@ -70,12 +70,12 @@
return getGroup(groupId);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new ConnectorException(e);
}
}
- public Table getGroup(Object groupId) throws QueryMetadataException, MetaMatrixComponentException {
+ public Table getGroup(Object groupId) throws QueryMetadataException, TeiidComponentException {
if (!metadata.isVirtualGroup(groupId) && groupId instanceof Table) {
return (Table)groupId;
}
@@ -89,7 +89,7 @@
return getProcedure(sp);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new ConnectorException(e);
}
}
@@ -113,7 +113,7 @@
return metadata.getBinaryVDBResource(resourcePath);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new ConnectorException(e);
}
}
@@ -123,7 +123,7 @@
return metadata.getCharacterVDBResource(resourcePath);
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new ConnectorException(e);
}
}
@@ -133,7 +133,7 @@
return metadata.getVDBResourcePaths();
} catch (QueryMetadataException e) {
throw new ConnectorException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new ConnectorException(e);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/ByteLobChunkStream.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -28,8 +28,8 @@
import org.teiid.client.lob.LobChunk;
import org.teiid.client.lob.LobChunkProducer;
+import org.teiid.core.CorePlugin;
-import com.metamatrix.core.CorePlugin;
/**
* A wrapper class, given a InputStream object can convert a underlying
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedFinder.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -27,17 +27,17 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.resource.ConnectorException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
/**
*/
@@ -63,7 +63,7 @@
/**
* Find capabilities used the cache if possible, otherwise do the lookup.
*/
- public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
+ public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
SourceCapabilities caps = userCache.get(modelName);
if(caps != null) {
return caps;
@@ -86,11 +86,11 @@
}
if (exception != null) {
- throw new MetaMatrixComponentException(exception);
+ throw new TeiidComponentException(exception);
}
if (caps == null) {
- throw new MetaMatrixRuntimeException("No sources were given for the model " + modelName); //$NON-NLS-1$
+ throw new TeiidRuntimeException("No sources were given for the model " + modelName); //$NON-NLS-1$
}
userCache.put(modelName, caps);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CachedResults.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,10 +22,11 @@
package org.teiid.dqp.internal.process;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.sql.lang.Command;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.sql.lang.Command;
+
public class CachedResults {
private Command command;
private AnalysisRecord analysisRecord;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/CodeTableCache.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -29,14 +29,14 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.logging.LogManager;
+import org.teiid.query.util.CommandContext;
+import org.teiid.vdb.runtime.VDBKey;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.vdb.runtime.VDBKey;
/**
* Code table cache. Heavily synchronized in-memory cache of code tables. There is no purging policy for this cache. Once the limits have been reached exceptions will occur.
@@ -136,9 +136,9 @@
* @param requestID Part of RequestKey
* @param nodeID Part of RequestKey
* @param results QueryResults of <List<List<keyValue, returnValue>>
- * @throws MetaMatrixProcessingException
+ * @throws TeiidProcessingException
*/
- public synchronized void loadTable(CacheKey cacheKey, List[] records) throws MetaMatrixProcessingException {
+ public synchronized void loadTable(CacheKey cacheKey, List[] records) throws TeiidProcessingException {
// Lookup the existing data
// Map of data: keyValue --> returnValue;
CodeTable table = codeTableCache.get(cacheKey);
@@ -150,11 +150,11 @@
// Depends on size of results and available memory and system parameters
int potentialSize = table.codeMap.size() + records.length;
if (potentialSize > maxCodeTableRecords) {
- throw new MetaMatrixProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", "maxCodeTables")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw new TeiidProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", "maxCodeTables")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
if (potentialSize + rowCount > maxCodeRecords) {
- throw new MetaMatrixProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", "maxCodeTableRecords")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw new TeiidProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", "maxCodeTableRecords")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
// Add data: <List<List<keyValue, returnValue>> from results to the code table cache
@@ -165,7 +165,7 @@
Object returnValue = record.get(1);
Object existing = table.codeMap.put(keyValue, returnValue);
if (existing != null) {
- throw new MetaMatrixProcessingException(DQPPlugin.Util.getString("CodeTableCache.duplicate_key", cacheKey.getCodeTable(), cacheKey.getKeyElement(), keyValue)); //$NON-NLS-1$
+ throw new TeiidProcessingException(DQPPlugin.Util.getString("CodeTableCache.duplicate_key", cacheKey.getCodeTable(), cacheKey.getKeyElement(), keyValue)); //$NON-NLS-1$
}
}
}
@@ -178,14 +178,14 @@
* @param keyValue Input key value
* @return Object of return value in code table cache
*/
- public synchronized Object lookupValue(String codeTable, String returnElement, String keyElement, Object keyValue, CommandContext context) throws MetaMatrixComponentException {
+ public synchronized Object lookupValue(String codeTable, String returnElement, String keyElement, Object keyValue, CommandContext context) throws TeiidComponentException {
// Create CacheKey
CacheKey cacheKey = new CacheKey(codeTable, returnElement, keyElement, context.getVdbName(), context.getVdbVersion());
// Find the corresponding data map in cache for the cache key
CodeTable table = codeTableCache.get(cacheKey);
if(table == null || table.codeMap == null) {
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("CodeTableCache.No_code_table", cacheKey.codeTable,cacheKey.keyElement,cacheKey.returnElement)); //$NON-NLS-1$
+ throw new TeiidComponentException(DQPPlugin.Util.getString("CodeTableCache.No_code_table", cacheKey.codeTable,cacheKey.keyElement,cacheKey.returnElement)); //$NON-NLS-1$
}
return table.codeMap.get(keyValue);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPCore.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -55,29 +55,29 @@
import org.teiid.client.util.ResultsReceiver;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.cache.DQPContextCache;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.BufferService;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionService;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.logging.CommandLogMessage;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.TransactionContext.Scope;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
/**
* Implements the core DQP processing.
@@ -323,7 +323,7 @@
}
public ResultsFuture<ResultsMessage> processCursorRequest(long reqID,
- int batchFirst, int fetchSize) throws MetaMatrixProcessingException {
+ int batchFirst, int fetchSize) throws TeiidProcessingException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "DQP process cursor request from " + batchFirst); //$NON-NLS-1$
}
@@ -353,7 +353,7 @@
this.processWorkerPool.scheduleWork(work);
} catch (WorkException e) {
//TODO: cancel? close?
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
@@ -372,7 +372,7 @@
}
}, null, delay);
} catch (WorkException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
@@ -382,7 +382,7 @@
public ResultsFuture<?> closeLobChunkStream(int lobRequestId,
long requestId, String streamId)
- throws MetaMatrixProcessingException {
+ throws TeiidProcessingException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "Request to close the Lob stream with Stream id="+streamId+" instance id="+lobRequestId); //$NON-NLS-1$//$NON-NLS-2$
}
@@ -396,7 +396,7 @@
public ResultsFuture<LobChunk> requestNextLobChunk(int lobRequestId,
long requestId, String streamId)
- throws MetaMatrixProcessingException {
+ throws TeiidProcessingException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "Request for next Lob chunk with Stream id="+streamId+" instance id="+lobRequestId); //$NON-NLS-1$//$NON-NLS-2$
}
@@ -421,10 +421,10 @@
// workItem.requestAtomicRequestCancel(requestID);
// }
- RequestWorkItem getRequestWorkItem(RequestID reqID) throws MetaMatrixProcessingException {
+ RequestWorkItem getRequestWorkItem(RequestID reqID) throws TeiidProcessingException {
RequestWorkItem result = this.requests.get(reqID);
if (result == null) {
- throw new MetaMatrixProcessingException(DQPPlugin.Util.getString("DQPCore.The_request_has_been_closed.", reqID));//$NON-NLS-1$
+ throw new TeiidProcessingException(DQPPlugin.Util.getString("DQPCore.The_request_has_been_closed.", reqID));//$NON-NLS-1$
}
return result;
}
@@ -450,7 +450,7 @@
for (RequestID reqId : state.getRequests()) {
try {
cancelRequest(reqId);
- } catch (MetaMatrixComponentException err) {
+ } catch (TeiidComponentException err) {
LogManager.logWarning(LogConstants.CTX_DQP, err, "Failed to cancel " + reqId); //$NON-NLS-1$
}
}
@@ -464,12 +464,12 @@
contextCache.removeSessionScopedCache(sessionId);
}
- public boolean cancelRequest(String sessionId, long requestId) throws MetaMatrixComponentException {
+ public boolean cancelRequest(String sessionId, long requestId) throws TeiidComponentException {
RequestID requestID = new RequestID(sessionId, requestId);
return cancelRequest(requestID);
}
- private boolean cancelRequest(RequestID requestID) throws MetaMatrixComponentException {
+ private boolean cancelRequest(RequestID requestID) throws TeiidComponentException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "cancelQuery for requestID=" + requestID); //$NON-NLS-1$
}
@@ -488,7 +488,7 @@
return markCancelled;
}
- public ResultsFuture<?> closeRequest(long requestId) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ public ResultsFuture<?> closeRequest(long requestId) throws TeiidProcessingException, TeiidComponentException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
closeRequest(workContext.getRequestID(requestId));
return ResultsFuture.NULL_FUTURE;
@@ -497,9 +497,9 @@
/**
* Close the request with given ID
* @param requestID
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- void closeRequest(RequestID requestID) throws MetaMatrixComponentException {
+ void closeRequest(RequestID requestID) throws TeiidComponentException {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
LogManager.logDetail(LogConstants.CTX_DQP, "closeQuery for requestID=" + requestID); //$NON-NLS-1$
}
@@ -668,7 +668,7 @@
@Override
public boolean cancelRequest(long requestID)
- throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ throws TeiidProcessingException, TeiidComponentException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
return this.cancelRequest(workContext.getRequestID(requestID));
}
@@ -748,7 +748,7 @@
try {
this.workManager.scheduleWork(work);
} catch (WorkException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
return work.getResult();
}
@@ -787,7 +787,7 @@
}
public MetadataResult getMetadata(long requestID)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache, workContext.getVdbName(), workContext.getVdbVersion());
return processor.processMessage(workContext.getRequestID(requestID), workContext, null, true);
@@ -795,7 +795,7 @@
public MetadataResult getMetadata(long requestID, String preparedSql,
boolean allowDoubleQuotedVariable)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
DQPWorkContext workContext = DQPWorkContext.getWorkContext();
MetaDataProcessor processor = new MetaDataProcessor(this, this.prepPlanCache, workContext.getVdbName(), workContext.getVdbVersion());
return processor.processMessage(workContext.getRequestID(requestID), workContext, preparedSql, allowDoubleQuotedVariable);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DQPWorkContext.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -39,9 +39,9 @@
import org.teiid.adminapi.impl.SessionMetadata;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.security.SessionToken;
+import org.teiid.dqp.message.RequestID;
import org.teiid.security.SecurityHelper;
-import com.metamatrix.dqp.message.RequestID;
public class DQPWorkContext implements Serializable {
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 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -34,6 +34,9 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.client.RequestMessage;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
import org.teiid.connector.language.SQLReservedWords;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.Column;
@@ -44,41 +47,38 @@
import org.teiid.connector.metadata.runtime.ProcedureParameter;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.BlobImpl;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.ClobImpl;
+import org.teiid.core.types.ClobType;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManager;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
import org.teiid.dqp.internal.process.CodeTableCache.CacheKey;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.BufferService;
import org.teiid.metadata.CompositeMetadataStore;
import org.teiid.metadata.TransformationMetadata;
+import org.teiid.query.processor.CollectionTupleSource;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
import org.teiid.resource.ConnectorException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.BlobImpl;
-import com.metamatrix.common.types.BlobType;
-import com.metamatrix.common.types.ClobImpl;
-import com.metamatrix.common.types.ClobType;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.core.CoreConstants;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.BufferService;
-import com.metamatrix.query.processor.CollectionTupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.CommandContext;
public class DataTierManagerImpl implements ProcessorDataManager {
@@ -122,7 +122,7 @@
return this.connectorManagerRepository.getConnectorManager(connectorName);
}
- public TupleSource registerRequest(Object processorId, Command command, String modelName, String connectorBindingId, int nodeID) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleSource registerRequest(Object processorId, Command command, String modelName, String connectorBindingId, int nodeID) throws TeiidComponentException, TeiidProcessingException {
RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
if(CoreConstants.SYSTEM_MODEL.equals(modelName)) {
@@ -138,11 +138,11 @@
* @param command
* @param workItem
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
@SuppressWarnings("unchecked")
private TupleSource processSystemQuery(Command command,
- DQPWorkContext workContext) throws MetaMatrixComponentException {
+ DQPWorkContext workContext) throws TeiidComponentException {
String vdbName = workContext.getVdbName();
int vdbVersion = workContext.getVdbVersion();
VDBMetaData vdb = workContext.getVDB();
@@ -318,7 +318,7 @@
private AtomicRequestMessage createRequest(Object processorId,
Command command, String modelName, String connectorBindingId, int nodeID)
- throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ throws TeiidProcessingException, TeiidComponentException {
RequestWorkItem workItem = requestMgr.getRequestWorkItem((RequestID)processorId);
RequestMessage request = workItem.requestMsg;
@@ -337,7 +337,7 @@
List<String> bindings = model.getSourceNames();
if (bindings == null || bindings.size() != 1) {
// this should not happen, but it did occur when setting up the SystemAdmin models
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DataTierManager.could_not_obtain_connector_binding", new Object[]{modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion() })); //$NON-NLS-1$
+ throw new TeiidComponentException(DQPPlugin.Util.getString("DataTierManager.could_not_obtain_connector_binding", new Object[]{modelName, workItem.getDqpWorkContext().getVdbName(), workItem.getDqpWorkContext().getVdbVersion() })); //$NON-NLS-1$
}
connectorBindingId = bindings.get(0);
Assertion.isNotNull(connectorBindingId, "could not obtain connector id"); //$NON-NLS-1$
@@ -372,7 +372,7 @@
String returnElementName,
String keyElementName,
Object keyValue)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
switch (this.codeTableCache.cacheExists(codeTableName, returnElementName, keyElementName, context)) {
case CACHE_NOT_EXIST:
@@ -380,7 +380,7 @@
case CACHE_EXISTS:
return this.codeTableCache.lookupValue(codeTableName, returnElementName, keyElementName, keyValue, context);
case CACHE_OVERLOAD:
- throw new MetaMatrixProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", "maxCodeTables")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ throw new TeiidProcessingException("ERR.018.005.0100", DQPPlugin.Util.getString("ERR.018.005.0100", "maxCodeTables")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
default:
throw BlockedException.INSTANCE;
}
@@ -391,7 +391,7 @@
final String codeTableName,
String returnElementName,
String keyElementName)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
String query = SQLReservedWords.SELECT + ' ' + keyElementName + " ," + returnElementName + ' ' + SQLReservedWords.FROM + ' ' + codeTableName; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierTupleSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -26,15 +26,15 @@
import java.util.List;
import org.teiid.client.SourceWarning;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
import org.teiid.dqp.internal.datamgr.impl.ConnectorWork;
+import org.teiid.dqp.message.AtomicRequestMessage;
+import org.teiid.dqp.message.AtomicResultsMessage;
import org.teiid.resource.ConnectorException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.message.AtomicRequestMessage;
-import com.metamatrix.dqp.message.AtomicResultsMessage;
/**
* This tuple source impl can only be used once; once it is closed, it
@@ -77,7 +77,7 @@
return this.schema;
}
- public List nextTuple() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public List nextTuple() throws TeiidComponentException, TeiidProcessingException {
if (this.arm == null) {
open();
}
@@ -107,7 +107,7 @@
return this.arm != null && this.arm.getFinalRow() >= 0;
}
- void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ void open() throws TeiidComponentException, TeiidProcessingException {
try {
if (this.cwi == null) {
this.cwi = this.dataMgr.executeRequest(aqr, this.workItem, this.connectorName);
@@ -157,7 +157,7 @@
}
}
- void exceptionOccurred(ConnectorException exception, boolean removeState) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ void exceptionOccurred(ConnectorException exception, boolean removeState) throws TeiidComponentException, TeiidProcessingException {
if (removeState) {
fullyCloseSource();
}
@@ -167,13 +167,13 @@
emptyResults.setFinalRow(this.rowsProcessed);
receiveResults(arm);
} else {
- if (exception.getCause() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)exception.getCause();
+ if (exception.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)exception.getCause();
}
- if (exception.getCause() instanceof MetaMatrixProcessingException) {
- throw (MetaMatrixProcessingException)exception.getCause();
+ if (exception.getCause() instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException)exception.getCause();
}
- throw new MetaMatrixProcessingException(exception);
+ throw new TeiidProcessingException(exception);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/LobWorkItem.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -30,16 +30,16 @@
import org.teiid.client.lob.LobChunk;
import org.teiid.client.util.ResultsReceiver;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.BlobType;
+import org.teiid.core.types.ClobType;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.ReaderInputStream;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.logging.LogManager;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.types.BlobType;
-import com.metamatrix.common.types.ClobType;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.common.util.ReaderInputStream;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
public class LobWorkItem implements Work {
@@ -74,7 +74,7 @@
// now get the chunk from stream
chunk = stream.getNextChunk();
shouldClose = chunk.isLast();
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
LogManager.logWarning(org.teiid.logging.LogConstants.CTX_DQP, e, DQPPlugin.Util.getString("ProcessWorker.LobError")); //$NON-NLS-1$
ex = e;
} catch (IOException e) {
@@ -112,7 +112,7 @@
* LOB object
*/
private ByteLobChunkStream createLobStream(String referenceStreamId)
- throws MetaMatrixComponentException, IOException {
+ throws TeiidComponentException, IOException {
// get the reference object in the buffer manager, and try to stream off
// the original sources.
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/MetaDataProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -29,42 +29,42 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.metadata.MetadataResult;
import org.teiid.client.metadata.ResultsMetadataConstants;
import org.teiid.client.metadata.ResultsMetadataDefaults;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.XMLType;
import org.teiid.dqp.internal.process.DQPCore.ClientState;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.parser.ParseInfo;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.tempdata.TempTableStore;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.tempdata.TempTableStore;
/**
* Handles MetaDataMessages on behalf of DQPCore.
@@ -93,10 +93,10 @@
* an already processed command.
* @param metadataMsg The message from the client
* @return The message for the client
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
*/
- MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ MetadataResult processMessage(RequestID requestId, DQPWorkContext workContext, String preparedSql, boolean allowDoubleQuotedVariable) throws TeiidComponentException, TeiidProcessingException {
this.requestID = requestId;
this.metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
@@ -110,7 +110,7 @@
RequestWorkItem workItem = null;
try {
workItem = requestManager.getRequestWorkItem(requestID);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
if (preparedSql == null) {
throw e;
}
@@ -136,7 +136,7 @@
}
// For each projected symbol, construct a metadata map
- private MetadataResult getMetadataForCommand(Command originalCommand) throws MetaMatrixComponentException {
+ private MetadataResult getMetadataForCommand(Command originalCommand) throws TeiidComponentException {
Map[] columnMetadata = null;
switch(originalCommand.getType()) {
@@ -178,7 +178,7 @@
return new MetadataResult(columnMetadata, paramMetadata);
}
- private Map[] createProjectedSymbolMetadata(Command originalCommand) throws MetaMatrixComponentException {
+ private Map[] createProjectedSymbolMetadata(Command originalCommand) throws TeiidComponentException {
Map[] columnMetadata;
// Allow command to use temporary metadata
Map tempMetadata = originalCommand.getTemporaryMetadata();
@@ -200,13 +200,13 @@
try {
columnMetadata[i] = createColumnMetadata(shortColumnName, symbol);
} catch(QueryMetadataException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
}
return columnMetadata;
}
- private MetadataResult obtainMetadataForPreparedSql(String sql, DQPWorkContext workContext, boolean isDoubleQuotedVariablesAllowed) throws QueryParserException, QueryResolverException, MetaMatrixComponentException {
+ private MetadataResult obtainMetadataForPreparedSql(String sql, DQPWorkContext workContext, boolean isDoubleQuotedVariablesAllowed) throws QueryParserException, QueryResolverException, TeiidComponentException {
Command command = null;
ParseInfo info = new ParseInfo();
@@ -242,7 +242,7 @@
return xqueryMetadata;
}
- private Map createColumnMetadata(String shortColumnName, SingleElementSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
+ private Map createColumnMetadata(String shortColumnName, SingleElementSymbol symbol) throws QueryMetadataException, TeiidComponentException {
if(symbol instanceof ElementSymbol) {
return createElementMetadata(shortColumnName, (ElementSymbol) symbol);
} else if(symbol instanceof AggregateSymbol) {
@@ -251,7 +251,7 @@
return createTypedMetadata(shortColumnName, symbol);
}
- private Map createElementMetadata(String shortColumnName, ElementSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
+ private Map createElementMetadata(String shortColumnName, ElementSymbol symbol) throws QueryMetadataException, TeiidComponentException {
Object elementID = symbol.getMetadataID();
Map column = new HashMap();
@@ -318,7 +318,7 @@
}
private Map createAggregateMetadata(String shortColumnName,
- AggregateSymbol symbol) throws QueryMetadataException, MetaMatrixComponentException {
+ AggregateSymbol symbol) throws QueryMetadataException, TeiidComponentException {
Expression expression = symbol.getExpression();
String function = symbol.getAggregateFunction();
@@ -334,7 +334,7 @@
return getDefaultColumn(null, shortColumnName, symbol.getType());
}
- private int getColumnPrecision(Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
+ private int getColumnPrecision(Class dataType, Object elementID) throws QueryMetadataException, TeiidComponentException {
if (!Number.class.isAssignableFrom(dataType)) {
int length = metadata.getElementLength(elementID);
if (length > 0) {
@@ -362,7 +362,7 @@
* @param dataType A string representing the MetaMatrix data type of the column
* @return An int value giving the displaysize of the column
*/
- private Integer getColumnDisplaySize(int precision, Class dataType, Object elementID) throws QueryMetadataException, MetaMatrixComponentException {
+ private Integer getColumnDisplaySize(int precision, Class dataType, Object elementID) throws QueryMetadataException, TeiidComponentException {
if(elementID != null && dataType.equals(DataTypeManager.DefaultDataClasses.STRING)) {
int length = metadata.getElementLength(elementID);
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -24,11 +24,12 @@
import java.util.List;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.Reference;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.Reference;
+
class PreparedPlan{
private ProcessorPlan plan;
private Command command;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/PreparedStatementRequest.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -27,36 +27,36 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.batch.BatchedUpdatePlanner;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.batch.BatchedUpdatePlanner;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
/**
* Specific request for handling prepared statement calls.
@@ -76,11 +76,11 @@
}
/**
- * @see org.teiid.dqp.internal.process.Request#resolveCommand(com.metamatrix.query.sql.lang.Command)
+ * @see org.teiid.dqp.internal.process.Request#resolveCommand(org.teiid.query.sql.lang.Command)
*/
@Override
protected void resolveCommand(Command command) throws QueryResolverException,
- MetaMatrixComponentException {
+ TeiidComponentException {
handleCallableStatement(command);
super.resolveCommand(command);
@@ -123,11 +123,11 @@
}
/**
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
* @see org.teiid.dqp.internal.process.Request#generatePlan()
*/
- protected void generatePlan() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected void generatePlan() throws TeiidComponentException, TeiidProcessingException {
String sqlQuery = requestMsg.getCommands()[0];
CacheID id = new CacheID(this.workContext, Request.createParseInfo(this.requestMsg), sqlQuery);
prepPlan = prepPlanCache.get(id);
@@ -176,13 +176,13 @@
* create a batchedupdatecommand that represents the batch operation
* @param command
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryResolverException
* @throws QueryPlannerException
* @throws QueryValidatorException
*/
private void handlePreparedBatchUpdate() throws QueryMetadataException,
- MetaMatrixComponentException, QueryResolverException, QueryPlannerException, QueryValidatorException {
+ TeiidComponentException, QueryResolverException, QueryPlannerException, QueryValidatorException {
List<List<?>> paramValues = (List<List<?>>) requestMsg.getParameterValues();
if (paramValues.isEmpty()) {
throw new QueryValidatorException("No batch values sent for prepared batch update"); //$NON-NLS-1$
@@ -254,7 +254,7 @@
* @throws QueryValidatorException
*/
public static void resolveParameterValues(List<Reference> params,
- List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException, QueryValidatorException {
+ List values, CommandContext context, QueryMetadataInterface metadata) throws QueryResolverException, TeiidComponentException, QueryValidatorException {
VariableContext result = new VariableContext();
//the size of the values must be the same as that of the parameters
if (params.size() != values.size()) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/Request.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -28,72 +28,72 @@
import java.util.Properties;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.RequestMessage;
import org.teiid.client.RequestMessage.ResultsMode;
import org.teiid.client.RequestMessage.ShowPlan;
import org.teiid.client.xa.XATransactionException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.id.IntegerIDFactory;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.datamgr.impl.ConnectorManagerRepository;
import org.teiid.dqp.internal.process.multisource.MultiSourceCapabilitiesFinder;
import org.teiid.dqp.internal.process.multisource.MultiSourceMetadataWrapper;
import org.teiid.dqp.internal.process.multisource.MultiSourcePlanToProcessConverter;
import org.teiid.dqp.internal.process.validator.AuthorizationValidationVisitor;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionService;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.eval.SecurityFunctionEvaluator;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.parser.ParseInfo;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.TempTableDataManager;
+import org.teiid.query.processor.xml.XMLPlan;
+import org.teiid.query.processor.xquery.XQueryPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ContextProperties;
+import org.teiid.query.validator.AbstractValidationVisitor;
+import org.teiid.query.validator.ValidationVisitor;
+import org.teiid.query.validator.Validator;
+import org.teiid.query.validator.ValidatorFailure;
+import org.teiid.query.validator.ValidatorReport;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerIDFactory;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.TransactionContext.Scope;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.TempTableDataManager;
-import com.metamatrix.query.processor.xml.XMLPlan;
-import com.metamatrix.query.processor.xquery.XQueryPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ContextProperties;
-import com.metamatrix.query.validator.AbstractValidationVisitor;
-import com.metamatrix.query.validator.ValidationVisitor;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorFailure;
-import com.metamatrix.query.validator.ValidatorReport;
/**
* Server side representation of the RequestMessage. Knows how to process itself.
@@ -170,9 +170,9 @@
/**
* if the metadata has not been supplied via setMetadata, this method will create the appropriate state
*
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- protected void initMetadata() throws MetaMatrixComponentException {
+ protected void initMetadata() throws TeiidComponentException {
if (this.metadata != null) {
return;
}
@@ -183,7 +183,7 @@
metadata = workContext.getVDB().getAttachment(QueryMetadataInterface.class);
if (metadata == null) {
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", this.vdbName, this.vdbVersion)); //$NON-NLS-1$
+ throw new TeiidComponentException(DQPPlugin.Util.getString("DQPCore.Unable_to_load_metadata_for_VDB_name__{0},_version__{1}", this.vdbName, this.vdbVersion)); //$NON-NLS-1$
}
this.metadata = new TempMetadataAdapter(metadata, new TempMetadataStore());
@@ -253,7 +253,7 @@
context.setSecurityFunctionEvaluator(new SecurityFunctionEvaluator() {
@Override
- public boolean hasRole(String roleType, String roleName) throws MetaMatrixComponentException {
+ public boolean hasRole(String roleType, String roleName) throws TeiidComponentException {
if (!useEntitlements) {
return true;
}
@@ -279,7 +279,7 @@
}
}
- protected void resolveCommand(Command command) throws QueryResolverException, MetaMatrixComponentException {
+ protected void resolveCommand(Command command) throws QueryResolverException, TeiidComponentException {
if (this.tempTableStore != null) {
QueryResolver.setChildMetadata(command, tempTableStore.getMetadataStore().getData(), null);
}
@@ -291,7 +291,7 @@
}
private void validateQuery(Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
+ throws QueryValidatorException, TeiidComponentException {
// Create generic sql validation visitor
AbstractValidationVisitor visitor = new ValidationVisitor();
@@ -323,7 +323,7 @@
AbstractValidationVisitor visitor,
QueryMetadataInterface metadata,
Command command)
- throws QueryValidatorException, MetaMatrixComponentException {
+ throws QueryValidatorException, TeiidComponentException {
// Validate with visitor
ValidatorReport report = Validator.validate(command, metadata, visitor);
@@ -333,7 +333,7 @@
}
}
- private void createProcessor() throws MetaMatrixComponentException {
+ private void createProcessor() throws TeiidComponentException {
TransactionContext tc = transactionService.getOrCreateTransactionContext(workContext.getSessionId());
@@ -356,7 +356,7 @@
try {
tc = transactionService.begin(tc);
} catch (XATransactionException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
}
}
}
@@ -380,10 +380,10 @@
* adds a limit clause if the row limit is specified
* sets the processor plan
*
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
*/
- protected void generatePlan() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected void generatePlan() throws TeiidComponentException, TeiidProcessingException {
Command command = parseCommand();
List<Reference> references = ReferenceCollectorVisitor.getReferences(command);
@@ -446,7 +446,7 @@
}
public void processRequest()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
LogManager.logDetail(LogConstants.CTX_DQP, this.requestId, "executing", this.requestMsg.isPreparedStatement()?"prepared":"", this.requestMsg.getCommandString()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -472,7 +472,7 @@
this.context.setValidateXML(requestMsg.getValidationMode());
}
- public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ public QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws TeiidProcessingException, TeiidComponentException {
boolean isRootXQuery = recursionGroup == null && commandContext.getCallStackDepth() == 0 && userCommand instanceof XQuery;
ParseInfo parseInfo = new ParseInfo();
@@ -502,7 +502,7 @@
return new QueryProcessor(plan, copy, bufferManager, processorDataManager);
}
- protected void validateAccess(Command command) throws QueryValidatorException, MetaMatrixComponentException {
+ protected void validateAccess(Command command) throws QueryValidatorException, TeiidComponentException {
AuthorizationValidationVisitor visitor = new AuthorizationValidationVisitor(this.workContext.getVDB(), this.useEntitlements, this.workContext.getAllowedDataPolicies(), this.workContext.getUserName());
validateWithVisitor(visitor, this.metadata, command);
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/RequestWorkItem.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -38,36 +38,36 @@
import org.teiid.client.metadata.ParameterInfo;
import org.teiid.client.util.ResultsReceiver;
import org.teiid.client.xa.XATransactionException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.process.SessionAwareCache.CacheID;
+import org.teiid.dqp.message.AtomicRequestID;
+import org.teiid.dqp.message.RequestID;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionService;
+import org.teiid.dqp.service.TransactionContext.Scope;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
import org.teiid.logging.CommandLogMessage.Event;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.BatchCollector.BatchHandler;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
import org.teiid.resource.cci.DataNotAvailableException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixCoreException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.message.AtomicRequestID;
-import com.metamatrix.dqp.message.RequestID;
-import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.TransactionContext.Scope;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.BatchCollector;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.BatchCollector.BatchHandler;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
public class RequestWorkItem extends AbstractWorkItem {
@@ -106,7 +106,7 @@
private Throwable processingException;
private Map<AtomicRequestID, DataTierTupleSource> connectorInfo = new ConcurrentHashMap<AtomicRequestID, DataTierTupleSource>(4);
// This exception contains details of all the atomic requests that failed when query is run in partial results mode.
- private List<MetaMatrixException> warnings = new LinkedList<MetaMatrixException>();
+ private List<TeiidException> warnings = new LinkedList<TeiidException>();
private boolean doneProducingBatches;
private volatile boolean isClosed;
private volatile boolean isCanceled;
@@ -168,7 +168,7 @@
state = ProcessingState.PROCESSING;
processNew();
if (isCanceled) {
- this.processingException = new MetaMatrixProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", this.requestID)); //$NON-NLS-1$
+ this.processingException = new TeiidProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", this.requestID)); //$NON-NLS-1$
state = ProcessingState.CLOSE;
}
}
@@ -197,7 +197,7 @@
//Case 5558: Differentiate between system level errors and
//processing errors. Only log system level errors as errors,
//log the processing errors as warnings only
- if(e instanceof MetaMatrixProcessingException) {
+ if(e instanceof TeiidProcessingException) {
Throwable cause = e;
while (cause.getCause() != null && cause.getCause() != cause) {
cause = cause.getCause();
@@ -245,7 +245,7 @@
}
}
- protected void processMore() throws BlockedException, MetaMatrixCoreException {
+ protected void processMore() throws BlockedException, TeiidException {
if (!doneProducingBatches) {
this.processor.getContext().setTimeSliceEnd(System.currentTimeMillis() + this.processorTimeslice);
sendResultsIfNeeded(null);
@@ -334,7 +334,7 @@
}
}
- protected void processNew() throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ protected void processNew() throws TeiidProcessingException, TeiidComponentException {
SessionAwareCache<CachedResults> rsCache = dqpCore.getRsCache();
CacheID cacheId = new CacheID(this.dqpWorkContext, Request.createParseInfo(requestMsg), requestMsg.getCommandString());
cacheId.setParameters(requestMsg.getParameterValues());
@@ -356,7 +356,7 @@
processor = request.processor;
collector = processor.createBatchCollector();
collector.setBatchHandler(new BatchHandler() {
- public boolean batchProduced(TupleBatch batch) throws MetaMatrixComponentException {
+ public boolean batchProduced(TupleBatch batch) throws TeiidComponentException {
return sendResultsIfNeeded(batch);
}
});
@@ -380,7 +380,7 @@
/**
* Send results if they have been requested. This should only be called from the processing thread.
*/
- protected boolean sendResultsIfNeeded(TupleBatch batch) throws MetaMatrixComponentException {
+ protected boolean sendResultsIfNeeded(TupleBatch batch) throws TeiidComponentException {
if (batch != null) {
doneProducingBatches = batch.getTerminationFlag();
if (doneProducingBatches && cid != null) {
@@ -548,7 +548,7 @@
this.lobStreams.remove(new Integer(streamRequestId));
}
- public boolean requestCancel() throws MetaMatrixComponentException {
+ public boolean requestCancel() throws TeiidComponentException {
synchronized (this) {
if (this.isCanceled) {
return false;
@@ -570,7 +570,7 @@
try {
transactionService.cancelTransactions(requestID.getConnectionID(), true);
} catch (XATransactionException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
}
}
} finally {
@@ -580,7 +580,7 @@
return true;
}
- public boolean requestAtomicRequestCancel(AtomicRequestID ari) throws MetaMatrixComponentException {
+ public boolean requestAtomicRequestCancel(AtomicRequestID ari) throws TeiidComponentException {
// in the case that this does not support partial results; cancel
// the original processor request.
if(!requestMsg.supportsPartialResults()) {
@@ -597,7 +597,7 @@
return false;
}
- public void requestClose() throws MetaMatrixComponentException {
+ public void requestClose() throws TeiidComponentException {
synchronized (this) {
if (this.state == ProcessingState.CLOSE || this.closeRequested) {
if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
@@ -639,10 +639,10 @@
return isCanceled;
}
- Command getOriginalCommand() throws MetaMatrixProcessingException {
+ Command getOriginalCommand() throws TeiidProcessingException {
if (this.originalCommand == null) {
if (this.processingException != null) {
- throw new MetaMatrixProcessingException(this.processingException);
+ throw new TeiidProcessingException(this.processingException);
}
throw new IllegalStateException("Original command is not available"); //$NON-NLS-1$
}
@@ -666,7 +666,7 @@
return this.connectorInfo.get(id);
}
- public List<MetaMatrixException> getWarnings() {
+ public List<TeiidException> getWarnings() {
return warnings;
}
@@ -687,7 +687,7 @@
public void release() {
try {
requestCancel();
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
LogManager.logWarning(LogConstants.CTX_DQP, e, "Failed to cancel " + requestID); //$NON-NLS-1$
}
}
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 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/SessionAwareCache.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -27,12 +27,13 @@
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.query.parser.ParseInfo;
-import com.metamatrix.vdb.runtime.VDBKey;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.core.util.LRUCache;
+import org.teiid.query.parser.ParseInfo;
+import org.teiid.vdb.runtime.VDBKey;
+
/**
* This class is used to cache session aware objects
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/StatsCapturingWorkManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -43,12 +43,12 @@
import javax.resource.spi.work.WorkRejectedException;
import org.teiid.adminapi.impl.WorkerPoolStatisticsMetadata;
+import org.teiid.core.util.NamedThreadFactory;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.QueryPlugin;
-import com.metamatrix.core.util.NamedThreadFactory;
-import com.metamatrix.query.QueryPlugin;
/**
* StatsCapturingWorkManager acts as a wrapper to the passed in {@link WorkManager} to
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceCapabilitiesFinder.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -30,12 +30,13 @@
import java.util.HashSet;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+
/**
* A capabilities finder proxy that intercepts capabilities calls for multi-source models
* and hard-codes some capabilities for certain functionality that will not be planned
@@ -53,7 +54,7 @@
this.multiSourceModels = multiSourceModels;
}
- public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
+ public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
SourceCapabilities caps = finder.findCapabilities(modelName);
if(multiSourceModels.contains(modelName)) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceElementReplacementVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,12 +22,13 @@
package org.teiid.dqp.internal.process.multisource;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+
public class MultiSourceElementReplacementVisitor extends ExpressionMappingVisitor {
private String bindingName;
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourceMetadataWrapper.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -28,13 +28,14 @@
import java.util.Properties;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.metadata.BasicQueryMetadataWrapper;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.metadata.BasicQueryMetadataWrapper;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+
/**
* This classs is a proxy to QueryMetadataInterface. It knows VDBService
* and VNB name.
@@ -49,9 +50,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementID(java.lang.String)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementID(java.lang.String)
*/
- public Object getElementID(String elementName) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getElementID(String elementName) throws TeiidComponentException, QueryMetadataException {
String shortName = getShortElementName(elementName);
if(shortName.equalsIgnoreCase(MultiSourceElement.MULTI_SOURCE_ELEMENT_NAME)) {
try {
@@ -76,9 +77,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModelID(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModelID(java.lang.Object)
*/
- public Object getModelID(Object groupOrElementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getModelID(Object groupOrElementID) throws TeiidComponentException, QueryMetadataException {
if(groupOrElementID instanceof MultiSourceElement) {
Object groupID = ((MultiSourceElement)groupOrElementID).groupID;
return this.getModelID(groupID);
@@ -88,9 +89,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getFullName(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getFullName(java.lang.Object)
*/
- public String getFullName(Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getFullName(Object metadataID) throws TeiidComponentException, QueryMetadataException {
if(metadataID instanceof MultiSourceElement) {
return ((MultiSourceElement)metadataID).fullName;
}
@@ -98,9 +99,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInGroupID(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInGroupID(java.lang.Object)
*/
- public List getElementIDsInGroupID(Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public List getElementIDsInGroupID(Object groupID) throws TeiidComponentException, QueryMetadataException {
List elements = actualMetadata.getElementIDsInGroupID(groupID);
Object modelID = this.getModelID(groupID);
@@ -133,9 +134,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupIDForElementID(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getGroupIDForElementID(java.lang.Object)
*/
- public Object getGroupIDForElementID(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getGroupIDForElementID(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return ((MultiSourceElement)elementID).groupID;
}
@@ -144,9 +145,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementType(java.lang.Object)
*/
- public String getElementType(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getElementType(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return DataTypeManager.DefaultDataTypes.STRING;
}
@@ -155,9 +156,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getDefaultValue(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getDefaultValue(java.lang.Object)
*/
- public Object getDefaultValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getDefaultValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return null;
}
@@ -166,9 +167,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMinimumValue(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMinimumValue(java.lang.Object)
*/
- public Object getMinimumValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMinimumValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return null;
}
@@ -177,9 +178,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaximumValue(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaximumValue(java.lang.Object)
*/
- public Object getMaximumValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMaximumValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return null;
}
@@ -188,9 +189,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getDistinctValues(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getDistinctValues(java.lang.Object)
*/
- public int getDistinctValues(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getDistinctValues(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return ((MultiSourceElement)elementID).position;
}
@@ -199,9 +200,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getNullValues(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getNullValues(java.lang.Object)
*/
- public int getNullValues(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getNullValues(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return ((MultiSourceElement)elementID).position;
}
@@ -210,9 +211,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getPosition(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getPosition(java.lang.Object)
*/
- public int getPosition(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPosition(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return ((MultiSourceElement)elementID).position;
}
@@ -221,9 +222,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getPrecision(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getPrecision(java.lang.Object)
*/
- public int getPrecision(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPrecision(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return 0;
}
@@ -232,9 +233,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getScale(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getScale(java.lang.Object)
*/
- public int getScale(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getScale(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return 0;
}
@@ -243,9 +244,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getRadix(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getRadix(java.lang.Object)
*/
- public int getRadix(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getRadix(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return 0;
}
@@ -254,9 +255,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#elementSupports(java.lang.Object, int)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#elementSupports(java.lang.Object, int)
*/
- public boolean elementSupports(Object elementID, int elementConstant) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean elementSupports(Object elementID, int elementConstant) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
switch(elementConstant) {
case SupportConstants.Element.NULL:
@@ -288,9 +289,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
*/
- public Properties getExtensionProperties(Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Properties getExtensionProperties(Object metadataID) throws TeiidComponentException, QueryMetadataException {
if(metadataID instanceof MultiSourceElement) {
return new Properties();
}
@@ -298,9 +299,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getNameInSource(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getNameInSource(java.lang.Object)
*/
- public String getNameInSource(Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getNameInSource(Object metadataID) throws TeiidComponentException, QueryMetadataException {
if(metadataID instanceof MultiSourceElement) {
return null;
}
@@ -309,9 +310,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementLength(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementLength(java.lang.Object)
*/
- public int getElementLength(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getElementLength(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return 255;
}
@@ -320,9 +321,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getNativeType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getNativeType(java.lang.Object)
*/
- public String getNativeType(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getNativeType(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof MultiSourceElement) {
return null;
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -28,27 +28,27 @@
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.PlanToProcessConverter;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.NullNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalNodeUtil;
+import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.PlanToProcessConverter;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.NullNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalNodeUtil;
-import com.metamatrix.query.processor.relational.UnionAllNode;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.util.CommandContext;
public class MultiSourcePlanToProcessConverter extends PlanToProcessConverter {
@@ -64,13 +64,13 @@
this.workContext = workContext;
}
- protected RelationalNode convertNode(PlanNode planNode) throws QueryPlannerException, MetaMatrixComponentException {
+ protected RelationalNode convertNode(PlanNode planNode) throws QueryPlannerException, TeiidComponentException {
RelationalNode node = super.convertNode(planNode);
if (node instanceof AccessNode) {
try {
return multiSourceModify((AccessNode)node);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new QueryPlannerException(e, e.getMessage());
}
}
@@ -78,7 +78,7 @@
return node;
}
- private RelationalNode multiSourceModify(AccessNode accessNode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private RelationalNode multiSourceModify(AccessNode accessNode) throws TeiidComponentException, TeiidProcessingException {
String modelName = accessNode.getModelName();
if(!this.multiSourceModels.contains(modelName)) {
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/validator/AuthorizationValidationVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -37,33 +37,33 @@
import org.teiid.adminapi.impl.DataPolicyMetadata;
import org.teiid.adminapi.impl.ModelMetaData;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.dqp.internal.process.multisource.MultiSourceElement;
import org.teiid.logging.AuditMessage;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.validator.AbstractValidationVisitor;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Symbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.validator.AbstractValidationVisitor;
public class AuthorizationValidationVisitor extends AbstractValidationVisitor {
@@ -96,7 +96,7 @@
this.validateModelVisibility(modelID, obj);
} catch(QueryMetadataException e) {
handleException(e, obj);
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e, obj);
}
}
@@ -132,9 +132,9 @@
symbols.add(lookup.getKeyElement());
symbols.add(lookup.getReturnElement());
validateEntitlements(symbols, DataPolicy.PermissionType.READ, Context.QUERY);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e, obj);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
handleException(e, obj);
}
}
@@ -200,7 +200,7 @@
intoElements = ResolverUtil.resolveElementsInGroup(intoGroup, getMetadata());
} catch (QueryMetadataException err) {
handleException(err, intoGroup);
- } catch (MetaMatrixComponentException err) {
+ } catch (TeiidComponentException err) {
handleException(err, intoGroup);
}
validateEntitlements(intoElements,
@@ -271,7 +271,7 @@
nameToSymbolMap.put(fullName, symbol);
} catch(QueryMetadataException e) {
handleException(e);
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -307,7 +307,7 @@
if(!model.isVisible()) {
handleValidationError(DQPPlugin.Util.getString("ERR.018.005.0088", getMetadata().getFullName(group.getMetadataID()))); //$NON-NLS-1$
}
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e, group);
}
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/transaction/TransactionServerImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -52,13 +52,13 @@
import org.teiid.adminapi.impl.TransactionMetadata;
import org.teiid.client.xa.XATransactionException;
import org.teiid.client.xa.XidImpl;
+import org.teiid.core.util.Assertion;
+import org.teiid.dqp.DQPPlugin;
import org.teiid.dqp.internal.process.DQPCore.FutureWork;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionService;
+import org.teiid.dqp.service.TransactionContext.Scope;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.dqp.service.TransactionService;
-import com.metamatrix.dqp.service.TransactionContext.Scope;
public class TransactionServerImpl implements TransactionService {
Copied: trunk/engine/src/main/java/org/teiid/dqp/message (from rev 2112, trunk/engine/src/main/java/com/metamatrix/dqp/message)
Modified: trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestID.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestID.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestID.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;
-import com.metamatrix.core.util.HashCodeUtil;
+import org.teiid.core.util.HashCodeUtil;
+
/**
* This class uniquely identifies a AtomicRequestMessage
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicRequestMessage.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/message/AtomicRequestMessage.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,18 +22,18 @@
/*
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;
import org.teiid.client.RequestMessage;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
+import org.teiid.dqp.service.TransactionContext;
+import org.teiid.dqp.service.TransactionContext.Scope;
+import org.teiid.query.sql.lang.Command;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.dqp.service.TransactionContext;
-import com.metamatrix.dqp.service.TransactionContext.Scope;
-import com.metamatrix.query.sql.lang.Command;
/**
* This class defines a request message for the Connector layer. This is uniquely identified
Modified: trunk/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/AtomicResultsMessage.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/message/AtomicResultsMessage.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
import java.io.Externalizable;
import java.io.IOException;
@@ -29,8 +29,8 @@
import java.util.List;
import org.teiid.client.BatchSerializer;
+import org.teiid.core.util.ExternalizeUtil;
-import com.metamatrix.core.util.ExternalizeUtil;
public class AtomicResultsMessage implements Externalizable {
Modified: trunk/engine/src/main/java/org/teiid/dqp/message/RequestID.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/message/RequestID.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/message/RequestID.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.message;
+package org.teiid.dqp.message;
import java.io.Externalizable;
import java.io.IOException;
Copied: trunk/engine/src/main/java/org/teiid/dqp/service (from rev 2112, trunk/engine/src/main/java/com/metamatrix/dqp/service)
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/BufferService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/BufferService.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/BufferService.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
+import org.teiid.cache.CacheFactory;
+import org.teiid.common.buffer.BufferManager;
import org.teiid.dqp.internal.cache.DQPContextCache;
-import com.metamatrix.cache.CacheFactory;
-import com.metamatrix.common.buffer.BufferManager;
/**
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionService.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/SessionService.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
import java.util.Collection;
import java.util.Properties;
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/SessionServiceException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/SessionServiceException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/SessionServiceException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
-import org.teiid.client.security.MetaMatrixSecurityException;
+import org.teiid.client.security.TeiidSecurityException;
-public class SessionServiceException extends MetaMatrixSecurityException {
+public class SessionServiceException extends TeiidSecurityException {
/**
* No-Arg Constructor
*/
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionContext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionContext.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
import java.io.Serializable;
import java.util.Collections;
Modified: trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/dqp/service/TransactionService.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/dqp/service/TransactionService.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,7 +22,7 @@
/*
*/
-package com.metamatrix.dqp.service;
+package org.teiid.dqp.service;
import java.util.Collection;
Copied: trunk/engine/src/main/java/org/teiid/internal/core/xml (from rev 2112, trunk/engine/src/main/java/com/metamatrix/internal/core/xml)
Modified: trunk/engine/src/main/java/org/teiid/internal/core/xml/JdomHelper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/internal/core/xml/JdomHelper.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/internal/core/xml/JdomHelper.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.internal.core.xml;
+package org.teiid.internal.core.xml;
import java.io.File;
import java.io.FileOutputStream;
@@ -45,9 +45,9 @@
import org.jdom.input.SAXBuilder;
import org.jdom.output.Format;
import org.jdom.output.XMLOutputter;
+import org.teiid.core.CorePlugin;
+import org.teiid.core.util.ArgCheck;
-import com.metamatrix.core.CorePlugin;
-import com.metamatrix.core.util.ArgCheck;
public class JdomHelper {
Modified: trunk/engine/src/main/java/org/teiid/internal/core/xml/SAXBuilderHelper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/internal/core/xml/SAXBuilderHelper.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/internal/core/xml/SAXBuilderHelper.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.internal.core.xml;
+package org.teiid.internal.core.xml;
import org.jdom.input.SAXBuilder;
Modified: trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/metadata/CompositeMetadataStore.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -27,14 +27,14 @@
import java.util.LinkedList;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.metadata.runtime.MetadataStore;
import org.teiid.connector.metadata.runtime.Procedure;
import org.teiid.connector.metadata.runtime.Schema;
import org.teiid.connector.metadata.runtime.Table;
import org.teiid.connector.metadata.runtime.Table.Type;
+import org.teiid.core.TeiidComponentException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
/**
* Aggregates the metadata from multiple stores.
@@ -100,7 +100,7 @@
}
public Collection<Procedure> getStoredProcedure(String name)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
List<Procedure> result = new LinkedList<Procedure>();
int index = name.indexOf(TransformationMetadata.DELIMITER_STRING);
if (index > -1) {
Modified: trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/main/java/org/teiid/metadata/TransformationMetadata.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -38,6 +38,7 @@
import org.jboss.virtual.VirtualFile;
import org.teiid.adminapi.impl.VDBMetaData;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.metadata.runtime.AbstractMetadataRecord;
import org.teiid.connector.metadata.runtime.Column;
import org.teiid.connector.metadata.runtime.ColumnSet;
@@ -51,34 +52,33 @@
import org.teiid.connector.metadata.runtime.BaseColumn.NullType;
import org.teiid.connector.metadata.runtime.Column.SearchType;
import org.teiid.connector.metadata.runtime.ProcedureParameter.Type;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.BlobImpl;
+import org.teiid.core.types.ClobImpl;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.LRUCache;
+import org.teiid.core.util.ObjectConverterUtil;
+import org.teiid.core.util.StringUtil;
+import org.teiid.dqp.DQPPlugin;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionTree;
+import org.teiid.query.function.SystemFunctionManager;
+import org.teiid.query.function.UDFSource;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingLoader;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.metadata.BasicQueryMetadata;
+import org.teiid.query.metadata.GroupInfo;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.sql.lang.SPParameter;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.BlobImpl;
-import com.metamatrix.common.types.ClobImpl;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.InputStreamFactory;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.LRUCache;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.dqp.DQPPlugin;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionTree;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.function.UDFSource;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingLoader;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.metadata.BasicQueryMetadata;
-import com.metamatrix.query.metadata.GroupInfo;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.sql.lang.SPParameter;
/**
* Modelers implementation of QueryMetadataInterface that reads columns, groups, models etc.
@@ -144,7 +144,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementID(java.lang.String)
*/
- public Object getElementID(final String elementName) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getElementID(final String elementName) throws TeiidComponentException, QueryMetadataException {
int columnIndex = elementName.lastIndexOf(TransformationMetadata.DELIMITER_STRING);
if (columnIndex == -1) {
throw new QueryMetadataException(elementName+TransformationMetadata.NOT_EXISTS_MESSAGE);
@@ -162,7 +162,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupID(java.lang.String)
*/
- public Object getGroupID(final String groupName) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getGroupID(final String groupName) throws TeiidComponentException, QueryMetadataException {
return getMetadataStore().findGroup(groupName.toLowerCase());
}
@@ -170,7 +170,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupsForPartialName(java.lang.String)
*/
public Collection getGroupsForPartialName(final String partialGroupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(partialGroupName);
Collection<Table> matches = this.partialNameToFullNameCache.get(partialGroupName);
@@ -199,7 +199,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getModelID(java.lang.Object)
*/
- public Object getModelID(final Object groupOrElementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getModelID(final Object groupOrElementID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(AbstractMetadataRecord.class, groupOrElementID);
AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) groupOrElementID;
AbstractMetadataRecord parent = metadataRecord.getParent();
@@ -219,7 +219,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getFullName(java.lang.Object)
*/
- public String getFullName(final Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getFullName(final Object metadataID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) metadataID;
return metadataRecord.getFullName();
@@ -229,7 +229,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getFullElementName(java.lang.String, java.lang.String)
*/
public String getFullElementName(final String fullGroupName, final String shortElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(fullGroupName);
ArgCheck.isNotEmpty(shortElementName);
@@ -239,7 +239,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getShortElementName(java.lang.String)
*/
- public String getShortElementName(final String fullElementName) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getShortElementName(final String fullElementName) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(fullElementName);
int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
if(index >= 0) {
@@ -258,9 +258,9 @@
* why it is important not to introduce new metadata here. Also, returning
* null indicates that no portion of the fullElementName is a
* group name - that is ok as it will be resolved as an ambiguous element.
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupName(java.lang.String)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getGroupName(java.lang.String)
*/
- public String getGroupName(final String fullElementName) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getGroupName(final String fullElementName) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(fullElementName);
int index = fullElementName.lastIndexOf(DELIMITER_CHAR);
@@ -273,7 +273,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInGroupID(java.lang.Object)
*/
- public List getElementIDsInGroupID(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public List getElementIDsInGroupID(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table)groupID).getColumns();
}
@@ -281,7 +281,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getGroupIDForElementID(java.lang.Object)
*/
- public Object getGroupIDForElementID(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getGroupIDForElementID(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
Column columnRecord = (Column) elementID;
return this.getGroupID(getGroupName(columnRecord.getFullName()));
@@ -297,7 +297,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getStoredProcedureInfoForProcedure(java.lang.String)
*/
public StoredProcedureInfo getStoredProcedureInfoForProcedure(final String fullyQualifiedProcedureName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isNotEmpty(fullyQualifiedProcedureName);
String lowerGroupName = fullyQualifiedProcedureName.toLowerCase();
Collection<StoredProcedureInfo> results = this.procedureCache.get(lowerGroupName);
@@ -396,7 +396,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementType(java.lang.Object)
*/
- public String getElementType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getElementType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getRuntimeType();
} else if(elementID instanceof ProcedureParameter){
@@ -409,7 +409,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getDefaultValue(java.lang.String)
*/
- public Object getDefaultValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getDefaultValue(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getDefaultValue();
} else if(elementID instanceof ProcedureParameter){
@@ -419,7 +419,7 @@
}
}
- public Object getMinimumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMinimumValue(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getMinimumValue();
} else if(elementID instanceof ProcedureParameter){
@@ -429,7 +429,7 @@
}
}
- public Object getMaximumValue(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMaximumValue(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getMaximumValue();
} else if(elementID instanceof ProcedureParameter){
@@ -442,16 +442,16 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#isVirtualGroup(java.lang.Object)
*/
- public boolean isVirtualGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isVirtualGroup(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table) groupID).isVirtual();
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#isProcedureInputElement(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#isProcedureInputElement(java.lang.Object)
* @since 4.2
*/
- public boolean isProcedure(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isProcedure(final Object groupID) throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof Procedure) {
return true;
}
@@ -461,7 +461,7 @@
throw createInvalidRecordTypeException(groupID);
}
- public boolean isVirtualModel(final Object modelID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isVirtualModel(final Object modelID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Schema.class, modelID);
Schema modelRecord = (Schema) modelID;
return !modelRecord.isPhysical();
@@ -470,7 +470,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualPlan(java.lang.Object)
*/
- public QueryNode getVirtualPlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public QueryNode getVirtualPlan(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -494,7 +494,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getInsertPlan(java.lang.Object)
*/
- public String getInsertPlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getInsertPlan(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecordImpl = (Table)groupID;
if (!tableRecordImpl.isVirtual()) {
@@ -506,7 +506,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getUpdatePlan(java.lang.Object)
*/
- public String getUpdatePlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getUpdatePlan(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecordImpl = (Table)groupID;
if (!tableRecordImpl.isVirtual()) {
@@ -518,7 +518,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getDeletePlan(java.lang.Object)
*/
- public String getDeletePlan(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getDeletePlan(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecordImpl = (Table)groupID;
if (!tableRecordImpl.isVirtual()) {
@@ -531,7 +531,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#modelSupports(java.lang.Object, int)
*/
public boolean modelSupports(final Object modelID, final int modelConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Schema.class, modelID);
switch(modelConstant) {
@@ -544,7 +544,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#groupSupports(java.lang.Object, int)
*/
public boolean groupSupports(final Object groupID, final int groupConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -560,7 +560,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#elementSupports(java.lang.Object, int)
*/
public boolean elementSupports(final Object elementID, final int elementConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
Column columnRecord = (Column) elementID;
@@ -634,7 +634,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaxSetSize(java.lang.Object)
*/
- public int getMaxSetSize(final Object modelID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getMaxSetSize(final Object modelID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Schema.class, modelID);
return 0;
}
@@ -642,7 +642,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
*/
- public Collection getIndexesInGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Collection getIndexesInGroup(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table)groupID).getIndexes();
}
@@ -651,7 +651,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getUniqueKeysInGroup(java.lang.Object)
*/
public Collection getUniqueKeysInGroup(final Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecordImpl = (Table)groupID;
ArrayList<ColumnSet> result = new ArrayList<ColumnSet>(tableRecordImpl.getUniqueKeys());
@@ -670,7 +670,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getForeignKeysInGroup(java.lang.Object)
*/
public Collection getForeignKeysInGroup(final Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table)groupID).getForeignKeys();
}
@@ -679,7 +679,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getPrimaryKeyIDForForeignKeyID(java.lang.Object)
*/
public Object getPrimaryKeyIDForForeignKeyID(final Object foreignKeyID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(ForeignKey.class, foreignKeyID);
ForeignKey fkRecord = (ForeignKey) foreignKeyID;
return fkRecord.getPrimaryKey();
@@ -689,7 +689,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(java.lang.Object)
*/
public Collection getAccessPatternsInGroup(final Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table)groupID).getAccessPatterns();
}
@@ -697,7 +697,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
*/
- public List getElementIDsInIndex(final Object index) throws MetaMatrixComponentException, QueryMetadataException {
+ public List getElementIDsInIndex(final Object index) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(ColumnSet.class, index);
return ((ColumnSet)index).getColumns();
}
@@ -705,7 +705,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInKey(java.lang.Object)
*/
- public List getElementIDsInKey(final Object key) throws MetaMatrixComponentException, QueryMetadataException {
+ public List getElementIDsInKey(final Object key) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(ColumnSet.class, key);
return ((ColumnSet)key).getColumns();
}
@@ -714,7 +714,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(java.lang.Object)
*/
public List getElementIDsInAccessPattern(final Object accessPattern)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(ColumnSet.class, accessPattern);
return ((ColumnSet)accessPattern).getColumns();
}
@@ -722,7 +722,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#isXMLGroup(java.lang.Object)
*/
- public boolean isXMLGroup(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isXMLGroup(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -730,10 +730,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
* @since 4.2
*/
- public boolean hasMaterialization(final Object groupID) throws MetaMatrixComponentException,
+ public boolean hasMaterialization(final Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -741,10 +741,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
* @since 4.2
*/
- public Object getMaterialization(final Object groupID) throws MetaMatrixComponentException,
+ public Object getMaterialization(final Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -755,10 +755,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
* @since 4.2
*/
- public Object getMaterializationStage(final Object groupID) throws MetaMatrixComponentException,
+ public Object getMaterializationStage(final Object groupID) throws TeiidComponentException,
QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -771,7 +771,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMappingNode(java.lang.Object)
*/
- public MappingNode getMappingNode(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public MappingNode getMappingNode(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -786,7 +786,7 @@
mappingDoc = reader.loadDocument(inputStream);
mappingDoc.setName(groupName);
} catch (Exception e){
- throw new MetaMatrixComponentException(e, DQPPlugin.Util.getString("TransformationMetadata.Error_trying_to_read_virtual_document_{0},_with_body__n{1}_1", groupName, mappingDoc)); //$NON-NLS-1$
+ throw new TeiidComponentException(e, DQPPlugin.Util.getString("TransformationMetadata.Error_trying_to_read_virtual_document_{0},_with_body__n{1}_1", groupName, mappingDoc)); //$NON-NLS-1$
} finally {
try {
inputStream.close();
@@ -799,9 +799,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
*/
- public String getVirtualDatabaseName() throws MetaMatrixComponentException, QueryMetadataException {
+ public String getVirtualDatabaseName() throws TeiidComponentException, QueryMetadataException {
if (vdbMetaData == null) {
return null;
}
@@ -816,9 +816,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getXMLTempGroups(java.lang.Object)
*/
- public Collection getXMLTempGroups(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Collection getXMLTempGroups(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -831,7 +831,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getCardinality(java.lang.Object)
*/
- public int getCardinality(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getCardinality(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
return ((Table) groupID).getCardinality();
}
@@ -839,7 +839,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLSchemas(java.lang.Object)
*/
- public List<SQLXMLImpl> getXMLSchemas(final Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public List<SQLXMLImpl> getXMLSchemas(final Object groupID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(Table.class, groupID);
Table tableRecord = (Table) groupID;
@@ -867,7 +867,7 @@
}
if (schema == null) {
- throw new MetaMatrixComponentException(DQPPlugin.Util.getString("TransformationMetadata.Error_trying_to_read_schemas_for_the_document/table____1")+groupName); //$NON-NLS-1$
+ throw new TeiidComponentException(DQPPlugin.Util.getString("TransformationMetadata.Error_trying_to_read_schemas_for_the_document/table____1")+groupName); //$NON-NLS-1$
}
schemas.add(schema);
}
@@ -875,12 +875,12 @@
return schemas;
}
- public String getNameInSource(final Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getNameInSource(final Object metadataID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
return ((AbstractMetadataRecord) metadataID).getNameInSource();
}
- public int getElementLength(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getElementLength(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getLength();
} else if(elementID instanceof ProcedureParameter){
@@ -890,7 +890,7 @@
}
}
- public int getPosition(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPosition(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getPosition();
} else if(elementID instanceof ProcedureParameter) {
@@ -900,7 +900,7 @@
}
}
- public int getPrecision(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPrecision(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getPrecision();
} else if(elementID instanceof ProcedureParameter) {
@@ -910,7 +910,7 @@
}
}
- public int getRadix(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getRadix(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getRadix();
} else if(elementID instanceof ProcedureParameter) {
@@ -920,14 +920,14 @@
}
}
- public String getFormat(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getFormat(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getFormat();
}
throw createInvalidRecordTypeException(elementID);
}
- public int getScale(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getScale(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getScale();
} else if(elementID instanceof ProcedureParameter) {
@@ -937,7 +937,7 @@
}
}
- public int getDistinctValues(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getDistinctValues(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getDistinctValues();
} else if(elementID instanceof ProcedureParameter) {
@@ -947,7 +947,7 @@
}
}
- public int getNullValues(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getNullValues(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getNullValues();
} else if(elementID instanceof ProcedureParameter) {
@@ -957,7 +957,7 @@
}
}
- public String getNativeType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getNativeType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof Column) {
return ((Column) elementID).getNativeType();
} else if(elementID instanceof ProcedureParameter) {
@@ -970,7 +970,7 @@
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
*/
- public Properties getExtensionProperties(final Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Properties getExtensionProperties(final Object metadataID) throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
AbstractMetadataRecord metadataRecord = (AbstractMetadataRecord) metadataID;
Map<String, String> result = metadataRecord.getProperties();
@@ -983,10 +983,10 @@
}
/**
- * @see com.metamatrix.query.metadata.BasicQueryMetadata#getBinaryVDBResource(java.lang.String)
+ * @see org.teiid.query.metadata.BasicQueryMetadata#getBinaryVDBResource(java.lang.String)
* @since 4.3
*/
- public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ public byte[] getBinaryVDBResource(String resourcePath) throws TeiidComponentException, QueryMetadataException {
final VirtualFile f = getFile(resourcePath);
if (f == null) {
return null;
@@ -994,7 +994,7 @@
try {
return ObjectConverterUtil.convertToByteArray(f.openStream());
} catch (IOException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
}
@@ -1057,10 +1057,10 @@
}
/**
- * @see com.metamatrix.query.metadata.BasicQueryMetadata#getCharacterVDBResource(java.lang.String)
+ * @see org.teiid.query.metadata.BasicQueryMetadata#getCharacterVDBResource(java.lang.String)
* @since 4.3
*/
- public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getCharacterVDBResource(String resourcePath) throws TeiidComponentException, QueryMetadataException {
try {
byte[] bytes = getBinaryVDBResource(resourcePath);
if (bytes == null) {
@@ -1068,7 +1068,7 @@
}
return ObjectConverterUtil.convertToString(new ByteArrayInputStream(bytes));
} catch (IOException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
}
@@ -1077,10 +1077,10 @@
}
/**
- * @see com.metamatrix.query.metadata.BasicQueryMetadata#getVDBResourcePaths()
+ * @see org.teiid.query.metadata.BasicQueryMetadata#getVDBResourcePaths()
* @since 4.3
*/
- public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
+ public String[] getVDBResourcePaths() throws TeiidComponentException, QueryMetadataException {
LinkedList<String> paths = new LinkedList<String>();
for (Map.Entry<String, Resource> entry : this.vdbEntries.entrySet()) {
if (entry.getValue().visible) {
@@ -1091,10 +1091,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
* @since 5.0
*/
- public String getModeledType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getModeledType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
Datatype record = getDatatypeRecord(elementID);
if (record != null) {
return record.getDatatypeID();
@@ -1103,10 +1103,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
* @since 5.0
*/
- public String getModeledBaseType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getModeledBaseType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
Datatype record = getDatatypeRecord(elementID);
if (record != null) {
return record.getBasetypeID();
@@ -1115,10 +1115,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
* @since 5.0
*/
- public String getModeledPrimitiveType(final Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getModeledPrimitiveType(final Object elementID) throws TeiidComponentException, QueryMetadataException {
Datatype record = getDatatypeRecord(elementID);
if (record != null) {
return record.getPrimitiveTypeID();
@@ -1138,7 +1138,7 @@
@Override
public Object addToMetadataCache(Object metadataID, String key, Object value)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
boolean groupInfo = key.startsWith(GroupInfo.CACHE_PREFIX);
key = getCacheKey(key, (AbstractMetadataRecord)metadataID);
@@ -1150,7 +1150,7 @@
@Override
public Object getFromMetadataCache(Object metadataID, String key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
ArgCheck.isInstanceOf(AbstractMetadataRecord.class, metadataID);
boolean groupInfo = key.startsWith(GroupInfo.CACHE_PREFIX);
key = getCacheKey(key, (AbstractMetadataRecord)metadataID);
Added: trunk/engine/src/main/java/org/teiid/metadata/VdbConstants.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/metadata/VdbConstants.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/metadata/VdbConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,37 @@
+/*
+ * 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.metadata;
+
+
+
+/**
+ * Constants used for VDB processing.
+ */
+public interface VdbConstants {
+
+ public static final String DEPLOYMENT_FILE = "vdb.xml"; // !!! DO NOT CHANGE VALUE as this would cause problems with existing VDBs having DEF files !!! //$NON-NLS-1$
+ public static final String VDB_ARCHIVE_EXTENSION = ".vdb"; //$NON-NLS-1$
+ public final static String INDEX_EXT = ".INDEX"; //$NON-NLS-1$
+ public final static String SEARCH_INDEX_EXT = ".SEARCH_INDEX"; //$NON-NLS-1$
+ public final static String MODEL_EXT = ".xmi"; //$NON-NLS-1$
+}
Copied: trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/QueryPlugin.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/QueryPlugin.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+import java.util.ResourceBundle;
+
+import org.teiid.core.BundleUtil;
+
+/**
+ * QueryPlugin
+ * <p>
+ * Used here in <code>query</code> to have access to the new logging framework for <code>LogManager</code>.
+ * </p>
+ */
+public class QueryPlugin { // extends Plugin {
+
+ /**
+ * The plug-in identifier of this plugin (value <code>"com.metamatrix.common"</code>).
+ */
+ public static final String PLUGIN_ID = QueryPlugin.class.getPackage().getName();
+
+ public static final BundleUtil Util = new BundleUtil(PLUGIN_ID,
+ PLUGIN_ID + ".i18n", ResourceBundle.getBundle(PLUGIN_ID + ".i18n")); //$NON-NLS-1$ //$NON-NLS-2$
+}
Copied: trunk/engine/src/main/java/org/teiid/query/analysis (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/analysis)
Modified: trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/analysis/AnalysisRecord.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/analysis/AnalysisRecord.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.analysis;
+package org.teiid.query.analysis;
import java.io.PrintWriter;
import java.io.Serializable;
@@ -33,15 +33,15 @@
import org.teiid.client.plan.Annotation;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
/**
* <p>The AnalysisRecord holds all debug/analysis information for
Copied: trunk/engine/src/main/java/org/teiid/query/eval (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/eval)
Modified: trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/Evaluator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/eval/Evaluator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.eval;
+package org.teiid.query.eval;
import java.sql.SQLException;
import java.util.ArrayList;
@@ -33,59 +33,60 @@
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
-import com.metamatrix.api.exception.ComponentNotFoundException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.types.Sequencable;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.source.XMLSystemFunctions;
-import com.metamatrix.query.function.source.XMLSystemFunctions.NameValuePair;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.AbstractSetCriteria;
-import com.metamatrix.query.sql.lang.CollectionValueIterator;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ContextReference;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.XMLElement;
-import com.metamatrix.query.sql.symbol.XMLForest;
-import com.metamatrix.query.sql.symbol.XMLNamespaces;
-import com.metamatrix.query.sql.symbol.XMLNamespaces.NamespaceItem;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorSource;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.Sequencable;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.source.XMLSystemFunctions;
+import org.teiid.query.function.source.XMLSystemFunctions.NameValuePair;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.AbstractSetCriteria;
+import org.teiid.query.sql.lang.CollectionValueIterator;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ContextReference;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.XMLElement;
+import org.teiid.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.symbol.XMLNamespaces;
+import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
+import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.sql.util.ValueIteratorSource;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class Evaluator {
private final static char[] REGEX_RESERVED = new char[] {'$', '(', ')', '*', '.', '?', '[', '\\', ']', '^', '{', '|', '}'}; //in sorted order
@@ -96,11 +97,11 @@
protected ProcessorDataManager dataMgr;
protected CommandContext context;
- public static boolean evaluate(Criteria criteria) throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ public static boolean evaluate(Criteria criteria) throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
return new Evaluator(Collections.emptyMap(), null, null).evaluate(criteria, Collections.emptyList());
}
- public static Object evaluate(Expression expression) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ public static Object evaluate(Expression expression) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
return new Evaluator(Collections.emptyMap(), null, null).evaluate(expression, Collections.emptyList());
}
@@ -116,13 +117,13 @@
}
public boolean evaluate(Criteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
return Boolean.TRUE.equals(evaluateTVL(criteria, tuple));
}
public Boolean evaluateTVL(Criteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
if(criteria instanceof CompoundCriteria) {
return evaluate((CompoundCriteria)criteria, tuple);
@@ -146,7 +147,7 @@
}
public Boolean evaluate(CompoundCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
List subCrits = criteria.getCriteria();
Iterator subCritIter = subCrits.iterator();
@@ -170,7 +171,7 @@
}
public Boolean evaluate(NotCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
Criteria subCrit = criteria.getCriteria();
Boolean result = evaluateTVL(subCrit, tuple);
@@ -184,7 +185,7 @@
}
public Boolean evaluate(CompareCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate left expression
Object leftValue = null;
@@ -241,7 +242,7 @@
}
public Boolean evaluate(MatchCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
boolean result = false;
// Evaluate left expression
@@ -306,7 +307,7 @@
}
private Boolean evaluate(AbstractSetCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate expression
Object leftValue = null;
@@ -331,7 +332,7 @@
Set<Object> values;
try {
values = vis.getCachedSet(ref.getValueExpression());
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new CriteriaEvaluationException(e, e.getMessage());
}
if (values != null) {
@@ -343,7 +344,7 @@
} else if (criteria instanceof SubquerySetCriteria) {
try {
valueIter = evaluateSubquery((SubquerySetCriteria)criteria, tuple);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new CriteriaEvaluationException(e, e.getMessage());
}
} else {
@@ -379,7 +380,7 @@
}
public boolean evaluate(IsNullCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate expression
Object value = null;
@@ -393,7 +394,7 @@
}
private Boolean evaluate(SubqueryCompareCriteria criteria, List tuple)
- throws CriteriaEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws CriteriaEvaluationException, BlockedException, TeiidComponentException {
// Evaluate expression
Object leftValue = null;
@@ -421,7 +422,7 @@
ValueIterator valueIter;
try {
valueIter = evaluateSubquery(criteria, tuple);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new CriteriaEvaluationException(e, e.getMessage());
}
while(valueIter.hasNext()) {
@@ -504,12 +505,12 @@
}
public boolean evaluate(ExistsCriteria criteria, List tuple)
- throws BlockedException, MetaMatrixComponentException, CriteriaEvaluationException {
+ throws BlockedException, TeiidComponentException, CriteriaEvaluationException {
ValueIterator valueIter;
try {
valueIter = evaluateSubquery(criteria, tuple);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new CriteriaEvaluationException(e, e.getMessage());
}
if(valueIter.hasNext()) {
@@ -519,7 +520,7 @@
}
public Object evaluate(Expression expression, List tuple)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
try {
return internalEvaluate(expression, tuple);
@@ -529,7 +530,7 @@
}
private Object internalEvaluate(Expression expression, List tuple)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
if(expression instanceof SingleElementSymbol) {
if (elements != null) {
@@ -578,7 +579,7 @@
attributes = getNameValuePairs(tuple, function.getAttributes().getArgs());
}
return XMLSystemFunctions.xmlElement(context, function.getName(), namespaces(function.getNamespaces()), attributes, values);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new FunctionExecutionException(e, e.getMessage());
}
} else if (expression instanceof XMLForest){
@@ -588,16 +589,16 @@
try {
return XMLSystemFunctions.xmlForest(context, namespaces(function.getNamespaces()), nameValuePairs);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new FunctionExecutionException(e, e.getMessage());
}
} else {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0016, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0016, expression.getClass().getName()));
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0016, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0016, expression.getClass().getName()));
}
}
private NameValuePair<Object>[] getNameValuePairs(List tuple, List<SingleElementSymbol> args)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
NameValuePair<Object>[] nameValuePairs = new NameValuePair[args.size()];
for (int i = 0; i < args.size(); i++) {
SingleElementSymbol symbol = args.get(i);
@@ -625,7 +626,7 @@
}
private Object evaluate(CaseExpression expr, List tuple)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
Object exprVal = internalEvaluate(expr.getExpression(), tuple);
for (int i = 0; i < expr.getWhenCount(); i++) {
if (EquivalenceUtil.areEqual(exprVal, internalEvaluate(expr.getWhenExpression(i), tuple))) {
@@ -639,7 +640,7 @@
}
private Object evaluate(SearchedCaseExpression expr, List tuple)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
for (int i = 0; i < expr.getWhenCount(); i++) {
try {
if (evaluate(expr.getWhenCriteria(i), tuple)) {
@@ -656,7 +657,7 @@
}
private Object evaluate(Function function, List tuple)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
// Get function based on resolved function info
FunctionDescriptor fd = function.getFunctionDescriptor();
@@ -681,7 +682,7 @@
// Check for function we can't evaluate
if(fd.getPushdown() == FunctionMethod.MUST_PUSHDOWN) {
- throw new MetaMatrixComponentException(QueryPlugin.Util.getString("ExpressionEvaluator.Must_push", fd.getName())); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryPlugin.Util.getString("ExpressionEvaluator.Must_push", fd.getName())); //$NON-NLS-1$
}
// Check for special lookup function
@@ -696,7 +697,7 @@
try {
return dataMgr.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, values[3]);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new ExpressionEvaluationException(e, e.getMessage());
}
}
@@ -707,13 +708,13 @@
}
private Object evaluate(ScalarSubquery scalarSubquery, List tuple)
- throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
Object result = null;
ValueIterator valueIter;
try {
valueIter = evaluateSubquery(scalarSubquery, tuple);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new ExpressionEvaluationException(e, e.getMessage());
}
if(valueIter.hasNext()) {
@@ -728,13 +729,13 @@
}
protected ValueIterator evaluateSubquery(SubqueryContainer container, List tuple)
- throws MetaMatrixProcessingException, BlockedException, MetaMatrixComponentException {
+ throws TeiidProcessingException, BlockedException, TeiidComponentException {
throw new UnsupportedOperationException("Subquery evaluation not possible with a base Evaluator"); //$NON-NLS-1$
}
- private CommandContext getContext(LanguageObject expression) throws MetaMatrixComponentException {
+ private CommandContext getContext(LanguageObject expression) throws TeiidComponentException {
if (context == null) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
}
return context;
}
Modified: trunk/engine/src/main/java/org/teiid/query/eval/SecurityFunctionEvaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/eval/SecurityFunctionEvaluator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/eval/SecurityFunctionEvaluator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.eval;
+package org.teiid.query.eval;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
+import org.teiid.core.TeiidComponentException;
public interface SecurityFunctionEvaluator {
public static final String DATA_ROLE = "data"; //$NON-NLS-1$
- boolean hasRole(String roleType, String roleName) throws MetaMatrixComponentException;
+ boolean hasRole(String roleType, String roleName) throws TeiidComponentException;
}
Copied: trunk/engine/src/main/java/org/teiid/query/execution (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/execution)
Modified: trunk/engine/src/main/java/org/teiid/query/execution/QueryExecPlugin.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/execution/QueryExecPlugin.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/execution/QueryExecPlugin.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.execution;
+package org.teiid.query.execution;
import java.util.ResourceBundle;
-import com.metamatrix.core.BundleUtil;
+import org.teiid.core.BundleUtil;
+
/**
* QueryPlugin
* <p>Used here in <code>query</code> to have access to the new
@@ -36,7 +37,7 @@
* The plug-in identifier of this plugin
* (value <code>"com.metamatrix.common"</code>).
*/
- public static final String PLUGIN_ID = "com.metamatrix.query.execution" ; //$NON-NLS-1$
+ public static final String PLUGIN_ID = QueryExecPlugin.class.getPackage().getName();
/**
* Provides access to the plugin's log and to it's resources.
Copied: trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/FunctionDescriptor.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionDescriptor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,279 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.core.util.PropertiesUtils;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
+
+/**
+ * The FunctionDescriptor describes a particular function instance enough
+ * that the function library can retrieve a function instance based on the
+ * descriptor.
+ */
+public class FunctionDescriptor implements Serializable, Cloneable {
+
+ private static final boolean ALLOW_NAN_INFINITY = PropertiesUtils.getBooleanProperty(System.getProperties(), "org.teiid.allowNanInfinity", false); //$NON-NLS-1$
+
+ private String name;
+ private int pushdown;
+ private Class[] types;
+ private Class returnType;
+ private int hash;
+ private boolean requiresContext;
+ private boolean nullDependent;
+ private int deterministic;
+
+ // This is transient as it would be useless to invoke this method in
+ // a different VM. This function descriptor can be used to look up
+ // the real VM descriptor for execution.
+ private transient Method invocationMethod;
+
+ FunctionDescriptor() {
+ }
+
+ /**
+ * Construct a function descriptor with all the info
+ * @param name Name of function
+ * @param types Types of the arguments
+ * @param returnType Type of the return
+ * @param invocationMethod Reflection method used to invoke the function
+ * @param requiresContext during execution requires command context to be pushed into method as first argument
+ */
+ FunctionDescriptor(String name, int pushdown, Class[] types, Class returnType, Method invocationMethod, boolean requiresContext, boolean nullDependent, int deterministic) {
+ Assertion.isNotNull(name);
+ Assertion.isNotNull(types);
+ Assertion.isNotNull(returnType);
+
+ this.name = name;
+ this.pushdown = pushdown;
+ this.types = types;
+ this.returnType = returnType;
+ this.invocationMethod = invocationMethod;
+ this.requiresContext = requiresContext;
+ this.nullDependent = nullDependent;
+ this.deterministic = deterministic;
+
+ // Compute hash code
+ hash = HashCodeUtil.hashCode(0, name);
+ for(int i=0; i<types.length; i++) {
+ hash = HashCodeUtil.hashCode(hash, types[i]);
+ }
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public int getPushdown() {
+ return this.pushdown;
+ }
+
+ void setPushdown(int pushdown) {
+ this.pushdown = pushdown;
+ }
+
+ public Class[] getTypes() {
+ return this.types;
+ }
+
+ public Class getReturnType() {
+ return this.returnType;
+ }
+
+ Method getInvocationMethod() {
+ return this.invocationMethod;
+ }
+
+ public boolean requiresContext() {
+ return this.requiresContext;
+ }
+
+ public int hashCode() {
+ return this.hash;
+ }
+
+ public boolean equals(Object obj) {
+ if(obj == this) {
+ return true;
+ }
+
+ if(obj == null || !(obj instanceof FunctionDescriptor)) {
+ return false;
+ }
+ FunctionDescriptor other = (FunctionDescriptor) obj;
+
+ // Compare names
+ if(! this.getName().equals(other.getName())) {
+ return false;
+ }
+
+ // Compare arg types
+ Class[] thisTypes = this.getTypes();
+ Class[] otherTypes = other.getTypes();
+ if(thisTypes.length != otherTypes.length) {
+ return false;
+ }
+ for(int i=0; i<thisTypes.length; i++) {
+ if(! thisTypes[i].equals(otherTypes[i])) {
+ return false;
+ }
+ }
+
+ if (this.nullDependent != other.isNullDependent()) {
+ return false;
+ }
+
+ if (this.deterministic != other.deterministic) {
+ return false;
+ }
+
+ // Must be a match
+ return true;
+ }
+
+ public String toString() {
+ StringBuffer str = new StringBuffer(this.name);
+ str.append("("); //$NON-NLS-1$
+ for(int i=0; i<types.length; i++) {
+ if(types[i] != null) {
+ str.append(types[i].getName());
+ } else {
+ str.append("null"); //$NON-NLS-1$
+ }
+ if(i<(types.length-1)) {
+ str.append(", "); //$NON-NLS-1$
+ }
+ }
+ str.append(") : "); //$NON-NLS-1$
+ if(returnType == null) {
+ str.append("null"); //$NON-NLS-1$
+ } else {
+ str.append(returnType.getName());
+ }
+ return str.toString();
+ }
+
+ public boolean isNullDependent() {
+ return nullDependent;
+ }
+
+ public int getDeterministic() {
+ return deterministic;
+ }
+
+ void setDeterministic(int deterministic) {
+ this.deterministic = deterministic;
+ }
+
+ public Object clone() {
+ try {
+ return super.clone();
+ } catch (CloneNotSupportedException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ void setReturnType(Class returnType) {
+ this.returnType = returnType;
+ }
+
+
+ /**
+ * Invoke the function described in the function descriptor, using the
+ * values provided. Return the result of the function.
+ * @param fd Function descriptor describing the name and types of the arguments
+ * @param values Values that should match 1-to-1 with the types described in the
+ * function descriptor
+ * @return Result of invoking the function
+ */
+ public Object invokeFunction(Object[] values) throws FunctionExecutionException {
+
+ if (!isNullDependent()) {
+ for (int i = 0; i < values.length; i++) {
+ if (values[i] == null) {
+ return null;
+ }
+ }
+ }
+
+ // If descriptor is missing invokable method, find this VM's descriptor
+ // give name and types from fd
+ Method method = getInvocationMethod();
+ if(method == null) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0002, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0002, getName()));
+ }
+
+ if (getDeterministic() >= FunctionMethod.SESSION_DETERMINISTIC && values.length > 0 && values[0] instanceof CommandContext) {
+ CommandContext cc = (CommandContext)values[0];
+ cc.setSessionFunctionEvaluated(true);
+ }
+
+ // Invoke the method and return the result
+ try {
+ if (method.isVarArgs()) {
+ int i = method.getParameterTypes().length;
+ Object[] newValues = Arrays.copyOf(values, i);
+ newValues[i - 1] = Arrays.copyOfRange(values, i - 1, values.length);
+ values = newValues;
+ }
+ Object result = method.invoke(null, values);
+ if (!ALLOW_NAN_INFINITY) {
+ if (result instanceof Double) {
+ Double floatVal = (Double)result;
+ if (Double.isInfinite(floatVal) || Double.isNaN(floatVal)) {
+ throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName())); //$NON-NLS-1$
+ }
+ } else if (result instanceof Float) {
+ Float floatVal = (Float)result;
+ if (Float.isInfinite(floatVal) || Float.isNaN(floatVal)) {
+ throw new FunctionExecutionException(new ArithmeticException("Infinite or invalid result"), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName())); //$NON-NLS-1$
+ }
+ }
+ }
+ result = DataTypeManager.convertToRuntimeType(result);
+ result = DataTypeManager.transformValue(result, getReturnType());
+ return result;
+ } catch(InvocationTargetException e) {
+ throw new FunctionExecutionException(e.getTargetException(), ErrorMessageKeys.FUNCTION_0003, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0003, getName()));
+ } catch(IllegalAccessException e) {
+ throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0004, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0004, method.toString()));
+ } catch (TransformationException e) {
+ throw new FunctionExecutionException(e, e.getMessage());
+ }
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/FunctionForm.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionForm.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,282 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+import java.util.*;
+
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.function.metadata.*;
+
+
+/**
+ * The FunctionForm class represents a particular form of a function signature.
+ * It is different from the FunctionMethod class because it ignores type
+ * information and instead differentiates function signatures based on their
+ * function name and the names of the arguments.
+ */
+public class FunctionForm implements Serializable, Comparable {
+
+ private String name;
+ private String description;
+ private String category;
+ private List inputParamNames;
+ private List inputParamDescs;
+ private String outputParamName;
+ private String outputParamDesc;
+
+ /**
+ * Construct a function form by pulling all info from a FunctionMethod. Because
+ * a FunctionForm is only created from a <b>validated</b> method, we can assume
+ * many things, such as that function name, type, category are non-null.
+ * @param method FunctionMethod to build form from
+ */
+ public FunctionForm(FunctionMethod method) {
+ Assertion.isNotNull(method);
+
+ // Get function stuff
+ this.name = method.getName().toUpperCase();
+ this.description = method.getDescription();
+ this.category = method.getCategory().toUpperCase();
+
+ // Get input parameter stuff
+ FunctionParameter[] inputParams = method.getInputParameters();
+ if(inputParams == null) {
+ inputParamNames = new ArrayList(0);
+ inputParamDescs = new ArrayList(0);
+ } else {
+ inputParamNames = new ArrayList(inputParams.length);
+ inputParamDescs = new ArrayList(inputParams.length);
+
+ for(int i=0; i<inputParams.length; i++) {
+ inputParamNames.add(inputParams[i].getName().toUpperCase());
+ inputParamDescs.add(inputParams[i].getDescription());
+ }
+ }
+
+ // Get output parameter stuff
+ FunctionParameter outParam = method.getOutputParameter();
+ this.outputParamName = outParam.getName().toUpperCase();
+ this.outputParamDesc = outParam.getDescription();
+ }
+
+ /**
+ * Get name of function.
+ * @return Name
+ */
+ public String getName() {
+ return this.name;
+ }
+
+ /**
+ * Get description of function.
+ * @return Description
+ */
+ public String getDescription() {
+ return this.description;
+ }
+
+ /**
+ * Get category.
+ * @return Category
+ */
+ public String getCategory() {
+ return this.category;
+ }
+
+ /**
+ * Get list of argument names.
+ * @return List of argument names ({@link java.lang.String})
+ */
+ public List getArgNames() {
+ return this.inputParamNames;
+ }
+
+ /**
+ * Get argument name at index.
+ * @param index Index to use
+ * @return Argument name at index
+ */
+ public String getArgName(int index) {
+ return (String) this.inputParamNames.get(index);
+ }
+
+ /**
+ * Get list of argument descriptions.
+ * @return List of argument descriptions ({@link java.lang.String})
+ */
+ public List getArgDescriptions() {
+ return this.inputParamDescs;
+ }
+
+ /**
+ * Get argument description at index.
+ * @param index Index to use
+ * @return Argument description at index
+ */
+ public String getArgDescription(int index) {
+ return (String) this.inputParamDescs.get(index);
+ }
+
+ /**
+ * Get name of return parameter
+ * @return Name of return parameter
+ */
+ public String getReturnName() {
+ return this.outputParamName;
+ }
+
+ /**
+ * Get description of return parameter
+ * @return Description of return parameter
+ */
+ public String getReturnDescription() {
+ return this.outputParamDesc;
+ }
+
+ /**
+ * Get display string for this function form
+ * @return Display version of this function form
+ */
+ public String getDisplayString() {
+ StringBuffer str = new StringBuffer();
+
+ if(name.equalsIgnoreCase(FunctionLibrary.CAST)) {
+ str.append(name);
+ str.append("("); //$NON-NLS-1$
+ str.append(inputParamNames.get(0));
+ if(name.equalsIgnoreCase(FunctionLibrary.CONVERT) || name.equalsIgnoreCase(FunctionLibrary.CAST)) {
+ str.append(", "); //$NON-NLS-1$
+ } else {
+ str.append(" "); //$NON-NLS-1$
+ str.append(SQLReservedWords.AS);
+ str.append(" "); //$NON-NLS-1$
+ }
+ str.append(inputParamNames.get(1));
+ str.append(")"); //$NON-NLS-1$
+
+ } else if(name.equals("+") || name.equals("-") || name.equals("*") || name.equals("/") || name.equals("||")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
+ str.append("("); //$NON-NLS-1$
+ str.append(inputParamNames.get(0));
+ str.append(name);
+ str.append(inputParamNames.get(1));
+ str.append(")"); //$NON-NLS-1$
+ } else {
+ str.append(name);
+ str.append("("); //$NON-NLS-1$
+
+ if(inputParamNames.size() > 0) {
+ Iterator iter = inputParamNames.iterator();
+ str.append(iter.next());
+ while(iter.hasNext()) {
+ str.append(", "); //$NON-NLS-1$
+ str.append(iter.next());
+ }
+ }
+
+ str.append(")"); //$NON-NLS-1$
+ }
+
+ return str.toString();
+ }
+
+ /**
+ * String representation of the function form for debugging purposes.
+ * @return String representation
+ */
+ public String toString() {
+ return this.getDisplayString();
+ }
+
+ /**
+ * Return hash code based on the name and input parameter names
+ * @return Hash code
+ */
+ public int hashCode() {
+ return HashCodeUtil.hashCode(name.hashCode(), inputParamNames.hashCode());
+ }
+
+ /**
+ * Compare this function form with another based on the name and
+ * argument names.
+ * @param obj Other object
+ */
+ public boolean equals(Object obj) {
+ if(obj == this) {
+ return true;
+ } else if(obj == null || !(obj instanceof FunctionForm)) {
+ return false;
+ } else {
+ FunctionForm other = (FunctionForm) obj;
+ return other.getName().equals(getName()) &&
+ other.getArgNames().equals(getArgNames());
+ }
+ }
+
+ /**
+ * Implements Comparable interface so that this object can be compared to
+ * other FunctionForm objects and ordered alphabetically.
+ * @param obj Other object
+ * @return 1 if other > this, 0 if other == this, -1 if other < this
+ */
+ public int compareTo(Object obj) {
+ if(obj == this) {
+ return 0;
+ } else if(obj == null) {
+ // Should never happen, but sort nulls low
+ return -1;
+ } else {
+ // may throw ClassCastException - this is expected for compareTo()
+ FunctionForm other = (FunctionForm) obj;
+
+ int compare = this.getName().compareTo( other.getName() );
+ if(compare != 0) {
+ return compare;
+ }
+
+ // Look further into arg names to compare as names are ==
+ List otherArgs = other.getArgNames();
+ List myArgs = this.getArgNames();
+
+ // Compare # of args first
+ if(myArgs.size() < otherArgs.size()) {
+ return -1;
+ } else if(myArgs.size() > otherArgs.size()) {
+ return 1;
+ } // else continue
+
+ // Same # of args
+ for(int i=0; i < myArgs.size(); i++) {
+ compare = ((String)myArgs.get(i)).compareTo( ((String)otherArgs.get(i)) );
+ if(compare != 0) {
+ return compare;
+ }
+ }
+
+ // Same
+ return 0;
+ }
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/FunctionLibrary.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,338 @@
+/*
+ * 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.function;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.teiid.api.exception.query.InvalidFunctionException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+
+
+
+/**
+ * The function library is the primary way for the system to find out what
+ * functions are available, resolve function signatures, and invoke system
+ * and user-defined functions.
+ */
+public class FunctionLibrary {
+
+ // Special type conversion functions
+ public static final String CONVERT = "convert"; //$NON-NLS-1$
+ public static final String CAST = "cast"; //$NON-NLS-1$
+
+ // Special lookup function
+ public static final String LOOKUP = "lookup"; //$NON-NLS-1$
+
+ // Special user function
+ public static final String USER = "user"; //$NON-NLS-1$
+ // Special environment variable lookup function
+ public static final String ENV = "env"; //$NON-NLS-1$
+
+ // Special pseudo-functions only for XML queries
+ public static final String CONTEXT = "context"; //$NON-NLS-1$
+ public static final String ROWLIMIT = "rowlimit"; //$NON-NLS-1$
+ public static final String ROWLIMITEXCEPTION = "rowlimitexception"; //$NON-NLS-1$
+
+ // Misc.
+ public static final String DECODESTRING = "decodestring"; //$NON-NLS-1$
+ public static final String DECODEINTEGER = "decodeinteger"; //$NON-NLS-1$
+ public static final String COMMAND_PAYLOAD = "commandpayload"; //$NON-NLS-1$
+
+ public static final String CONCAT = "CONCAT"; //$NON-NLS-1$
+ public static final String CONCAT2 = "CONCAT2"; //$NON-NLS-1$
+ public static final String CONCAT_OPERATOR = "||"; //$NON-NLS-1$
+ public static final String SUBSTRING = "substring"; //$NON-NLS-1$
+ public static final String NVL = "NVL"; //$NON-NLS-1$
+ public static final String IFNULL = "IFNULL"; //$NON-NLS-1$
+
+ public static final String FROM_UNIXTIME = "from_unixtime"; //$NON-NLS-1$
+ public static final String TIMESTAMPADD = "timestampadd"; //$NON-NLS-1$
+
+ public static final String PARSETIME = "parsetime"; //$NON-NLS-1$
+ public static final String PARSEDATE = "parsedate"; //$NON-NLS-1$
+ public static final String FORMATTIME = "formattime"; //$NON-NLS-1$
+ public static final String FORMATDATE = "formatdate"; //$NON-NLS-1$
+
+ public static final String NULLIF = "nullif"; //$NON-NLS-1$
+ public static final String COALESCE = "coalesce"; //$NON-NLS-1$
+
+ public static final String SPACE = "space"; //$NON-NLS-1$
+
+ public static final String XMLFOREST = "XMLFOREST"; //$NON-NLS-1$
+ public static final String XMLATTRIBUTES = "XMLATTRIBUTES"; //$NON-NLS-1$
+ public static final String XMLNAMESPACES = "XMLNAMESPACES"; //$NON-NLS-1$
+ public static final String XMLELEMENT = "XMLELEMENT"; //$NON-NLS-1$
+
+ // Function tree for system functions (never reloaded)
+ private FunctionTree systemFunctions;
+
+ // Function tree for user-defined functions
+ private FunctionTree userFunctions;
+
+ /**
+ * Construct the function library. This should be called only once by the
+ * FunctionLibraryManager.
+ */
+ public FunctionLibrary(FunctionTree systemFuncs, FunctionTree userFuncs) {
+ systemFunctions = systemFuncs;
+ userFunctions = userFuncs;
+ }
+
+ /**
+ * Get all function categories, sorted in alphabetical order
+ * @return List of function category names, sorted in alphabetical order
+ */
+ public List getFunctionCategories() {
+ // Remove category duplicates
+ HashSet categories = new HashSet();
+ categories.addAll( systemFunctions.getCategories() );
+ categories.addAll( userFunctions.getCategories() );
+
+ // Sort alphabetically
+ ArrayList categoryList = new ArrayList(categories);
+ Collections.sort(categoryList);
+ return categoryList;
+ }
+
+ /**
+ * Get all function forms in a category, sorted by name, then # of args, then names of args.
+ * @param category Category name
+ * @return List of {@link FunctionForm}s in a category
+ */
+ public List getFunctionForms(String category) {
+ List forms = new ArrayList();
+ forms.addAll(systemFunctions.getFunctionForms(category));
+ forms.addAll(userFunctions.getFunctionForms(category));
+
+ // Sort alphabetically
+ Collections.sort(forms);
+ return forms;
+ }
+
+ /**
+ * Find function form based on function name and # of arguments.
+ * @param name Function name
+ * @param numArgs Number of arguments
+ * @return Corresponding form or null if not found
+ */
+ public FunctionForm findFunctionForm(String name, int numArgs) {
+ FunctionForm form = systemFunctions.findFunctionForm(name, numArgs);
+ if(form == null) {
+ form = userFunctions.findFunctionForm(name, numArgs);
+ }
+ return form;
+ }
+
+ /**
+ * Find a function descriptor given a name and the types of the arguments.
+ * This method matches based on case-insensitive function name and
+ * an exact match of the number and types of parameter arguments.
+ * @param name Name of the function to resolve
+ * @param types Array of classes representing the types
+ * @return Descriptor if found, null if not found
+ */
+ public FunctionDescriptor findFunction(String name, Class[] types) {
+ // First look in system functions
+ FunctionDescriptor descriptor = systemFunctions.getFunction(name, types);
+
+ // If that fails, check the user defined functions
+ if(descriptor == null) {
+ descriptor = userFunctions.getFunction(name, types);
+ }
+
+ return descriptor;
+ }
+
+ /**
+ * Get the conversions that are needed to call the named function with arguments
+ * of the given type. In the case of an exact match, the list will contain all nulls.
+ * In other cases the list will contain one or more non-null values where the value
+ * is a conversion function that can be used to convert to the proper types for
+ * executing the function.
+ * @param name Name of function
+ * @param returnType
+ * @param types Existing types passed to the function
+ * @return Null if no conversion could be found, otherwise an array of conversions
+ * to apply to each argument. The list should match 1-to-1 with the parameters.
+ * Parameters that do not need a conversion are null; parameters that do are
+ * FunctionDescriptors.
+ * @throws QueryResolverException
+ */
+ public FunctionDescriptor[] determineNecessaryConversions(String name, Class<?> returnType, Class<?>[] types, boolean hasUnknownType) {
+ // Check for no args - no conversion necessary
+ if(types.length == 0) {
+ return new FunctionDescriptor[0];
+ }
+
+ // Construct results array
+ FunctionDescriptor[] results = null;
+
+ //First find existing functions with same name and same number of parameters
+ final Collection<FunctionMethod> functionMethods = new LinkedList<FunctionMethod>();
+ functionMethods.addAll( this.systemFunctions.findFunctionMethods(name , types.length) );
+ functionMethods.addAll( this.userFunctions.findFunctionMethods(name , types.length) );
+
+ //Score each match, reject any where types can not be converted implicitly
+ //Score of current method (lower score means better match with less converts
+ //Current best score (lower score is best. Higher score results in more implicit conversions
+ int bestScore = Integer.MAX_VALUE;
+ boolean ambiguous = false;
+
+ for (FunctionMethod nextMethod : functionMethods) {
+ int currentScore = 0;
+ final FunctionParameter[] methodTypes = nextMethod.getInputParameters();
+ //Holder for current signature with converts where required
+ FunctionDescriptor[] currentSignature = new FunctionDescriptor[types.length];
+
+ //Iterate over the parameters adding conversions where required or failing when
+ //no implicit conversion is possible
+ int i = 0;
+ for(; i < types.length; i++) {
+ //treat all varags as the same type
+ final String tmpTypeName = methodTypes[Math.min(i, methodTypes.length - 1)].getType();
+ Class<?> targetType = DataTypeManager.getDataTypeClass(tmpTypeName);
+
+ Class<?> sourceType = types[i];
+ if (sourceType == null) {
+ FunctionDescriptor fd = findTypedConversionFunction(DataTypeManager.DefaultDataClasses.NULL, targetType);
+ currentSignature[i] = fd;
+ currentScore++;
+ continue;
+ }
+
+ try {
+ FunctionDescriptor fd = getConvertFunctionDescriptor(sourceType, targetType);
+ if (fd != null) {
+ currentScore++;
+ currentSignature[i] = fd;
+ }
+ } catch (InvalidFunctionException e) {
+ break;
+ }
+ }
+
+ //If the method is valid match and it is the current best score, capture those values as current best match
+ if (i != types.length || currentScore > bestScore) {
+ continue;
+ }
+
+ if (hasUnknownType) {
+ if (returnType != null) {
+ try {
+ FunctionDescriptor fd = getConvertFunctionDescriptor(DataTypeManager.getDataTypeClass(nextMethod.getOutputParameter().getType()), returnType);
+ if (fd != null) {
+ currentScore++;
+ }
+ } catch (InvalidFunctionException e) {
+ //there still may be a common type, but use any other valid conversion over this one
+ currentScore += (types.length + 1);
+ }
+ }
+ ambiguous = currentScore == bestScore;
+ }
+
+ if (currentScore < bestScore) {
+
+ if (currentScore == 0) {
+ //this must be an exact match
+ return currentSignature;
+ }
+
+ bestScore = currentScore;
+ results = currentSignature;
+ }
+ }
+
+ if (ambiguous) {
+ return null;
+ }
+
+ return results;
+ }
+
+ private FunctionDescriptor getConvertFunctionDescriptor(Class<?> sourceType, Class<?> targetType) throws InvalidFunctionException {
+ final String sourceTypeName = DataTypeManager.getDataTypeName(sourceType);
+ final String targetTypeName = DataTypeManager.getDataTypeName(targetType);
+ //If exact match no conversion necessary
+ if(sourceTypeName.equals(targetTypeName)) {
+ return null;
+ }
+ //Else see if an implicit conversion is possible.
+ if(!DataTypeManager.isImplicitConversion(sourceTypeName, targetTypeName)){
+ throw new InvalidFunctionException();
+ }
+ //Else no conversion is available and the current method is not a valid match
+ final FunctionDescriptor fd = findTypedConversionFunction(sourceType, targetType);
+ if(fd == null) {
+ throw new InvalidFunctionException();
+ }
+ return fd;
+ }
+
+ /**
+ * Find conversion function and set return type to proper type.
+ * @param sourceType The source type class
+ * @param targetType The target type class
+ * @return A CONVERT function descriptor or null if not possible
+ */
+ public FunctionDescriptor findTypedConversionFunction(Class sourceType, Class targetType) {
+ FunctionDescriptor fd = findFunction(CONVERT, new Class[] {sourceType, DataTypeManager.DefaultDataClasses.STRING});
+ if (fd != null) {
+ return copyFunctionChangeReturnType(fd, targetType);
+ }
+ return null;
+ }
+
+ /**
+ * Return a copy of the given FunctionDescriptor with the sepcified return type.
+ * @param fd FunctionDescriptor to be copied.
+ * @param returnType The return type to apply to the copied FunctionDescriptor.
+ * @return The copy of FunctionDescriptor.
+ */
+ public FunctionDescriptor copyFunctionChangeReturnType(FunctionDescriptor fd, Class returnType) {
+ if(fd != null) {
+ FunctionDescriptor fdImpl = fd;
+ FunctionDescriptor copy = (FunctionDescriptor)fdImpl.clone();
+ copy.setReturnType(returnType);
+ return copy;
+ }
+ return fd;
+ }
+
+ public static boolean isConvert(Function function) {
+ Expression[] args = function.getArgs();
+ String funcName = function.getName().toLowerCase();
+
+ return args.length == 2 && (funcName.equalsIgnoreCase(FunctionLibrary.CONVERT) || funcName.equalsIgnoreCase(FunctionLibrary.CAST));
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMetadataSource.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMetadataSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,56 @@
+/*
+ * 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.function;
+
+import java.util.Collection;
+
+import org.teiid.query.function.metadata.FunctionMethod;
+
+
+/**
+ * A FunctionMetadataSource represents a source of function metadata for
+ * the function library. A FunctionMetadataSource needs to know how to
+ * return a collection of all the function signatures it knows about.
+ */
+public interface FunctionMetadataSource {
+
+ /**
+ * This method requests that the source return all
+ * {@link com.metamatrix.query.function.FunctionMethod}s
+ * the source knows about. This can occur in several situations -
+ * on initial registration with the FunctionLibraryManager, on a
+ * general reload, etc. This may be called multiple times and should
+ * always return the newest information available.
+ * @return Collection of FunctionMethod objects
+ */
+ Collection<FunctionMethod> getFunctionMethods();
+
+ /**
+ * This method determines where the invocation classes specified in the
+ * function metadata are actually retrieved from.
+ * @param className Name of class
+ * @return Class reference
+ * @throws ClassNotFoundException If class could not be found
+ */
+ Class getInvocationClass(String className) throws ClassNotFoundException;
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/FunctionMethods.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,1249 @@
+/*
+ * 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.function;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.math.BigInteger;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Properties;
+import java.util.TimeZone;
+
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
+
+public final class FunctionMethods {
+
+ // ================== Function = plus =====================
+
+ public static int plus(int x, int y) {
+ return x + y;
+ }
+
+ public static long plus(long x, long y) {
+ return x + y;
+ }
+
+ public static float plus(float x, float y) {
+ return x + y;
+ }
+
+ public static double plus(double x, double y) {
+ return x + y;
+ }
+
+ public static Object plus(BigInteger x, BigInteger y) {
+ return x.add(y);
+ }
+
+ public static Object plus(BigDecimal x, BigDecimal y) {
+ return x.add(y);
+ }
+
+ // ================== Function = minus =====================
+
+ public static int minus(int x, int y) {
+ return x - y;
+ }
+
+ public static long minus(long x, long y) {
+ return x - y;
+ }
+
+ public static float minus(float x, float y) {
+ return x - y;
+ }
+
+ public static double minus(double x, double y) {
+ return x - y;
+ }
+
+ public static Object minus(BigInteger x, BigInteger y) {
+ return x.subtract(y);
+ }
+
+ public static Object minus(BigDecimal x, BigDecimal y) {
+ return x.subtract(y);
+ }
+
+ // ================== Function = multiply =====================
+
+ public static int multiply(int x, int y) {
+ return x * y;
+ }
+
+ public static long multiply(long x, long y) {
+ return x * y;
+ }
+
+ public static float multiply(float x, float y) {
+ return x * y;
+ }
+
+ public static double multiply(double x, double y) {
+ return x * y;
+ }
+
+ public static Object multiply(BigInteger x, BigInteger y) {
+ return x.multiply(y);
+ }
+
+ public static Object multiply(BigDecimal x, BigDecimal y) {
+ return x.multiply(y);
+ }
+
+ // ================== Function = divide =====================
+
+ public static int divide(int x, int y) {
+ return x / y;
+ }
+
+ public static long divide(long x, long y) {
+ return x / y;
+ }
+
+ public static float divide(float x, float y) {
+ return x / y;
+ }
+
+ public static double divide(double x, double y) {
+ return x / y;
+ }
+
+ public static Object divide(BigInteger x, BigInteger y) {
+ return x.divide(y);
+ }
+
+ public static Object divide(BigDecimal x, BigDecimal y) {
+ return x.divide(y, BigDecimal.ROUND_HALF_UP);
+ }
+
+ // ================== Function = abs =====================
+
+ public static int abs(int x) {
+ return Math.abs(x);
+ }
+
+ public static long abs(long x) {
+ return Math.abs(x);
+ }
+
+ public static float abs(float x) {
+ return Math.abs(x);
+ }
+
+ public static double abs(double x) {
+ return Math.abs(x);
+ }
+
+ public static Object abs(BigInteger x) {
+ return x.abs();
+ }
+
+ public static Object abs(BigDecimal x) {
+ return x.abs();
+ }
+
+ // ================== Function = ceiling =====================
+
+ public static Object ceiling(Number x) {
+ return new Double(Math.ceil(x.doubleValue()));
+ }
+
+ // ================== Function = exp =====================
+
+ public static Object exp(Number x) {
+ return new Double(Math.exp(x.doubleValue()));
+ }
+
+ // ================== Function = floor =====================
+
+ public static Object floor(Number x) {
+ return new Double(Math.floor(x.doubleValue()));
+ }
+
+ // ================== Function = log =====================
+
+ public static Object log(Number x) {
+ return new Double(Math.log(x.doubleValue()));
+ }
+
+ // ================== Function = log10 =====================
+
+ private static final double log10baseE = Math.log(10);
+
+ public static Object log10(Number x) {
+ return new Double( Math.log(x.doubleValue()) / log10baseE);
+ }
+
+ // ================== Function = rand=====================
+
+ public static Object rand(CommandContext context, Object seed) throws FunctionExecutionException {
+ if(context != null) {
+ if(seed == null) {
+ return new Double(context.getNextRand());
+ } else if(seed instanceof Integer) {
+ return new Double(context.getNextRand(((Integer)seed).longValue()));
+ }
+ }
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0069, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0069, "rand", seed)); //$NON-NLS-1$
+ }
+
+ public static Object rand(CommandContext context) throws FunctionExecutionException {
+ if(context != null) {
+ return new Double(context.getNextRand());
+ }
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0069, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0069, "rand")); //$NON-NLS-1$
+ }
+
+ // ================== Function = mod =====================
+
+ public static int mod(int x, int y) {
+ return x % y;
+ }
+
+ public static long mod(long x, long y) {
+ return x % y;
+ }
+
+ public static float mod(float x, float y) {
+ return x % y;
+ }
+
+ public static double mod(double x, double y) {
+ return x % y;
+ }
+
+ public static Object mod(BigInteger x, BigInteger y) {
+ return x.remainder(y);
+ }
+
+ public static Object mod(BigDecimal x, BigDecimal y) {
+ return x.remainder(y);
+ }
+
+ // ================== Function = power =====================
+
+ public static double power(double x, double y) {
+ return Math.pow(x, y);
+ }
+
+ public static BigInteger power(BigInteger x, int y) {
+ return x.pow(y);
+ }
+
+ public static BigDecimal power(BigDecimal x, int y) {
+ return x.pow(y);
+ }
+
+ public static int round(int number, int places) {
+ if(places < 0){
+ return round(new BigDecimal(number), places).intValue();
+ }
+ return number;
+ }
+
+ public static float round(float number, int places) {
+ return round(new BigDecimal(number), places).floatValue();
+ }
+
+ public static double round(double number, int places) {
+ return round(new BigDecimal(number), places).doubleValue();
+ }
+
+ public static BigDecimal round(BigDecimal bigDecimalNumber, int places) {
+ int scale = bigDecimalNumber.scale();
+ if (scale <= places) {
+ return bigDecimalNumber;
+ }
+ bigDecimalNumber = bigDecimalNumber.setScale(places,BigDecimal.ROUND_HALF_UP);
+ return bigDecimalNumber.setScale(scale,BigDecimal.ROUND_HALF_UP);
+ }
+
+ // ================== Function = sign =====================
+
+ public static Object sign(int x) {
+ return Integer.signum(x);
+ }
+
+ public static Object sign(long x) {
+ return Long.signum(x);
+ }
+
+ public static Object sign(float x) {
+ return Math.signum(x);
+ }
+
+ public static Object sign(double x) {
+ return Math.signum(x);
+ }
+
+ public static Object sign(BigInteger x) {
+ return new Integer(x.signum());
+ }
+
+ public static Object sign(BigDecimal x) {
+ return new Integer(x.signum());
+ }
+
+ // ================== Function = sqrt =====================
+
+
+ public static Object sqrt(Number x) {
+ return new Double( Math.sqrt(x.doubleValue()));
+ }
+
+ // ================== Function = currentDate =====================
+
+ public static Object currentDate() {
+ return TimestampWithTimezone.createDate(new Date());
+ }
+
+ // ================== Function = currentTime =====================
+
+ public static Object currentTime() {
+ return TimestampWithTimezone.createTime(new Date());
+ }
+
+ // ================== Function = currentTimestamp =====================
+
+ public static Object currentTimestamp() {
+ return new Timestamp(System.currentTimeMillis());
+ }
+
+ // ================== Helper for a bunch of date functions =====================
+
+ private static int getField(java.util.Date date, int field) {
+ Calendar cal = TimestampWithTimezone.getCalendar();
+ cal.setTime(date);
+
+ return cal.get(field);
+ }
+
+ // ================== Function = dayname =====================
+
+ static final String[] dayNames = new String[] {
+ "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$
+
+ public static Object dayName(Date x) {
+ return dayNames[getField(x, Calendar.DAY_OF_WEEK) - 1];
+ }
+
+ // ================== Function = dayofmonth =====================
+
+ public static Object dayOfMonth(Date x) {
+ return Integer.valueOf(getField(x, Calendar.DATE));
+ }
+
+ // ================== Function = dayofweek =====================
+
+ public static Object dayOfWeek(Date x) {
+ return Integer.valueOf(getField(x, Calendar.DAY_OF_WEEK));
+ }
+
+ // ================== Function = dayofyear =====================
+
+ public static Object dayOfYear(Date x) {
+ return Integer.valueOf(getField(x, Calendar.DAY_OF_YEAR));
+ }
+
+ // ================== Function = hour =====================
+
+ public static Object hour(Date x) {
+ return Integer.valueOf(getField(x, Calendar.HOUR_OF_DAY));
+ }
+
+ // ================== Function = minute =====================
+
+ public static Object minute(Date x) {
+ return Integer.valueOf(getField(x, Calendar.MINUTE));
+ }
+
+ // ================== Function = month =====================
+
+ public static Object month(Date x) {
+ return Integer.valueOf(getField(x, Calendar.MONTH)+1);
+ }
+
+ // ================== Function = monthname =====================
+
+ static final String[] monthNames = new String[] {
+ "January", "February", "March", "April", "May", "June", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+ "July", "August", "September", "October", "November", "December" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
+
+ public static Object monthName(Date x) {
+ return monthNames[getField(x, Calendar.MONTH)];
+ }
+
+ // ================== Function = second =====================
+
+ public static Object second(Date x) {
+ return Integer.valueOf(getField(x, Calendar.SECOND));
+ }
+
+ // ================== Function = week =====================
+
+ public static Object week(Date x) {
+ return Integer.valueOf(getField(x, Calendar.WEEK_OF_YEAR));
+ }
+
+ // ================== Function = year =====================
+
+ public static Object year(Date x) {
+ return Integer.valueOf(getField(x, Calendar.YEAR));
+ }
+
+ // ================== Function = quarter =====================
+
+ public static Object quarter(Date date)
+ throws FunctionExecutionException {
+ int month = getField(date, Calendar.MONTH);
+
+ if (month > 11) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0066, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0066,
+ new Object[] {"quarter", date.getClass().getName()})); //$NON-NLS-1$
+ }
+ return Integer.valueOf(month/3 + 1);
+ }
+
+ // ================== Function = timestampadd =====================
+
+ public static Object timestampAdd(String intervalType, Integer count, Timestamp timestamp) {
+ Calendar cal = TimestampWithTimezone.getCalendar();
+
+ int nanos = timestamp.getNanos();
+ cal.setTime(timestamp);
+
+ // case of interval = 1, fractional seconds (nanos), don't go to branches of addField()
+ if (intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
+ int countValue = count.intValue();
+ nanos += countValue;
+
+ // Handle the case of nanos > 999,999,999 and increase the second.
+ // Since the count number is an interger, so the maximum is definite,
+ // and nanos/999,999,999 can at most be added to second
+ if ( nanos > 999999999) {
+ int addSecond = nanos / 999999999;
+ int leftNanos = nanos % 999999999;
+ cal.add(Calendar.SECOND, addSecond);
+
+ Timestamp ts = new Timestamp(cal.getTime().getTime());
+ ts.setNanos(leftNanos);
+ return ts;
+ }
+ // nanos <= 999,999,999
+ Timestamp ts = new Timestamp(cal.getTime().getTime());
+ ts.setNanos(nanos);
+ return ts;
+ }
+ // for interval from 2 to 9
+ addField(intervalType, count, cal);
+ Timestamp ts = new Timestamp(cal.getTime().getTime());
+
+ //rectify returned timestamp with original nanos
+ ts.setNanos(nanos);
+ return ts;
+ }
+
+ /** Helper method for timestampAdd method
+ * @param interval Integer
+ * @param count Integer
+ * @param cal Calendar instance
+ */
+ private static void addField(String interval, Integer count, Calendar cal) {
+ int countValue = count.intValue();
+
+ if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
+ //nano seconds - should never get into this branch
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
+ cal.add(Calendar.SECOND, countValue);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
+ cal.add(Calendar.MINUTE, countValue);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
+ cal.add(Calendar.HOUR_OF_DAY, countValue);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
+ cal.add(Calendar.DAY_OF_YEAR, countValue);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
+ cal.add(Calendar.WEEK_OF_YEAR, countValue);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
+ cal.add(Calendar.MONTH, countValue);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
+ cal.add(Calendar.MONTH, countValue*3);
+ } else if(interval.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
+ cal.add(Calendar.YEAR, countValue);
+ }
+ }
+
+ // ================== Function = timestampdiff =====================
+
+ /**
+ * This method truncates (ignores) figures
+ * @param interval
+ * @param timestamp1
+ * @param timestamp2
+ * @return
+ * @throws FunctionExecutionException
+ */
+ public static Object timestampDiff(String intervalType, Timestamp ts1Obj, Timestamp ts2Obj) {
+ long ts1 = ts1Obj.getTime() / 1000 * 1000000000 + ts1Obj.getNanos();
+ long ts2 = ts2Obj.getTime() / 1000 * 1000000000 + ts2Obj.getNanos();
+
+ long tsDiff = ts2 - ts1;
+
+ long count = 0;
+ if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_FRAC_SECOND)) {
+ count = tsDiff;
+ } else {
+ tsDiff = tsDiff / 1000000; //convert to milliseconds
+ if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_SECOND)) {
+ count = tsDiff / 1000;
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MINUTE)) {
+ count = (tsDiff / 1000) / 60;
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_HOUR)) {
+ count = (tsDiff / 1000) / (60*60);
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_DAY)) {
+ count = (tsDiff / 1000) / (60*60*24);
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_WEEK)) {
+ count = (tsDiff / 1000) / (60*60*24*7);
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_MONTH)) {
+ count = (tsDiff / 1000) / (60*60*24*30);
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_QUARTER)) {
+ count = (tsDiff / 1000) / (60*60*24*91);
+ } else if(intervalType.equalsIgnoreCase(SQLReservedWords.SQL_TSI_YEAR)) {
+ count = (tsDiff / 1000) / (60*60*24*365);
+ }
+ }
+ return new Long(count);
+ }
+
+ // ================== Function = timestampcreate =====================
+
+ /**
+ * This method truncates (ignores) figures
+ * @param interval
+ * @param timestamp1
+ * @param timestamp2
+ * @return
+ * @throws FunctionExecutionException
+ */
+ public static Object timestampCreate(java.sql.Date date, Time time) {
+ Calendar tsCal = TimestampWithTimezone.getCalendar();
+ tsCal.setTime(time);
+ int hour = tsCal.get(Calendar.HOUR_OF_DAY);
+ int minute = tsCal.get(Calendar.MINUTE);
+ int second = tsCal.get(Calendar.SECOND);
+
+ tsCal.setTime(date);
+
+ tsCal.set(Calendar.HOUR_OF_DAY, hour);
+ tsCal.set(Calendar.MINUTE, minute);
+ tsCal.set(Calendar.SECOND, second);
+
+ return new Timestamp(tsCal.getTime().getTime());
+ }
+
+ // ================== Function = length =====================
+
+ public static Object length(String str) {
+ return new Integer(str.length());
+ }
+
+ // ================== Function = concat =====================
+
+ public static Object concat(String str1, String str2) {
+ return str1 + str2;
+ }
+
+ // ================== Function = substring =====================
+
+ public static Object substring(String string, Integer startVal, Integer lengthVal) {
+ if (startVal < 0) {
+ startVal = string.length() + startVal;
+ } else if (startVal > 0){
+ startVal--; // Adjust to 1-based
+ }
+
+ if(startVal < 0 || startVal >= string.length()) {
+ return null;
+ }
+
+ if(lengthVal < 0) {
+ return null;
+ }
+
+ int endVal = Math.min(startVal+lengthVal, string.length());
+
+ return string.substring(startVal, endVal);
+ }
+
+ public static Object substring(String string, Integer start) {
+ int startVal = start.intValue();
+ return substring(string, startVal, string.length());
+ }
+
+ // ================== Function = left =====================
+
+ public static Object left(String string, Integer count)
+ throws FunctionExecutionException {
+ int countValue = count.intValue();
+ if(countValue < 0) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
+ }
+ if(string.length() < countValue) {
+ return string;
+ }
+ return string.substring(0, countValue);
+ }
+
+ // ================== Function = right =====================
+
+ public static Object right(String string, Integer count)
+ throws FunctionExecutionException {
+ int countValue = count.intValue();
+ if(countValue < 0) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0017, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0017, countValue));
+ } else if(string.length() < countValue) {
+ return string;
+ } else {
+ return string.substring(string.length() - countValue);
+ }
+ }
+
+ // ================== Function = lowercase =====================
+
+ public static Object lowerCase(String str) {
+ return str.toLowerCase();
+ }
+
+ // ================== Function = uppercase =====================
+
+ public static Object upperCase(String str) {
+ return str.toUpperCase();
+ }
+
+ // ================== Function = locate =====================
+
+ public static Object locate(String sub, String str) {
+ return locate(sub, str, 1);
+ }
+
+ /**
+ * TODO: The treatment of negative start indexes is inconsistent here.
+ * We're treating the null value like Derby, but not throwing an
+ * exception if the value is less than 1 (less than 0 in DB2).
+ */
+ public static Object locate(String sub, String str, Integer start) {
+ if(str == null || sub == null) {
+ return null;
+ }
+ if (start == null) {
+ start = 1;
+ }
+ return new Integer(str.indexOf(sub, start.intValue() - 1) + 1);
+ }
+
+ // ================== Function = lefttrim =====================
+
+ private static final char SPACE = ' ';
+
+ public static Object leftTrim(String string) {
+ for(int i=0; i<string.length(); i++) {
+ if(string.charAt(i) != SPACE) {
+ // end of trim, return what's left
+ return string.substring(i);
+ }
+ }
+
+ // All spaces, so trim it all
+ return ""; //$NON-NLS-1$
+ }
+
+ // ================== Function = righttrim =====================
+
+ public static Object rightTrim(String string) {
+ for(int i=string.length()-1; i>=0; i--) {
+ if(string.charAt(i) != SPACE) {
+ // end of trim, return what's left
+ return string.substring(0, i+1);
+ }
+ }
+
+ // All spaces, so trim it all
+ return ""; //$NON-NLS-1$
+ }
+
+ // ================== Function = replace =====================
+
+ public static Object replace(String string, String subString, String replaceString) {
+ // Check some simple cases that require no work
+ if(subString.length() > string.length() || string.length() == 0 || subString.length() == 0) {
+ return string;
+ }
+
+ StringBuffer result = new StringBuffer();
+ int index = 0;
+
+ while(true) {
+ int newIndex = string.indexOf(subString, index);
+ if(newIndex < 0) {
+ // No more replacement sections, grab from old index to end of string
+ result.append( string.substring(index) );
+
+ // Break out of loop
+ break;
+
+ }
+ // Matched the substring at newIndex
+
+ // First append section from old index to new
+ result.append( string.substring( index, newIndex) );
+
+ // Then append replacement section for sub
+ result.append( replaceString );
+
+ // Then move the index counter forward
+ index = newIndex + subString.length();
+ }
+
+ return result.toString();
+ }
+
+ // ================== Function = insert =====================
+
+ public static Object insert(String string1, Integer start, Integer length, String str2)
+ throws FunctionExecutionException {
+ int startValue = start.intValue();
+ int len = length.intValue();
+
+ // Check some invalid cases
+ if(startValue < 1 || (startValue-1) > string1.length()) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0061, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0061, start, string1));
+ } else if (len < 0) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0062, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0062, len));
+ } else if (string1.length() == 0 && (startValue > 1 || len >0) ) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0063, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0063));
+ }
+
+ StringBuffer result = new StringBuffer();
+ result.append(string1.substring(0, startValue-1));
+ int endValue = startValue + len - 1;
+
+ // str2.length() = 0 is a valid case
+ if (endValue > string1.length()) {
+ result.append(str2);
+ } else {
+ result.append(str2);
+ result.append(string1.substring( endValue ));
+ }
+
+ return result.toString();
+ }
+
+ // ================== Function = repeat =====================
+ public static Object repeat(String str, Integer count) {
+ int repeatCount = count.intValue();
+ StringBuffer result = new StringBuffer();
+
+ for (int i = 0; i < repeatCount && result.length() <= DataTypeManager.MAX_STRING_LENGTH; i++) {
+ result.append(str);
+ }
+ return result.toString();
+ }
+
+ // ================== Function = ascii =====================
+
+ public static Integer ascii(String ch) {
+ if(ch.length() == 0) {
+ return null;
+ }
+ return (int)ch.charAt(0);
+ }
+
+ public static Integer ascii(Character ch) {
+ return (int)ch.charValue();
+ }
+
+ // ================== Function = chr =====================
+
+ public static Object chr(int intValue) {
+ return new Character((char) intValue);
+ }
+
+ // ================== Function = initCap =====================
+
+ public static Object initCap(String s) {
+ StringBuffer cap = new StringBuffer();
+
+ boolean checkCap = true;
+ for(int i=0; i<s.length(); i++) {
+ char c = s.charAt(i);
+
+ // Decide whether to upper case
+ if(checkCap) {
+ cap.append(Character.toUpperCase(c));
+ } else {
+ cap.append(Character.toLowerCase(c));
+ }
+
+ // Reset flag for next character
+ checkCap = Character.isWhitespace(c);
+ }
+ return cap.toString();
+ }
+
+ // ================== Function = lpad =====================
+
+ public static Object lpad(String inputString, Integer padLength, String padStr)
+ throws FunctionExecutionException {
+
+ return pad(inputString, padLength, padStr, true);
+ }
+
+ public static Object pad(String str, Integer padLength, String padStr, boolean left)
+ throws FunctionExecutionException {
+ int length = padLength.intValue();
+ if(length < 1) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0025, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0025));
+ }
+ if(length < str.length()) {
+ return str.substring(0, length);
+ }
+ if(length > DataTypeManager.MAX_STRING_LENGTH) {
+ length = DataTypeManager.MAX_STRING_LENGTH;
+ }
+ // Get pad character
+ if(padStr.length() == 0) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0027, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0027));
+ }
+ // Pad string
+ StringBuffer outStr = new StringBuffer(str);
+ while(outStr.length() < length) {
+ if (left) {
+ outStr.insert(0, padStr);
+ } else {
+ outStr.append(padStr);
+ }
+ }
+ if (left) {
+ return outStr.substring(outStr.length() - length);
+ }
+ return outStr.substring(0, length);
+ }
+
+
+ public static final String SPACE_CHAR = " "; //$NON-NLS-1$
+
+ public static Object lpad(String inputString, Integer padLength)
+ throws FunctionExecutionException {
+
+ return lpad(inputString, padLength, SPACE_CHAR);
+ }
+
+ // ================== Function = rpad =====================
+
+ public static Object rpad(String inputString, Integer padLength, String padStr)
+ throws FunctionExecutionException {
+
+ return pad(inputString, padLength, padStr, false);
+ }
+
+ public static Object rpad(String inputString, Integer padLength)
+ throws FunctionExecutionException {
+
+ return rpad(inputString, padLength, SPACE_CHAR);
+ }
+
+ // ================== Function = translate =====================
+
+ public static Object translate(String str, String in, String out)
+ throws FunctionExecutionException {
+ if(in.length() != out.length()) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0031, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0031));
+ }
+
+ if(in.length() == 0 || str.length() == 0) {
+ return str;
+ }
+
+ StringBuffer translated = new StringBuffer(str.length());
+ for(int i=0; i<str.length(); i++) {
+ char c = str.charAt(i);
+ boolean matched = false;
+ for(int j=0; j<in.length(); j++) {
+ char inChar = in.charAt(j);
+ if(c == inChar) {
+ translated.append(out.charAt(j));
+ matched = true;
+ break;
+ }
+ }
+ if(! matched) {
+ translated.append(c);
+ }
+ }
+ return translated.toString();
+ }
+
+ // ================== Function = convert =====================
+
+ @SuppressWarnings("unchecked")
+ public static Object convert(Object src, String type)
+ throws FunctionExecutionException {
+ try {
+ return DataTypeManager.transformValue(src, DataTypeManager.getDataTypeClass(type));
+ } catch(TransformationException e) {
+ throw new FunctionExecutionException(e, ErrorMessageKeys.FUNCTION_0033, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0033, new Object[]{src, DataTypeManager.getDataTypeName(src.getClass()), type}));
+ }
+ }
+
+ // ================== Function = context and rowlimit =====================
+
+ /**
+ * This function should never actually be called - it is here solely so the
+ * xml context function can be resolved properly. The actual function is
+ * implemented in the XML planner.
+ * @param context The context to apply the criteria in
+ * @param expression The expression on the left side of the criteria
+ * @return Same as expression
+ */
+ public static Object context(Object context, Object expression)
+ throws FunctionExecutionException {
+
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0035, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0035));
+ }
+
+ /**
+ * This pseudo-function should never actually be called - it is here solely so the
+ * xml rowlimit function can be resolved properly. The actual functionality is
+ * implemented in the XML planner/processor.
+ * @param expression The expression on the left side of the criteria, an xml node
+ * @return doesn't really return anything; this pseudo-function is used to control
+ * the number of rows returned from a mapping class.
+ */
+ public static Object rowlimit(Object expression)
+ throws FunctionExecutionException {
+
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0035a, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0035a));
+ }
+
+ /**
+ * This pseudo-function should never actually be called - it is here solely so the
+ * xml rowlimitexception function can be resolved properly. The actual functionality is
+ * implemented in the XML planner/processor.
+ * @param expression The expression on the left side of the criteria, an xml node
+ * @return doesn't really return anything; this pseudo-function is used to control
+ * the number of rows returned from a mapping class.
+ */
+ public static Object rowlimitexception(Object expression)
+ throws FunctionExecutionException {
+
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0035a, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0035a));
+ }
+
+ // ================== Function = lookup =====================
+
+ /**
+ * This function should never actually be called - it is here solely so the
+ * lookup function can be resolved properly. The actual function is
+ * implemented in the ExpresionEvaluator
+ * @param context The context to apply the criteria in
+ * @param expression The expression on the left side of the criteria
+ * @return Same as expression
+ */
+ public static Object lookup(Object codeTable, Object returnElement, Object keyElement, Object keyValue) {
+
+ throw new UnsupportedOperationException("This method should never be called."); //$NON-NLS-1$
+ }
+
+ // ================== Function = nvl =====================
+
+ public static Object ifnull(Object value, Object ifNullValue) {
+ return coalesce(value, ifNullValue);
+ }
+
+ public static Object coalesce(Object value, Object value1, Object... other) {
+ if (value != null) {
+ return value;
+ }
+ if (value1 != null) {
+ return value1;
+ }
+ for (Object object : other) {
+ if (object != null) {
+ return object;
+ }
+ }
+ return null;
+ }
+
+ // ================== Format date/time/timestamp TO String ==================
+ public static String format(Date date, String format)
+ throws FunctionExecutionException {
+ try {
+ SimpleDateFormat sdf = new SimpleDateFormat(format);
+ return sdf.format(date);
+ } catch (IllegalArgumentException iae) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0042, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0042 ,
+ iae.getMessage()));
+ }
+ }
+
+ // ================== Parse String TO date/time/timestamp ==================
+ private static Date parseDateHelper(String date, String format)
+ throws FunctionExecutionException {
+ DateFormat df = new SimpleDateFormat(format);
+ try {
+ return df.parse(date);
+ } catch (ParseException e) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
+ date, format));
+ }
+ }
+
+ public static Timestamp parseTimestamp(String timestamp, String format)
+ throws FunctionExecutionException {
+ return new Timestamp(parseDateHelper(timestamp, format).getTime());
+ }
+
+ // ================== Format number TO String ==================
+ public static String format(Number number, String format)
+ throws FunctionExecutionException {
+ try {
+ DecimalFormat df = new DecimalFormat(format);
+ return df.format(number);
+ } catch (IllegalArgumentException iae) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0042, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0042 ,
+ iae.getMessage()));
+ }
+ }
+
+ // ================== Parse String TO numbers ==================
+ public static Object parseInteger(String number, String format)
+ throws FunctionExecutionException {
+ Number intNum = parseNumberHelper(number, format);
+ return new Integer(intNum.intValue());
+ }
+
+ public static Object parseLong(String number, String format)
+ throws FunctionExecutionException {
+ Number longNum = parseNumberHelper(number, format);
+ return new Long(longNum.longValue());
+ }
+
+ public static Object parseDouble(String number, String format)
+ throws FunctionExecutionException {
+ Number doubleNum = parseNumberHelper(number, format);
+ return new Double(doubleNum.doubleValue());
+ }
+
+ public static Object parseFloat(String number, String format)
+ throws FunctionExecutionException {
+ Number longNum = parseNumberHelper(number, format);
+ return new Float(longNum.floatValue());
+ }
+
+ public static Object parseBigInteger(String number, String format)
+ throws FunctionExecutionException {
+ Number bigIntegerNum = parseNumberHelper(number, format);
+ return new BigInteger(bigIntegerNum.toString());
+ }
+
+ public static Object parseBigDecimal(String number, String format)
+ throws FunctionExecutionException {
+ Number bigDecimalNum = parseNumberHelper(number, format);
+ return new BigDecimal(bigDecimalNum.toString());
+ }
+
+ // ============== Helper Function for format/parse numbers ==================
+
+ private static Number parseNumberHelper(String number, String format)
+ throws FunctionExecutionException {
+ DecimalFormat df= new DecimalFormat(format);
+ try {
+ return df.parse(number);
+ } catch (ParseException e) {
+ throw new FunctionExecutionException(ErrorMessageKeys.FUNCTION_0043, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0043 ,
+ number,format));
+ }
+ }
+
+ // ================== Function - ACOS =====================
+ public static Object acos(Number number) {
+ return new Double(Math.acos(number.doubleValue()));
+ }
+
+ // ================== Function - ASIN =====================
+ public static Object asin(Number number) {
+ return new Double(Math.asin(number.doubleValue()));
+ }
+
+ // ================== Function - ATAN =====================
+ public static Object atan(Number number) {
+ return new Double(Math.atan(number.doubleValue()));
+ }
+
+ // ================== Function - ATAN2 =====================
+ public static Object atan2(Number number1, Number number2) {
+ return new Double(Math.atan2(number1.doubleValue(), number2.doubleValue()));
+ }
+
+ // ================== Function - COS =====================
+ public static Object cos(Number number) {
+ return new Double(Math.cos(number.doubleValue()));
+ }
+
+ // ================== Function - COT =====================
+ public static Object cot(Number number) {
+ return new Double(1/Math.tan(number.doubleValue()));
+ }
+
+ // ================== Function - DEGREES =====================
+ public static Object degrees(Number number) {
+ return new Double(Math.toDegrees(number.doubleValue()));
+ }
+
+ // ================== Function - PI =====================
+ public static Object pi() {
+ return new Double(Math.PI);
+ }
+
+ // ================== Function - RADIANS =====================
+ public static Object radians(Number number) {
+ return new Double(Math.toRadians(number.doubleValue()));
+ }
+
+ // ================== Function - SIN =====================
+ public static Object sin(Number number) {
+ return new Double(Math.sin(number.doubleValue()));
+ }
+
+ // ================== Function - TAN =====================
+ public static Object tan(Number number) {
+ return new Double(Math.tan(number.doubleValue()));
+ }
+
+ // ================== Function - BITAND =====================
+ public static Object bitand(int x, int y) {
+ return x & y;
+ }
+
+ // ================== Function - BITOR =====================
+ public static Object bitor(int x, int y) {
+ return x | y;
+ }
+
+ // ================== Function - BITXOR =====================
+ public static Object bitxor(int x, int y) {
+ return x ^ y;
+ }
+
+ // ================== Function - BITNOT =====================
+ public static int bitnot(int x) {
+ return x ^ 0xFFFFFFFF;
+ }
+
+ // ================= Function - USER ========================
+ public static Object user(CommandContext context) {
+ return context.getUserName();
+ }
+
+ // ================= Function - COMMANDPAYLOAD ========================
+ public static Object commandPayload(CommandContext context) {
+ Serializable payload = context.getCommandPayload();
+ if(payload == null) {
+ return null;
+ }
+ // 0-arg form - just return payload as a string if it exists
+ return payload.toString();
+ }
+
+ public static Object commandPayload(CommandContext context, String param)
+ throws ExpressionEvaluationException, FunctionExecutionException{
+ Serializable payload = context.getCommandPayload();
+ if(payload == null) {
+ return null;
+ }
+
+ // 1-arg form - assume payload is a Properties object
+ if(payload instanceof Properties) {
+ return ((Properties)payload).getProperty(param);
+ }
+ // Payload was bad
+ throw new ExpressionEvaluationException(QueryPlugin.Util.getString("ExpressionEvaluator.Expected_props_for_payload_function", "commandPayload", payload.getClass().getName())); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ // ================= Function - ENV ========================
+ public static Object env(CommandContext context, String propertyName) {
+ // All context property keys must be lowercase - we lowercase the incoming key here to match regardless of case
+ String propertyNameNocase = propertyName.toLowerCase();
+ Properties envProps = context.getEnvironmentProperties();
+ if(envProps != null && envProps.containsKey(propertyNameNocase)) {
+ return envProps.getProperty(propertyNameNocase);
+ }
+ String value = System.getProperty(propertyName);
+ if (value == null) {
+ value = System.getProperty(propertyNameNocase);
+ }
+ return value;
+ }
+
+ // ================= Function - MODIFYTIMEZONE ========================
+
+ public static Object modifyTimeZone(Timestamp value, String originalTimezoneString, String targetTimezoneString) {
+ TimeZone originalTimeZone = TimeZone.getTimeZone(originalTimezoneString);
+ TimeZone dbmsTimeZone = TimeZone.getTimeZone(targetTimezoneString);
+
+ // Check that the dbms time zone is really different than the local time zone
+ if (originalTimeZone.equals(dbmsTimeZone)) {
+ return value;
+ }
+
+ Calendar cal = Calendar.getInstance(dbmsTimeZone);
+
+ return TimestampWithTimezone.createTimestamp(value, originalTimeZone, cal);
+ }
+
+ public static Object modifyTimeZone(CommandContext context, Timestamp value, String targetTimezoneString) {
+ TimeZone dbmsTimeZone = TimeZone.getTimeZone(targetTimezoneString);
+
+ Calendar cal = Calendar.getInstance(dbmsTimeZone);
+
+ return TimestampWithTimezone.createTimestamp(value, context.getServerTimeZone(), cal);
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/FunctionTree.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,415 @@
+/*
+ * 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.function;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.ReflectionHelper;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.metadata.FunctionCategoryConstants;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
+
+/**
+ * Data structure used to store function signature information. There are multiple uses
+ * of this signature information so there are multiple data structures within the FunctionTree
+ * for handling each. One type of information is the function metadata required by users of
+ * this class for data driving GUIs or function selection. The other type of information is that
+ * needed to quickly find and/or invoke the functions at execution time. In general all methods
+ * are concerned with function metadata EXCEPT {@link #getFunction} which is used to find a function
+ * for execution.
+ */
+public class FunctionTree {
+
+ // Constant used to look up the special descriptor key in a node map
+ private static final Integer DESCRIPTOR_KEY = new Integer(-1);
+
+ private Map<String, Set<String>> categories = new HashMap<String, Set<String>>();
+
+ private Map<String, List<FunctionMethod>> functionsByName = new HashMap<String, List<FunctionMethod>>();
+
+ private Set<FunctionMethod> allFunctions = new HashSet<FunctionMethod>();
+
+ /**
+ * Function lookup and invocation use: Function name (uppercase) to Map (recursive tree)
+ */
+ private Map treeRoot = new HashMap();
+
+ /**
+ * Construct a new tree with the given source of function metadata.
+ * @param source The metadata source
+ */
+ public FunctionTree(FunctionMetadataSource source) {
+ // Load data structures
+ addSource(source);
+ }
+
+ /**
+ * Construct a new tree with the given collection of sources.
+ * @param sources The collection of function metadata sources ({@link org.teiid.query.function.FunctionMetadataSource})
+ */
+ FunctionTree(Collection sources) {
+ // Load data structures
+ addSources(sources);
+ }
+
+ /**
+ * Add a collection of functions to the data structures.
+ * @param sources The function metadata sources ({@link org.teiid.query.function.FunctionMetadataSource})
+ */
+ private void addSources(Collection sources) {
+ if(sources == null) {
+ return;
+ }
+
+ Iterator sourceIter = sources.iterator();
+ while(sourceIter.hasNext()) {
+ Object sourceObj = sourceIter.next();
+ if(sourceObj instanceof FunctionMetadataSource) {
+ addSource((FunctionMetadataSource) sourceObj);
+ } else {
+ Assertion.failed(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0044, sourceObj.getClass().getName()));
+ }
+ }
+ }
+
+ /**
+ * Add all functions from a metadata source to the data structures.
+ * @param source The source of the functions
+ */
+ private void addSource(FunctionMetadataSource source) {
+ if(source == null) {
+ return;
+ }
+
+ Collection functions = source.getFunctionMethods();
+ if(functions != null) {
+ Iterator functionIter = functions.iterator();
+ while(functionIter.hasNext()) {
+ Object functionObj = functionIter.next();
+ if(! (functionObj instanceof FunctionMethod)) {
+ Assertion.failed(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0045, functionObj.getClass().getName()));
+ }
+ FunctionMethod method = (FunctionMethod) functionObj;
+
+ if (!containsIndistinguishableFunction(method)){
+ // Store method metadata for retrieval
+ addMetadata(method);
+
+ // Add to tree
+ addFunction(source, method);
+ } else {
+ LogManager.logWarning(LogConstants.CTX_FUNCTION_TREE, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0046, new Object[]{method}));
+ }
+ }
+ }
+ }
+
+ // ---------------------- FUNCTION SELECTION USE METHODS ----------------------
+
+ /*
+ * Per defect 4612 -
+ * Because of the fix for defect 4264, it is possible in the modeler to
+ * define two functions with different implementations, but having the
+ * same name (using the "alias") and the same parameter types, making the
+ * two FunctionMethod objects indistinguishable by their equals method.
+ * This method will check if any indistinguishable functions are already
+ * present in this FunctionTree. If so, it will be logged and any
+ * newer indistinguishable functions will just not be added.
+ */
+ private boolean containsIndistinguishableFunction(FunctionMethod method){
+ return allFunctions.contains(method);
+ }
+
+ /**
+ * Store the method in the function metadata.
+ * @param method The function metadata for a particular method signature
+ */
+ private void addMetadata(FunctionMethod method) {
+ String categoryKey = method.getCategory();
+ if (categoryKey == null) {
+ method.setCategory(FunctionCategoryConstants.MISCELLANEOUS);
+ categoryKey = FunctionCategoryConstants.MISCELLANEOUS;
+ }
+ categoryKey = categoryKey.toUpperCase();
+ String nameKey = method.getName().toUpperCase();
+
+ // Look up function map (create if necessary)
+ Set<String> functions = categories.get(categoryKey);
+ if (functions == null) {
+ functions = new HashSet<String>();
+ categories.put(categoryKey, functions);
+ }
+
+ // Look up function in function map
+ functions.add(nameKey);
+
+ // Add method to list by function name
+ List<FunctionMethod> knownMethods = functionsByName.get(nameKey);
+ if(knownMethods == null) {
+ knownMethods = new ArrayList<FunctionMethod>();
+ functionsByName.put(nameKey, knownMethods);
+ }
+ knownMethods.add(method);
+ allFunctions.add(method);
+ }
+
+ /**
+ * Get collection of category names.
+ * @return Category names
+ */
+ Collection<String> getCategories() {
+ return categories.keySet();
+ }
+
+ /**
+ * Get collection of function forms in a category
+ * @param category Category to get (case-insensitive)
+ * @return Collection of {@link FunctionForm}s
+ */
+ Collection<FunctionForm> getFunctionForms(String category) {
+ Set<FunctionForm> functionForms = new HashSet<FunctionForm>();
+
+ Set<String> functions = categories.get(category.toUpperCase());
+ if(functions != null) {
+ for (String functionName : functions) {
+ for (FunctionMethod functionMethod : this.functionsByName.get(functionName)) {
+ functionForms.add(new FunctionForm(functionMethod));
+ }
+ }
+ }
+
+ return functionForms;
+ }
+
+ /**
+ * Find function form based on function name and # of arguments.
+ * @param name Function name, case insensitive
+ * @param args Number of arguments
+ * @return Corresponding form or null if not found
+ */
+ FunctionForm findFunctionForm(String name, int args) {
+ List<FunctionMethod> results = findFunctionMethods(name, args);
+ if (results.size() > 0) {
+ return new FunctionForm(results.get(0));
+ }
+ return null;
+ }
+
+ /**
+ * Find all function methods with the given name and arg length
+ * @param name Function name, case insensitive
+ * @param args Number of arguments
+ * @return Corresponding form or null if not found
+ */
+ List<FunctionMethod> findFunctionMethods(String name, int args) {
+ final List<FunctionMethod> allMatches = new ArrayList<FunctionMethod>();
+ List<FunctionMethod> methods = functionsByName.get(name.toUpperCase());
+ if(methods == null || methods.size() == 0) {
+ return allMatches;
+ }
+
+ for (FunctionMethod functionMethod : methods) {
+ if(functionMethod.getInputParameterCount() == args || functionMethod.isVarArgs() && args >= functionMethod.getInputParameterCount() - 1) {
+ allMatches.add(functionMethod);
+ }
+ }
+
+ return allMatches;
+ }
+
+ // ---------------------- FUNCTION INVOCATION USE METHODS ----------------------
+
+ /**
+ * Store the method for function resolution and invocation.
+ * @param source The function metadata source, which knows how to obtain the invocation class
+ * @param method The function metadata for a particular method signature
+ */
+ private void addFunction(FunctionMetadataSource source, FunctionMethod method) {
+ // Get method name
+ String methodName = method.getName();
+
+ // Get input types for path
+ FunctionParameter[] inputParams = method.getInputParameters();
+ List<Class> inputTypes = new LinkedList<Class>();
+ if(inputParams != null) {
+ for(int i=0; i<inputParams.length; i++) {
+ String typeName = inputParams[i].getType();
+ inputTypes.add(DataTypeManager.getDataTypeClass(typeName));
+ }
+ }
+ Class[] types = inputTypes.toArray(new Class[inputTypes.size()]);
+
+ if (method.isVarArgs()) {
+ inputTypes.set(inputTypes.size() - 1, Array.newInstance(inputTypes.get(inputTypes.size() - 1), 0).getClass());
+ }
+
+ // Get return type
+ FunctionParameter outputParam = method.getOutputParameter();
+ Class outputType = null;
+ if(outputParam != null) {
+ outputType = DataTypeManager.getDataTypeClass(outputParam.getType());
+ }
+
+ Method invocationMethod = null;
+ boolean requiresContext = false;
+ // Defect 20007 - Ignore the invocation method if pushdown is not required.
+ if (method.getPushdown() == FunctionMethod.CAN_PUSHDOWN || method.getPushdown() == FunctionMethod.CANNOT_PUSHDOWN) {
+ try {
+ Class methodClass = source.getInvocationClass(method.getInvocationClass());
+ ReflectionHelper helper = new ReflectionHelper(methodClass);
+ try {
+ invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
+ } catch (NoSuchMethodException e) {
+ inputTypes.add(0, CommandContext.class);
+ invocationMethod = helper.findBestMethodWithSignature(method.getInvocationMethod(), inputTypes);
+ requiresContext = true;
+ }
+ } catch (ClassNotFoundException e) {
+ // Failed to load class, so can't load method - this will fail at invocation time.
+ // We don't fail here because this situation can occur in the modeler, which does
+ // not have the function jar files. The modeler never invokes, so this isn't a
+ // problem.
+ } catch (Exception e) {
+ throw new TeiidRuntimeException(e, ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, inputTypes}));
+ }
+ if(invocationMethod != null && !FunctionTree.isValidMethod(invocationMethod)) {
+ throw new TeiidRuntimeException(ErrorMessageKeys.FUNCTION_0047, QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0047, new Object[]{method.getInvocationClass(), invocationMethod, inputTypes}));
+ }
+ } else {
+ inputTypes.add(0, CommandContext.class);
+ }
+
+ FunctionDescriptor descriptor = new FunctionDescriptor(method.getName(), method.getPushdown(), types, outputType, invocationMethod, requiresContext, method.isNullDependent(), method.getDeterministic());
+ // Store this path in the function tree
+ Map node = treeRoot;
+ Object[] path = buildPath(methodName, types);
+ for(int pathIndex = 0; pathIndex < path.length; pathIndex++) {
+ Object pathPart = path[pathIndex];
+ Map children = (Map) node.get(pathPart);
+ if(children == null) {
+ children = new HashMap();
+ node.put(pathPart, children);
+ }
+ if (method.isVarArgs() && pathIndex == path.length - 1) {
+ node.put(DESCRIPTOR_KEY, descriptor);
+ }
+ node = children;
+ }
+
+ if (method.isVarArgs()) {
+ node.put(types[types.length - 1], node);
+ }
+ // Store the leaf descriptor in the tree
+ node.put(DESCRIPTOR_KEY, descriptor);
+ }
+
+ /**
+ * Validate a method looked up by reflection. The method should have a non-void return type
+ * and be a public static method.
+ * @param method Method to validate
+ * @return True if valid
+ */
+ static boolean isValidMethod(Method method) {
+ // Check return type is non void
+ Class methodReturn = method.getReturnType();
+ if(methodReturn.equals(Void.TYPE)) {
+ return false;
+ }
+
+ // Check that method is public
+ int modifiers = method.getModifiers();
+ if(! Modifier.isPublic(modifiers)) {
+ return false;
+ }
+
+ // Check that method is static
+ if(! Modifier.isStatic(modifiers)) {
+ return false;
+ }
+
+ return true;
+ }
+
+ /**
+ * Look up a function descriptor by signature in the tree. If none is
+ * found, null is returned.
+ * @param name Name of the function, case is not important
+ * @param argTypes Types of each argument in the function
+ * @return Descriptor which can be used to invoke the function
+ */
+ FunctionDescriptor getFunction(String name, Class[] argTypes) {
+ // Build search path
+ Object[] path = buildPath(name, argTypes);
+
+ // Walk path in tree
+ Map node = treeRoot;
+ for(int i=0; i<path.length; i++) {
+ node = (Map)node.get(path[i]);
+ if (node == null) {
+ return null;
+ }
+ }
+
+ // Look for key at the end
+ if(node.containsKey(DESCRIPTOR_KEY)) {
+ // This is the end - return descriptor
+ return (FunctionDescriptor) node.get(DESCRIPTOR_KEY);
+ }
+ // No descriptor at this location in tree
+ return null;
+ }
+
+ /**
+ * Build the path in the function storage tree. The path for a function consists
+ * of it's name (uppercased) and each of the argument classes.
+ * @param name Name of function
+ * @param argTypes Types of each arguments
+ * @return Path in function storage tree
+ */
+ private Object[] buildPath(String name, Class[] argTypes) {
+ Object[] path = new Object[argTypes.length + 1];
+ path[0] = name.toUpperCase();
+ System.arraycopy(argTypes, 0, path, 1, argTypes.length);
+ return path;
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/SystemFunctionManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,72 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.query.function;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.metadata.FunctionMetadataValidator;
+import org.teiid.query.function.source.SystemSource;
+import org.teiid.query.report.ActivityReport;
+import org.teiid.query.util.ErrorMessageKeys;
+
+
+public class SystemFunctionManager {
+
+ private static FunctionTree systemFunctionTree;
+
+ static {
+ // Create the system source and add it to the source list
+ SystemSource systemSource = new SystemSource();
+
+ // Validate the system source - should never fail
+ ActivityReport report = new ActivityReport("Function Validation"); //$NON-NLS-1$
+ validateSource(systemSource, report);
+ if(report.hasItems()) {
+ // Should never happen as SystemSource doesn't change
+ System.err.println(QueryPlugin.Util.getString(ErrorMessageKeys.FUNCTION_0005, report));
+ }
+
+ systemFunctionTree = new FunctionTree(systemSource);
+ }
+
+
+ public static FunctionTree getSystemFunctions() {
+ return systemFunctionTree;
+ }
+
+ public static FunctionLibrary getSystemFunctionLibrary() {
+ return new FunctionLibrary(systemFunctionTree, new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
+ }
+
+ /**
+ * Validate all function metadata in the source with the FunctionMetadataValidator. Add
+ * any problems to the specified report.
+ * @param source Source of function metadata
+ * @param report Report to update with any problems
+ */
+ private static void validateSource(FunctionMetadataSource source, ActivityReport report) {
+ Collection functionMethods = source.getFunctionMethods();
+ FunctionMetadataValidator.validateFunctionMethods(functionMethods,report);
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/UDFSource.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/UDFSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,46 @@
+/*
+ * 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.function;
+
+import java.util.Collection;
+
+import org.teiid.query.function.metadata.FunctionMethod;
+
+
+
+public class UDFSource implements FunctionMetadataSource {
+
+ private Collection <FunctionMethod> methods = null;
+
+ public UDFSource(Collection <FunctionMethod> methods) {
+ this.methods = methods;
+ }
+
+ public Collection getFunctionMethods() {
+ return this.methods;
+ }
+
+ public Class getInvocationClass(String className) throws ClassNotFoundException {
+ return Class.forName(className);
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/function/aggregate (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/aggregate)
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/AggregateFunction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/AggregateFunction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/AggregateFunction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
/**
* This represents the interface for an aggregate function. The basic lifecycle
* is that the AggregateFunction is initialize()'d with the type of the element
@@ -54,15 +55,15 @@
* @param input Input value, may be null
*/
public abstract void addInput(Object input)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException;
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException;
/**
* Called after all values have been processed to get the result.
* @return Result value
- * @throws MetaMatrixProcessingException
+ * @throws TeiidProcessingException
*/
public abstract Object getResult()
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException, MetaMatrixProcessingException;
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException, TeiidProcessingException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/Avg.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/Avg.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/Avg.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
import java.math.BigDecimal;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* Accumulates (per tuple) and calculates the average of the values
* of a column. The type of the result varies depending on the type
@@ -51,7 +52,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
if (dataType.equals(DataTypeManager.DefaultDataClasses.BIG_DECIMAL)) {
@@ -67,20 +68,20 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object input)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
super.addInput(input);
count++;
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult()
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
Object sum = super.getResult();
if (count == 0 || sum == null) {
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/ConstantFunction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/ConstantFunction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/ConstantFunction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+
/**
*/
public class ConstantFunction implements AggregateFunction {
@@ -40,7 +41,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
}
@@ -50,19 +51,19 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object input)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
value = input;
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult()
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
return this.value;
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/Count.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/Count.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/Count.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
/**
* Just a simple COUNT() implementation that counts every non-null row it sees.
@@ -37,7 +37,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
}
@@ -47,14 +47,14 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object input) {
count++;
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult() {
return new Integer(count);
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/Max.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/Max.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/Max.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
*/
public class Max implements AggregateFunction {
@@ -42,7 +43,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
}
@@ -52,10 +53,10 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object value)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
if(maxValue == null) {
maxValue = value;
@@ -73,7 +74,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult() {
return this.maxValue;
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/Min.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/Min.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/Min.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
*/
public class Min implements AggregateFunction {
@@ -42,7 +43,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
}
@@ -52,10 +53,10 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object value)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
if(minValue == null) {
minValue = value;
@@ -73,7 +74,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult() {
return this.minValue;
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/NullFilter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/NullFilter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/NullFilter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
/**
*/
public class NullFilter implements AggregateFunction {
@@ -48,7 +49,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
this.proxy.initialize(dataType, inputType);
@@ -59,10 +60,10 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object input)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
if(input != null) {
this.proxy.addInput(input);
@@ -70,11 +71,11 @@
}
/**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @throws TeiidProcessingException
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
return this.proxy.getResult();
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/aggregate/Sum.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/aggregate/Sum.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/aggregate/Sum.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.aggregate;
+package org.teiid.query.function.aggregate;
import java.math.BigDecimal;
import java.math.BigInteger;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.DataTypeManager;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+
/**
* Accumulates (per tuple) and calculates the sum of the values
* of a column. The type of the result varies depending on the type
@@ -62,7 +63,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(boolean, String)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(boolean, String)
*/
public void initialize(Class dataType, Class inputType) {
if(dataType.equals(DataTypeManager.DefaultDataClasses.LONG)) {
@@ -86,10 +87,10 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object input)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
if (this.sum == null) {
switch (this.accumulatorType) {
@@ -130,10 +131,10 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult()
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
return sum;
}
Copied: trunk/engine/src/main/java/org/teiid/query/function/metadata (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/metadata)
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionCategoryConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionCategoryConstants.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionCategoryConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
/**
* This interface defines the default set of function category constants.
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMetadataReader.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataReader.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
import java.io.IOException;
import java.io.InputStream;
@@ -31,8 +31,8 @@
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.Namespace;
+import org.teiid.internal.core.xml.JdomHelper;
-import com.metamatrix.internal.core.xml.JdomHelper;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMetadataValidator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
import java.util.Collection;
import java.util.Iterator;
-import com.metamatrix.api.exception.query.FunctionMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.report.ActivityReport;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.FunctionMetadataException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.report.ActivityReport;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* The validator encodes business logic with respect to what a valid function
* description is. These methods call each other from the most complex components
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionMethod.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
import java.io.Serializable;
import java.util.Arrays;
-import com.metamatrix.core.util.HashCodeUtil;
+import org.teiid.core.util.HashCodeUtil;
+
/**
* <p>This class represents information about a particular function signature.
* Function signatures are unique with respect to their name, # of arguments,
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/FunctionParameter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionParameter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
import java.io.Serializable;
@@ -30,7 +30,7 @@
* verified by this class. Validation of this object can be done with the
* {@link FunctionMetadataValidator}. The type string used in the function
* parameter should be one of the standard type names defined in
- * {@link com.metamatrix.common.types.DataTypeManager.DefaultDataTypes}.
+ * {@link org.teiid.core.types.DataTypeManager.DefaultDataTypes}.
*/
public class FunctionParameter implements Serializable {
public static final String OUTPUT_PARAMETER_NAME = "result"; //$NON-NLS-1$
@@ -107,7 +107,7 @@
/**
* Get type of parameter
* @return Type name
- * @see com.metamatrix.common.types.DataTypeManager.DefaultDataTypes
+ * @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
*/
public String getType() {
return this.type;
@@ -116,7 +116,7 @@
/**
* Set type of parameter
* @param type Type of parameter
- * @see com.metamatrix.common.types.DataTypeManager.DefaultDataTypes
+ * @see org.teiid.core.types.DataTypeManager.DefaultDataTypes
*/
public void setType(String type) {
if(type == null) {
Modified: trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/metadata/InvalidFunctionItem.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/InvalidFunctionItem.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.metadata;
+package org.teiid.query.function.metadata;
-import com.metamatrix.query.report.ReportItem;
+import org.teiid.query.report.ReportItem;
/**
* This is a specialized report item for reporting invalid function methods during
Copied: trunk/engine/src/main/java/org/teiid/query/function/source (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/function/source)
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SecuritySystemFunctions.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SecuritySystemFunctions.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SecuritySystemFunctions.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.source;
+package org.teiid.query.function.source;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.eval.SecurityFunctionEvaluator;
+import org.teiid.query.util.CommandContext;
+
public class SecuritySystemFunctions {
public static boolean hasRole(CommandContext context, Object roleName) throws FunctionExecutionException {
@@ -39,7 +40,7 @@
try {
return eval.hasRole(SecurityFunctionEvaluator.DATA_ROLE, (String)roleName);
- } catch (MetaMatrixComponentException err) {
+ } catch (TeiidComponentException err) {
throw new FunctionExecutionException(err, err.getMessage());
}
}
@@ -54,7 +55,7 @@
try {
return eval.hasRole((String)roleType, (String)roleName);
- } catch (MetaMatrixComponentException err) {
+ } catch (TeiidComponentException err) {
throw new FunctionExecutionException(err, err.getMessage());
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/SystemSource.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,22 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.function.source;
+package org.teiid.query.function.source;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionMetadataSource;
+import org.teiid.query.function.FunctionMethods;
+import org.teiid.query.function.metadata.FunctionCategoryConstants;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.function.metadata.FunctionParameter;
import org.teiid.resource.cci.SourceSystemFunctions;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionMetadataSource;
-import com.metamatrix.query.function.FunctionMethods;
-import com.metamatrix.query.function.metadata.FunctionCategoryConstants;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.metadata.FunctionParameter;
/**
* This metadata source has metadata for the hard-coded system functions. All
Deleted: trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/function/source/XMLSystemFunctions.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,541 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function.source;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.Writer;
-import java.sql.Clob;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.List;
-
-import javax.xml.XMLConstants;
-import javax.xml.namespace.NamespaceContext;
-import javax.xml.namespace.QName;
-import javax.xml.stream.EventFilter;
-import javax.xml.stream.FactoryConfigurationError;
-import javax.xml.stream.XMLEventFactory;
-import javax.xml.stream.XMLEventReader;
-import javax.xml.stream.XMLEventWriter;
-import javax.xml.stream.XMLInputFactory;
-import javax.xml.stream.XMLOutputFactory;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
-import javax.xml.stream.events.XMLEvent;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-import javax.xml.transform.stream.StreamSource;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathConstants;
-import javax.xml.xpath.XPathExpressionException;
-import javax.xml.xpath.XPathFactory;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.ClobType;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.common.types.XMLTranslator;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.common.types.XMLType.Type;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionMethods;
-import com.metamatrix.query.processor.xml.XMLUtil;
-import com.metamatrix.query.util.CommandContext;
-
-/**
- * This class contains scalar system functions supporting for XML manipulation.
- *
- * @since 4.2
- */
-public class XMLSystemFunctions {
-
- public static class NameValuePair<T> {
- String name;
- T value;
-
- public NameValuePair(String name, T value) {
- this.name = name;
- this.value = value;
- }
- }
-
- //YEAR 0 in the server timezone. used to determine negative years
- public static long YEAR_ZERO;
- static String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; //$NON-NLS-1$
-
- static String TIMESTAMP_MICROZEROS = "000000000"; //$NON-NLS-1$
-
- static {
- Calendar cal = Calendar.getInstance();
-
- for (int i = 0; i <= Calendar.MILLISECOND; i++) {
- cal.set(i, 0);
- }
- YEAR_ZERO = cal.getTimeInMillis();
- }
-
- public static ClobType xslTransform(CommandContext context, String xmlResults, String styleSheet) throws Exception {
- return xslTransform(context, DataTypeManager.transformValue(xmlResults, DataTypeManager.DefaultDataClasses.XML), DataTypeManager.transformValue(styleSheet, DataTypeManager.DefaultDataClasses.XML));
- }
-
- public static ClobType xslTransform(CommandContext context, String xmlResults, XMLType styleSheet) throws Exception {
- return xslTransform(context, DataTypeManager.transformValue(xmlResults, DataTypeManager.DefaultDataClasses.XML), styleSheet);
- }
-
- public static ClobType xslTransform(CommandContext context, XMLType xmlResults, String styleSheet) throws Exception {
- return xslTransform(context, xmlResults, DataTypeManager.transformValue(styleSheet, DataTypeManager.DefaultDataClasses.XML));
- }
-
- public static ClobType xslTransform(CommandContext context, XMLType xmlResults, XMLType styleSheet) throws Exception {
- Reader styleSheetReader = styleSheet.getCharacterStream();
- final Source styleSource = new StreamSource(styleSheetReader);
- Reader reader = xmlResults.getCharacterStream();
- final Source xmlSource = new StreamSource(reader);
- try {
- //this creates a non-validated sqlxml - it may not be valid xml/root-less xml
- SQLXML result = XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
-
- @Override
- public void translate(Writer writer) throws TransformerException {
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer(styleSource);
- //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
- // Feed the resultant I/O stream into the XSLT processor
- transformer.transform(xmlSource, new StreamResult(writer));
- }
- }, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
- return DataTypeManager.transformValue(new XMLType(result), DataTypeManager.DefaultDataClasses.CLOB);
- } finally {
- try {
- reader.close();
- } catch (IOException e) {
- }
- try {
- styleSheetReader.close();
- } catch (IOException e) {
- }
- }
- }
-
- public static XMLType xmlForest(final CommandContext context, final NameValuePair[] namespaces, final NameValuePair[] values) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- boolean valueExists = false;
- for (NameValuePair nameValuePair : values) {
- if (nameValuePair.value != null) {
- valueExists = true;
- break;
- }
- }
- if (!valueExists) {
- return null;
- }
-
- XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
-
- @Override
- public void translate(Writer writer) throws TransformerException,
- IOException {
- try {
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
- XMLEventFactory eventFactory = XMLEventFactory.newInstance();
- for (NameValuePair nameValuePair : values) {
- if (nameValuePair.value == null) {
- continue;
- }
- addElement(nameValuePair.name, writer, eventWriter, eventFactory, namespaces, null, Collections.singletonList(nameValuePair.value));
- }
- } catch (XMLStreamException e) {
- throw new TransformerException(e);
- }
- }
- }, context.getStreamingBatchSize()));
- result.setType(Type.SIBLINGS);
- return result;
- }
-
- /**
- * Basic support for xmlelement. namespaces are not yet supported.
- * @param context
- * @param name
- * @param contents
- * @return
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
- */
- public static XMLType xmlElement(CommandContext context, final String name,
- final NameValuePair<String>[] namespaces, final NameValuePair<?>[] attributes, final List<?> contents) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
-
- @Override
- public void translate(Writer writer) throws TransformerException,
- IOException {
- try {
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
- XMLEventFactory eventFactory = XMLEventFactory.newInstance();
- addElement(name, writer, eventWriter, eventFactory, namespaces, attributes, contents);
- } catch (XMLStreamException e) {
- throw new TransformerException(e);
- }
- }
-
- }, context.getStreamingBatchSize()));
- result.setType(Type.FRAGMENT);
- return result;
- }
-
- private static void addElement(final String name, Writer writer, XMLEventWriter eventWriter, XMLEventFactory eventFactory,
- NameValuePair<String> namespaces[], NameValuePair<?> attributes[], List<?> contents) throws XMLStreamException, IOException, TransformerException {
- eventWriter.add(eventFactory.createStartElement("", null, name)); //$NON-NLS-1$
- if (namespaces != null) {
- for (NameValuePair<String> nameValuePair : namespaces) {
- if (nameValuePair.name == null) {
- if (nameValuePair.value == null) {
- eventWriter.add(eventFactory.createNamespace(XMLConstants.NULL_NS_URI));
- } else {
- eventWriter.add(eventFactory.createNamespace(nameValuePair.value));
- }
- } else {
- eventWriter.add(eventFactory.createNamespace(nameValuePair.name, nameValuePair.value));
- }
- }
- }
- if (attributes != null) {
- for (NameValuePair<?> nameValuePair : attributes) {
- if (nameValuePair.value != null) {
- eventWriter.add(eventFactory.createAttribute(new QName(nameValuePair.name), getStringValue(nameValuePair.value)));
- }
- }
- }
- //add empty chars to close the start tag
- eventWriter.add(eventFactory.createCharacters("")); //$NON-NLS-1$
- for (Object object : contents) {
- convertValue(writer, eventWriter, eventFactory, object);
- }
- eventWriter.add(eventFactory.createEndElement("", null, name)); //$NON-NLS-1$
- }
-
- public static XMLType xmlConcat(CommandContext context, final XMLType xml, final Object... other) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
-
- @Override
- public void translate(Writer writer) throws TransformerException,
- IOException {
- try {
- XMLOutputFactory factory = XMLOutputFactory.newInstance();
- XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
- XMLEventFactory eventFactory = XMLEventFactory.newInstance();
- convertValue(writer, eventWriter, eventFactory, xml);
- for (Object object : other) {
- convertValue(writer, eventWriter, eventFactory, object);
- }
- } catch (XMLStreamException e) {
- throw new TransformerException(e);
- }
- }
- }, context.getStreamingBatchSize()));
- result.setType(Type.SIBLINGS);
- return result;
- }
-
- public static XMLType xmlPi(String name) {
- return xmlPi(name, ""); //$NON-NLS-1$
- }
-
- public static XMLType xmlPi(String name, String content) {
- int start = 0;
- char[] chars = content.toCharArray();
- while (start < chars.length && chars[start] == ' ') {
- start++;
- }
- XMLType result = new XMLType(new SQLXMLImpl("<?" + name + " " + content.substring(start) + "?>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- result.setType(Type.PI);
- return result;
- }
-
- static String getStringValue(Object object) throws TransformerException {
- if (object instanceof Timestamp) {
- try {
- return timestampToDateTime((Timestamp)object);
- } catch (FunctionExecutionException e) {
- throw new TransformerException(e);
- }
- }
- try {
- return DataTypeManager.transformValue(object, DataTypeManager.DefaultDataClasses.STRING);
- } catch (TransformationException e) {
- throw new TransformerException(e);
- }
- }
-
- static void convertValue(Writer writer, XMLEventWriter eventWriter, XMLEventFactory eventFactory, Object object) throws IOException,
- FactoryConfigurationError, XMLStreamException,
- TransformerException {
- if (object == null) {
- return;
- }
- Reader r = null;
- try {
- if (object instanceof XMLType) {
- XMLType xml = (XMLType)object;
- r = xml.getCharacterStream();
- Type type = xml.getType();
- convertReader(writer, eventWriter, r, type);
- } else if (object instanceof Clob) {
- Clob clob = (Clob)object;
- r = clob.getCharacterStream();
- convertReader(writer, eventWriter, r, Type.TEXT);
- } else {
- String val = getStringValue(object);
- eventWriter.add(eventFactory.createCharacters(val));
- }
- } catch (SQLException e) {
- throw new IOException(e);
- } finally {
- if (r != null) {
- r.close();
- }
- }
- //TODO: blob - with base64 encoding
- }
-
- private static void convertReader(Writer writer,
- XMLEventWriter eventWriter, Reader r, Type type)
- throws XMLStreamException, IOException, FactoryConfigurationError {
- if (!(r instanceof BufferedReader)) {
- r = new BufferedReader(r);
- }
- switch(type) {
- case FRAGMENT:
- case SIBLINGS:
- case PI:
- case COMMENT: //write the value directly to the writer
- eventWriter.flush();
- int chr = -1;
- while ((chr = r.read()) != -1) {
- writer.write(chr);
- }
- break;
- case UNKNOWN: //assume a document
- case DOCUMENT: //filter the doc declaration
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
- XMLEventReader eventReader = inputFactory.createXMLEventReader(r);
- eventReader = inputFactory.createFilteredReader(eventReader, new EventFilter() {
- @Override
- public boolean accept(XMLEvent event) {
- return !event.isStartDocument() && !event.isEndDocument();
- }
- });
- eventWriter.add(eventReader);
- break;
- }
- }
-
- public static XMLType xmlComment(String comment) {
- return new XMLType(new SQLXMLImpl("<!--" + comment + "-->")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Formats a timestamp to an xs:dateTime. This uses DATETIME_FORMAT
- * with a trailing string for nanoseconds (without right zeros).
- */
- public static String timestampToDateTime(Timestamp time) throws FunctionExecutionException {
- String result = FunctionMethods.format(time, DATETIME_FORMAT);
- int nanos = time.getNanos();
- if (nanos == 0) {
- return result;
- }
-
- StringBuffer resultBuffer = new StringBuffer();
- boolean first = true;
- int i = 0;
- for (; i < 9 && nanos > 0; i++) {
- int digit = nanos%10;
- if (first) {
- if (digit > 0) {
- resultBuffer.insert(0, digit);
- first = false;
- }
- } else {
- resultBuffer.insert(0, digit);
- }
- nanos /= 10;
- }
- if (i < 9) {
- resultBuffer.insert(0, TIMESTAMP_MICROZEROS.substring(i));
- }
- resultBuffer.insert(0, "."); //$NON-NLS-1$
- resultBuffer.insert(0, result);
- if (time.getTime() < YEAR_ZERO) {
- resultBuffer.insert(0, "-"); //$NON-NLS-1$
- }
- return resultBuffer.toString();
-
- }
-
- public static String xpathValue(XMLType document, String xpathStr, String namespaces) throws IOException, XPathExpressionException, SQLException, FunctionExecutionException {
- Reader stream = document.getCharacterStream();
- return xpathValue(stream, xpathStr, namespaces);
- }
-
- public static String xpathValue(String document, String xpathStr, String namespaces) throws IOException, XPathExpressionException, FunctionExecutionException {
- return xpathValue(new StringReader(document), xpathStr, namespaces);
- }
-
- public static String xpathValue(String document, String xpathStr) throws IOException, XPathExpressionException, FunctionExecutionException {
- return xpathValue(document, xpathStr, null);
- }
-
- public static String xpathValue(XMLType document, String xpathStr) throws IOException, SQLException, XPathExpressionException, FunctionExecutionException {
- return xpathValue(document, xpathStr, null);
- }
-
- public static XMLType xpathQuery(CommandContext context, String document, String xpathStr) throws IOException, MetaMatrixComponentException, MetaMatrixProcessingException, XPathExpressionException {
- return xpathQuery(context, document, xpathStr, null);
- }
-
- public static XMLType xpathQuery(CommandContext context, XMLType document, String xpathStr) throws IOException, SQLException, XPathExpressionException, MetaMatrixComponentException, MetaMatrixProcessingException {
- return xpathQuery(context, document, xpathStr, null);
- }
-
- public static XMLType xpathQuery(CommandContext context, String document, String xpathStr, String namespaces) throws IOException, MetaMatrixComponentException, MetaMatrixProcessingException, XPathExpressionException {
- Reader stream = new StringReader(document);
- return xpathQuery(context, xpathStr, stream, namespaces);
- }
-
- public static XMLType xpathQuery(CommandContext context, XMLType document, String xpathStr, String namespaces) throws IOException, SQLException, XPathExpressionException, MetaMatrixComponentException, MetaMatrixProcessingException {
- Reader stream = ((SQLXML)document).getCharacterStream();
- return xpathQuery(context, xpathStr, stream, namespaces);
- }
-
- private static XMLType xpathQuery(CommandContext context, String xpathStr,
- Reader stream, String namespaces) throws XPathExpressionException,
- MetaMatrixComponentException, MetaMatrixProcessingException,
- IOException {
- try {
- XPathFactory xpathFactory = XPathFactory.newInstance();
- XPath xp = xpathFactory.newXPath();
- NamespaceContext nc = getNamespaces(namespaces);
- if (nc != null) {
- xp.setNamespaceContext(nc);
- }
- final NodeList nodes = (NodeList)xp.evaluate(xpathStr, new InputSource(stream), XPathConstants.NODESET);
- if (nodes.getLength() == 0) {
- return null;
- }
- Type type = nodes.getLength() > 1 ? Type.SIBLINGS : Type.FRAGMENT;
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- if (node.getNodeType() == Node.TEXT_NODE) {
- type = Type.TEXT;
- }
- }
- SQLXML sqlXml = XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
-
- @Override
- public void translate(Writer writer) throws TransformerException {
- TransformerFactory factory = TransformerFactory.newInstance();
- Transformer transformer = factory.newTransformer();
- transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- transformer.transform(new DOMSource(node), new StreamResult(writer));
- }
- }
- }, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
- XMLType result = new XMLType(sqlXml);
- result.setType(type);
- return result;
- } finally {
- stream.close();
- }
- }
-
- public static String xpathValue(Reader documentReader, String xpath, String namespaces) throws IOException, XPathExpressionException, FunctionExecutionException {
- try {
- XPathFactory xpathFactory = XPathFactory.newInstance();
- XPath xp = xpathFactory.newXPath();
- NamespaceContext nc = getNamespaces(namespaces);
- if (nc != null) {
- xp.setNamespaceContext(nc);
- }
- Node node = (Node)xp.evaluate(xpath, new InputSource(documentReader), XPathConstants.NODE);
- if (node == null) {
- return null;
- }
- return node.getTextContent();
- } finally {
- // Always close the reader
- documentReader.close();
- }
- }
-
- public static NamespaceContext getNamespaces(String namespaces) throws FunctionExecutionException {
- if (namespaces == null) {
- return null;
- }
- XMLInputFactory inputFactory = XMLInputFactory.newInstance();
- try {
- XMLStreamReader eventReader = inputFactory.createXMLStreamReader(new StringReader("<x " + namespaces + " />")); //$NON-NLS-1$ //$NON-NLS-2$
- eventReader.next();
- return eventReader.getNamespaceContext();
- } catch (XMLStreamException e) {
- throw new FunctionExecutionException(e, QueryPlugin.Util.getString("XMLSystemFunctions.invalid_namespaces", namespaces)); //$NON-NLS-1$
- }
- }
-
- /**
- * Validate whether the XPath is a valid XPath. If not valid, an XPathExpressionException will be thrown.
- * @param xpath An xpath expression, for example: a/b/c/getText()
- * @throws XPathExpressionException
- */
- public static void validateXpath(String xpath) throws XPathExpressionException {
- if(xpath == null) {
- return;
- }
-
- XPathFactory factory = XPathFactory.newInstance();
- XPath xp = factory.newXPath();
- xp.compile(xpath);
- }
-
-}
Copied: trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java (from rev 2113, trunk/engine/src/main/java/com/metamatrix/query/function/source/XMLSystemFunctions.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/XMLSystemFunctions.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,550 @@
+/*
+ * 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.function.source;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.Writer;
+import java.nio.CharBuffer;
+import java.sql.Clob;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Collections;
+import java.util.List;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+import javax.xml.stream.EventFilter;
+import javax.xml.stream.FactoryConfigurationError;
+import javax.xml.stream.XMLEventFactory;
+import javax.xml.stream.XMLEventReader;
+import javax.xml.stream.XMLEventWriter;
+import javax.xml.stream.XMLInputFactory;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.stream.events.XMLEvent;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Source;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.ClobType;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.types.XMLTranslator;
+import org.teiid.core.types.XMLType;
+import org.teiid.core.types.XMLType.Type;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionMethods;
+import org.teiid.query.processor.xml.XMLUtil;
+import org.teiid.query.util.CommandContext;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+
+
+/**
+ * This class contains scalar system functions supporting for XML manipulation.
+ *
+ * @since 4.2
+ */
+public class XMLSystemFunctions {
+
+ public static class NameValuePair<T> {
+ String name;
+ T value;
+
+ public NameValuePair(String name, T value) {
+ this.name = name;
+ this.value = value;
+ }
+ }
+
+ //YEAR 0 in the server timezone. used to determine negative years
+ public static long YEAR_ZERO;
+ static String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ss"; //$NON-NLS-1$
+
+ static String TIMESTAMP_MICROZEROS = "000000000"; //$NON-NLS-1$
+
+ static {
+ Calendar cal = Calendar.getInstance();
+
+ for (int i = 0; i <= Calendar.MILLISECOND; i++) {
+ cal.set(i, 0);
+ }
+ YEAR_ZERO = cal.getTimeInMillis();
+ }
+
+ public static ClobType xslTransform(CommandContext context, String xmlResults, String styleSheet) throws Exception {
+ return xslTransform(context, DataTypeManager.transformValue(xmlResults, DataTypeManager.DefaultDataClasses.XML), DataTypeManager.transformValue(styleSheet, DataTypeManager.DefaultDataClasses.XML));
+ }
+
+ public static ClobType xslTransform(CommandContext context, String xmlResults, XMLType styleSheet) throws Exception {
+ return xslTransform(context, DataTypeManager.transformValue(xmlResults, DataTypeManager.DefaultDataClasses.XML), styleSheet);
+ }
+
+ public static ClobType xslTransform(CommandContext context, XMLType xmlResults, String styleSheet) throws Exception {
+ return xslTransform(context, xmlResults, DataTypeManager.transformValue(styleSheet, DataTypeManager.DefaultDataClasses.XML));
+ }
+
+ public static ClobType xslTransform(CommandContext context, XMLType xmlResults, XMLType styleSheet) throws Exception {
+ Reader styleSheetReader = styleSheet.getCharacterStream();
+ final Source styleSource = new StreamSource(styleSheetReader);
+ Reader reader = xmlResults.getCharacterStream();
+ final Source xmlSource = new StreamSource(reader);
+ try {
+ //this creates a non-validated sqlxml - it may not be valid xml/root-less xml
+ SQLXML result = XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
+
+ @Override
+ public void translate(Writer writer) throws TransformerException {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer(styleSource);
+ //transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
+ // Feed the resultant I/O stream into the XSLT processor
+ transformer.transform(xmlSource, new StreamResult(writer));
+ }
+ }, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
+ return DataTypeManager.transformValue(new XMLType(result), DataTypeManager.DefaultDataClasses.CLOB);
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ }
+ try {
+ styleSheetReader.close();
+ } catch (IOException e) {
+ }
+ }
+ }
+
+ public static XMLType xmlForest(final CommandContext context, final NameValuePair[] namespaces, final NameValuePair[] values) throws TeiidComponentException, TeiidProcessingException {
+ boolean valueExists = false;
+ for (NameValuePair nameValuePair : values) {
+ if (nameValuePair.value != null) {
+ valueExists = true;
+ break;
+ }
+ }
+ if (!valueExists) {
+ return null;
+ }
+
+ XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
+
+ @Override
+ public void translate(Writer writer) throws TransformerException,
+ IOException {
+ try {
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
+ XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+ for (NameValuePair nameValuePair : values) {
+ if (nameValuePair.value == null) {
+ continue;
+ }
+ addElement(nameValuePair.name, writer, eventWriter, eventFactory, namespaces, null, Collections.singletonList(nameValuePair.value));
+ }
+ } catch (XMLStreamException e) {
+ throw new TransformerException(e);
+ }
+ }
+ }, context.getStreamingBatchSize()));
+ result.setType(Type.SIBLINGS);
+ return result;
+ }
+
+ /**
+ * Basic support for xmlelement. namespaces are not yet supported.
+ * @param context
+ * @param name
+ * @param contents
+ * @return
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
+ */
+ public static XMLType xmlElement(CommandContext context, final String name,
+ final NameValuePair<String>[] namespaces, final NameValuePair<?>[] attributes, final List<?> contents) throws TeiidComponentException, TeiidProcessingException {
+ XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
+
+ @Override
+ public void translate(Writer writer) throws TransformerException,
+ IOException {
+ try {
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
+ XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+ addElement(name, writer, eventWriter, eventFactory, namespaces, attributes, contents);
+ } catch (XMLStreamException e) {
+ throw new TransformerException(e);
+ }
+ }
+
+ }, context.getStreamingBatchSize()));
+ result.setType(Type.FRAGMENT);
+ return result;
+ }
+
+ private static void addElement(final String name, Writer writer, XMLEventWriter eventWriter, XMLEventFactory eventFactory,
+ NameValuePair<String> namespaces[], NameValuePair<?> attributes[], List<?> contents) throws XMLStreamException, IOException, TransformerException {
+ eventWriter.add(eventFactory.createStartElement("", null, name)); //$NON-NLS-1$
+ if (namespaces != null) {
+ for (NameValuePair<String> nameValuePair : namespaces) {
+ if (nameValuePair.name == null) {
+ if (nameValuePair.value == null) {
+ eventWriter.add(eventFactory.createNamespace(XMLConstants.NULL_NS_URI));
+ } else {
+ eventWriter.add(eventFactory.createNamespace(nameValuePair.value));
+ }
+ } else {
+ eventWriter.add(eventFactory.createNamespace(nameValuePair.name, nameValuePair.value));
+ }
+ }
+ }
+ if (attributes != null) {
+ for (NameValuePair<?> nameValuePair : attributes) {
+ if (nameValuePair.value != null) {
+ eventWriter.add(eventFactory.createAttribute(new QName(nameValuePair.name), getStringValue(nameValuePair.value)));
+ }
+ }
+ }
+ //add empty chars to close the start tag
+ eventWriter.add(eventFactory.createCharacters("")); //$NON-NLS-1$
+ for (Object object : contents) {
+ convertValue(writer, eventWriter, eventFactory, object);
+ }
+ eventWriter.add(eventFactory.createEndElement("", null, name)); //$NON-NLS-1$
+ }
+
+ public static XMLType xmlConcat(CommandContext context, final XMLType xml, final Object... other) throws TeiidComponentException, TeiidProcessingException {
+ XMLType result = new XMLType(XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
+
+ @Override
+ public void translate(Writer writer) throws TransformerException,
+ IOException {
+ try {
+ XMLOutputFactory factory = XMLOutputFactory.newInstance();
+ XMLEventWriter eventWriter = factory.createXMLEventWriter(writer);
+ XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+ convertValue(writer, eventWriter, eventFactory, xml);
+ for (Object object : other) {
+ convertValue(writer, eventWriter, eventFactory, object);
+ }
+ } catch (XMLStreamException e) {
+ throw new TransformerException(e);
+ }
+ }
+ }, context.getStreamingBatchSize()));
+ result.setType(Type.SIBLINGS);
+ return result;
+ }
+
+ public static XMLType xmlPi(String name) {
+ return xmlPi(name, ""); //$NON-NLS-1$
+ }
+
+ public static XMLType xmlPi(String name, String content) {
+ int start = 0;
+ char[] chars = content.toCharArray();
+ while (start < chars.length && chars[start] == ' ') {
+ start++;
+ }
+ XMLType result = new XMLType(new SQLXMLImpl("<?" + name + " " + content.substring(start) + "?>")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ result.setType(Type.PI);
+ return result;
+ }
+
+ static String getStringValue(Object object) throws TransformerException {
+ if (object instanceof Timestamp) {
+ try {
+ return timestampToDateTime((Timestamp)object);
+ } catch (FunctionExecutionException e) {
+ throw new TransformerException(e);
+ }
+ }
+ try {
+ return DataTypeManager.transformValue(object, DataTypeManager.DefaultDataClasses.STRING);
+ } catch (TransformationException e) {
+ throw new TransformerException(e);
+ }
+ }
+
+ static void convertValue(Writer writer, XMLEventWriter eventWriter, XMLEventFactory eventFactory, Object object) throws IOException,
+ FactoryConfigurationError, XMLStreamException,
+ TransformerException {
+ if (object == null) {
+ return;
+ }
+ Reader r = null;
+ try {
+ if (object instanceof XMLType) {
+ XMLType xml = (XMLType)object;
+ r = xml.getCharacterStream();
+ Type type = xml.getType();
+ convertReader(writer, eventWriter, r, type);
+ } else if (object instanceof Clob) {
+ Clob clob = (Clob)object;
+ r = clob.getCharacterStream();
+ convertReader(writer, eventWriter, r, Type.TEXT);
+ } else {
+ String val = getStringValue(object);
+ eventWriter.add(eventFactory.createCharacters(val));
+ }
+ } catch (SQLException e) {
+ throw new IOException(e);
+ } finally {
+ if (r != null) {
+ r.close();
+ }
+ }
+ //TODO: blob - with base64 encoding
+ }
+
+ private static void convertReader(Writer writer,
+ XMLEventWriter eventWriter, Reader r, Type type)
+ throws XMLStreamException, IOException, FactoryConfigurationError {
+ if (!(r instanceof BufferedReader)) {
+ r = new BufferedReader(r);
+ }
+ switch(type) {
+ case FRAGMENT:
+ case SIBLINGS:
+ case PI:
+ case COMMENT: //write the value directly to the writer
+ eventWriter.flush();
+ int chr = -1;
+ while ((chr = r.read()) != -1) {
+ writer.write(chr);
+ }
+ break;
+ case UNKNOWN: //assume a document
+ case DOCUMENT: //filter the doc declaration
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ XMLEventReader eventReader = inputFactory.createXMLEventReader(r);
+ eventReader = inputFactory.createFilteredReader(eventReader, new EventFilter() {
+ @Override
+ public boolean accept(XMLEvent event) {
+ return !event.isStartDocument() && !event.isEndDocument();
+ }
+ });
+ eventWriter.add(eventReader);
+ break;
+ case TEXT:
+ CharBuffer buffer = CharBuffer.allocate(1 << 13);
+ XMLEventFactory eventFactory = XMLEventFactory.newInstance();
+ while (r.read(buffer) != -1) {
+ eventWriter.add(eventFactory.createCharacters(new String(buffer.array(), 0, buffer.position())));
+ buffer.reset();
+ }
+ break;
+ }
+ }
+
+ public static XMLType xmlComment(String comment) {
+ return new XMLType(new SQLXMLImpl("<!--" + comment + "-->")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ /**
+ * Formats a timestamp to an xs:dateTime. This uses DATETIME_FORMAT
+ * with a trailing string for nanoseconds (without right zeros).
+ */
+ public static String timestampToDateTime(Timestamp time) throws FunctionExecutionException {
+ String result = FunctionMethods.format(time, DATETIME_FORMAT);
+ int nanos = time.getNanos();
+ if (nanos == 0) {
+ return result;
+ }
+
+ StringBuffer resultBuffer = new StringBuffer();
+ boolean first = true;
+ int i = 0;
+ for (; i < 9 && nanos > 0; i++) {
+ int digit = nanos%10;
+ if (first) {
+ if (digit > 0) {
+ resultBuffer.insert(0, digit);
+ first = false;
+ }
+ } else {
+ resultBuffer.insert(0, digit);
+ }
+ nanos /= 10;
+ }
+ if (i < 9) {
+ resultBuffer.insert(0, TIMESTAMP_MICROZEROS.substring(i));
+ }
+ resultBuffer.insert(0, "."); //$NON-NLS-1$
+ resultBuffer.insert(0, result);
+ if (time.getTime() < YEAR_ZERO) {
+ resultBuffer.insert(0, "-"); //$NON-NLS-1$
+ }
+ return resultBuffer.toString();
+
+ }
+
+ public static String xpathValue(XMLType document, String xpathStr, String namespaces) throws IOException, XPathExpressionException, SQLException, FunctionExecutionException {
+ Reader stream = document.getCharacterStream();
+ return xpathValue(stream, xpathStr, namespaces);
+ }
+
+ public static String xpathValue(String document, String xpathStr, String namespaces) throws IOException, XPathExpressionException, FunctionExecutionException {
+ return xpathValue(new StringReader(document), xpathStr, namespaces);
+ }
+
+ public static String xpathValue(String document, String xpathStr) throws IOException, XPathExpressionException, FunctionExecutionException {
+ return xpathValue(document, xpathStr, null);
+ }
+
+ public static String xpathValue(XMLType document, String xpathStr) throws IOException, SQLException, XPathExpressionException, FunctionExecutionException {
+ return xpathValue(document, xpathStr, null);
+ }
+
+ public static XMLType xpathQuery(CommandContext context, String document, String xpathStr) throws IOException, TeiidComponentException, TeiidProcessingException, XPathExpressionException {
+ return xpathQuery(context, document, xpathStr, null);
+ }
+
+ public static XMLType xpathQuery(CommandContext context, XMLType document, String xpathStr) throws IOException, SQLException, XPathExpressionException, TeiidComponentException, TeiidProcessingException {
+ return xpathQuery(context, document, xpathStr, null);
+ }
+
+ public static XMLType xpathQuery(CommandContext context, String document, String xpathStr, String namespaces) throws IOException, TeiidComponentException, TeiidProcessingException, XPathExpressionException {
+ Reader stream = new StringReader(document);
+ return xpathQuery(context, xpathStr, stream, namespaces);
+ }
+
+ public static XMLType xpathQuery(CommandContext context, XMLType document, String xpathStr, String namespaces) throws IOException, SQLException, XPathExpressionException, TeiidComponentException, TeiidProcessingException {
+ Reader stream = ((SQLXML)document).getCharacterStream();
+ return xpathQuery(context, xpathStr, stream, namespaces);
+ }
+
+ private static XMLType xpathQuery(CommandContext context, String xpathStr,
+ Reader stream, String namespaces) throws XPathExpressionException,
+ TeiidComponentException, TeiidProcessingException,
+ IOException {
+ try {
+ XPathFactory xpathFactory = XPathFactory.newInstance();
+ XPath xp = xpathFactory.newXPath();
+ NamespaceContext nc = getNamespaces(namespaces);
+ if (nc != null) {
+ xp.setNamespaceContext(nc);
+ }
+ final NodeList nodes = (NodeList)xp.evaluate(xpathStr, new InputSource(stream), XPathConstants.NODESET);
+ if (nodes.getLength() == 0) {
+ return null;
+ }
+ Type type = nodes.getLength() > 1 ? Type.SIBLINGS : Type.FRAGMENT;
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ if (node.getNodeType() == Node.TEXT_NODE) {
+ type = Type.TEXT;
+ }
+ }
+ SQLXML sqlXml = XMLUtil.saveToBufferManager(context.getBufferManager(), new XMLTranslator() {
+
+ @Override
+ public void translate(Writer writer) throws TransformerException {
+ TransformerFactory factory = TransformerFactory.newInstance();
+ Transformer transformer = factory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes"); //$NON-NLS-1$
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node node = nodes.item(i);
+ transformer.transform(new DOMSource(node), new StreamResult(writer));
+ }
+ }
+ }, Streamable.STREAMING_BATCH_SIZE_IN_BYTES);
+ XMLType result = new XMLType(sqlXml);
+ result.setType(type);
+ return result;
+ } finally {
+ stream.close();
+ }
+ }
+
+ public static String xpathValue(Reader documentReader, String xpath, String namespaces) throws IOException, XPathExpressionException, FunctionExecutionException {
+ try {
+ XPathFactory xpathFactory = XPathFactory.newInstance();
+ XPath xp = xpathFactory.newXPath();
+ NamespaceContext nc = getNamespaces(namespaces);
+ if (nc != null) {
+ xp.setNamespaceContext(nc);
+ }
+ Node node = (Node)xp.evaluate(xpath, new InputSource(documentReader), XPathConstants.NODE);
+ if (node == null) {
+ return null;
+ }
+ return node.getTextContent();
+ } finally {
+ // Always close the reader
+ documentReader.close();
+ }
+ }
+
+ public static NamespaceContext getNamespaces(String namespaces) throws FunctionExecutionException {
+ if (namespaces == null) {
+ return null;
+ }
+ XMLInputFactory inputFactory = XMLInputFactory.newInstance();
+ try {
+ XMLStreamReader eventReader = inputFactory.createXMLStreamReader(new StringReader("<x " + namespaces + " />")); //$NON-NLS-1$ //$NON-NLS-2$
+ eventReader.next();
+ return eventReader.getNamespaceContext();
+ } catch (XMLStreamException e) {
+ throw new FunctionExecutionException(e, QueryPlugin.Util.getString("XMLSystemFunctions.invalid_namespaces", namespaces)); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Validate whether the XPath is a valid XPath. If not valid, an XPathExpressionException will be thrown.
+ * @param xpath An xpath expression, for example: a/b/c/getText()
+ * @throws XPathExpressionException
+ */
+ public static void validateXpath(String xpath) throws XPathExpressionException {
+ if(xpath == null) {
+ return;
+ }
+
+ XPathFactory factory = XPathFactory.newInstance();
+ XPath xp = factory.newXPath();
+ xp.compile(xpath);
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/mapping/relational (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/mapping/relational)
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/relational/QueryNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/relational/QueryNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.relational;
+package org.teiid.query.mapping.relational;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Command;
+
/**
* <p>The QueryNode represents a virtual or temporary group in the modeler. QueryNodes may
* be nested to indicate data queries built from other virtual or temporary groups. The
Copied: trunk/engine/src/main/java/org/teiid/query/mapping/xml (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/mapping/xml)
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/InterceptingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/InterceptingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/InterceptingVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.HashMap;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingAllNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingAllNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingAllNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingAttribute.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingAttribute.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
/**
@@ -102,7 +102,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingNode#getPathName()
+ * @see org.teiid.query.mapping.xml.MappingNode#getPathName()
*/
public String getPathName() {
return "@" + super.getPathName(); //$NON-NLS-1$
@@ -169,7 +169,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingNode#getSourceNode()
+ * @see org.teiid.query.mapping.xml.MappingNode#getSourceNode()
*/
public MappingSourceNode getSourceNode() {
String nameInSource = getNameInSource();
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingBaseNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingBaseNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.QueryPlugin;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.QueryPlugin;
+
/**
* This is base class to define all nodes except the attribute. However, this quite not
* enough to define a Element node. Specially designed for sequence, choice and all node
@@ -88,7 +89,7 @@
if (parent != null) {
return parent.getRecursiveRootNode(elem);
}
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("invalid_recurive_node", elem)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("invalid_recurive_node", elem)); //$NON-NLS-1$
}
/**
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingChoiceNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingChoiceNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingChoiceNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.QueryPlugin;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.QueryPlugin;
+
/**
* Node that describes a <b>choice</b> node in an XML Scheam Mapping document
*
@@ -85,22 +86,22 @@
}
public MappingAllNode addAllNode(MappingAllNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingChoiceNode addChoiceNode(MappingChoiceNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingSequenceNode addSequenceNode(MappingSequenceNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingElement addChildElement(MappingElement elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingSourceNode addSourceNode(MappingSourceNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingCommentNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingCommentNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingCommentNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingCriteriaNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingCriteriaNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.List;
-import com.metamatrix.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Criteria;
+
/**
* Represents a Criteria Node under a Choice Node, which defines the criteria
* on the selection of child elements.
@@ -104,7 +105,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingNode#isExcluded()
+ * @see org.teiid.query.mapping.xml.MappingNode#isExcluded()
*/
public boolean isExcluded() {
return false;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingDocument.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingDocument.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingDocument.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.StringWriter;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.QueryPlugin;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.QueryPlugin;
+
/**
* A Mapping Node document object.
*/
@@ -128,20 +129,20 @@
}
public MappingAllNode addAllNode(MappingAllNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingChoiceNode addChoiceNode(MappingChoiceNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingSequenceNode addSequenceNode(MappingSequenceNode elem) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("WrongTypeChild")); //$NON-NLS-1$
}
public MappingElement addChildElement(MappingElement elem) {
if (elem == null) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("root_cannotbe_null")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("root_cannotbe_null")); //$NON-NLS-1$
}
fixCardinality(elem);
setRoot(elem);
@@ -150,14 +151,14 @@
public MappingSourceNode addSourceNode(MappingSourceNode elem) {
if (elem == null) {
- throw new MetaMatrixRuntimeException(QueryPlugin.Util.getString("root_cannotbe_null")); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryPlugin.Util.getString("root_cannotbe_null")); //$NON-NLS-1$
}
setRoot(elem);
return elem;
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingNode#clone()
+ * @see org.teiid.query.mapping.xml.MappingNode#clone()
*/
public Object clone() {
// I found this as cheap way of cloneing for now fast, may be we will
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingElement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingElement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
/**
* A Mapping Node which defines a Element in XML Schema Mapping document
*/
@@ -294,7 +295,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingBaseNode#isTagRoot()
+ * @see org.teiid.query.mapping.xml.MappingBaseNode#isTagRoot()
*/
public boolean isTagRoot() {
MappingBaseNode parent = getParentNode();
@@ -316,7 +317,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingNode#getSourceNode()
+ * @see org.teiid.query.mapping.xml.MappingNode#getSourceNode()
*/
public MappingSourceNode getSourceNode() {
String nameInSource = getNameInSource();
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingException.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingException.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingException.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingInterceptor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingInterceptor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingInterceptor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.Map;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingLoader.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingLoader.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.File;
import java.io.IOException;
@@ -35,9 +35,9 @@
import org.jdom.Element;
import org.jdom.JDOMException;
import org.jdom.input.SAXBuilder;
+import org.teiid.internal.core.xml.SAXBuilderHelper;
+import org.teiid.query.QueryPlugin;
-import com.metamatrix.internal.core.xml.SAXBuilderHelper;
-import com.metamatrix.query.QueryPlugin;
/**
* <p>Reads an mapping definition file in XML format. When finished reading
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.PrintStream;
import java.io.Serializable;
@@ -31,10 +31,11 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* There will be a mapping node
* for every entity (element or attribute) in a target XML document.
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingNodeConstants.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.Arrays;
import java.util.Collection;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeLogger.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingNodeLogger.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingNodeLogger.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingOutputter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingOutputter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.IOException;
import java.io.PrintWriter;
@@ -34,10 +34,10 @@
import org.jdom.Element;
import org.jdom.Namespace;
import org.jdom.output.XMLOutputter;
+import org.teiid.internal.core.xml.JdomHelper;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.internal.core.xml.JdomHelper;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* <p>Outputs a mapping definition in XML format. The mapping definition is
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingRecursiveElement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingRecursiveElement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.List;
-import com.metamatrix.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Criteria;
+
/**
* A element which specifies a recursive element inside and xml schema.
* A recursive element is that embeds the self node type of elements
@@ -54,7 +55,7 @@
/**
* Is recursice
- * @see com.metamatrix.query.mapping.xml.MappingElement#isRecursive()
+ * @see org.teiid.query.mapping.xml.MappingElement#isRecursive()
*/
public boolean isRecursive() {
return true;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingSequenceNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingSequenceNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingSequenceNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingSourceNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingSourceNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingSourceNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* This represents a source node. A source node is which produces results from
* executing a relational query.
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/MappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/MappingVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.Iterator;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/Namespace.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/Namespace.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/Namespace.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.io.Serializable;
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/Navigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/Navigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/Navigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
@@ -49,7 +49,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingVisitor#visit(com.metamatrix.query.mapping.xml.MappingElement)
+ * @see org.teiid.query.mapping.xml.MappingVisitor#visit(org.teiid.query.mapping.xml.MappingElement)
*/
public void visit(MappingElement element) {
if (preOrder) {
@@ -67,7 +67,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingVisitor#visit(com.metamatrix.query.mapping.xml.MappingRecursiveElement)
+ * @see org.teiid.query.mapping.xml.MappingVisitor#visit(org.teiid.query.mapping.xml.MappingRecursiveElement)
*/
public void visit(MappingRecursiveElement element) {
this.realVisitor.visit(element);
@@ -77,7 +77,7 @@
}
/**
- * @see com.metamatrix.query.mapping.xml.MappingVisitor#shouldAbort()
+ * @see org.teiid.query.mapping.xml.MappingVisitor#shouldAbort()
*/
protected boolean shouldAbort() {
return super.shouldAbort() || realVisitor.shouldAbort();
Modified: trunk/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/mapping/xml/ResultSetInfo.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/mapping/xml/ResultSetInfo.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.mapping.xml;
+package org.teiid.query.mapping.xml;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
/**
* Represents a result set used in an XML query - this can be based on either a mapping class query
* or a staging table. All info about the result set is stored in this object - some is only applicable
Copied: trunk/engine/src/main/java/org/teiid/query/metadata (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/metadata)
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadata.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadata.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,21 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* This is an abstract implementation of the metadata interface. It can
* be subclassed to create test implementations or partial implementations.
@@ -52,7 +53,7 @@
* @see QueryMetadataInterface#getElementID(String)
*/
public Object getElementID(String elementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -60,7 +61,7 @@
* @see QueryMetadataInterface#getGroupID(String)
*/
public Object getGroupID(String groupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -68,7 +69,7 @@
* @see QueryMetadataInterface#getGroupID(String)
*/
public Collection getGroupsForPartialName(String partialGroupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_LIST;
}
@@ -76,7 +77,7 @@
* @see QueryMetadataInterface#getModelID(Object)
*/
public Object getModelID(Object groupOrElementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -84,7 +85,7 @@
* @see QueryMetadataInterface#getFullName(Object)
*/
public String getFullName(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -94,7 +95,7 @@
public String getFullElementName(
String fullGroupName,
String shortElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -102,7 +103,7 @@
* @see QueryMetadataInterface#getShortElementName(String)
*/
public String getShortElementName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -110,7 +111,7 @@
* @see QueryMetadataInterface#getGroupName(String)
*/
public String getGroupName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -118,7 +119,7 @@
* @see QueryMetadataInterface#getElementIDsInGroupID(Object)
*/
public List getElementIDsInGroupID(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_LIST;
}
@@ -126,7 +127,7 @@
* @see QueryMetadataInterface#getGroupIDForElementID(Object)
*/
public Object getGroupIDForElementID(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -134,7 +135,7 @@
* @see QueryMetadataInterface#getStoredProcedureInfoForProcedure(String)
*/
public StoredProcedureInfo getStoredProcedureInfoForProcedure(String fullyQualifiedProcedureName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -142,64 +143,64 @@
* @see QueryMetadataInterface#getElementType(ElementSymbol)
*/
public String getElementType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
public Object getDefaultValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaximumValue(java.lang.Object)
*/
- public Object getMaximumValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMaximumValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
return null;
}
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMinimumValue(java.lang.Object)
*/
- public Object getMinimumValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMinimumValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
return null;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getDistinctValues(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getDistinctValues(java.lang.Object)
* @since 4.3
*/
- public int getDistinctValues(Object elementID) throws MetaMatrixComponentException,
+ public int getDistinctValues(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return -1;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getNullValues(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getNullValues(java.lang.Object)
* @since 4.3
*/
- public int getNullValues(Object elementID) throws MetaMatrixComponentException,
+ public int getNullValues(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return -1;
}
- public int getPosition(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPosition(Object elementID) throws TeiidComponentException, QueryMetadataException {
return 0;
}
- public int getPrecision(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPrecision(Object elementID) throws TeiidComponentException, QueryMetadataException {
return 0;
}
- public int getRadix(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getRadix(Object elementID) throws TeiidComponentException, QueryMetadataException {
return 0;
}
@Override
- public String getFormat(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getFormat(Object elementID) throws TeiidComponentException, QueryMetadataException {
return null;
}
- public int getScale(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getScale(Object elementID) throws TeiidComponentException, QueryMetadataException {
return 0;
}
@@ -208,34 +209,34 @@
* @see QueryMetadataInterface#isVirtualGroup(Object)
*/
public boolean isVirtualGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
* @since 4.2
*/
public boolean hasMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
* @since 4.2
*/
public Object getMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
* @since 4.2
*/
public Object getMaterializationStage(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -243,7 +244,7 @@
* @see QueryMetadataInterface#isVirtualModel(Object)
*/
public boolean isVirtualModel(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
@@ -251,7 +252,7 @@
* @see QueryMetadataInterface#getVirtualPlan(GroupSymbol)
*/
public QueryNode getVirtualPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -261,7 +262,7 @@
* @return A string giving the procedure for inserts.
*/
public String getInsertPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -271,7 +272,7 @@
* @return A string giving the procedure for inserts.
*/
public String getUpdatePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -281,7 +282,7 @@
* @return A string giving the procedure for inserts.
*/
public String getDeletePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
@@ -289,7 +290,7 @@
* @see QueryMetadataInterface#modelSupports(Object, int)
*/
public boolean modelSupports(Object modelID, int modelConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
@@ -297,7 +298,7 @@
* @see QueryMetadataInterface#groupSupports(Object, int)
*/
public boolean groupSupports(Object groupID, int groupConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
@@ -305,7 +306,7 @@
* @see QueryMetadataInterface#elementSupports(Object, int)
*/
public boolean elementSupports(Object elementID, int elementConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
@@ -313,16 +314,16 @@
* @see QueryMetadataInterface#getMaxSetSize(Object)
*/
public int getMaxSetSize(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return 0;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
*/
public Collection getIndexesInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_SET;
}
@@ -330,7 +331,7 @@
* @see QueryMetadataInterface#getUniqueKeysInGroup(Object)
*/
public Collection getUniqueKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_SET;
}
@@ -338,7 +339,7 @@
* @see QueryMetadataInterface#getForeignKeysInGroup(Object)
*/
public Collection getForeignKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_SET;
}
@@ -346,7 +347,7 @@
* @see QueryMetadataInterface#getPrimaryKeyIDForForeignKeyID(Object)
*/
public Object getPrimaryKeyIDForForeignKeyID(Object foreignKeyID)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
return null;
}
@@ -354,31 +355,31 @@
* @see QueryMetadataInterface#getElementIDsInKey(Object)
*/
public List getElementIDsInKey(Object key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_LIST;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
*/
public List getElementIDsInIndex(Object index)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_LIST;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(Object)
*/
public Collection getAccessPatternsInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_SET;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(Object)
*/
public List getElementIDsInAccessPattern(Object accessPattern)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return Collections.EMPTY_LIST;
}
@@ -386,7 +387,7 @@
* @see QueryMetadataInterface#isXMLGroup(Object)
*/
public boolean isXMLGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
@@ -394,27 +395,27 @@
* @see QueryMetadataInterface#getMappingNode(GroupSymbol)
*/
public MappingNode getMappingNode(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
*/
public String getVirtualDatabaseName()
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
public Collection getXMLTempGroups(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
return Collections.EMPTY_SET;
}
public int getCardinality(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
return QueryMetadataInterface.UNKNOWN_CARDINALITY;
}
@@ -422,21 +423,21 @@
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLSchemas(java.lang.Object)
*/
- public List getXMLSchemas(Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public List getXMLSchemas(Object groupID) throws TeiidComponentException, QueryMetadataException {
return null;
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getNameInSource(java.lang.Object)
*/
- public String getNameInSource(Object metadataID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getNameInSource(Object metadataID) throws TeiidComponentException, QueryMetadataException {
return null;
}
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementLength(java.lang.Object)
*/
- public int getElementLength(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getElementLength(Object elementID) throws TeiidComponentException, QueryMetadataException {
return 0;
}
@@ -444,75 +445,75 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
*/
public Properties getExtensionProperties(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
- public String getNativeType(Object elementID) throws MetaMatrixComponentException,
+ public String getNativeType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return null;
}
- public boolean isProcedure(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isProcedure(Object elementID) throws TeiidComponentException, QueryMetadataException {
return false;
}
- public byte[] getBinaryVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ public byte[] getBinaryVDBResource(String resourcePath) throws TeiidComponentException, QueryMetadataException {
return null;
}
- public String getCharacterVDBResource(String resourcePath) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getCharacterVDBResource(String resourcePath) throws TeiidComponentException, QueryMetadataException {
return null;
}
- public String[] getVDBResourcePaths() throws MetaMatrixComponentException, QueryMetadataException {
+ public String[] getVDBResourcePaths() throws TeiidComponentException, QueryMetadataException {
return null;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
* @since 5.0
*/
- public String getModeledType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return null;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
* @since 5.0
*/
- public String getModeledBaseType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledBaseType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return null;
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
* @since 5.0
*/
- public String getModeledPrimitiveType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledPrimitiveType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return null;
}
public boolean isTemporaryTable(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
public Object addToMetadataCache(Object metadataID, String key, Object value)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
public Object getFromMetadataCache(Object metadataID, String key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return null;
}
public boolean isScalarGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return false;
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/BasicQueryMetadataWrapper.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/BasicQueryMetadataWrapper.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingNode;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingNode;
+
public class BasicQueryMetadataWrapper implements QueryMetadataInterface {
protected QueryMetadataInterface actualMetadata;
@@ -41,325 +42,325 @@
}
public boolean elementSupports(Object elementID, int elementConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.elementSupports(elementID, elementConstant);
}
public Collection getAccessPatternsInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getAccessPatternsInGroup(groupID);
}
public byte[] getBinaryVDBResource(String resourcePath)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getBinaryVDBResource(resourcePath);
}
public int getCardinality(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getCardinality(groupID);
}
public String getCharacterVDBResource(String resourcePath)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getCharacterVDBResource(resourcePath);
}
public Object getDefaultValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getDefaultValue(elementID);
}
public String getDeletePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getDeletePlan(groupID);
}
public int getDistinctValues(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getDistinctValues(elementID);
}
public Object getElementID(String elementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementID(elementName);
}
public List getElementIDsInAccessPattern(Object accessPattern)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementIDsInAccessPattern(accessPattern);
}
public List getElementIDsInGroupID(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementIDsInGroupID(groupID);
}
public List getElementIDsInIndex(Object index)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementIDsInIndex(index);
}
public List getElementIDsInKey(Object key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementIDsInKey(key);
}
public int getElementLength(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementLength(elementID);
}
public String getElementType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getElementType(elementID);
}
public Properties getExtensionProperties(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getExtensionProperties(metadataID);
}
public Collection getForeignKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getForeignKeysInGroup(groupID);
}
public String getFullElementName(String fullGroupName,
- String shortElementName) throws MetaMatrixComponentException,
+ String shortElementName) throws TeiidComponentException,
QueryMetadataException {
return actualMetadata.getFullElementName(fullGroupName,
shortElementName);
}
public String getFullName(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getFullName(metadataID);
}
public Object getGroupID(String groupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getGroupID(groupName);
}
public Object getGroupIDForElementID(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getGroupIDForElementID(elementID);
}
public String getGroupName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getGroupName(fullElementName);
}
public Collection getGroupsForPartialName(String partialGroupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getGroupsForPartialName(partialGroupName);
}
public Collection getIndexesInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getIndexesInGroup(groupID);
}
public String getInsertPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getInsertPlan(groupID);
}
public MappingNode getMappingNode(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getMappingNode(groupID);
}
public Object getMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getMaterialization(groupID);
}
public Object getMaterializationStage(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getMaterializationStage(groupID);
}
public Object getMaximumValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getMaximumValue(elementID);
}
public int getMaxSetSize(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getMaxSetSize(modelID);
}
public Object getMinimumValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getMinimumValue(elementID);
}
public String getModeledBaseType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getModeledBaseType(elementID);
}
public String getModeledPrimitiveType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getModeledPrimitiveType(elementID);
}
public String getModeledType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getModeledType(elementID);
}
public Object getModelID(Object groupOrElementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getModelID(groupOrElementID);
}
public String getNameInSource(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getNameInSource(metadataID);
}
public String getNativeType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getNativeType(elementID);
}
public int getNullValues(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getNullValues(elementID);
}
public int getPosition(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getPosition(elementID);
}
public int getPrecision(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getPrecision(elementID);
}
public Object getPrimaryKeyIDForForeignKeyID(Object foreignKeyID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getPrimaryKeyIDForForeignKeyID(foreignKeyID);
}
- public int getRadix(Object elementID) throws MetaMatrixComponentException,
+ public int getRadix(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return actualMetadata.getRadix(elementID);
}
- public String getFormat(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public String getFormat(Object elementID) throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getFormat(elementID);
}
- public int getScale(Object elementID) throws MetaMatrixComponentException,
+ public int getScale(Object elementID) throws TeiidComponentException,
QueryMetadataException {
return actualMetadata.getScale(elementID);
}
public String getShortElementName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getShortElementName(fullElementName);
}
public StoredProcedureInfo getStoredProcedureInfoForProcedure(
String fullyQualifiedProcedureName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata
.getStoredProcedureInfoForProcedure(fullyQualifiedProcedureName);
}
public Collection getUniqueKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getUniqueKeysInGroup(groupID);
}
public String getUpdatePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getUpdatePlan(groupID);
}
- public String[] getVDBResourcePaths() throws MetaMatrixComponentException,
+ public String[] getVDBResourcePaths() throws TeiidComponentException,
QueryMetadataException {
return actualMetadata.getVDBResourcePaths();
}
- public String getVirtualDatabaseName() throws MetaMatrixComponentException,
+ public String getVirtualDatabaseName() throws TeiidComponentException,
QueryMetadataException {
return actualMetadata.getVirtualDatabaseName();
}
public QueryNode getVirtualPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getVirtualPlan(groupID);
}
public List getXMLSchemas(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getXMLSchemas(groupID);
}
public Collection getXMLTempGroups(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getXMLTempGroups(groupID);
}
public boolean groupSupports(Object groupID, int groupConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.groupSupports(groupID, groupConstant);
}
public boolean hasMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.hasMaterialization(groupID);
}
public boolean isProcedure(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.isProcedure(groupID);
}
public boolean isTemporaryTable(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.isTemporaryTable(groupID);
}
public boolean isVirtualGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.isVirtualGroup(groupID);
}
public boolean isVirtualModel(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.isVirtualModel(modelID);
}
public boolean isXMLGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.isXMLGroup(groupID);
}
public boolean modelSupports(Object modelID, int modelConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.modelSupports(modelID, modelConstant);
}
public Object addToMetadataCache(Object metadataID, String key, Object value)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.addToMetadataCache(metadataID, key, value);
}
public Object getFromMetadataCache(Object metadataID, String key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.getFromMetadataCache(metadataID, key);
}
public boolean isScalarGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return actualMetadata.isScalarGroup(groupID);
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/GroupInfo.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/GroupInfo.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.io.Serializable;
import java.util.ArrayList;
@@ -30,8 +30,9 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
public class GroupInfo implements Serializable {
private static final long serialVersionUID = 5724520038004637086L;
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/QueryMetadataInterface.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/QueryMetadataInterface.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.util.Collection;
import java.util.List;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingNode;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingNode;
+
/**
* This interface defines the way that query components access metadata. Any
* user of a query component will need to implement this interface. Many
@@ -50,30 +51,30 @@
* @param elementName Fully qualified element name
* @return Metadata identifier for this element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getElementID(String elementName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the metadata-implementation identifier object for the given group name.
* @param groupName Fully qualified group name
* @return Metadata identifier for this group
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getGroupID(String groupName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get a collection of group names that match the partially qualified group name.
* @param partialGroupName Partially qualified group name
* @return A collection of groups whose names are matched by the partial name.
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Collection getGroupsForPartialName(String partialGroupName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the metadata-implementation identifier object for the model containing the
@@ -81,10 +82,10 @@
* @param groupOrElementID Metadata group or element ID
* @return Metadata identifier for the model
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getModelID(Object groupOrElementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the fully qualified (unique) name of the metadata identifier specified. This metadata
@@ -92,10 +93,10 @@
* @param metadataID Metadata identifier
* @return Metadata identifier for this model
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getFullName(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the fully qualified (unique) element name given the full group name and the short element name.
@@ -103,151 +104,151 @@
* @param shortElementName Short element name
* @return Unique element name for the specified group and element name
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getFullElementName(String fullGroupName, String shortElementName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the short (unique only to group) name of an element, given a fully qualified element name.
* @param fullElementName Fully qualified element name
* @return Short (unique only to group) name of element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getShortElementName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the group name from a fully qualified element name.
* @param fullElementName Fully qualified element name
* @return Group name
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getGroupName(String fullElementName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get list of metadata element IDs for a group ID
* @param groupID Group ID
* @return List of Object, where each object is a metadata elementID for element within group
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
List getElementIDsInGroupID(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get containg group ID given element ID
* @param elementID Element ID
* @return Group ID containing elementID
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getGroupIDForElementID(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the the StoredProcedureInfo based on the fully qualified procedure name
* @param fullyQualifiedProcedureName the fully qualified stored procedure name
* @return StoredProcedureInfo containing the runtime model id
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
StoredProcedureInfo getStoredProcedureInfoForProcedure(String fullyQualifiedProcedureName)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element type name for an element symbol. These types are defined in
- * {@link com.metamatrix.common.types.DataTypeManager.DefaultDataTypes}.
+ * {@link org.teiid.core.types.DataTypeManager.DefaultDataTypes}.
* @param symbol The element symbol
* @return The element data type
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getElementType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's default value for an element symbol
* @param elementID The element ID
* @return The default value of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getDefaultValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's minimum value for an element symbol
* @param elementID The element ID
* @return The minimum value of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getMinimumValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's default value for an element symbol
* @param elementID The element ID
* @return The maximum value of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getMaximumValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's position in the group
* @param elementID The element ID
* @return The position of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getPosition(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's precision
* @param elementID The element ID
* @return The precision of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getPrecision(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's scale
* @param elementID The element ID
* @return The scale of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getScale(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's radix
* @param elementID The element ID
* @return The radix of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getRadix(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element's format
* @param elementID The element ID
* @return The format of the element
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getFormat(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the number of distinct values for this column. Negative values (typically -1)
@@ -255,10 +256,10 @@
* @param elementID The element ID
* @return The number of distinct values of this element in the data source
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getDistinctValues(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the number of distinct values for this column. Negative values (typically -1)
@@ -266,30 +267,30 @@
* @param elementID The element ID
* @return The number of distinct values of this element in the data source
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getNullValues(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether a group is virtual or not.
* @param symbol Group symbol
* @return True if virtual
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
boolean isVirtualGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether a model is virtual or not.
* @param symbol model symbol
* @return True if virtual
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
boolean isVirtualModel(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get virtual plan for a group symbol.
@@ -297,7 +298,7 @@
* @return Root of tree of QueryNode objects
*/
QueryNode getVirtualPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get procedure defining the insert plan for this group.
@@ -305,7 +306,7 @@
* @return A string giving the procedure for inserts.
*/
String getInsertPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get procedure defining the update plan for this group.
@@ -313,7 +314,7 @@
* @return A string giving the procedure for inserts.
*/
String getUpdatePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get procedure defining the delete plan for this group.
@@ -321,7 +322,7 @@
* @return A string giving the procedure for inserts.
*/
String getDeletePlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether the specified model supports some feature.
@@ -329,10 +330,10 @@
* @param modelConstant Constant from {@link SupportConstants.Model}
* @return True if model supports feature
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
boolean modelSupports(Object modelID, int modelConstant)
- throws MetaMatrixComponentException,QueryMetadataException;
+ throws TeiidComponentException,QueryMetadataException;
/**
* Determine whether the specified group supports some feature.
@@ -340,10 +341,10 @@
* @param groupConstant Constant from {@link SupportConstants.Group}
* @return True if group supports feature
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
boolean groupSupports(Object groupID, int groupConstant)
- throws MetaMatrixComponentException,QueryMetadataException;
+ throws TeiidComponentException,QueryMetadataException;
/**
* Determine whether the specified element supports some feature.
@@ -351,60 +352,60 @@
* @param elementConstant Constant from {@link SupportConstants.Element}
* @return True if element supports feature
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
boolean elementSupports(Object elementID, int elementConstant)
- throws MetaMatrixComponentException,QueryMetadataException;
+ throws TeiidComponentException,QueryMetadataException;
/**
* Get all extension properties defined on this metadata object
* @param metadataID Typically element, group, model, or procedure
* @return All extension properties for this object or null for none
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Properties getExtensionProperties(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the max set size for the specified model.
* @param modelID Metadata identifier specifying model
* @return Maximum set size
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getMaxSetSize(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the indexes for the specified group
* @param groupID Metadata identifier specifying group
* @return Collection of Object (never null), each object representing an index
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Collection getIndexesInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the unique keys for the specified group (primary and unique keys)
* @param groupID Metadata identifier specifying group
* @return Collection of Object (never null), each object representing a unique key
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Collection getUniqueKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the foreign keys for the specified group
* @param groupID Metadata identifier specifying group
* @return Collection of Object (never null), each object representing a key
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Collection getForeignKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the corresponding primary key ID for the specified foreign
@@ -412,50 +413,50 @@
* @param foreignKeyID Metadata identifier of a foreign key
* @return Metadata ID of the corresponding primary key
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Object getPrimaryKeyIDForForeignKeyID(Object foreignKeyID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the access patterns for the specified group
* @param groupID Metadata identifier specifying group
* @return Collection of Object (never null), each object representing an access pattern
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
Collection getAccessPatternsInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the elements in the index
* @param index Index identifier, as returned by {@link #getIndexesInGroup}
* @return List of Object, where each object is a metadata element identifier
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
List getElementIDsInIndex(Object index)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the elements in the key
* @param key Key identifier, as returned by {@link #getUniqueKeysInGroup}
* @return List of Object, where each object is a metadata element identifier
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
List getElementIDsInKey(Object key)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the elements in the access pattern
* @param accessPattern access pattern identifier, as returned by {@link #getAccessPatternsInGroup}
* @return List of Object, where each object is a metadata element identifier
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
List getElementIDsInAccessPattern(Object accessPattern)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether a group is an XML virtual document.
@@ -463,27 +464,27 @@
* @return True if group is an XML virtual document
*/
boolean isXMLGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the mapping node for the given groupID
* @param groupID Metadata group ID
* @return A MappingNode defining the group
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
MappingNode getMappingNode(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the currently connected virtual database name. If the current metadata is not
* virtual-database specific, then null should be returned.
* @return Name of current virtual database
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getVirtualDatabaseName()
- throws MetaMatrixComponentException, QueryMetadataException ;
+ throws TeiidComponentException, QueryMetadataException ;
/**
* Return a list of all the temp groups used in this document.
@@ -491,7 +492,7 @@
* @return List of all the temp groups used in this document.
*/
Collection getXMLTempGroups(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Return the cardinality for this group
@@ -499,7 +500,7 @@
* @return cardinality for the given group. If unknown, return UNKNOWN_CARDINALITY.
*/
int getCardinality(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get XML schemas for a document group.
@@ -507,7 +508,7 @@
* @return List of String where each string is an XML schema for the document
*/
List getXMLSchemas(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the name in source of the metadata identifier specified. This metadata
@@ -515,21 +516,21 @@
* @param metadataID Metadata identifier
* @return Name in source as a string.
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
String getNameInSource(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the element length for a given element ID. These types are defined in
- * {@link com.metamatrix.common.types.DataTypeManager.DefaultDataTypes}.
+ * {@link org.teiid.core.types.DataTypeManager.DefaultDataTypes}.
* @param elementID The element ID
* @return The element length
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
int getElementLength(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether given virtual group has an associated <i>Materialization</i>.
@@ -537,23 +538,23 @@
* @param groupID the groupID of the virtual group in question.
* @return True if given virtual group has been marked as having a Materialization.
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @since 4.2
*/
boolean hasMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Accquire the physical group ID (the <i>Materialization</i>) for the given virtual
* group ID, or <code>null</code> if the given virtual group has no Materialization.
* @param groupID the groupID of a virtual group that has a Materialization.
* @return The groupID of the physical group that is a Materialization of the given virtual group.
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @throws QueryMetadataException Metadata implementation detected a problem during the request
* @since 4.2
*/
Object getMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Accquire the physical group ID that is used for the staging area for loading
@@ -562,12 +563,12 @@
* @param groupID the groupID of a virtual group that has a Materialization.
* @return The groupID of the physical group that is the staging table for loading
* the Materialization of the given virtual group.
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @throws QueryMetadataException Metadata implementation detected a problem during the request
* @since 4.2
*/
Object getMaterializationStage(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the native type of the element specified. This element
@@ -575,11 +576,11 @@
* @param elementID Element identifier
* @return Native type name
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @since 4.2
*/
String getNativeType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the design-time model type of the element specified. This element
@@ -587,11 +588,11 @@
* @param elementID Element identifier
* @return Modeled type name
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @since 5.0
*/
String getModeledType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the design-time model base type of the element specified. This element
@@ -599,11 +600,11 @@
* @param elementID Element identifier
* @return Modeled base type name
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @since 5.0
*/
String getModeledBaseType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Get the design-time model primitive type of the element specified. This element
@@ -611,53 +612,53 @@
* @param elementID Element identifier
* @return Modeled primitive type name
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @since 5.0
*/
String getModeledPrimitiveType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether this is a procedure
* @param groupID Group identifier
* @return True if it is an procedure; false otherwise
* @throws QueryMetadataException Metadata implementation detected a problem during the request
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
*/
boolean isProcedure(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Gets the resource paths of all the resources in the VDB.
* @return an array of resource paths of the resources in the VDB
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @throws QueryMetadataException Metadata implementation detected a problem during the request
* @since 4.3
*/
String[] getVDBResourcePaths()
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Gets the contents of a VDB resource as a String.
* @param resourcePath a path returned by getVDBResourcePaths()
* @return the contents of the resource as a String.
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @throws QueryMetadataException Metadata implementation detected a problem during the request
* @since 4.3
*/
String getCharacterVDBResource(String resourcePath)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Gets the contents of a VDB resource in binary form.
* @param resourcePath a path returned by getVDBResourcePaths()
* @return the binary contents of the resource in a byte[]
- * @throws MetaMatrixComponentException Unexpected internal system problem during request
+ * @throws TeiidComponentException Unexpected internal system problem during request
* @throws QueryMetadataException Metadata implementation detected a problem during the request
* @since 4.3
*/
byte[] getBinaryVDBResource(String resourcePath)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
/**
* Determine whether a group is a temporary table.
@@ -665,16 +666,16 @@
* @return True if group is a temporary group
*/
boolean isTemporaryTable(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
Object addToMetadataCache(Object metadataID, String key, Object value)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
Object getFromMetadataCache(Object metadataID, String key)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
boolean isScalarGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException;
+ throws TeiidComponentException, QueryMetadataException;
FunctionLibrary getFunctionLibrary();
}
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/StoredProcedureInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/StoredProcedureInfo.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/StoredProcedureInfo.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.io.Serializable;
import java.util.List;
import java.util.ArrayList;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.sql.lang.SPParameter;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.sql.lang.SPParameter;
/**
* This class encapsulates everything needed to pass between runtime metadata
* and the QueryResolver via the facades
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/SupportConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/SupportConstants.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/SupportConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
public class SupportConstants {
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataAdapter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataAdapter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,13 +29,14 @@
import java.util.Map;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingNode;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingNode;
+
/**
* <p>This is an adapter class, it contains another instance of
* QueryMetadataInterface as well as a TempMetadataStore. It defers to
@@ -81,7 +82,7 @@
* Check metadata first, then check temp groups if not found
*/
public Object getElementID(String elementName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Object tempID = null;
try {
@@ -106,7 +107,7 @@
* Check metadata first, then check temp groups if not found
*/
public Object getGroupID(String groupName)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Object tempID = null;
try {
@@ -129,7 +130,7 @@
public Object getModelID(Object groupOrElementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupOrElementID instanceof TempMetadataID) {
return TempMetadataAdapter.TEMP_MODEL;
@@ -139,7 +140,7 @@
// SPECIAL: Override for temp groups
public String getFullName(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(metadataID instanceof TempMetadataID) {
return ((TempMetadataID)metadataID).getID();
@@ -149,7 +150,7 @@
// SPECIAL: Override for temp groups
public List getElementIDsInGroupID(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return new ArrayList(((TempMetadataID)groupID).getElements());
@@ -159,7 +160,7 @@
// SPECIAL: Override for temp groups
public Object getGroupIDForElementID(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof TempMetadataID) {
String elementName = ((TempMetadataID)elementID).getID();
@@ -171,7 +172,7 @@
// SPECIAL: Override for temp groups
public String getElementType(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof TempMetadataID) {
TempMetadataID tempID = (TempMetadataID)elementID;
@@ -186,7 +187,7 @@
}
public Object getDefaultValue(Object elementID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof TempMetadataID) {
return null;
@@ -197,7 +198,7 @@
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaximumValue(java.lang.Object)
*/
- public Object getMaximumValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMaximumValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
elementID = id.getOriginalMetadataID();
@@ -211,7 +212,7 @@
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getMinimumValue(java.lang.Object)
*/
- public Object getMinimumValue(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public Object getMinimumValue(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
elementID = id.getOriginalMetadataID();
@@ -223,9 +224,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getDistinctValues(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getDistinctValues(java.lang.Object)
*/
- public int getDistinctValues(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getDistinctValues(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof TempMetadataID) {
return -1;
}
@@ -233,9 +234,9 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getNullValues(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getNullValues(java.lang.Object)
*/
- public int getNullValues(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getNullValues(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
elementID = id.getOriginalMetadataID();
@@ -247,7 +248,7 @@
}
public QueryNode getVirtualPlan(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (this.queryNodes != null && this.queryNodes.containsKey(groupID)) {
return (QueryNode)this.queryNodes.get(groupID);
@@ -261,7 +262,7 @@
// SPECIAL: Override for temp groups
public boolean isVirtualGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return ((TempMetadataID)groupID).isVirtual();
@@ -270,11 +271,11 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#hasMaterialization(java.lang.Object)
* @since 4.2
*/
public boolean hasMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
// check if any dynamic materialization tables are defined
if (this.materializationTables != null && this.materializationTables.containsKey(groupID)) {
@@ -289,11 +290,11 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaterialization(java.lang.Object)
* @since 4.2
*/
public Object getMaterialization(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
// check if any dynamic materialization tables are defined
if (this.materializationTables != null && this.materializationTables.containsKey(groupID)) {
@@ -308,11 +309,11 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getMaterializationStage(java.lang.Object)
* @since 4.2
*/
public Object getMaterializationStage(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return null;
@@ -323,7 +324,7 @@
}
public boolean isVirtualModel(Object modelID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(modelID.equals(TEMP_MODEL)) {
return true;
@@ -334,7 +335,7 @@
// --------------------- Implement OptimizerMetadata -------------------
public boolean elementSupports(Object elementID, int supportConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
@@ -362,10 +363,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getIndexesInGroup(java.lang.Object)
*/
public Collection getIndexesInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return Collections.EMPTY_LIST;
}
@@ -373,7 +374,7 @@
}
public Collection getUniqueKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return Collections.EMPTY_LIST;
@@ -382,7 +383,7 @@
}
public Collection getForeignKeysInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return Collections.EMPTY_LIST;
@@ -391,21 +392,21 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInIndex(java.lang.Object)
*/
public List getElementIDsInIndex(Object index)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return this.actualMetadata.getElementIDsInIndex(index);
}
public List getElementIDsInKey(Object keyID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return this.actualMetadata.getElementIDsInKey(keyID);
}
public boolean groupSupports(Object groupID, int groupConstant)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID){
return true;
@@ -415,13 +416,13 @@
}
public MappingNode getMappingNode(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return this.actualMetadata.getMappingNode(groupID);
}
public boolean isXMLGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return false;
@@ -430,19 +431,19 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getVirtualDatabaseName()
*/
public String getVirtualDatabaseName()
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
return this.actualMetadata.getVirtualDatabaseName();
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getAccessPatternsInGroup(Object)
*/
public Collection getAccessPatternsInGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)groupID;
@@ -453,10 +454,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getElementIDsInAccessPattern(Object)
*/
public List getElementIDsInAccessPattern(Object accessPattern)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (accessPattern instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)accessPattern;
@@ -470,7 +471,7 @@
}
public Collection getXMLTempGroups(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
if(groupID instanceof TempMetadataID) {
return Collections.EMPTY_SET;
@@ -479,7 +480,7 @@
}
public int getCardinality(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
if(groupID instanceof TempMetadataID) {
return ((TempMetadataID)groupID).getCardinality();
@@ -490,7 +491,7 @@
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getXMLSchemas(java.lang.Object)
*/
- public List getXMLSchemas(Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public List getXMLSchemas(Object groupID) throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return Collections.EMPTY_LIST;
}
@@ -501,7 +502,7 @@
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getExtensionProperties(java.lang.Object)
*/
public Properties getExtensionProperties(Object metadataID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if(metadataID instanceof TempMetadataID) {
return null;
@@ -512,7 +513,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.metadata.QueryMetadataInterface#getElementLength(java.lang.Object)
*/
- public int getElementLength(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getElementLength(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
Object origElementID = id.getOriginalMetadataID();
@@ -529,7 +530,7 @@
return actualMetadata.getElementLength(elementID);
}
- public int getPosition(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPosition(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
String elementName = ((TempMetadataID)elementID).getID();
String groupName = elementName.substring(0, elementName.lastIndexOf(SEPARATOR));
@@ -540,7 +541,7 @@
return actualMetadata.getPosition(elementID);
}
- public int getPrecision(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getPrecision(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
elementID = id.getOriginalMetadataID();
@@ -551,7 +552,7 @@
return actualMetadata.getPrecision(elementID);
}
- public int getRadix(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getRadix(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
elementID = id.getOriginalMetadataID();
@@ -562,7 +563,7 @@
return actualMetadata.getRadix(elementID);
}
- public int getScale(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public int getScale(Object elementID) throws TeiidComponentException, QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
elementID = id.getOriginalMetadataID();
@@ -575,10 +576,10 @@
/**
* Get the native type name for the element.
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getNativeType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getNativeType(java.lang.Object)
* @since 4.2
*/
- public String getNativeType(Object elementID) throws MetaMatrixComponentException,
+ public String getNativeType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
if (elementID instanceof TempMetadataID) {
TempMetadataID id = (TempMetadataID)elementID;
@@ -594,7 +595,7 @@
/*
* @see com.metamatrix.query.metadata.QueryMetadataInterface#isProcedureInputElement(java.lang.Object)
*/
- public boolean isProcedure(Object elementID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isProcedure(Object elementID) throws TeiidComponentException, QueryMetadataException {
if(elementID instanceof TempMetadataID) {
Object oid = ((TempMetadataID) elementID).getOriginalMetadataID();
if (oid != null) {
@@ -607,10 +608,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledType(java.lang.Object)
* @since 5.0
*/
- public String getModeledType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
if (elementID instanceof TempMetadataID) {
@@ -625,10 +626,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledBaseType(java.lang.Object)
* @since 5.0
*/
- public String getModeledBaseType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledBaseType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
if (elementID instanceof TempMetadataID) {
@@ -643,10 +644,10 @@
}
/**
- * @see com.metamatrix.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
+ * @see org.teiid.query.metadata.QueryMetadataInterface#getModeledPrimitiveType(java.lang.Object)
* @since 5.0
*/
- public String getModeledPrimitiveType(Object elementID) throws MetaMatrixComponentException,
+ public String getModeledPrimitiveType(Object elementID) throws TeiidComponentException,
QueryMetadataException {
if (elementID instanceof TempMetadataID) {
@@ -660,7 +661,7 @@
return actualMetadata.getModeledPrimitiveType(elementID);
}
- public boolean isTemporaryTable(Object groupID) throws MetaMatrixComponentException, QueryMetadataException {
+ public boolean isTemporaryTable(Object groupID) throws TeiidComponentException, QueryMetadataException {
if(groupID instanceof TempMetadataID) {
return ((TempMetadataID)groupID).isTempTable();
}
@@ -670,7 +671,7 @@
@Override
public Object addToMetadataCache(Object metadataID, String key, Object value)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (metadataID instanceof TempMetadataID) {
TempMetadataID tid = (TempMetadataID)metadataID;
return tid.setProperty(key, value);
@@ -681,7 +682,7 @@
@Override
public Object getFromMetadataCache(Object metadataID, String key)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (metadataID instanceof TempMetadataID) {
TempMetadataID tid = (TempMetadataID)metadataID;
return tid.getProperty(key);
@@ -692,7 +693,7 @@
@Override
public boolean isScalarGroup(Object groupID)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (groupID instanceof TempMetadataID) {
TempMetadataID tid = (TempMetadataID)groupID;
return tid.isScalarGroup();
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataID.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataID.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.io.Serializable;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.core.util.LRUCache;
+import org.teiid.core.util.LRUCache;
+
/**
* This class represents a temporary metadata ID. A temporary metadata ID
* does not exist in a real metadata source. Rather, it is used temporarily
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/metadata/TempMetadataStore.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/TempMetadataStore.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.metadata;
+package org.teiid.query.metadata;
import java.io.Serializable;
import java.util.ArrayList;
@@ -29,14 +29,15 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
/**
* Store for temporary metadata discovering while resolving a query.
*/
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/CommandPlanner.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/CommandPlanner.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/CommandPlanner.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/CommandPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,62 @@
+/*
+ * 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.optimizer;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
+
+
+/**
+ * <p>The common interface of all planners which take a user's command
+ * object and produce a
+ * {@link org.teiid.query.processor.ProcessorPlan ProcessorPlan}
+ * object, which is a plan for executing the query.</p>
+ */
+public interface CommandPlanner {
+
+ /**
+ * Allows the planner a chance to optimize the canonical plan(s) stored in
+ * the CommandTreeNode tree. This method should be called in a bottom-up
+ * manner; from leaf nodes up to the root node.
+ * @param command TODO
+ * @param metadata source of metadata
+ * @param capFinder Class usable to find the connector capabilities for a particular model
+ * @param context
+ * @param debug whether or not to generate verbose debug output during planning
+ * @return ProcessorPlan implementation specific to the CommandPlanner
+ * @throws QueryPlannerException indicating a problem in planning
+ * @throws QueryMetadataException indicating an exception in accessing the metadata
+ * @throws TeiidComponentException indicating an unexpected exception
+ */
+ ProcessorPlan optimize(Command command, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException;
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/QueryOptimizer.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/QueryOptimizer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,127 @@
+/*
+ * 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.optimizer;
+
+import java.util.Map;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.id.IntegerIDFactory;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.batch.BatchedUpdatePlanner;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.proc.ProcedurePlanner;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.xml.XMLPlanner;
+import org.teiid.query.optimizer.xquery.XQueryPlanner;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.util.CommandContext;
+
+
+/**
+ * <p>This Class produces a ProcessorPlan object (a plan for query execution) from a
+ * user's command and a source of metadata.</p>
+ *
+ * <p>The user's Command object may in fact be a tree of commands and subcommands.
+ * This component is architected to defer to the proper
+ * {@link CommandPlanner CommandPlanner} implementation to plan each Command in the
+ * tree.</p>
+ */
+public class QueryOptimizer {
+
+ private static final CommandPlanner XML_PLANNER = new XMLPlanner();
+ private static final CommandPlanner PROCEDURE_PLANNER = new ProcedurePlanner();
+ private static final CommandPlanner XQUERY_PLANNER = new XQueryPlanner();
+ private static final CommandPlanner BATCHED_UPDATE_PLANNER = new BatchedUpdatePlanner();
+
+ // Can't construct
+ private QueryOptimizer() {}
+
+ public static ProcessorPlan optimizePlan(Command command, QueryMetadataInterface metadata, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
+
+ if (analysisRecord == null) {
+ analysisRecord = new AnalysisRecord(false, false);
+ }
+
+ if (context == null) {
+ context = new CommandContext();
+ }
+
+ boolean debug = analysisRecord.recordDebug();
+
+ Map tempMetadata = command.getTemporaryMetadata();
+ metadata = new TempMetadataAdapter(metadata, new TempMetadataStore(tempMetadata));
+
+ // Create an ID generator that can be used for all plans to generate unique data node IDs
+ if(idGenerator == null) {
+ idGenerator = new IDGenerator();
+ idGenerator.setDefaultFactory(new IntegerIDFactory());
+ }
+
+ if(debug) {
+ analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
+ analysisRecord.println("OPTIMIZE: \n" + command); //$NON-NLS-1$
+ }
+
+ ProcessorPlan result = null;
+
+ if (command.getType() == Command.TYPE_UPDATE_PROCEDURE){
+ result = PROCEDURE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ } else if (command.getType() == Command.TYPE_XQUERY){
+ result = XQUERY_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ } else if (command.getType() == Command.TYPE_BATCHED_UPDATE){
+ result = BATCHED_UPDATE_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ } else {
+ try {
+ if (command.getType() == Command.TYPE_QUERY && command instanceof Query && QueryResolver.isXMLQuery((Query)command, metadata)) {
+ result = XML_PLANNER.optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ } else {
+ result = new RelationalPlanner().optimize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+ }
+ } catch (QueryResolverException e) {
+ throw new TeiidRuntimeException(e);
+ }
+ }
+
+ if(debug) {
+ analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
+ analysisRecord.println("OPTIMIZATION COMPLETE:"); //$NON-NLS-1$
+ analysisRecord.println("PROCESSOR PLAN:\n" + result); //$NON-NLS-1$
+ analysisRecord.println("============================================================================"); //$NON-NLS-1$
+ }
+
+ return result;
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/batch (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/batch/BatchedUpdatePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/batch/BatchedUpdatePlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/batch/BatchedUpdatePlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,42 +20,43 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.batch;
+package org.teiid.query.optimizer.batch;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.id.IntegerID;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.rules.CapabilitiesUtil;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.batch.BatchedUpdatePlan;
-import com.metamatrix.query.processor.relational.BatchedUpdateNode;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.id.IntegerID;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.CommandPlanner;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.rules.CapabilitiesUtil;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.batch.BatchedUpdatePlan;
+import org.teiid.query.processor.relational.BatchedUpdateNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.util.CommandContext;
+
/**
* Planner for BatchedUpdateCommands
* @since 4.2
@@ -82,7 +83,7 @@
* </ol>
* <br/> this implementation will batch as follows: (1,2), (5, 6, 7), (8 thru 12).
* The remaining commands/plans will be executed individually.
- * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(Command, com.metamatrix.core.id.IDGenerator, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
+ * @see org.teiid.query.optimizer.CommandPlanner#optimize(Command, org.teiid.core.id.IDGenerator, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.analysis.AnalysisRecord, CommandContext)
* @since 4.2
*/
public ProcessorPlan optimize(Command command,
@@ -90,7 +91,7 @@
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder,
AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand)command;
List childPlans = new ArrayList(batchedUpdateCommand.getUpdateCommands().size());
List updateCommands = batchedUpdateCommand.getUpdateCommands();
@@ -196,7 +197,7 @@
} else if (type == Command.TYPE_DELETE) {
return ((Delete)command).getGroup();
}
- throw new MetaMatrixRuntimeException(QueryExecPlugin.Util.getString("BatchedUpdatePlanner.unrecognized_command", command)); //$NON-NLS-1$
+ throw new TeiidRuntimeException(QueryExecPlugin.Util.getString("BatchedUpdatePlanner.unrecognized_command", command)); //$NON-NLS-1$
}
/**
@@ -205,10 +206,10 @@
* @param metadata
* @return true if this command can be added to a batch; false otherwise
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.2
*/
- public static boolean isEligibleForBatching(Command command, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ public static boolean isEligibleForBatching(Command command, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
// If the command updates a physical group, it's eligible
return !metadata.isVirtualGroup(getUpdatedGroup(command).getMetadataID());
}
@@ -221,10 +222,10 @@
* @param capFinder
* @return true if this command can be place in a batch associated with the model ID; false otherwise
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.2
*/
- private static boolean canBeAddedToBatch(Command command, Object batchModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
+ private static boolean canBeAddedToBatch(Command command, Object batchModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
// If it's eligible ...
if (isEligibleForBatching(command, metadata)) {
Object modelID = metadata.getModelID(getUpdatedGroup(command).getMetadataID());
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/BasicSourceCapabilities.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/BasicSourceCapabilities.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
import java.io.Serializable;
import java.util.*;
@@ -92,7 +92,7 @@
}
/**
- * @see com.metamatrix.query.optimizer.capabilities.SourceCapabilities#getSourceProperty(java.lang.String)
+ * @see org.teiid.query.optimizer.capabilities.SourceCapabilities#getSourceProperty(java.lang.String)
* @since 4.2
*/
public Object getSourceProperty(Capability propertyName) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/CapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/CapabilitiesFinder.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/CapabilitiesFinder.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
+import org.teiid.core.TeiidComponentException;
/**
* This interface describes how to find connector capabilities.
*/
public interface CapabilitiesFinder {
- public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException;
+ public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/DefaultCapabilitiesFinder.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/DefaultCapabilitiesFinder.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/DefaultCapabilitiesFinder.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
+import org.teiid.core.TeiidComponentException;
/**
*/
@@ -43,7 +43,7 @@
/* (non-Javadoc)
* @see com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder#findCapabilities(java.lang.Object)
*/
- public SourceCapabilities findCapabilities(String modelName) throws MetaMatrixComponentException {
+ public SourceCapabilities findCapabilities(String modelName) throws TeiidComponentException {
return capabilities;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/capabilities/SourceCapabilities.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/capabilities/SourceCapabilities.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.capabilities;
+package org.teiid.query.optimizer.capabilities;
public interface SourceCapabilities {
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/proc (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/proc/ProcedurePlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/proc/ProcedurePlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/proc/ProcedurePlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,56 +20,57 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.proc;
+package org.teiid.query.optimizer.proc;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.proc.AssignmentInstruction;
-import com.metamatrix.query.processor.proc.BreakInstruction;
-import com.metamatrix.query.processor.proc.ContinueInstruction;
-import com.metamatrix.query.processor.proc.CreateCursorResultSetInstruction;
-import com.metamatrix.query.processor.proc.ErrorInstruction;
-import com.metamatrix.query.processor.proc.ExecDynamicSqlInstruction;
-import com.metamatrix.query.processor.proc.IfInstruction;
-import com.metamatrix.query.processor.proc.LoopInstruction;
-import com.metamatrix.query.processor.proc.ProcedurePlan;
-import com.metamatrix.query.processor.proc.WhileInstruction;
-import com.metamatrix.query.processor.program.Program;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.TranslatableProcedureContainer;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.proc.RaiseErrorStatement;
-import com.metamatrix.query.sql.proc.Statement;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.CommandPlanner;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.proc.AssignmentInstruction;
+import org.teiid.query.processor.proc.BreakInstruction;
+import org.teiid.query.processor.proc.ContinueInstruction;
+import org.teiid.query.processor.proc.CreateCursorResultSetInstruction;
+import org.teiid.query.processor.proc.ErrorInstruction;
+import org.teiid.query.processor.proc.ExecDynamicSqlInstruction;
+import org.teiid.query.processor.proc.IfInstruction;
+import org.teiid.query.processor.proc.LoopInstruction;
+import org.teiid.query.processor.proc.ProcedurePlan;
+import org.teiid.query.processor.proc.WhileInstruction;
+import org.teiid.query.processor.program.Program;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.TranslatableProcedureContainer;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.proc.RaiseErrorStatement;
+import org.teiid.query.sql.proc.Statement;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.visitor.CommandCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+
/**
- * <p> This prepares an {@link com.metamatrix.query.processor.proc.ProcedurePlan ProcedurePlan} from
- * a CreateUpdateProcedureCommand {@link com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand CreateUpdateProcedureCommand}.
+ * <p> This prepares an {@link org.teiid.query.processor.proc.ProcedurePlan ProcedurePlan} from
+ * a CreateUpdateProcedureCommand {@link org.teiid.query.sql.proc.CreateUpdateProcedureCommand CreateUpdateProcedureCommand}.
* </p>
*/
public final class ProcedurePlanner implements CommandPlanner {
@@ -83,10 +84,10 @@
* @return ProcessorPlan This processorPlan is a <code>ProcedurePlan</code>
* @throws QueryPlannerException indicating a problem in planning
* @throws QueryMetadataException indicating an exception in accessing the metadata
- * @throws MetaMatrixComponentException indicating an unexpected exception
+ * @throws TeiidComponentException indicating an unexpected exception
*/
public ProcessorPlan optimize(Command procCommand, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
boolean debug = analysisRecord.recordDebug();
if(debug) {
@@ -155,10 +156,10 @@
* @return A Program resulting in the block planning
* @throws QueryPlannerException if invalid statement is encountered in the block
* @throws QueryMetadataException if there is an error accessing metadata
- * @throws MetaMatrixComponentException if unexpected error occurs
+ * @throws TeiidComponentException if unexpected error occurs
*/
private Program planBlock(CreateUpdateProcedureCommand parentProcCommand, Block block, QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// Generate program and add instructions
// this program represents the block on the procedure
@@ -196,10 +197,10 @@
* in the statement planning
* @throws QueryPlannerException if invalid statement is encountered
* @throws QueryMetadataException if there is an error accessing metadata
- * @throws MetaMatrixComponentException if unexpected error occurs
+ * @throws TeiidComponentException if unexpected error occurs
*/
private Object planStatement(CreateUpdateProcedureCommand parentProcCommand, Statement statement, QueryMetadataInterface metadata, boolean debug, IDGenerator idGenerator, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
int stmtType = statement.getType();
// object array containing updated child index and the process instruction
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/AliasGenerator.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/AliasGenerator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,371 @@
+/*
+ * 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.optimizer.relational;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+
+
+/**
+ * Adds safe (generated) aliases to the source command
+ *
+ * The structure is a little convoluted:
+ * AliasGenerator - structure navigator, alters the command by adding alias symbols
+ * NamingVisitor - changes the output names of Element and Group symbols
+ * SQLNamingContext - a hierarchical context for tracking Element and Group names
+ */
+public class AliasGenerator extends PreOrderNavigator {
+
+ private static class NamingVisitor extends LanguageVisitor {
+
+ private class SQLNamingContext {
+ SQLNamingContext parent;
+
+ Map<String, Map<String, String>> elementMap = new HashMap<String, Map<String, String>>();
+ Map<String, String> groupNames = new HashMap<String, String>();
+ Map<SingleElementSymbol, String> currentSymbols;
+
+ boolean aliasColumns = false;
+
+ public SQLNamingContext(SQLNamingContext parent) {
+ this.parent = parent;
+ }
+
+ public String getElementName(SingleElementSymbol symbol, boolean renameGroup) {
+ String name = null;
+ if (currentSymbols != null) {
+ name = currentSymbols.get(symbol);
+ if (name != null) {
+ if (renameGroup && symbol instanceof ElementSymbol) {
+ renameGroup(((ElementSymbol)symbol).getGroupSymbol());
+ }
+ return name;
+ }
+ }
+ if (!(symbol instanceof ElementSymbol)) {
+ return null;
+ }
+ ElementSymbol element = (ElementSymbol)symbol;
+ Map<String, String> elements = this.elementMap.get(element.getGroupSymbol().getCanonicalName());
+ if (elements != null) {
+ name = elements.get(element.getShortCanonicalName());
+ if (name != null) {
+ if (renameGroup) {
+ renameGroup(element.getGroupSymbol());
+ }
+ return name;
+ }
+ }
+ if (parent != null) {
+ name = parent.getElementName(symbol, renameGroup);
+ if (name != null) {
+ return name;
+ }
+ }
+ if (renameGroup) {
+ renameGroup(element.getGroupSymbol());
+ }
+ return null;
+ }
+
+ public void renameGroup(GroupSymbol obj) {
+ if (aliasGroups) {
+ String definition = obj.getNonCorrelationName();
+ String newAlias = getGroupName(obj.getCanonicalName());
+ if (newAlias == null) {
+ return;
+ }
+ obj.setOutputName(newAlias);
+ obj.setOutputDefinition(definition);
+ } else if(obj.getDefinition() != null) {
+ obj.setOutputName(obj.getDefinition());
+ obj.setOutputDefinition(null);
+ }
+ }
+
+ private String getGroupName(String group) {
+ String groupName = groupNames.get(group);
+ if (groupName == null) {
+ if (parent == null) {
+ return null;
+ }
+ return parent.getGroupName(group);
+ }
+ return groupName;
+ }
+ }
+
+ private SQLNamingContext namingContext = new SQLNamingContext(null);
+ boolean aliasGroups;
+
+ public NamingVisitor(boolean aliasGroups) {
+ this.aliasGroups = aliasGroups;
+ }
+
+ /**
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.symbol.ElementSymbol)
+ */
+ @Override
+ public void visit(ElementSymbol obj) {
+ GroupSymbol group = obj.getGroupSymbol();
+ if(group == null) {
+ return;
+ }
+ String newName = namingContext.getElementName(obj, true);
+
+ if (newName == null) {
+ newName = ElementSymbol.getShortName(obj.getOutputName());
+ }
+
+ obj.setOutputName(group.getOutputName() + ElementSymbol.SEPARATOR + newName);
+ obj.setDisplayMode(ElementSymbol.DisplayMode.OUTPUT_NAME);
+ }
+
+ /**
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.symbol.GroupSymbol)
+ */
+ @Override
+ public void visit(GroupSymbol obj) {
+ this.namingContext.renameGroup(obj);
+ }
+
+ public void createChildNamingContext(boolean aliasColumns) {
+ this.namingContext = new SQLNamingContext(this.namingContext);
+ this.namingContext.aliasColumns = aliasColumns;
+ }
+
+ public void removeChildNamingContext() {
+ this.namingContext = this.namingContext.parent;
+ }
+
+ }
+
+ private NamingVisitor visitor;
+ private int groupIndex = 0;
+ private int viewIndex = 0;
+
+ public AliasGenerator(boolean aliasGroups) {
+ super(new NamingVisitor(aliasGroups));
+ this.visitor = (NamingVisitor)this.getVisitor();
+ }
+
+ /**
+ * visit the branches other than the first with individual naming contexts
+ * Aliases are being added in all cases, even though they may only be needed in the order by case.
+ * Adding the same alias to all branches ensures cross db support (db2 in particular)
+ */
+ public void visit(SetQuery obj) {
+ visitor.createChildNamingContext(true);
+ visitNode(obj.getRightQuery());
+ visitor.removeChildNamingContext();
+ visitor.namingContext.aliasColumns = true;
+ visitNode(obj.getLeftQuery());
+ visitNode(obj.getOrderBy());
+ }
+
+ public void visit(Select obj) {
+ List selectSymbols = obj.getSymbols();
+ HashMap<SingleElementSymbol, String> symbols = new HashMap<SingleElementSymbol, String>(selectSymbols.size());
+ for (int i = 0; i < selectSymbols.size(); i++) {
+ SingleElementSymbol symbol = (SingleElementSymbol)selectSymbols.get(i);
+
+ String newAlias = "c_" + i; //$NON-NLS-1$
+
+ boolean needsAlias = true;
+
+ Expression expr = SymbolMap.getExpression(symbol);
+
+ SingleElementSymbol newSymbol = symbol;
+
+ if (!(expr instanceof SingleElementSymbol)) {
+ newSymbol = new ExpressionSymbol(newSymbol.getShortName(), expr);
+ } else if (expr instanceof ElementSymbol) {
+ if (!needsAlias(newAlias, (ElementSymbol)expr)) {
+ needsAlias = false;
+ ((ElementSymbol)expr).setOutputName(newAlias);
+ }
+ newSymbol = (ElementSymbol)expr;
+ } else {
+ newSymbol = (SingleElementSymbol)expr;
+ }
+
+ symbols.put(symbol, newAlias);
+ if (visitor.namingContext.aliasColumns && needsAlias) {
+ newSymbol = new AliasSymbol(symbol.getShortName(), newSymbol);
+ newSymbol.setOutputName(newAlias);
+ }
+ selectSymbols.set(i, newSymbol);
+ }
+
+ super.visit(obj);
+ visitor.namingContext.currentSymbols = symbols;
+ }
+
+ private boolean needsAlias(String newAlias,
+ ElementSymbol symbol) {
+ return !(symbol.getMetadataID() instanceof TempMetadataID) || !newAlias.equalsIgnoreCase(visitor.namingContext.getElementName(symbol, false));
+ }
+
+ /**
+ * visit the query in definition order
+ */
+ public void visit(Query obj) {
+ if (obj.getOrderBy() != null || obj.getLimit() != null) {
+ visitor.namingContext.aliasColumns = true;
+ }
+ visitNode(obj.getFrom());
+ visitNode(obj.getCriteria());
+ visitNode(obj.getGroupBy());
+ visitNode(obj.getHaving());
+ visitNode(obj.getSelect());
+ visitNode(obj.getOrderBy());
+ }
+
+ public void visit(SubqueryFromClause obj) {
+ visitor.createChildNamingContext(true);
+ obj.getCommand().acceptVisitor(this);
+ Map<String, String> viewGroup = new HashMap<String, String>();
+ for (Entry<SingleElementSymbol, String> entry : visitor.namingContext.currentSymbols.entrySet()) {
+ viewGroup.put(entry.getKey().getShortCanonicalName(), entry.getValue());
+ }
+ visitor.namingContext.parent.elementMap.put(obj.getName().toUpperCase(), viewGroup);
+ visitor.removeChildNamingContext();
+ obj.getGroupSymbol().setOutputName(recontextGroup(obj.getGroupSymbol(), true));
+ }
+
+ @Override
+ public void visit(UnaryFromClause obj) {
+ if (visitor.aliasGroups) {
+ GroupSymbol symbol = obj.getGroup();
+ recontextGroup(symbol, false);
+ }
+ super.visit(obj);
+ }
+
+ /**
+ * @param symbol
+ */
+ private String recontextGroup(GroupSymbol symbol, boolean virtual) {
+ String newAlias = null;
+ if (virtual) {
+ newAlias = "v_" + viewIndex++; //$NON-NLS-1$
+ } else {
+ newAlias = "g_" + groupIndex++; //$NON-NLS-1$
+ }
+ visitor.namingContext.groupNames.put(symbol.getName().toUpperCase(), newAlias);
+ return newAlias;
+ }
+
+ public void visit(ScalarSubquery obj) {
+ visitor.createChildNamingContext(false);
+ visitNode(obj.getCommand());
+ visitor.removeChildNamingContext();
+ }
+
+ public void visit(SubqueryCompareCriteria obj) {
+ visitNode(obj.getLeftExpression());
+ visitor.createChildNamingContext(false);
+ visitNode(obj.getCommand());
+ visitor.removeChildNamingContext();
+ }
+
+ public void visit(SubquerySetCriteria obj) {
+ visitNode(obj.getExpression());
+ visitor.createChildNamingContext(false);
+ visitNode(obj.getCommand());
+ visitor.removeChildNamingContext();
+ }
+
+ public void visit(ExistsCriteria obj) {
+ visitor.createChildNamingContext(false);
+ visitNode(obj.getCommand());
+ visitor.removeChildNamingContext();
+ }
+
+ public void visit(OrderBy obj) {
+ //add/correct aliases if necessary
+ for (int i = 0; i < obj.getVariableCount(); i++) {
+ OrderByItem item = obj.getOrderByItems().get(i);
+ SingleElementSymbol element = item.getSymbol();
+ if (item.isUnrelated()) {
+ visitNode(element);
+ continue;
+ }
+ String name = visitor.namingContext.getElementName(element, false);
+ if (name != null) {
+ boolean needsAlias = true;
+
+ Expression expr = SymbolMap.getExpression(element);
+
+ if (!(expr instanceof SingleElementSymbol)) {
+ expr = new ExpressionSymbol(element.getShortName(), expr);
+ } else if (expr instanceof ElementSymbol) {
+ needsAlias = needsAlias(name, (ElementSymbol)expr);
+ }
+
+ if (needsAlias) {
+ element = new AliasSymbol(element.getShortName(), (SingleElementSymbol)expr);
+ obj.getOrderByItems().get(i).setSymbol(element);
+ }
+ element.setOutputName(name);
+ }
+
+ visitNode(element);
+
+ if (name != null && element instanceof ElementSymbol) {
+ element.setOutputName(SingleElementSymbol.getShortName(element.getOutputName()));
+ }
+ }
+ }
+
+ public void visit(Reference obj) {
+ //we need to follow references to correct correlated variables
+ visitNode(obj.getExpression());
+ }
+
+}
\ No newline at end of file
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/OptimizerRule.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/OptimizerRule.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/OptimizerRule.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/OptimizerRule.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,39 @@
+/*
+ * 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.optimizer.relational;
+
+import org.teiid.api.exception.query.*;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.*;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.util.CommandContext;
+
+
+public interface OptimizerRule {
+
+ PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capabilitiesFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException;
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanHints.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanHints.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanHints.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanHints.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,54 @@
+/*
+ * 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.optimizer.relational;
+
+
+public final class PlanHints {
+
+ // This flag indicates that the plan has a criteria somewhere
+ public boolean hasCriteria = false;
+
+ // This flag indicates that the plan has a join somewhere
+ public boolean hasJoin = false;
+
+ // This flag indicates that the plan has a virtual group somewhere
+ public boolean hasVirtualGroups = false;
+
+ // flag indicates that the plan has a union somewhere
+ public boolean hasSetQuery = false;
+
+ // flag indicating that the plan has a grouping node somewhere
+ public boolean hasAggregates = false;
+
+ public boolean hasLimit = false;
+
+ public boolean hasOptionalJoin = false;
+
+ public boolean hasRelationalProc = false;
+
+ public PlanHints() { }
+
+ public String toString(){
+ return "PlanHints"; //$NON-NLS-1$
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/PlanToProcessConverter.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/PlanToProcessConverter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,488 @@
+/*
+ * 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.optimizer.relational;
+
+import java.util.Collection;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.CoreConstants;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.id.IntegerID;
+import org.teiid.core.id.IntegerIDFactory;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.optimizer.relational.rules.CapabilitiesUtil;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.DependentAccessNode;
+import org.teiid.query.processor.relational.DependentProcedureAccessNode;
+import org.teiid.query.processor.relational.DependentProcedureExecutionNode;
+import org.teiid.query.processor.relational.GroupingNode;
+import org.teiid.query.processor.relational.InsertPlanExecutionNode;
+import org.teiid.query.processor.relational.JoinNode;
+import org.teiid.query.processor.relational.LimitNode;
+import org.teiid.query.processor.relational.MergeJoinStrategy;
+import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
+import org.teiid.query.processor.relational.NullNode;
+import org.teiid.query.processor.relational.PartitionedSortJoin;
+import org.teiid.query.processor.relational.PlanExecutionNode;
+import org.teiid.query.processor.relational.ProjectIntoNode;
+import org.teiid.query.processor.relational.ProjectNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.processor.relational.SelectNode;
+import org.teiid.query.processor.relational.SortNode;
+import org.teiid.query.processor.relational.UnionAllNode;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
+
+public class PlanToProcessConverter {
+ protected QueryMetadataInterface metadata;
+ private IDGenerator idGenerator;
+ private AnalysisRecord analysisRecord;
+ private CapabilitiesFinder capFinder;
+
+ public PlanToProcessConverter(QueryMetadataInterface metadata, IDGenerator idGenerator, AnalysisRecord analysisRecord, CapabilitiesFinder capFinder) {
+ this.metadata = metadata;
+ this.idGenerator = idGenerator;
+ this.analysisRecord = analysisRecord;
+ this.capFinder = capFinder;
+ }
+
+ public RelationalPlan convert(PlanNode planNode)
+ throws QueryPlannerException, TeiidComponentException {
+
+ boolean debug = analysisRecord.recordDebug();
+ if(debug) {
+ analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
+ analysisRecord.println("CONVERTING PLAN TREE TO PROCESS TREE"); //$NON-NLS-1$
+ }
+
+ // Convert plan tree nodes into process tree nodes
+ RelationalNode processNode = convertPlan(planNode);
+ if(debug) {
+ analysisRecord.println("\nPROCESS PLAN = \n" + processNode); //$NON-NLS-1$
+ analysisRecord.println("============================================================================"); //$NON-NLS-1$
+ }
+
+ RelationalPlan processPlan = new RelationalPlan(processNode);
+ return processPlan;
+
+ }
+
+ private RelationalNode convertPlan(PlanNode planNode)
+ throws QueryPlannerException, TeiidComponentException {
+
+ // Convert current node in planTree
+ RelationalNode convertedNode = convertNode(planNode);
+
+ if(convertedNode == null) {
+ Assertion.assertTrue(planNode.getChildCount() == 1);
+ return convertPlan(planNode.getFirstChild());
+ }
+
+ RelationalNode nextParent = convertedNode;
+
+ // convertedNode may be the head of 1 or more nodes - go to end of chain
+ while(nextParent.getChildren()[0] != null) {
+ nextParent = nextParent.getChildren()[0];
+ }
+
+ // Call convertPlan recursively on children
+ for (PlanNode childNode : planNode.getChildren()) {
+ nextParent.addChild(convertPlan(childNode));
+ }
+
+ // Return root of tree for top node
+ return convertedNode;
+ }
+
+ protected int getID() {
+ IntegerIDFactory intFactory = (IntegerIDFactory) idGenerator.getDefaultFactory();
+ return ((IntegerID) intFactory.create()).getValue();
+ }
+
+ protected RelationalNode convertNode(PlanNode node)
+ throws QueryPlannerException, TeiidComponentException {
+
+ RelationalNode processNode = null;
+
+ switch(node.getType()) {
+ case NodeConstants.Types.PROJECT:
+ GroupSymbol intoGroup = (GroupSymbol) node.getProperty(NodeConstants.Info.INTO_GROUP);
+ if(intoGroup != null) {
+ try {
+ Insert insert = (Insert)node.getFirstChild().getProperty(Info.VIRTUAL_COMMAND);
+ List<ElementSymbol> allIntoElements = insert.getVariables();
+
+ Object groupID = intoGroup.getMetadataID();
+ Object modelID = metadata.getModelID(groupID);
+ String modelName = metadata.getFullName(modelID);
+ if (metadata.isVirtualGroup(groupID)) {
+ InsertPlanExecutionNode ipen = new InsertPlanExecutionNode(getID(), metadata);
+ ipen.setProcessorPlan((ProcessorPlan)node.getFirstChild().getProperty(Info.PROCESSOR_PLAN));
+ ipen.setReferences(insert.getValues());
+ processNode = ipen;
+ } else {
+ ProjectIntoNode pinode = new ProjectIntoNode(getID());
+ pinode.setIntoGroup(intoGroup);
+ pinode.setIntoElements(allIntoElements);
+ pinode.setModelName(modelName);
+ processNode = pinode;
+ if (!metadata.isTemporaryTable(groupID)) {
+ SourceCapabilities caps = capFinder.findCapabilities(modelName);
+ pinode.setDoBatching(caps.supportsCapability(Capability.BATCHED_UPDATES));
+ pinode.setDoBulkInsert(caps.supportsCapability(Capability.BULK_UPDATE));
+ } else {
+ pinode.setDoBulkInsert(true);
+ }
+ }
+ } catch(QueryMetadataException e) {
+ throw new TeiidComponentException(e);
+ }
+
+ } else {
+ List symbols = (List) node.getProperty(NodeConstants.Info.PROJECT_COLS);
+
+ ProjectNode pnode = new ProjectNode(getID());
+ pnode.setSelectSymbols(symbols);
+ processNode = pnode;
+ }
+ break;
+
+ case NodeConstants.Types.JOIN:
+ JoinType jtype = (JoinType) node.getProperty(NodeConstants.Info.JOIN_TYPE);
+ JoinStrategyType stype = (JoinStrategyType) node.getProperty(NodeConstants.Info.JOIN_STRATEGY);
+
+ JoinNode jnode = new JoinNode(getID());
+ jnode.setJoinType(jtype);
+ jnode.setLeftDistinct(node.hasBooleanProperty(NodeConstants.Info.IS_LEFT_DISTINCT));
+ jnode.setRightDistinct(node.hasBooleanProperty(NodeConstants.Info.IS_RIGHT_DISTINCT));
+ List joinCrits = (List) node.getProperty(NodeConstants.Info.JOIN_CRITERIA);
+ String depValueSource = (String) node.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE);
+ SortOption leftSort = (SortOption)node.getProperty(NodeConstants.Info.SORT_LEFT);
+ if(stype.equals(JoinStrategyType.MERGE) || stype.equals(JoinStrategyType.PARTITIONED_SORT)) {
+ MergeJoinStrategy mjStrategy = null;
+ if (stype.equals(JoinStrategyType.PARTITIONED_SORT)) {
+ mjStrategy = new PartitionedSortJoin(leftSort, (SortOption)node.getProperty(NodeConstants.Info.SORT_RIGHT));
+ } else {
+ mjStrategy = new MergeJoinStrategy(leftSort, (SortOption)node.getProperty(NodeConstants.Info.SORT_RIGHT), false);
+ }
+ jnode.setJoinStrategy(mjStrategy);
+ List leftExpressions = (List) node.getProperty(NodeConstants.Info.LEFT_EXPRESSIONS);
+ List rightExpressions = (List) node.getProperty(NodeConstants.Info.RIGHT_EXPRESSIONS);
+ jnode.setJoinExpressions(leftExpressions, rightExpressions);
+ joinCrits = (List) node.getProperty(NodeConstants.Info.NON_EQUI_JOIN_CRITERIA);
+ } else {
+ NestedLoopJoinStrategy nljStrategy = new NestedLoopJoinStrategy();
+ jnode.setJoinStrategy(nljStrategy);
+ }
+ Criteria joinCrit = Criteria.combineCriteria(joinCrits);
+ jnode.setJoinCriteria(joinCrit);
+
+ processNode = jnode;
+
+ jnode.setDependentValueSource(depValueSource);
+
+ break;
+
+ case NodeConstants.Types.ACCESS:
+ ProcessorPlan plan = (ProcessorPlan) node.getProperty(NodeConstants.Info.PROCESSOR_PLAN);
+ if(plan != null) {
+
+ PlanExecutionNode peNode = null;
+
+ Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.PROCEDURE_CRITERIA);
+
+ if (crit != null) {
+ List references = (List)node.getProperty(NodeConstants.Info.PROCEDURE_INPUTS);
+ List defaults = (List)node.getProperty(NodeConstants.Info.PROCEDURE_DEFAULTS);
+
+ peNode = new DependentProcedureExecutionNode(getID(), crit, references, defaults);
+ } else {
+ peNode = new PlanExecutionNode(getID());
+ }
+
+ peNode.setProcessorPlan(plan);
+ processNode = peNode;
+
+ } else {
+ AccessNode aNode = null;
+ Command command = (Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
+ Object modelID = node.getProperty(NodeConstants.Info.MODEL_ID);
+
+ if(node.hasBooleanProperty(NodeConstants.Info.IS_DEPENDENT_SET)) {
+ if (command instanceof StoredProcedure) {
+ List references = (List)node.getProperty(NodeConstants.Info.PROCEDURE_INPUTS);
+ List defaults = (List)node.getProperty(NodeConstants.Info.PROCEDURE_DEFAULTS);
+ Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.PROCEDURE_CRITERIA);
+
+ DependentProcedureAccessNode depAccessNode = new DependentProcedureAccessNode(getID(), crit, references, defaults);
+ processNode = depAccessNode;
+ aNode = depAccessNode;
+ } else {
+ //create dependent access node
+ DependentAccessNode depAccessNode = new DependentAccessNode(getID());
+
+ if(modelID != null){
+ depAccessNode.setMaxSetSize(CapabilitiesUtil.getMaxInCriteriaSize(modelID, metadata, capFinder));
+ }
+ processNode = depAccessNode;
+ aNode = depAccessNode;
+ }
+ aNode.setShouldEvaluateExpressions(true);
+ } else {
+
+ // create access node
+ aNode = new AccessNode(getID());
+ processNode = aNode;
+
+ //-- special handling for temp tables. currently they cannot perform projection
+ try {
+ if (command instanceof Query) {
+ processNode = correctProjectionInternalTables(node, aNode, (Query)command);
+ }
+ } catch (QueryMetadataException err) {
+ throw new TeiidComponentException(err);
+ }
+ aNode.setShouldEvaluateExpressions(EvaluatableVisitor.needsProcessingEvaluation(command));
+ }
+
+ try {
+ command = (Command)command.clone();
+ command.acceptVisitor(new AliasGenerator(modelID != null && CapabilitiesUtil.supportsGroupAliases(modelID, metadata, capFinder)));
+ } catch (QueryMetadataException err) {
+ throw new TeiidComponentException(err);
+ }
+ aNode.setCommand(command);
+ aNode.setModelName(getRoutingName(node));
+ }
+ break;
+
+ case NodeConstants.Types.SELECT:
+
+ Criteria crit = (Criteria) node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
+
+ SelectNode selnode = new SelectNode(getID());
+ selnode.setCriteria(crit);
+ processNode = selnode;
+
+ break;
+
+ case NodeConstants.Types.SORT:
+ case NodeConstants.Types.DUP_REMOVE:
+ SortNode sortNode = new SortNode(getID());
+ OrderBy orderBy = (OrderBy) node.getProperty(NodeConstants.Info.SORT_ORDER);
+ if (orderBy != null) {
+ sortNode.setSortElements(orderBy.getSortKeys(), orderBy.getTypes());
+ }
+ if (node.getType() == NodeConstants.Types.DUP_REMOVE) {
+ sortNode.setMode(Mode.DUP_REMOVE);
+ } else if (node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL)) {
+ sortNode.setMode(Mode.DUP_REMOVE_SORT);
+ }
+
+ processNode = sortNode;
+ break;
+ case NodeConstants.Types.GROUP:
+ GroupingNode gnode = new GroupingNode(getID());
+ gnode.setGroupingElements( (List) node.getProperty(NodeConstants.Info.GROUP_COLS) );
+ gnode.setRemoveDuplicates(node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL));
+ processNode = gnode;
+ break;
+
+ case NodeConstants.Types.SOURCE:
+ SymbolMap symbolMap = (SymbolMap) node.getProperty(NodeConstants.Info.SYMBOL_MAP);
+ if(symbolMap != null) {
+ PlanNode child = node.getLastChild();
+
+ if (node.getParent().getType() != NodeConstants.Types.PROJECT || node.getParent().getProperty(NodeConstants.Info.INTO_GROUP) == null) {
+ if (child.getType() == NodeConstants.Types.PROJECT) {
+ //update the project cols based upon the original output
+ child.setProperty(NodeConstants.Info.PROJECT_COLS, child.getProperty(NodeConstants.Info.OUTPUT_COLS));
+ }
+ child.setProperty(NodeConstants.Info.OUTPUT_COLS, node.getProperty(NodeConstants.Info.OUTPUT_COLS));
+ }
+ }
+
+ return null;
+
+ case NodeConstants.Types.SET_OP:
+ Operation setOp = (Operation) node.getProperty(NodeConstants.Info.SET_OPERATION);
+ boolean useAll = ((Boolean) node.getProperty(NodeConstants.Info.USE_ALL)).booleanValue();
+ if(setOp == Operation.UNION) {
+ RelationalNode unionAllNode = new UnionAllNode(getID());
+
+ if(useAll) {
+ processNode = unionAllNode;
+ } else {
+ SortNode sNode = new SortNode(getID());
+ boolean onlyDupRemoval = node.hasBooleanProperty(NodeConstants.Info.IS_DUP_REMOVAL);
+ sNode.setMode(onlyDupRemoval?Mode.DUP_REMOVE:Mode.DUP_REMOVE_SORT);
+ processNode = sNode;
+
+ unionAllNode.setElements( (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS) );
+ processNode.addChild(unionAllNode);
+ }
+ } else {
+ JoinNode joinAsSet = new JoinNode(getID());
+ joinAsSet.setJoinStrategy(new MergeJoinStrategy(SortOption.SORT_DISTINCT, SortOption.SORT_DISTINCT, true));
+ List leftExpressions = (List) node.getFirstChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
+ List rightExpressions = (List) node.getLastChild().getProperty(NodeConstants.Info.OUTPUT_COLS);
+ joinAsSet.setJoinType(setOp == Operation.EXCEPT ? JoinType.JOIN_ANTI_SEMI : JoinType.JOIN_SEMI);
+ joinAsSet.setJoinExpressions(leftExpressions, rightExpressions);
+ processNode = joinAsSet;
+ }
+
+ break;
+
+ case NodeConstants.Types.TUPLE_LIMIT:
+ Expression rowLimit = (Expression)node.getProperty(NodeConstants.Info.MAX_TUPLE_LIMIT);
+ Expression offset = (Expression)node.getProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT);
+ processNode = new LimitNode(getID(), rowLimit, offset);
+ break;
+
+ case NodeConstants.Types.NULL:
+ processNode = new NullNode(getID());
+ break;
+
+ default:
+ throw new QueryPlannerException(QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0007, NodeConstants.getNodeTypeString(node.getType())));
+ }
+
+ if(processNode != null) {
+ processNode = prepareToAdd(node, processNode);
+ }
+
+ return processNode;
+ }
+
+ private RelationalNode correctProjectionInternalTables(PlanNode node,
+ AccessNode aNode, Query query) throws QueryMetadataException,
+ TeiidComponentException {
+ if (node.getGroups().size() != 1) {
+ return aNode;
+ }
+ GroupSymbol group = node.getGroups().iterator().next();
+ if (!group.isTempTable() && !CoreConstants.SYSTEM_MODEL.equals(metadata.getFullName(metadata.getModelID(group.getMetadataID())))) {
+ return aNode;
+ }
+ List projectSymbols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS);
+ List<ElementSymbol> acutalColumns = ResolverUtil.resolveElementsInGroup(group, metadata);
+ if (projectSymbols.equals(acutalColumns)) {
+ return aNode;
+ }
+ node.setProperty(NodeConstants.Info.OUTPUT_COLS, acutalColumns);
+ if (node.getParent() != null && node.getParent().getType() == NodeConstants.Types.PROJECT) {
+ //if the parent is already a project, just correcting the output cols is enough
+ return aNode;
+ }
+ ProjectNode pnode = new ProjectNode(getID());
+
+ pnode.setSelectSymbols(projectSymbols);
+ //if the following cast fails it means that we have a dependent temp table - that is not yet possible
+ aNode = (AccessNode)prepareToAdd(node, aNode);
+ node.setProperty(NodeConstants.Info.OUTPUT_COLS, projectSymbols);
+ pnode.addChild(aNode);
+ return pnode;
+ }
+
+ private RelationalNode prepareToAdd(PlanNode node,
+ RelationalNode processNode) {
+ // Set the output elements from the plan node
+ List cols = (List) node.getProperty(NodeConstants.Info.OUTPUT_COLS);
+
+ processNode.setElements(cols);
+
+ // Set the Cost Estimates
+ Number estimateNodeCardinality = (Number) node.getProperty(NodeConstants.Info.EST_CARDINALITY);
+ processNode.setEstimateNodeCardinality(estimateNodeCardinality);
+ Number estimateNodeSetSize = (Number) node.getProperty(NodeConstants.Info.EST_SET_SIZE);
+ processNode.setEstimateNodeSetSize(estimateNodeSetSize);
+ Number estimateDepAccessCardinality = (Number) node.getProperty(NodeConstants.Info.EST_DEP_CARDINALITY);
+ processNode.setEstimateDepAccessCardinality(estimateDepAccessCardinality);
+ Number estimateDepJoinCost = (Number) node.getProperty(NodeConstants.Info.EST_DEP_JOIN_COST);
+ processNode.setEstimateDepJoinCost(estimateDepJoinCost);
+ Number estimateJoinCost = (Number) node.getProperty(NodeConstants.Info.EST_JOIN_COST);
+ processNode.setEstimateJoinCost(estimateJoinCost);
+
+ return processNode;
+ }
+
+ private String getRoutingName(PlanNode node)
+ throws QueryPlannerException, TeiidComponentException {
+
+ // Look up connector binding name
+ try {
+ Object modelID = node.getProperty(NodeConstants.Info.MODEL_ID);
+ if(modelID == null || modelID instanceof TempMetadataID) {
+ Command command = (Command) node.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
+ if(command instanceof StoredProcedure){
+ modelID = ((StoredProcedure)command).getModelID();
+ }else{
+ Collection groups = GroupCollectorVisitor.getGroups(command, true);
+ Iterator groupIter = groups.iterator();
+ GroupSymbol group = (GroupSymbol) groupIter.next();
+
+ modelID = metadata.getModelID(group.getMetadataID());
+ }
+ }
+ String cbName = metadata.getFullName(modelID);
+ return cbName;
+ } catch(QueryMetadataException e) {
+ throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0009));
+ }
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RelationalPlanner.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RelationalPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,970 @@
+/*
+ * 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.optimizer.relational;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.client.plan.Annotation;
+import org.teiid.client.plan.Annotation.Priority;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.dqp.internal.process.Request;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.optimizer.CommandPlanner;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.optimizer.relational.rules.RuleConstants;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.BindVariableVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject.Util;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.Query;
+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.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.CorrelatedReferenceCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+import org.teiid.query.validator.ValidationVisitor;
+
+
+/**
+ * This class generates a relational plan for query execution. The output of
+ * this class is a {@link org.teiid.query.optimizer.relational.plantree.PlanNode PlanNode}
+ * object - this object then becomes the input to
+ * {@link PlanToProcessConverter PlanToProcessConverter}
+ * to produce a
+ * {@link org.teiid.query.processor.relational.RelationalPlan RelationalPlan}.
+ */
+public class RelationalPlanner implements CommandPlanner {
+
+ private AnalysisRecord analysisRecord;
+ private Command parentCommand;
+ private IDGenerator idGenerator;
+ private CommandContext context;
+ private CapabilitiesFinder capFinder;
+ private QueryMetadataInterface metadata;
+ private PlanHints hints = new PlanHints();
+ private Option option;
+
+ /**
+ * @see org.teiid.query.optimizer.CommandPlanner#optimize(com.metamatrix.query.optimizer.CommandTreeNode, java.util.Map, org.teiid.query.metadata.QueryMetadataInterface, boolean)
+ */
+ public ProcessorPlan optimize(
+ Command command,
+ IDGenerator idGenerator,
+ QueryMetadataInterface metadata,
+ CapabilitiesFinder capFinder,
+ AnalysisRecord analysisRecord, CommandContext context)
+ throws
+ QueryPlannerException,
+ QueryMetadataException,
+ TeiidComponentException {
+ initialize(command, idGenerator, metadata, capFinder, analysisRecord, context);
+
+ boolean debug = analysisRecord.recordDebug();
+ if(debug) {
+ analysisRecord.println("\n----------------------------------------------------------------------------"); //$NON-NLS-1$
+ analysisRecord.println("GENERATE CANONICAL: \n" + command); //$NON-NLS-1$
+ }
+ PlanNode plan;
+ try {
+ plan = generatePlan(command);
+ } catch (TeiidProcessingException e) {
+ throw new QueryPlannerException(e, e.getMessage());
+ }
+
+ if(debug) {
+ analysisRecord.println("\nCANONICAL PLAN: \n" + plan); //$NON-NLS-1$
+ }
+
+ // Connect ProcessorPlan to SubqueryContainer (if any) of SELECT or PROJECT nodes
+ connectSubqueryContainers(plan); //TODO: merge with node creation
+
+ // Set top column information on top node
+ List<SingleElementSymbol> topCols = Util.deepClone(command.getProjectedSymbols(), SingleElementSymbol.class);
+
+ // Build rule set based on hints
+ RuleStack rules = RelationalPlanner.buildRules(hints);
+
+ // Run rule-based optimizer
+ plan = executeRules(rules, plan);
+
+ PlanToProcessConverter planToProcessConverter = null;
+ if (context != null) {
+ planToProcessConverter = context.getPlanToProcessConverter();
+ }
+ if (planToProcessConverter == null) {
+ planToProcessConverter = new PlanToProcessConverter(metadata, idGenerator, analysisRecord, capFinder);
+ }
+
+ RelationalPlan result = planToProcessConverter.convert(plan);
+
+ result.setOutputElements(topCols);
+
+ return result;
+ }
+
+ public void initialize(Command command, IDGenerator idGenerator,
+ QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
+ AnalysisRecord analysisRecord, CommandContext context) {
+ this.parentCommand = command;
+ this.idGenerator = idGenerator;
+ this.metadata = metadata;
+ this.capFinder = capFinder;
+ this.analysisRecord = analysisRecord;
+ this.context = context;
+ }
+
+ private void connectSubqueryContainers(PlanNode plan) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
+ Set<GroupSymbol> groupSymbols = getGroupSymbols(plan);
+
+ for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.PROJECT | NodeConstants.Types.SELECT | NodeConstants.Types.JOIN)) {
+ List<SubqueryContainer> subqueryContainers = node.getSubqueryContainers();
+ if (subqueryContainers.isEmpty()){
+ continue;
+ }
+ Set<GroupSymbol> localGroupSymbols = groupSymbols;
+ if (node.getType() == NodeConstants.Types.JOIN) {
+ localGroupSymbols = getGroupSymbols(node);
+ }
+ for (SubqueryContainer container : subqueryContainers) {
+ ArrayList<Reference> correlatedReferences = new ArrayList<Reference>();
+ Command subCommand = container.getCommand();
+ ProcessorPlan procPlan = QueryOptimizer.optimizePlan(subCommand, metadata, idGenerator, capFinder, analysisRecord, context);
+ subCommand.setProcessorPlan(procPlan);
+ CorrelatedReferenceCollectorVisitor.collectReferences(subCommand, localGroupSymbols, correlatedReferences);
+ if (!correlatedReferences.isEmpty()) {
+ SymbolMap map = new SymbolMap();
+ for (Reference reference : correlatedReferences) {
+ map.addMapping(reference.getExpression(), reference.getExpression());
+ }
+ subCommand.setCorrelatedReferences(map);
+ }
+ }
+ node.addGroups(GroupsUsedByElementsVisitor.getGroups(node.getCorrelatedReferenceElements()));
+ }
+ }
+
+ private static Set<GroupSymbol> getGroupSymbols(PlanNode plan) {
+ Set<GroupSymbol> groupSymbols = new HashSet<GroupSymbol>();
+ for (PlanNode source : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
+ groupSymbols.addAll(source.getGroups());
+ }
+ return groupSymbols;
+ }
+
+ /**
+ * Distribute and "make (not) dependent" hints specified in the query into the
+ * fully resolved query plan. This is done after virtual group resolution so
+ * that all groups in the plan are known. The hint is attached to all SOURCE
+ * nodes for each group that should be made dependent/not dependent.
+ * @param groups List of groups (Strings) to be made dependent
+ * @param plan The canonical plan
+ */
+ private void distributeDependentHints(Collection<String> groups, PlanNode plan, QueryMetadataInterface metadata, NodeConstants.Info hintProperty)
+ throws QueryMetadataException, TeiidComponentException {
+
+ if(groups == null || groups.isEmpty()) {
+ return;
+ }
+ // Get all source nodes
+ List<PlanNode> nodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE);
+
+ // Walk through each dependent group hint and
+ // attach to the correct source node
+ for (String groupName : groups) {
+ // Walk through nodes and apply hint to all that match group name
+ boolean appliedHint = applyHint(nodes, groupName, hintProperty);
+
+ if(! appliedHint) {
+ //check if it is partial group name
+ Collection groupNames = metadata.getGroupsForPartialName(groupName);
+ if(groupNames.size() == 1) {
+ groupName = (String)groupNames.iterator().next();
+ appliedHint = applyHint(nodes, groupName, hintProperty);
+ }
+
+ if(! appliedHint) {
+ String msg = QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0010, groupName);
+ if (this.analysisRecord.recordAnnotations()) {
+ this.analysisRecord.addAnnotation(new Annotation(Annotation.HINTS, msg, "ignoring hint", Priority.MEDIUM)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+ }
+
+ private static boolean applyHint(List<PlanNode> nodes, String groupName, NodeConstants.Info hintProperty) {
+ boolean appliedHint = false;
+ for (PlanNode node : nodes) {
+ GroupSymbol nodeGroup = node.getGroups().iterator().next();
+
+ String sDefinition = nodeGroup.getDefinition();
+
+ if (nodeGroup.getName().equalsIgnoreCase(groupName)
+ || (sDefinition != null && sDefinition.equalsIgnoreCase(groupName)) ) {
+ node.setProperty(hintProperty, Boolean.TRUE);
+ appliedHint = true;
+ }
+ }
+ return appliedHint;
+ }
+
+ public static RuleStack buildRules(PlanHints hints) {
+ RuleStack rules = new RuleStack();
+
+ rules.push(RuleConstants.COLLAPSE_SOURCE);
+
+ rules.push(RuleConstants.PLAN_SORTS);
+
+ if(hints.hasJoin) {
+ rules.push(RuleConstants.IMPLEMENT_JOIN_STRATEGY);
+ }
+
+ rules.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
+
+ rules.push(RuleConstants.CALCULATE_COST);
+
+ if (hints.hasLimit) {
+ rules.push(RuleConstants.PUSH_LIMIT);
+ }
+ if (hints.hasJoin || hints.hasCriteria) {
+ rules.push(RuleConstants.MERGE_CRITERIA);
+ }
+ if (hints.hasRelationalProc) {
+ rules.push(RuleConstants.PLAN_PROCEDURES);
+ }
+ if(hints.hasJoin) {
+ rules.push(RuleConstants.CHOOSE_DEPENDENT);
+ }
+ if(hints.hasAggregates) {
+ rules.push(RuleConstants.PUSH_AGGREGATES);
+ }
+ if(hints.hasJoin) {
+ rules.push(RuleConstants.CHOOSE_JOIN_STRATEGY);
+ rules.push(RuleConstants.RAISE_ACCESS);
+ //after planning the joins, let the criteria be pushed back into place
+ rules.push(RuleConstants.PUSH_SELECT_CRITERIA);
+ rules.push(RuleConstants.PLAN_JOINS);
+ }
+ rules.push(RuleConstants.RAISE_ACCESS);
+ if (hints.hasSetQuery) {
+ rules.push(RuleConstants.PLAN_UNIONS);
+ }
+ if(hints.hasCriteria || hints.hasJoin) {
+ //after copy criteria, it is no longer necessary to have phantom criteria nodes, so do some cleaning
+ rules.push(RuleConstants.CLEAN_CRITERIA);
+ }
+ if(hints.hasJoin) {
+ rules.push(RuleConstants.COPY_CRITERIA);
+ rules.push(RuleConstants.PUSH_NON_JOIN_CRITERIA);
+ }
+ if(hints.hasVirtualGroups) {
+ rules.push(RuleConstants.MERGE_VIRTUAL);
+ }
+ if(hints.hasCriteria) {
+ rules.push(RuleConstants.PUSH_SELECT_CRITERIA);
+ }
+ if (hints.hasJoin && hints.hasOptionalJoin) {
+ rules.push(RuleConstants.REMOVE_OPTIONAL_JOINS);
+ }
+ rules.push(RuleConstants.PLACE_ACCESS);
+ return rules;
+ }
+
+ private PlanNode executeRules(RuleStack rules, PlanNode plan)
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
+
+ boolean debug = analysisRecord.recordDebug();
+ while(! rules.isEmpty()) {
+ if(debug) {
+ analysisRecord.println("\n============================================================================"); //$NON-NLS-1$
+ }
+
+ OptimizerRule rule = rules.pop();
+ if(debug) {
+ analysisRecord.println("EXECUTING " + rule); //$NON-NLS-1$
+ }
+
+ plan = rule.execute(plan, metadata, capFinder, rules, analysisRecord, context);
+ if(debug) {
+ analysisRecord.println("\nAFTER: \n" + plan); //$NON-NLS-1$
+ }
+ }
+ return plan;
+ }
+
+ public PlanNode generatePlan(Command cmd) throws TeiidComponentException, TeiidProcessingException {
+ //cascade the option clause nocache
+ Option savedOption = option;
+ option = cmd.getOption();
+ if (option == null) {
+ if (savedOption != null) {
+ option = savedOption;
+ }
+ } else if (savedOption != null && savedOption.isNoCache()) { //merge no cache settings
+ if (savedOption.getNoCacheGroups() == null || savedOption.getNoCacheGroups().isEmpty()) {
+ if (option.getNoCacheGroups() != null) {
+ option.getNoCacheGroups().clear(); // full no cache
+ }
+ } else if (option.getNoCacheGroups() != null && !option.getNoCacheGroups().isEmpty()) {
+ for (String noCache : savedOption.getNoCacheGroups()) {
+ option.addNoCacheGroup(noCache); // only groups
+ }
+ }
+ option.setNoCache(true);
+ }
+
+ PlanNode result = null;
+ switch (cmd.getType()) {
+ case Command.TYPE_QUERY:
+ result = createQueryPlan((QueryCommand)cmd);
+ break;
+ case Command.TYPE_INSERT:
+ case Command.TYPE_UPDATE:
+ case Command.TYPE_DELETE:
+ case Command.TYPE_CREATE:
+ case Command.TYPE_DROP:
+ result = createUpdatePlan(cmd);
+ break;
+ case Command.TYPE_STORED_PROCEDURE:
+ result = createStoredProcedurePlan((StoredProcedure)cmd);
+ break;
+ default:
+ throw new AssertionError("Invalid command type"); //$NON-NLS-1$
+ }
+ // Distribute make dependent hints as necessary
+ if (cmd.getOption() != null) {
+ if(cmd.getOption().getDependentGroups() != null) {
+ distributeDependentHints(cmd.getOption().getDependentGroups(), result, metadata, NodeConstants.Info.MAKE_DEP);
+ }
+ if (cmd.getOption().getNotDependentGroups() != null) {
+ distributeDependentHints(cmd.getOption().getNotDependentGroups(), result, metadata, NodeConstants.Info.MAKE_NOT_DEP);
+ }
+ }
+ this.option = savedOption;
+ return result;
+ }
+
+ PlanNode createUpdatePlan(Command command) throws TeiidComponentException, TeiidProcessingException {
+ // Create top project node - define output columns for stored query / procedure
+ PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
+
+ Collection<GroupSymbol> groups = GroupCollectorVisitor.getGroups(command, false);
+ projectNode.addGroups(groups);
+
+ // Set output columns
+ List<SingleElementSymbol> cols = command.getProjectedSymbols();
+ projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
+
+ // Define source of data for stored query / procedure
+ PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+ sourceNode.setProperty(NodeConstants.Info.ATOMIC_REQUEST, command);
+ sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, command);
+ if (command instanceof ProcedureContainer) {
+ ProcedureContainer container = (ProcedureContainer)command;
+ addNestedProcedure(sourceNode, container);
+ }
+ sourceNode.addGroups(groups);
+
+ attachLast(projectNode, sourceNode);
+
+ //for INTO query, attach source and project nodes
+ if(command instanceof Insert){
+ Insert insert = (Insert)command;
+ if (insert.getQueryExpression() != null) {
+ PlanNode plan = generatePlan(insert.getQueryExpression());
+ attachLast(sourceNode, plan);
+ mergeTempMetadata(insert.getQueryExpression(), insert);
+ projectNode.setProperty(NodeConstants.Info.INTO_GROUP, insert.getGroup());
+ }
+ }
+
+ return projectNode;
+ }
+
+ private void addNestedProcedure(PlanNode sourceNode,
+ ProcedureContainer container) throws TeiidComponentException,
+ QueryMetadataException, TeiidProcessingException {
+ //plan any subqueries in criteria/parameters/values
+ for (SubqueryContainer subqueryContainer : ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(container)) {
+ ProcessorPlan plan = QueryOptimizer.optimizePlan(subqueryContainer.getCommand(), metadata, null, capFinder, analysisRecord, context);
+ subqueryContainer.getCommand().setProcessorPlan(plan);
+ }
+
+ String cacheString = "transformation/" + container.getClass().getSimpleName(); //$NON-NLS-1$
+ Command c = (Command)metadata.getFromMetadataCache(container.getGroup().getMetadataID(), cacheString);
+ if (c == null) {
+ c = QueryResolver.expandCommand(container, metadata, analysisRecord);
+ if (c != null) {
+ Request.validateWithVisitor(new ValidationVisitor(), metadata, c);
+ metadata.addToMetadataCache(container.getGroup().getMetadataID(), cacheString, c.clone());
+ }
+ } else {
+ c = (Command)c.clone();
+ if (c instanceof CreateUpdateProcedureCommand) {
+ ((CreateUpdateProcedureCommand)c).setUserCommand(container);
+ }
+ }
+ if (c != null) {
+ c = QueryRewriter.rewrite(c, metadata, context);
+ addNestedCommand(sourceNode, container.getGroup(), container, c, false);
+ }
+ }
+
+ PlanNode createStoredProcedurePlan(StoredProcedure storedProc) throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
+ // Create top project node - define output columns for stored query / procedure
+ PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
+
+ // Set output columns
+ List cols = storedProc.getProjectedSymbols();
+ projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, cols);
+
+ // Define source of data for stored query / procedure
+ PlanNode sourceNode = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+ sourceNode.setProperty(NodeConstants.Info.VIRTUAL_COMMAND, storedProc);
+ addNestedProcedure(sourceNode, storedProc);
+
+ hints.hasRelationalProc |= storedProc.isProcedureRelational();
+
+ // Set group on source node
+ sourceNode.addGroup(storedProc.getGroup());
+
+ attachLast(projectNode, sourceNode);
+
+ return projectNode;
+ }
+
+ PlanNode createQueryPlan(QueryCommand command)
+ throws TeiidComponentException, TeiidProcessingException {
+ // Build canonical plan
+ PlanNode node = null;
+ if(command instanceof Query) {
+ node = createQueryPlan((Query) command);
+ } else {
+ hints.hasSetQuery = true;
+ SetQuery query = (SetQuery)command;
+ PlanNode leftPlan = createQueryPlan( query.getLeftQuery());
+ PlanNode rightPlan = createQueryPlan( query.getRightQuery());
+
+ node = NodeFactory.getNewNode(NodeConstants.Types.SET_OP);
+ node.setProperty(NodeConstants.Info.SET_OPERATION, query.getOperation());
+ node.setProperty(NodeConstants.Info.USE_ALL, query.isAll());
+
+ attachLast(node, leftPlan);
+ attachLast(node, rightPlan);
+ }
+
+ if(command.getOrderBy() != null) {
+ node = attachSorting(node, command.getOrderBy());
+ }
+
+ if (command.getLimit() != null) {
+ node = attachTupleLimit(node, command.getLimit(), hints);
+ }
+
+ return node;
+ }
+
+ private PlanNode createQueryPlan(Query query)
+ throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
+
+ PlanNode plan = null;
+
+ if(query.getFrom() != null){
+ FromClause fromClause = mergeClauseTrees(query.getFrom());
+
+ PlanNode dummyRoot = new PlanNode();
+
+ buildTree(fromClause, dummyRoot);
+
+ plan = dummyRoot.getFirstChild();
+
+ hints.hasJoin |= plan.getType() == NodeConstants.Types.JOIN;
+
+ // Attach criteria on top
+ if(query.getCriteria() != null) {
+ plan = attachCriteria(plan, query.getCriteria(), false);
+ hints.hasCriteria = true;
+ }
+
+ // Attach grouping node on top
+ if(query.getGroupBy() != null || query.getHaving() != null || !AggregateSymbolCollectorVisitor.getAggregates(query.getSelect(), false).isEmpty()) {
+ plan = attachGrouping(plan, query, hints);
+ }
+
+ // Attach having criteria node on top
+ if(query.getHaving() != null) {
+ plan = attachCriteria(plan, query.getHaving(), true);
+ hints.hasCriteria = true;
+ }
+
+ }
+
+ // Attach project on top
+ plan = attachProject(plan, query.getSelect());
+
+ // Attach dup removal on top
+ if(query.getSelect().isDistinct()) {
+ plan = attachDupRemoval(plan);
+ }
+
+ return plan;
+ }
+
+ /**
+ * Merges the from clause into a single join predicate if there are more than 1 from clauses
+ */
+ private static FromClause mergeClauseTrees(From from) {
+ List clauses = from.getClauses();
+
+ while (clauses.size() > 1) {
+ FromClause first = (FromClause)from.getClauses().remove(0);
+ FromClause second = (FromClause)from.getClauses().remove(0);
+ JoinPredicate jp = new JoinPredicate(first, second, JoinType.JOIN_CROSS);
+ clauses.add(0, jp);
+ }
+
+ return (FromClause)clauses.get(0);
+ }
+
+ /**
+ * Build a join plan based on the structure in a clause. These structures should be
+ * essentially the same tree, but with different objects and details.
+ * @param clause Clause to build tree from
+ * @param parent Parent node to attach join node structure to
+ * @param sourceMap Map of group to source node, used for connecting children to join plan
+ * @param markJoinsInternal Flag saying whether joins built in this method should be marked
+ * as internal
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ * @throws TeiidProcessingException
+ */
+ void buildTree(FromClause clause, PlanNode parent)
+ throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
+
+ PlanNode node = null;
+
+ if(clause instanceof UnaryFromClause) {
+ // No join required
+ UnaryFromClause ufc = (UnaryFromClause)clause;
+ GroupSymbol group = ufc.getGroup();
+ if (metadata.isVirtualGroup(group.getMetadataID())) {
+ hints.hasVirtualGroups = true;
+ }
+ Command nestedCommand = ufc.getExpandedCommand();
+ if (nestedCommand == null && !group.isTempGroupSymbol() && !group.isProcedure()
+ && (!(group.getMetadataID() instanceof TempMetadataID) || metadata.getVirtualPlan(group.getMetadataID()) != null)
+ && (metadata.isVirtualGroup(group.getMetadataID()))) {
+ //must be a view layer
+ nestedCommand = resolveVirtualGroup(group);
+ }
+ node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+ node.addGroup(group);
+ if (nestedCommand != null) {
+ addNestedCommand(node, group, nestedCommand, nestedCommand, true);
+ }
+ parent.addLastChild(node);
+ } else if(clause instanceof JoinPredicate) {
+ JoinPredicate jp = (JoinPredicate) clause;
+
+ // Set up new join node corresponding to this join predicate
+ node = NodeFactory.getNewNode(NodeConstants.Types.JOIN);
+ node.setProperty(NodeConstants.Info.JOIN_TYPE, jp.getJoinType());
+ node.setProperty(NodeConstants.Info.JOIN_STRATEGY, JoinStrategyType.NESTED_LOOP);
+ node.setProperty(NodeConstants.Info.JOIN_CRITERIA, jp.getJoinCriteria());
+
+ if (jp.getJoinType() == JoinType.JOIN_LEFT_OUTER) {
+ hints.hasOptionalJoin = true;
+ }
+
+ // Attach join node to parent
+ parent.addLastChild(node);
+
+ // Handle each child
+ FromClause[] clauses = new FromClause[] {jp.getLeftClause(), jp.getRightClause()};
+ for(int i=0; i<2; i++) {
+ buildTree(clauses[i], node);
+
+ // Add groups to joinNode
+ for (PlanNode child : node.getChildren()) {
+ node.addGroups(child.getGroups());
+ }
+ }
+ } else if (clause instanceof SubqueryFromClause) {
+ SubqueryFromClause sfc = (SubqueryFromClause)clause;
+ GroupSymbol group = sfc.getGroupSymbol();
+ Command nestedCommand = sfc.getCommand();
+ node = NodeFactory.getNewNode(NodeConstants.Types.SOURCE);
+ node.addGroup(group);
+ addNestedCommand(node, group, nestedCommand, nestedCommand, true);
+ hints.hasVirtualGroups = true;
+ parent.addLastChild(node);
+ }
+
+ if (clause.isOptional()) {
+ node.setProperty(NodeConstants.Info.IS_OPTIONAL, Boolean.TRUE);
+ hints.hasOptionalJoin = true;
+ }
+
+ if (clause.isMakeDep()) {
+ node.setProperty(NodeConstants.Info.MAKE_DEP, Boolean.TRUE);
+ } else if (clause.isMakeNotDep()) {
+ node.setProperty(NodeConstants.Info.MAKE_NOT_DEP, Boolean.TRUE);
+ }
+ }
+
+ private void addNestedCommand(PlanNode node,
+ GroupSymbol group, Command nestedCommand, Command toPlan, boolean merge) throws TeiidComponentException, QueryMetadataException, TeiidProcessingException {
+ if (nestedCommand instanceof QueryCommand) {
+ //remove unnecessary order by
+ QueryCommand queryCommand = (QueryCommand)nestedCommand;
+ if (queryCommand.getLimit() == null) {
+ queryCommand.setOrderBy(null);
+ }
+ }
+ node.setProperty(NodeConstants.Info.NESTED_COMMAND, nestedCommand);
+
+ if (merge && nestedCommand instanceof Query && QueryResolver.isXMLQuery((Query)nestedCommand, metadata)) {
+ merge = false;
+ }
+
+ if (merge) {
+ mergeTempMetadata(nestedCommand, parentCommand);
+ PlanNode childRoot = generatePlan(nestedCommand);
+ node.addFirstChild(childRoot);
+ List<SingleElementSymbol> projectCols = nestedCommand.getProjectedSymbols();
+ node.setProperty(NodeConstants.Info.SYMBOL_MAP, SymbolMap.createSymbolMap(group, projectCols, metadata));
+ } else {
+ QueryMetadataInterface actualMetadata = metadata;
+ if (actualMetadata instanceof TempMetadataAdapter) {
+ actualMetadata = ((TempMetadataAdapter)metadata).getMetadata();
+ }
+ ProcessorPlan plan = QueryOptimizer.optimizePlan(toPlan, actualMetadata, null, capFinder, analysisRecord, context);
+ node.setProperty(NodeConstants.Info.PROCESSOR_PLAN, plan);
+ }
+ }
+
+ /**
+ * Attach all criteria above the join nodes. The optimizer will push these
+ * criteria down to the appropriate source.
+ * @param plan Existing plan, which joins all source groups
+ * @param criteria Criteria from query
+ * @return Updated tree
+ */
+ private static PlanNode attachCriteria(PlanNode plan, Criteria criteria, boolean isHaving) {
+ List<Criteria> crits = Criteria.separateCriteriaByAnd(criteria);
+
+ for (Criteria crit : crits) {
+ PlanNode critNode = createSelectNode(crit, isHaving);
+ attachLast(critNode, plan);
+ plan = critNode;
+ }
+
+ return plan;
+ }
+
+ public static PlanNode createSelectNode(final Criteria crit, boolean isHaving) {
+ PlanNode critNode = NodeFactory.getNewNode(NodeConstants.Types.SELECT);
+ critNode.setProperty(NodeConstants.Info.SELECT_CRITERIA, crit);
+ if (isHaving && !AggregateSymbolCollectorVisitor.getAggregates(crit, false).isEmpty()) {
+ critNode.setProperty(NodeConstants.Info.IS_HAVING, Boolean.TRUE);
+ }
+ // Add groups to crit node
+ critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(crit));
+ critNode.addGroups(GroupsUsedByElementsVisitor.getGroups(critNode.getCorrelatedReferenceElements()));
+ return critNode;
+ }
+
+ /**
+ * Attach a grouping node at top of tree.
+ * @param plan Existing plan
+ * @param groupBy Group by clause, which may be null
+ * @return Updated plan
+ */
+ private static PlanNode attachGrouping(PlanNode plan, Query query, PlanHints hints) {
+ PlanNode groupNode = NodeFactory.getNewNode(NodeConstants.Types.GROUP);
+
+ GroupBy groupBy = query.getGroupBy();
+ if(groupBy != null) {
+ groupNode.setProperty(NodeConstants.Info.GROUP_COLS, groupBy.getSymbols());
+ groupNode.addGroups(GroupsUsedByElementsVisitor.getGroups(groupBy));
+ }
+
+ attachLast(groupNode, plan);
+
+ // Mark in hints
+ hints.hasAggregates = true;
+
+ return groupNode;
+ }
+
+ /**
+ * Attach SORT node at top of tree. The SORT may be pushed down to a source (or sources)
+ * if possible by the optimizer.
+ * @param plan Existing plan
+ * @param orderBy Sort description from the query
+ * @return Updated plan
+ */
+ private static PlanNode attachSorting(PlanNode plan, OrderBy orderBy) {
+ PlanNode sortNode = NodeFactory.getNewNode(NodeConstants.Types.SORT);
+
+ sortNode.setProperty(NodeConstants.Info.SORT_ORDER, orderBy);
+ if (orderBy.hasUnrelated()) {
+ sortNode.setProperty(Info.UNRELATED_SORT, true);
+ }
+ sortNode.addGroups(GroupsUsedByElementsVisitor.getGroups(orderBy));
+
+ attachLast(sortNode, plan);
+ return sortNode;
+ }
+
+ private static PlanNode attachTupleLimit(PlanNode plan, Limit limit, PlanHints hints) {
+ hints.hasLimit = true;
+ PlanNode limitNode = NodeFactory.getNewNode(NodeConstants.Types.TUPLE_LIMIT);
+
+ boolean attach = false;
+ if (limit.getOffset() != null) {
+ limitNode.setProperty(NodeConstants.Info.OFFSET_TUPLE_COUNT, limit.getOffset());
+ attach = true;
+ }
+ if (limit.getRowLimit() != null) {
+ limitNode.setProperty(NodeConstants.Info.MAX_TUPLE_LIMIT, limit.getRowLimit());
+ attach = true;
+ }
+ if (attach) {
+ attachLast(limitNode, plan);
+ plan = limitNode;
+ }
+ return plan;
+ }
+
+ /**
+ * Attach DUP_REMOVE node at top of tree. The DUP_REMOVE may be pushed down
+ * to a source (or sources) if possible by the optimizer.
+ * @param plan Existing plan
+ * @return Updated plan
+ */
+ private static PlanNode attachDupRemoval(PlanNode plan) {
+ PlanNode dupNode = NodeFactory.getNewNode(NodeConstants.Types.DUP_REMOVE);
+ attachLast(dupNode, plan);
+ return dupNode;
+ }
+
+ private static PlanNode attachProject(PlanNode plan, Select select) {
+ PlanNode projectNode = NodeFactory.getNewNode(NodeConstants.Types.PROJECT);
+ projectNode.setProperty(NodeConstants.Info.PROJECT_COLS, select.getProjectedSymbols());
+
+ // Set groups
+ projectNode.addGroups(GroupsUsedByElementsVisitor.getGroups(select));
+
+ attachLast(projectNode, plan);
+ return projectNode;
+ }
+
+ static final void attachLast(PlanNode parent, PlanNode child) {
+ if(child != null) {
+ parent.addLastChild(child);
+ }
+ }
+
+ /**
+ * Adds temp metadata (if any) of child command to temp metadata
+ * (if any) of parent command.
+ * @param childCommand
+ * @param parentCommand
+ */
+ static void mergeTempMetadata(
+ Command childCommand,
+ Command parentCommand) {
+ Map childTempMetadata = childCommand.getTemporaryMetadata();
+ if (childTempMetadata != null && !childTempMetadata.isEmpty()){
+ // Add to parent temp metadata
+ Map parentTempMetadata = parentCommand.getTemporaryMetadata();
+ if (parentTempMetadata == null){
+ parentCommand.setTemporaryMetadata(new HashMap(childTempMetadata));
+ } else {
+ parentTempMetadata.putAll(childTempMetadata);
+ }
+ }
+ }
+
+ private Command resolveVirtualGroup(GroupSymbol virtualGroup)
+ throws QueryMetadataException, TeiidComponentException, TeiidProcessingException {
+
+ QueryNode qnode = null;
+
+ Object metadataID = virtualGroup.getMetadataID();
+ boolean noCache = false;
+ boolean isMaterializedGroup = metadata.hasMaterialization(metadataID);
+ String cacheString = "select"; //$NON-NLS-1$
+ if( isMaterializedGroup) {
+ noCache = isNoCacheGroup(metadata, metadataID, option);
+ if(noCache){
+ //not use cache
+ qnode = metadata.getVirtualPlan(metadataID);
+ String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
+ recordMaterializationTableAnnotation(virtualGroup, analysisRecord, matTableName, "SimpleQueryResolver.materialized_table_not_used"); //$NON-NLS-1$
+ }else{
+ // Default query for a materialized group - go to cached table
+ String groupName = metadata.getFullName(metadataID);
+ String matTableName = metadata.getFullName(metadata.getMaterialization(metadataID));
+ qnode = new QueryNode(groupName, "SELECT * FROM " + matTableName); //$NON-NLS-1$
+ cacheString = "matview"; //$NON-NLS-1$
+ recordMaterializationTableAnnotation(virtualGroup, analysisRecord, matTableName, "SimpleQueryResolver.Query_was_redirected_to_Mat_table"); //$NON-NLS-1$
+ }
+ } else {
+ // Not a materialized view - query the primary transformation
+ qnode = metadata.getVirtualPlan(metadataID);
+ }
+
+ Command result = (Command)metadata.getFromMetadataCache(virtualGroup.getMetadataID(), "transformation/" + cacheString); //$NON-NLS-1$
+ if (result != null) {
+ result = (Command)result.clone();
+ } else {
+ //parse, resolve, validate
+ result = convertToSubquery(qnode, metadata);
+ QueryResolver.resolveCommand(result, Collections.EMPTY_MAP, metadata, analysisRecord);
+ Request.validateWithVisitor(new ValidationVisitor(), metadata, result);
+ metadata.addToMetadataCache(virtualGroup.getMetadataID(), "transformation/" + cacheString, result.clone()); //$NON-NLS-1$
+ }
+ return QueryRewriter.rewrite(result, metadata, context);
+ }
+
+ public static boolean isNoCacheGroup(QueryMetadataInterface metadata,
+ Object metadataID,
+ Option option) throws QueryMetadataException,
+ TeiidComponentException {
+ if(option == null || !option.isNoCache()){
+ return false;
+ }
+ if(option.getNoCacheGroups() == null || option.getNoCacheGroups().isEmpty()){
+ //only OPTION NOCACHE, no group specified
+ return true;
+ }
+ for (String groupName : option.getNoCacheGroups()) {
+ try {
+ Object noCacheGroupID = metadata.getGroupID(groupName);
+ if(metadataID.equals(noCacheGroupID)){
+ return true;
+ }
+ } catch (QueryMetadataException e) {
+ //log that an unknown groups was used in the no cache
+ LogManager.logWarning(LogConstants.CTX_QUERY_RESOLVER, e, QueryPlugin.Util.getString("SimpleQueryResolver.unknown_group_in_nocache", groupName)); //$NON-NLS-1$
+ }
+ }
+ return false;
+ }
+
+ private static void recordMaterializationTableAnnotation(GroupSymbol virtualGroup,
+ AnalysisRecord analysis,
+ String matTableName, String msg) {
+ if ( analysis.recordAnnotations() ) {
+ Object[] params = new Object[] {virtualGroup, matTableName};
+ Annotation annotation = new Annotation(Annotation.MATERIALIZED_VIEW,
+ QueryPlugin.Util.getString(msg, params),
+ null,
+ Priority.LOW);
+ analysis.addAnnotation(annotation);
+ }
+ }
+
+ private static Command convertToSubquery(QueryNode qnode, QueryMetadataInterface metadata)
+ throws QueryResolverException, TeiidComponentException {
+
+ // Parse this node's command
+ Command command = qnode.getCommand();
+
+ if (command == null) {
+ try {
+ command = QueryParser.getQueryParser().parseCommand(qnode.getQuery());
+ } catch(QueryParserException e) {
+ throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0011, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0011, qnode.getGroupName()));
+ }
+
+ //Handle bindings and references
+ List bindings = qnode.getBindings();
+ if (bindings != null){
+ BindVariableVisitor.bindReferences(command, bindings, metadata);
+ }
+ }
+
+ return command;
+ }
+
+}
\ No newline at end of file
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RuleStack.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/RuleStack.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RuleStack.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/RuleStack.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,67 @@
+/*
+ * 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.optimizer.relational;
+
+import java.util.LinkedList;
+
+public class RuleStack {
+
+ private LinkedList<OptimizerRule> rules = new LinkedList<OptimizerRule>();
+
+ public void push(OptimizerRule rule) {
+ rules.addFirst(rule);
+ }
+
+ public void addLast(OptimizerRule rule) {
+ rules.addLast(rule);
+ }
+
+ public OptimizerRule pop() {
+ if(rules.isEmpty()) {
+ return null;
+ }
+ return rules.removeFirst();
+ }
+
+ public boolean isEmpty() {
+ return rules.isEmpty();
+ }
+
+ public int size() {
+ return rules.size();
+ }
+
+ /**
+ * Remove all occurrences of this rule in the stack
+ * @param rule The rule to remove
+ * @since 4.2
+ */
+ public void remove(OptimizerRule rule) {
+ while(rules.remove(rule)) {}
+ }
+
+ public boolean contains(OptimizerRule rule) {
+ return rules.contains(rule);
+ }
+
+}
\ No newline at end of file
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeConstants.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.plantree;
+package org.teiid.query.optimizer.relational.plantree;
public final class NodeConstants {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeEditor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeEditor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.plantree;
+package org.teiid.query.optimizer.relational.plantree;
import java.util.LinkedList;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeFactory.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/NodeFactory.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/NodeFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.plantree;
+package org.teiid.query.optimizer.relational.plantree;
public class NodeFactory {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/plantree/PlanNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/plantree/PlanNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.plantree;
+package org.teiid.query.optimizer.relational.plantree;
import java.util.ArrayList;
import java.util.Arrays;
@@ -34,16 +34,17 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+
public class PlanNode {
// --------------------- Node State --------------------------
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CapabilitiesUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,33 +20,33 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
/**
*/
@@ -59,12 +59,12 @@
}
static boolean supportsInlineView(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_FROM_INLINE_VIEWS, modelID, metadata, capFinder);
}
public static boolean supportsSelfJoins(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
@@ -78,12 +78,12 @@
}
public static boolean supportsGroupAliases(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_FROM_GROUP_ALIAS, modelID, metadata, capFinder);
}
public static boolean supportsJoin(Object modelID, JoinType joinType, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
@@ -104,7 +104,7 @@
}
public static boolean supportsAggregates(List groupCols, Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
@@ -134,7 +134,7 @@
}
public static boolean supportsAggregateFunction(Object modelID, AggregateSymbol aggregate, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
@@ -185,7 +185,7 @@
}
public static boolean supportsScalarFunction(Object modelID, Function function, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
@@ -218,22 +218,22 @@
}
public static boolean supportsSelectDistinct(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_SELECT_DISTINCT, modelID, metadata, capFinder);
}
public static boolean supportsSelectExpression(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_SELECT_EXPRESSION, modelID, metadata, capFinder);
}
public static boolean supportsOrderBy(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_ORDERBY, modelID, metadata, capFinder);
}
public static boolean supportsSetOp(Object modelID, Operation setOp, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
@@ -255,22 +255,22 @@
}
public static boolean supportsSetQueryOrderBy(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_SET_ORDER_BY, modelID, metadata, capFinder);
}
public static boolean supportsCaseExpression(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_CASE, modelID, metadata, capFinder);
}
public static boolean supportsSearchedCaseExpression(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_SEARCHED_CASE, modelID, metadata, capFinder);
}
public static int getMaxInCriteriaSize(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return -1;
@@ -292,7 +292,7 @@
}
public static int getMaxFromGroups(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return -1;
@@ -313,7 +313,7 @@
return value;
}
- public static SupportedJoinCriteria getSupportedJoinCriteria(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
+ public static SupportedJoinCriteria getSupportedJoinCriteria(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return SupportedJoinCriteria.ANY;
}
@@ -326,17 +326,17 @@
}
public static boolean supportsRowLimit(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.ROW_LIMIT, modelID, metadata, capFinder);
}
public static boolean supportsRowOffset(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.ROW_OFFSET, modelID, metadata, capFinder);
}
public static boolean isSameConnector(Object modelID, Object modelID1, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (modelID == null || modelID1 == null || metadata.isVirtualModel(modelID) || metadata.isVirtualModel(modelID1)){
return false;
@@ -356,7 +356,7 @@
}
private static SourceCapabilities getCapabilities(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
// Find capabilities
String modelName = metadata.getFullName(modelID);
@@ -364,17 +364,17 @@
}
public static boolean requiresCriteria(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.REQUIRES_CRITERIA, modelID, metadata, capFinder);
}
public static boolean useAnsiJoin(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return supports(Capability.QUERY_FROM_ANSI_JOIN, modelID, metadata, capFinder);
}
public static boolean supports(Capability cap, Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (metadata.isVirtualModel(modelID)){
return false;
}
@@ -390,7 +390,7 @@
* TODO: this check is too general and not type based
*/
static boolean checkElementsAreSearchable(List<? extends LanguageObject> objs, QueryMetadataInterface metadata, int searchableType)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Collection<ElementSymbol> elements = new ArrayList<ElementSymbol>();
ElementCollectorVisitor.getElements(objs, elements);
for (ElementSymbol elementSymbol : elements) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/CriteriaCapabilityValidatorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,56 +20,57 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Arrays;
import java.util.Collection;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.AbstractCompareCriteria;
-import com.metamatrix.query.sql.lang.AbstractSetCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.XMLAttributes;
-import com.metamatrix.query.sql.symbol.XMLElement;
-import com.metamatrix.query.sql.symbol.XMLForest;
-import com.metamatrix.query.sql.symbol.XMLNamespaces;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.AbstractCompareCriteria;
+import org.teiid.query.sql.lang.AbstractSetCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLElement;
+import org.teiid.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.symbol.XMLNamespaces;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+
/**
*/
public class CriteriaCapabilityValidatorVisitor extends LanguageVisitor {
@@ -83,15 +84,15 @@
private SourceCapabilities caps;
// Output state
- private MetaMatrixComponentException exception;
+ private TeiidComponentException exception;
private boolean valid = true;
/**
* @param iterator
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
- CriteriaCapabilityValidatorVisitor(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, SourceCapabilities caps) throws QueryMetadataException, MetaMatrixComponentException {
+ CriteriaCapabilityValidatorVisitor(Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, SourceCapabilities caps) throws QueryMetadataException, TeiidComponentException {
this.modelID = modelID;
this.metadata = metadata;
this.capFinder = capFinder;
@@ -124,8 +125,8 @@
markInvalid();
}
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -171,8 +172,8 @@
try {
checkElementsAreSearchable(obj, SupportConstants.Element.SEARCHABLE_COMPARE);
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -200,8 +201,8 @@
markInvalid();
}
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -244,8 +245,8 @@
try {
checkElementsAreSearchable(obj, SupportConstants.Element.SEARCHABLE_LIKE);
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -278,14 +279,14 @@
return;
}
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ExistsCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.ExistsCriteria)
*/
public void visit(ExistsCriteria crit) {
// Check if exists criteria are allowed
@@ -298,13 +299,13 @@
if (validateSubqueryPushdown(crit, modelID, metadata, capFinder) == null) {
markInvalid();
}
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e);
}
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubqueryCompareCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubqueryCompareCriteria)
*/
public void visit(SubqueryCompareCriteria crit) {
// Check if quantification operator is allowed
@@ -333,8 +334,8 @@
markInvalid();
}
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -351,8 +352,8 @@
markInvalid();
}
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -370,8 +371,8 @@
markInvalid();
}
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -392,8 +393,8 @@
checkElementsAreSearchable(crit, SupportConstants.Element.SEARCHABLE_COMPARE);
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e));
- } catch(MetaMatrixComponentException e) {
+ handleException(new TeiidComponentException(e));
+ } catch(TeiidComponentException e) {
handleException(e);
}
@@ -404,7 +405,7 @@
}
private void checkElementsAreSearchable(LanguageObject crit, int searchableType)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (!CapabilitiesUtil.checkElementsAreSearchable(Arrays.asList(crit), metadata, searchableType)) {
markInvalid();
}
@@ -418,9 +419,9 @@
* @param metadata
* @param capFinder
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- static Object validateSubqueryPushdown(SubqueryContainer subqueryContainer, Object critNodeModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws MetaMatrixComponentException {
+ static Object validateSubqueryPushdown(SubqueryContainer subqueryContainer, Object critNodeModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws TeiidComponentException {
ProcessorPlan plan = subqueryContainer.getCommand().getProcessorPlan();
if (plan != null) {
if(!(plan instanceof RelationalPlan)) {
@@ -457,7 +458,7 @@
return null;
}
} catch(QueryMetadataException e) {
- throw new MetaMatrixComponentException(e, QueryExecPlugin.Util.getString("RulePushSelectCriteria.Error_getting_modelID")); //$NON-NLS-1$
+ throw new TeiidComponentException(e, QueryExecPlugin.Util.getString("RulePushSelectCriteria.Error_getting_modelID")); //$NON-NLS-1$
}
}
if (critNodeModelID == null) {
@@ -477,20 +478,20 @@
}
}
} catch(QueryMetadataException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
// Found no reason why this node is not eligible
return critNodeModelID;
}
- private void handleException(MetaMatrixComponentException e) {
+ private void handleException(TeiidComponentException e) {
this.valid = false;
this.exception = e;
setAbort(true);
}
- public MetaMatrixComponentException getException() {
+ public TeiidComponentException getException() {
return this.exception;
}
@@ -503,7 +504,7 @@
return this.valid;
}
- public static boolean canPushLanguageObject(LanguageObject obj, Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
+ public static boolean canPushLanguageObject(LanguageObject obj, Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
if(obj == null) {
return true;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/FrameUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/FrameUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collections;
@@ -31,42 +31,43 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.resolver.util.AccessPattern;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.resolver.util.AccessPattern;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class FrameUtil {
public static void convertFrame(PlanNode startNode, GroupSymbol oldGroup, Set<GroupSymbol> newGroups, Map symbolMap, QueryMetadataInterface metadata)
@@ -283,10 +284,10 @@
// Simplify criteria if possible
try {
return QueryRewriter.rewriteCriteria(criteria, null, null, metadata);
- } catch(MetaMatrixProcessingException e) {
+ } catch(TeiidProcessingException e) {
throw new QueryPlannerException(e, QueryExecPlugin.Util.getString(ErrorMessageKeys.OPTIMIZER_0023, criteria));
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
}
@@ -300,10 +301,10 @@
* @param metadata
* @return
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
public static Map<ElementSymbol, Expression> buildSymbolMap(GroupSymbol oldGroup, GroupSymbol newGroup, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
String newGroupName = null;
if (newGroup != null) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinRegion.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinRegion.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collection;
@@ -33,24 +33,25 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.resolver.util.AccessPattern;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.FunctionCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.resolver.util.AccessPattern;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+
/**
* A join region is a set of cross and inner joins whose ordering is completely interchangeable.
*
@@ -300,7 +301,7 @@
return true;
}
- public void initializeCostingInformation(QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ public void initializeCostingInformation(QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
for (PlanNode node : joinSourceNodes.values()) {
NewCalculateCostUtil.computeCostForTree(node, metadata);
}
@@ -311,10 +312,10 @@
/**
* @param metadata
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private void estimateCriteriaSelectivity(QueryMetadataInterface metadata) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode node : criteriaNodes) {
Criteria crit = (Criteria)node.getProperty(NodeConstants.Info.SELECT_CRITERIA);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/JoinUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/JoinUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,28 +20,29 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Collection;
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.core.TeiidException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+
/**
* <p>
* Utility methods for query planning related to joins.
@@ -140,7 +141,7 @@
Criteria simplifiedCrit = (Criteria)replaceWithNullValues(innerGroups, crit);
try {
simplifiedCrit = QueryRewriter.rewriteCriteria(simplifiedCrit, null, null, metadata);
- } catch (MetaMatrixException err) {
+ } catch (TeiidException err) {
//log the exception
return true;
}
@@ -153,7 +154,7 @@
Expression simplifiedExpression = (Expression)replaceWithNullValues(innerGroups, expr);
try {
simplifiedExpression = QueryRewriter.rewriteExpression(simplifiedExpression, null, null, metadata);
- } catch (MetaMatrixException err) {
+ } catch (TeiidException err) {
//log the exception
return true;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/NewCalculateCostUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.sql.Date;
import java.sql.Time;
@@ -34,43 +34,43 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.sql.lang.AbstractSetCriteria;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.PredicateCriteria;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.sql.lang.AbstractSetCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.PredicateCriteria;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.CommandContext;
/**
@@ -92,10 +92,10 @@
* @param metadata
* @return Cost computed at the passed node
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
static float computeCostForTree(PlanNode node, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Float cost = (Float) node.getProperty(NodeConstants.Info.EST_CARDINALITY);
@@ -120,10 +120,10 @@
* @param node
* @param metadata
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private static void computeNodeCost(PlanNode node, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
switch(node.getType()) {
case NodeConstants.Types.SOURCE:
@@ -206,7 +206,7 @@
private static void estimateSetOpCost(PlanNode node,
QueryMetadataInterface metadata) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
float cost = 0;
SetQuery.Operation op = (SetQuery.Operation)node.getProperty(NodeConstants.Info.SET_OPERATION);
@@ -252,7 +252,7 @@
private static float getDistinctEstimate(PlanNode node,
QueryMetadataInterface metadata, float cost)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
PlanNode projectNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.PROJECT);
if (projectNode != null) {
cost = getDistinctEstimate(projectNode, (List)projectNode.getProperty(NodeConstants.Info.PROJECT_COLS), metadata, cost);
@@ -273,7 +273,7 @@
* @param metadata
*/
private static void estimateJoinNodeCost(PlanNode node, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Iterator children = node.getChildren().iterator();
PlanNode child1 = (PlanNode)children.next();
@@ -316,7 +316,7 @@
* @param metadata
*/
private static void estimateSelectNodeCost(PlanNode node, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
PlanNode child = node.getFirstChild();
Float childCostFloat = (Float)child.getProperty(NodeConstants.Info.EST_CARDINALITY);
@@ -337,10 +337,10 @@
* @param node
* @param metadata
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private static void estimateSourceNodeCost(PlanNode node, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
float cost = UNKNOWN_VALUE;
if(node.getChildCount() > 0) {
@@ -367,10 +367,10 @@
* @param node
* @param metadata
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private static void estimateNodeCost(PlanNode node, List expressions, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
PlanNode child = node.getFirstChild();
float childCost = ((Float)child.getProperty(NodeConstants.Info.EST_CARDINALITY)).floatValue();
@@ -388,7 +388,7 @@
List elements,
QueryMetadataInterface metadata,
float childCost) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
if(elements == null) {
return new Float(childCost);
}
@@ -407,7 +407,7 @@
}
static float recursiveEstimateCostOfCriteria(float childCost, PlanNode currentNode, Criteria crit, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
float cost = childCost;
if(crit instanceof CompoundCriteria) {
@@ -543,7 +543,7 @@
* @since 4.3
*/
private static float estimatePredicateCost(float childCost, PlanNode currentNode, PredicateCriteria predicateCriteria, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Collection<ElementSymbol> elements = ElementCollectorVisitor.getElements(predicateCriteria, true);
@@ -674,7 +674,7 @@
private static float getCostForComparison(float childCost,
QueryMetadataInterface metadata,
- CompareCriteria compCrit, boolean unknownChildCost) throws MetaMatrixComponentException,
+ CompareCriteria compCrit, boolean unknownChildCost) throws TeiidComponentException,
QueryMetadataException {
if (!(compCrit.getLeftExpression() instanceof ElementSymbol) || !(compCrit.getRightExpression() instanceof Constant)) {
if (unknownChildCost) {
@@ -758,7 +758,7 @@
return cost;
}
- static boolean usesKey(PlanNode planNode, Collection<? extends SingleElementSymbol> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ static boolean usesKey(PlanNode planNode, Collection<? extends SingleElementSymbol> allElements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
return NodeEditor.findAllNodes(planNode, NodeConstants.Types.SOURCE, NodeConstants.Types.JOIN | NodeConstants.Types.SET_OP).size() == 1
&& usesKey(allElements, metadata);
}
@@ -769,7 +769,7 @@
* if a key column is used after a non 1-1 join or a union all, then it may be non-unique.
*/
private static boolean usesKey(Collection<? extends SingleElementSymbol> allElements, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if(allElements == null || allElements.size() == 0) {
return false;
@@ -821,7 +821,7 @@
* NOTE: this is not a good approximation over unions, joins, grouping, etc.
*/
private static float getNDV(Collection<ElementSymbol> elements, PlanNode current, float cardinality, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
float result = 1;
for (ElementSymbol elementSymbol : elements) {
@@ -856,7 +856,7 @@
* NOTE: assumes that the expression does not allow nulls
*/
private static float getNNV(Collection<ElementSymbol> elements, PlanNode current, float cardinality, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
float result = 0;
for (ElementSymbol elementSymbol : elements) {
Object elemID = elementSymbol.getMetadataID();
@@ -891,7 +891,7 @@
* Computes the cost of a Merge Join
*/
public static float computeCostForJoin(PlanNode leftChildNode, PlanNode rightChildNode, JoinStrategyType joinStrategy, QueryMetadataInterface metadata, CommandContext context)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
float leftChildCardinality = computeCostForTree(leftChildNode, metadata);
float rightChildCardinality = computeCostForTree(rightChildNode, metadata);
@@ -946,7 +946,7 @@
*
*/
public static float computeCostForDepJoin(PlanNode joinNode, boolean leftIndependent, JoinStrategyType joinStrategy, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, CommandContext context)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
PlanNode independentNode = leftIndependent?joinNode.getFirstChild():joinNode.getLastChild();
PlanNode dependentNode = leftIndependent?joinNode.getLastChild():joinNode.getFirstChild();
@@ -1063,7 +1063,7 @@
List expressions,
QueryMetadataInterface metadata,
float nodeCardinality, boolean independent) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
float result = UNKNOWN_VALUE;
for(Iterator iter = expressions.iterator(); iter.hasNext();) {
Expression expr = (Expression)iter.next();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAccessPatternValidation.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAccessPatternValidation.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAccessPatternValidation.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,29 +20,30 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* Validates that the access pattern(s) of a source are satisfied. This means that,
* during planning, exactly the required criteria specified by only one (if any)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleAssignOutputElements.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleAssignOutputElements.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,37 +31,38 @@
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.CommandContext;
+
/**
* <p>This rule is responsible for assigning the output elements to every node in the
* plan. The output elements define the columns that are returned from every node.
@@ -81,7 +82,7 @@
* @return The updated plan
*/
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// Record project node output columns in top node
PlanNode projectNode = NodeEditor.findNodePreOrder(plan, NodeConstants.Types.PROJECT);
@@ -118,7 +119,7 @@
* @param metadata Metadata implementation
*/
private void assignOutputElements(PlanNode root, List<SingleElementSymbol> outputElements, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
int nodeType = root.getType();
@@ -241,13 +242,13 @@
* So, in this case filtering should not occur. In fact the output columns
* that were set on root above are filtered, but we actually want all the
* virtual elements - so just reset it and proceed as before
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
static List<? extends SingleElementSymbol> determineSourceOutput(PlanNode root,
List<SingleElementSymbol> outputElements,
QueryMetadataInterface metadata,
- CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
+ CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
PlanNode virtualRoot = root.getLastChild();
if(hasDupRemoval(virtualRoot)) {
@@ -299,7 +300,7 @@
* @throws QueryPlannerException
*/
private ElementSymbol selectOutputElement(Collection<GroupSymbol> groups, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
// Find a group with selectable elements and pick the first one
for (GroupSymbol group : groups) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCalculateCost.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCalculateCost.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCalculateCost.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.util.CommandContext;
+
public class RuleCalculateCost implements OptimizerRule {
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.optimizer.relational.RuleStack, com.metamatrix.query.analysis.AnalysisRecord, com.metamatrix.query.util.CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.optimizer.relational.RuleStack, org.teiid.query.analysis.AnalysisRecord, org.teiid.query.util.CommandContext)
*/
public PlanNode execute(PlanNode plan,
QueryMetadataInterface metadata,
@@ -45,7 +46,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
NewCalculateCostUtil.computeCostForTree(plan, metadata);
return plan;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseDependent.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseDependent.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Iterator;
@@ -28,25 +28,26 @@
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.util.CommandContext;
+
/**
* Finds nodes that can be turned into dependent joins
*/
@@ -63,7 +64,7 @@
public static final int DEFAULT_INDEPENDENT_CARDINALITY = 10;
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// Find first criteria node in plan with conjuncts
List<CandidateJoin> matches = findCandidate(plan, metadata, analysisRecord);
@@ -126,7 +127,7 @@
}
boolean decideForAgainstDependentJoin(float depJoinCost, PlanNode independentNode, PlanNode dependentNode, PlanNode joinNode, QueryMetadataInterface metadata, CommandContext context)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
JoinStrategyType joinStrategy = (JoinStrategyType)joinNode.getProperty(NodeConstants.Info.JOIN_STRATEGY);
joinNode.setProperty(NodeConstants.Info.EST_DEP_JOIN_COST, new Float(depJoinCost));
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleChooseJoinStrategy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleChooseJoinStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,34 +29,35 @@
import java.util.Set;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.CommandContext;
+
/**
* Marks join as a candidate merge join if conditions are met
*/
public class RuleChooseJoinStrategy implements OptimizerRule {
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
for (PlanNode joinNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS)) {
chooseJoinStrategy(joinNode, metadata);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCleanCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCleanCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.util.CommandContext;
+
/**
* Removes phantom and TRUE or FALSE criteria
*/
@@ -48,7 +49,7 @@
* @see OptimizerRule#execute(PlanNode, QueryMetadataInterface, RuleStack)
*/
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, MetaMatrixComponentException {
+ throws QueryPlannerException, TeiidComponentException {
boolean pushRaiseNull = false;
@@ -81,9 +82,9 @@
}
//none of the following exceptions should ever occur
} catch(BlockedException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
} catch (CriteriaEvaluationException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCollapseSource.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,64 +20,65 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.LinkedHashSet;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.navigator.DeepPostOrderNavigator;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.AccessNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+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.SubqueryContainer;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+
public final class RuleCollapseSource implements OptimizerRule {
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
for (PlanNode accessNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.ACCESS)) {
@@ -121,12 +122,12 @@
* @param accessNode
* @param queryCommand
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private void addDistinct(QueryMetadataInterface metadata,
CapabilitiesFinder capFinder, PlanNode accessNode,
QueryCommand queryCommand) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
if (queryCommand.getLimit() != null) {
return; //TODO: could create an inline view
}
@@ -181,7 +182,7 @@
return root;
}
- private QueryCommand createQuery(QueryMetadataInterface metadata, CapabilitiesFinder capFinder, PlanNode accessRoot, PlanNode node) throws QueryMetadataException, MetaMatrixComponentException, QueryPlannerException {
+ private QueryCommand createQuery(QueryMetadataInterface metadata, CapabilitiesFinder capFinder, PlanNode accessRoot, PlanNode node) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
PlanNode setOpNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.SET_OP, NodeConstants.Types.SOURCE);
if (setOpNode != null) {
Operation setOp = (Operation)setOpNode.getProperty(NodeConstants.Info.SET_OPERATION);
@@ -227,7 +228,7 @@
return query;
}
- void buildQuery(PlanNode accessRoot, PlanNode node, Query query, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException, QueryPlannerException {
+ void buildQuery(PlanNode accessRoot, PlanNode node, Query query, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
//visit source and join nodes as they appear
switch(node.getType()) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleConstants.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.OptimizerRule;
public final class RuleConstants {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleCopyCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCopyCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Collection;
import java.util.Collections;
@@ -32,27 +32,27 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.CommandContext;
/**
* For each join node this rule will find the set of criteria allowed to influence the join (the join criteria, and inner
@@ -78,7 +78,7 @@
* @return Updated query plan if rule fired, else original query plan
*/
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, MetaMatrixComponentException {
+ throws QueryPlannerException, TeiidComponentException {
//do an initial check to see if an execution will be necessary
List<PlanNode> critNodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.SELECT);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,32 +28,33 @@
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.CommandContext;
+
/**
* Inserts sort nodes for specific join strategies.
*/
public class RuleImplementJoinStrategy implements OptimizerRule {
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.optimizer.relational.RuleStack, com.metamatrix.query.analysis.AnalysisRecord, com.metamatrix.query.util.CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.optimizer.relational.RuleStack, org.teiid.query.analysis.AnalysisRecord, org.teiid.query.util.CommandContext)
*/
public PlanNode execute(PlanNode plan,
QueryMetadataInterface metadata,
@@ -62,7 +63,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode joinNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.JOIN, NodeConstants.Types.ACCESS)) {
JoinStrategyType stype = (JoinStrategyType) joinNode.getProperty(NodeConstants.Info.JOIN_STRATEGY);
@@ -103,11 +104,11 @@
* @param expressions The expressions that need to be sorted on
* @param jnode The planner merge join node to attach to
* @return returns true if a project node needs added
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
private static boolean insertSort(PlanNode childNode, List<SingleElementSymbol> expressions, PlanNode jnode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
- boolean attemptPush) throws QueryMetadataException, MetaMatrixComponentException {
+ boolean attemptPush) throws QueryMetadataException, TeiidComponentException {
Set<SingleElementSymbol> orderSymbols = new LinkedHashSet<SingleElementSymbol>(expressions);
PlanNode sourceNode = FrameUtil.findJoinSourceNode(childNode);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,27 +20,28 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.CommandContext;
+
/**
* TODO: this rule should attempt to intelligently order the criteria
*/
@@ -50,7 +51,7 @@
* @see OptimizerRule#execute(PlanNode, QueryMetadataInterface, RuleStack)
*/
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, MetaMatrixComponentException {
+ throws QueryPlannerException, TeiidComponentException {
// Find strings of criteria and merge them, removing duplicates
List<PlanNode> criteriaChains = new ArrayList<PlanNode>();
@@ -70,7 +71,7 @@
* @param foundNodes Roots of criteria chains
*/
void findCriteriaChains(PlanNode root, List<PlanNode> foundNodes)
- throws QueryPlannerException, MetaMatrixComponentException {
+ throws QueryPlannerException, TeiidComponentException {
PlanNode recurseRoot = root;
if(root.getType() == NodeConstants.Types.SELECT) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleMergeVirtual.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,33 +29,34 @@
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.FunctionCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+
public final class RuleMergeVirtual implements
OptimizerRule {
@@ -66,7 +67,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode sourceNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE)) {
if (sourceNode.getChildCount() > 0) {
@@ -79,7 +80,7 @@
static PlanNode doMerge(PlanNode frame,
PlanNode root,
- QueryMetadataInterface metadata) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ QueryMetadataInterface metadata) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
GroupSymbol virtualGroup = frame.getGroups().iterator().next();
@@ -196,13 +197,13 @@
/**
* Removes source layers that only do a simple projection of the elements below.
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
private static PlanNode checkForSimpleProjection(PlanNode frame,
PlanNode root,
PlanNode parentProject,
- QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
// check that the parent only performs projection
PlanNode nodeToCheck = parentProject.getFirstChild();
while (nodeToCheck != frame) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlaceAccess.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlaceAccess.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlaceAccess.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Arrays;
import java.util.Collections;
@@ -29,27 +29,28 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.util.CommandContext;
+
/**
* This rule finds all SOURCE nodes and associates ACCESS patterns, ACCESS nodes, and aliases.
*/
@@ -64,7 +65,7 @@
RuleStack rules,
AnalysisRecord analysisRecord,
CommandContext context) throws QueryMetadataException,
- MetaMatrixComponentException,
+ TeiidComponentException,
QueryPlannerException {
Set<String> groups = context.getGroups();
@@ -96,11 +97,11 @@
* @param sourceNode
* @return true if the source node has an access pattern
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private void addAccessNode(QueryMetadataInterface metadata,
PlanNode sourceNode, CapabilitiesFinder finder, boolean[] additionalRules) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
boolean isInsert = false;
Object req = sourceNode.getProperty(NodeConstants.Info.ATOMIC_REQUEST);
if (req == null) {
@@ -158,13 +159,13 @@
* @param groups
* @param metadata
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryPlannerException
*/
private void addAlias(PlanNode sourceNode,
Set<String> groups,
QueryMetadataInterface metadata) throws QueryMetadataException,
- MetaMatrixComponentException,
+ TeiidComponentException,
QueryPlannerException {
// select with no from
if (sourceNode.getGroups().isEmpty()) {
@@ -290,12 +291,12 @@
* if there is an exception accessing metadata
* @throws QueryResolverException
* if the GroupSymbol of an atomic command cannot be resolved
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* indicating some unexpected non-business exception
*/
static boolean addAccessPatternsProperty(final PlanNode node,
final QueryMetadataInterface metadata) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
if (node.hasCollectionProperty(NodeConstants.Info.ACCESS_PATTERNS)) {
return false;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanJoins.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,27 +33,27 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.resolver.util.AccessPattern;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.Permutation;
import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.resolver.util.AccessPattern;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.Permutation;
/**
* Determines join orderings based upon dependency and cost information
@@ -92,7 +92,7 @@
public static final int EXHAUSTIVE_SEARCH_GROUPS = 6;
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.optimizer.relational.RuleStack, com.metamatrix.query.analysis.AnalysisRecord, com.metamatrix.query.util.CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.optimizer.relational.RuleStack, org.teiid.query.analysis.AnalysisRecord, org.teiid.query.util.CommandContext)
*/
public PlanNode execute(PlanNode plan,
QueryMetadataInterface metadata,
@@ -101,7 +101,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
@@ -180,12 +180,12 @@
* @param metadata
* @param joinRegion
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryPlannerException
*/
private void groupJoinsForPushing(QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
JoinRegion joinRegion, CommandContext context) throws QueryMetadataException,
- MetaMatrixComponentException, QueryPlannerException {
+ TeiidComponentException, QueryPlannerException {
//TODO: consider moving select criteria if it is preventing a join from being pushed down
//TODO: make the criteria checks based upon a guess at selectivity
@@ -323,7 +323,7 @@
private boolean canPushCrossJoin(QueryMetadataInterface metadata, CommandContext context,
PlanNode accessNode1, PlanNode accessNode2)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
float cost1 = NewCalculateCostUtil.computeCostForTree(accessNode1, metadata);
float cost2 = NewCalculateCostUtil.computeCostForTree(accessNode2, metadata);
float acceptableCost = context == null? 45.0f : (float)Math.sqrt(context.getProcessorBatchSize());
@@ -337,7 +337,7 @@
private Map getAccessMap(QueryMetadataInterface metadata,
CapabilitiesFinder capFinder,
JoinRegion joinRegion) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Map accessMap = new HashMap();
for (Iterator joinSourceIter = joinRegion.getJoinSourceNodes().values().iterator(); joinSourceIter.hasNext();) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanProcedures.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanProcedures.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanProcedures.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Collection;
import java.util.HashSet;
@@ -29,37 +29,38 @@
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+
public class RulePlanProcedures implements OptimizerRule {
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.optimizer.relational.RuleStack, com.metamatrix.query.analysis.AnalysisRecord, com.metamatrix.query.util.CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.optimizer.relational.RuleStack, org.teiid.query.analysis.AnalysisRecord, org.teiid.query.util.CommandContext)
*/
public PlanNode execute(PlanNode plan,
final QueryMetadataInterface metadata,
@@ -68,7 +69,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.SOURCE, NodeConstants.Types.ACCESS)) {
if (!FrameUtil.isProcedure(node.getFirstChild())) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanSorts.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanSorts.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,29 +20,30 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.processor.relational.JoinNode.JoinStrategyType;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.processor.relational.JoinNode.JoinStrategyType;
+import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.CommandContext;
+
/**
* Attempts to minimize the cost of sorting operations across the plan.
*/
@@ -53,7 +54,7 @@
CapabilitiesFinder capabilitiesFinder, RuleStack rules,
AnalysisRecord analysisRecord, CommandContext context)
throws QueryPlannerException, QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
return optimizeSorts(false, plan, plan);
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanUnions.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePlanUnions.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePlanUnions.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Iterator;
@@ -29,28 +29,29 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.util.CommandContext;
+
/**
* Organizes union branches so that push down is possible. This does not check to actually ensure that push down will happen.
*/
public class RulePlanUnions implements OptimizerRule {
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.optimizer.relational.RuleStack, com.metamatrix.query.analysis.AnalysisRecord, com.metamatrix.query.util.CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.optimizer.relational.RuleStack, org.teiid.query.analysis.AnalysisRecord, org.teiid.query.util.CommandContext)
*/
public PlanNode execute(PlanNode plan,
QueryMetadataInterface metadata,
@@ -59,7 +60,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
optimizeUnions(plan, metadata, capabilitiesFinder);
@@ -71,12 +72,12 @@
* @param metadata
* @param capabilitiesFinder
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private void optimizeUnions(PlanNode plan,
QueryMetadataInterface metadata,
CapabilitiesFinder capabilitiesFinder) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
//look for all union branches and their sources
for (PlanNode unionNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.SET_OP, NodeConstants.Types.SET_OP | NodeConstants.Types.ACCESS)) {
List accessNodes = NodeEditor.findAllNodes(unionNode, NodeConstants.Types.ACCESS);
@@ -165,7 +166,7 @@
PlanNode unionNode,
Map sourceNodes,
boolean all, Operation setOp) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode child : unionNode.getChildren()) {
if (child.getType() == NodeConstants.Types.SET_OP) {
if (!all && Operation.UNION == child.getProperty(NodeConstants.Info.SET_OPERATION)) {
@@ -210,7 +211,7 @@
private Object getModelId(QueryMetadataInterface metadata,
List accessNodes, CapabilitiesFinder capFinder) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Object modelID = null;
for (Iterator k = accessNodes.iterator(); k.hasNext();) {
@@ -244,14 +245,14 @@
* @param node
* @param accessModelID
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
static void buildModelMap(QueryMetadataInterface metadata,
CapabilitiesFinder capFinder,
Map accessMap,
PlanNode node,
Object accessModelID) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
List accessNodes = null;
for (Iterator i = accessMap.entrySet().iterator(); i.hasNext();) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushAggregates.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushAggregates.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Arrays;
@@ -35,54 +35,54 @@
import java.util.Map;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants.Info;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject.Util;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants.Info;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.LanguageObject.Util;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.util.CommandContext;
/**
* @since 4.2
@@ -91,9 +91,9 @@
OptimizerRule {
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode,
- * com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder,
- * com.metamatrix.query.optimizer.relational.RuleStack, AnalysisRecord, CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode,
+ * org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder,
+ * org.teiid.query.optimizer.relational.RuleStack, AnalysisRecord, CommandContext)
* @since 4.2
*/
public PlanNode execute(PlanNode plan,
@@ -103,7 +103,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode groupNode : NodeEditor.findAllNodes(plan, NodeConstants.Types.GROUP, NodeConstants.Types.ACCESS)) {
PlanNode child = groupNode.getFirstChild();
@@ -116,7 +116,7 @@
try {
pushGroupNodeOverUnion(plan, metadata, capFinder, groupNode, child, groupingExpressions, setOp);
} catch (QueryResolverException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
continue;
}
@@ -160,7 +160,7 @@
QueryMetadataInterface metadata, CapabilitiesFinder capFinder,
PlanNode groupNode, PlanNode child,
List<SingleElementSymbol> groupingExpressions, PlanNode setOp)
- throws MetaMatrixComponentException, QueryMetadataException,
+ throws TeiidComponentException, QueryMetadataException,
QueryPlannerException, QueryResolverException {
if (setOp.getType() != NodeConstants.Types.SET_OP || setOp.getProperty(NodeConstants.Info.SET_OPERATION) != Operation.UNION) {
return; //must not be a union
@@ -243,7 +243,7 @@
CapabilitiesFinder capFinder,
List<SingleElementSymbol> groupingExpressions,
LinkedHashSet<AggregateSymbol> aggregates, PlanNode planNode)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (planNode.getType() != NodeConstants.Types.ACCESS) {
return false;
}
@@ -292,7 +292,7 @@
public void addView(PlanNode root, PlanNode unionSource, boolean pushdown, List<SingleElementSymbol> groupingExpressions,
Set<AggregateSymbol> aggregates, List<ElementSymbol> virtualElements,
QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws MetaMatrixComponentException, QueryPlannerException, QueryResolverException {
+ throws TeiidComponentException, QueryPlannerException, QueryResolverException {
PlanNode originalNode = unionSource;
//branches other than the first need to have their projected column names updated
PlanNode sortNode = NodeEditor.findNodePreOrder(unionSource, NodeConstants.Types.SORT, NodeConstants.Types.SOURCE);
@@ -326,7 +326,7 @@
try {
group.setMetadataID(ResolverUtil.addTempGroup(tma, group, virtualElements, false));
} catch (QueryResolverException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
intermediateView.addGroup(group);
List<ElementSymbol> projectedSymbols = ResolverUtil.resolveElementsInGroup(group, metadata);
@@ -434,7 +434,7 @@
List<SingleElementSymbol> groupingExpressions,
Set<AggregateSymbol> allAggregates,
QueryMetadataInterface metadata,
- CapabilitiesFinder capFinder) throws MetaMatrixComponentException,
+ CapabilitiesFinder capFinder) throws TeiidComponentException,
QueryMetadataException, QueryPlannerException {
Map<PlanNode, List<AggregateSymbol>> aggregateMap = createNodeMapping(groupNode, allAggregates);
@@ -514,7 +514,7 @@
static void stageAggregates(PlanNode groupNode,
QueryMetadataInterface metadata,
Collection<SingleElementSymbol> stagedGroupingSymbols,
- Collection<AggregateSymbol> aggregates) throws MetaMatrixComponentException, QueryPlannerException {
+ Collection<AggregateSymbol> aggregates) throws TeiidComponentException, QueryPlannerException {
//remove any aggregates that are computed over a group by column
Set<Expression> expressions = new HashSet<Expression>();
for (SingleElementSymbol expression : stagedGroupingSymbols) {
@@ -541,7 +541,7 @@
aggregates.clear();
aggregates.addAll(newAggs);
} catch (QueryResolverException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
}
}
}
@@ -661,7 +661,7 @@
private static Map<AggregateSymbol, Expression> buildAggregateMap(Collection<? extends SingleElementSymbol> aggregateExpressions,
QueryMetadataInterface metadata, Set<AggregateSymbol> nestedAggregates) throws QueryResolverException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Map<AggregateSymbol, Expression> aggMap = new HashMap<AggregateSymbol, Expression>();
for (SingleElementSymbol symbol : aggregateExpressions) {
AggregateSymbol partitionAgg = (AggregateSymbol)symbol;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushLimit.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushLimit.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,35 +20,36 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.util.CommandContext;
+
/**
* Pushes limit nodes to their lowest points. This rule should only be run once. Should be run after all access nodes have been raised
*/
@@ -56,7 +57,7 @@
/**
- * @see com.metamatrix.query.optimizer.relational.OptimizerRule#execute(com.metamatrix.query.optimizer.relational.plantree.PlanNode, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.optimizer.relational.RuleStack, com.metamatrix.query.analysis.AnalysisRecord, com.metamatrix.query.util.CommandContext)
+ * @see org.teiid.query.optimizer.relational.OptimizerRule#execute(org.teiid.query.optimizer.relational.plantree.PlanNode, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.optimizer.relational.RuleStack, org.teiid.query.analysis.AnalysisRecord, org.teiid.query.util.CommandContext)
*/
public PlanNode execute(PlanNode plan,
QueryMetadataInterface metadata,
@@ -65,7 +66,7 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
List<PlanNode> limitNodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.TUPLE_LIMIT);
@@ -109,7 +110,7 @@
return plan;
}
- boolean canPushLimit(PlanNode rootNode, PlanNode limitNode, List<PlanNode> limitNodes, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
+ boolean canPushLimit(PlanNode rootNode, PlanNode limitNode, List<PlanNode> limitNodes, QueryMetadataInterface metadata, CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
PlanNode child = limitNode.getFirstChild();
if (child == null || child.getChildCount() == 0) {
return false;
@@ -176,7 +177,7 @@
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder,
PlanNode parentNode) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Object modelID = RuleRaiseAccess.getModelIDFromAccess(accessNode, metadata);
if (modelID == null) {
return null;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushNonJoinCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushNonJoinCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushNonJoinCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,30 +20,31 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
+
/**
* Pushes on criteria out of the on clause if possible.
*
@@ -61,7 +62,7 @@
* @return Updated query plan if rule fired, else original query plan
*/
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
boolean treeChanged = false;
boolean removeCopiedFlag = false;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RulePushSelectCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RulePushSelectCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.Collection;
import java.util.Collections;
@@ -30,35 +30,36 @@
import java.util.Set;
import java.util.Stack;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.resolver.util.AccessPattern;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.resolver.util.AccessPattern;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
public final class RulePushSelectCriteria implements OptimizerRule {
/**
@@ -69,7 +70,7 @@
* @return Updated query plan if rule fired, else original query plan
*/
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// Initialize movedNode to true so the loop will start
boolean movedAnyNode = true;
@@ -138,7 +139,7 @@
private PlanNode findOriginatingNode(QueryMetadataInterface metadata,
CapabilitiesFinder capFinder, PlanNode critNode)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
if (critNode.getGroups().isEmpty()) {
//check to see if pushing may impact cardinality
PlanNode groupNode = NodeEditor.findNodePreOrder(critNode, NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE);
@@ -162,7 +163,7 @@
private Object getSubqueryModelId(QueryMetadataInterface metadata,
CapabilitiesFinder capFinder, PlanNode critNode)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Object modelId = null;
for (SubqueryContainer subqueryContainer : critNode.getSubqueryContainers()) {
Object validId = CriteriaCapabilityValidatorVisitor.validateSubqueryPushdown(subqueryContainer, null, metadata, capFinder);
@@ -235,10 +236,10 @@
* @param capFinder
* @throws QueryPlannerException
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
void pushTowardOriginatingNode(PlanNode sourceNode, PlanNode critNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
boolean groupSelects = sourceNode.getParent().getType() == NodeConstants.Types.SELECT && sourceNode.getChildCount() == 0;
@@ -265,7 +266,7 @@
* @return destinationChild
*/
PlanNode examinePath(PlanNode critNode, PlanNode sourceNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryPlannerException, MetaMatrixComponentException {
+ throws QueryPlannerException, TeiidComponentException {
// Walk from source node up to critNode to build list of intervening nodes
Stack<PlanNode> path = new Stack<PlanNode>();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseAccess.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,39 +28,39 @@
import java.util.List;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.util.CommandContext;
import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.util.CommandContext;
public final class RuleRaiseAccess implements OptimizerRule {
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
boolean afterJoinPlanning = !rules.contains(RuleConstants.PLAN_JOINS);
@@ -85,7 +85,7 @@
* @return null if nothing changed, and a new plan root if something changed
*/
static PlanNode raiseAccessNode(PlanNode rootNode, PlanNode accessNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, boolean afterJoinPlanning)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
PlanNode parentNode = accessNode.getParent();
if(parentNode == null) {
@@ -218,7 +218,7 @@
Collection<? extends SingleElementSymbol> aggregates,
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Object modelID = getModelIDFromAccess(accessNode, metadata);
if(modelID == null) {
return false;
@@ -248,7 +248,7 @@
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder,
PlanNode parentNode) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
// Find the model for this node by getting ACCESS node's model
Object modelID = getModelIDFromAccess(accessNode, metadata);
if(modelID == null) {
@@ -302,14 +302,14 @@
* @param parentNode
* @return
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryPlannerException
*/
static boolean canRaiseOverSelect(PlanNode accessNode,
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder,
PlanNode parentNode) throws QueryMetadataException,
- MetaMatrixComponentException,
+ TeiidComponentException,
QueryPlannerException {
if (parentNode.hasBooleanProperty(NodeConstants.Info.IS_PHANTOM)) {
return true;
@@ -353,12 +353,12 @@
* @param metadata Metadata
* @param capFinder Capabilities finder
* @return True if can push symbol to source
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
* @since 4.1.2
*/
private static boolean canPushSymbol(SingleElementSymbol symbol, boolean inSelectClause, Object modelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Expression expr = SymbolMap.getExpression(symbol);
@@ -401,7 +401,7 @@
* nodes will be sent to
*/
private static Object canRaiseOverJoin(Object modelId, PlanNode joinNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, boolean afterJoinPlanning)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
List crits = (List) joinNode.getProperty(NodeConstants.Info.JOIN_CRITERIA);
JoinType type = (JoinType) joinNode.getProperty(NodeConstants.Info.JOIN_TYPE);
@@ -445,7 +445,7 @@
CapabilitiesFinder capFinder,
List<Criteria> crits,
JoinType type) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
//we only want to consider binary joins
if (children.size() != 2) {
return null;
@@ -565,7 +565,7 @@
* Checks criteria one predicate at a time. Only tests up to the equi restriction.
*/
static boolean isSupportedJoinCriteria(SupportedJoinCriteria sjc, Criteria crit, Object accessModelID, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if(!CriteriaCapabilityValidatorVisitor.canPushLanguageObject(crit, accessModelID, metadata, capFinder) ) {
return false;
}
@@ -598,7 +598,7 @@
*/
private static boolean matchesForeignKey(QueryMetadataInterface metadata,
List<Object> leftIds, List<Object> rightIds, GroupSymbol leftGroup)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
Collection fks = metadata.getForeignKeysInGroup(leftGroup.getMetadataID());
for (Object fk : fks) {
List fkColumns = metadata.getElementIDsInKey(fk);
@@ -660,10 +660,10 @@
* @param metadata Metadata access
* @return Object Model ID or null if not found.
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
static Object getModelIDFromAccess(PlanNode accessNode, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Object accessModelID = accessNode.getProperty(NodeConstants.Info.MODEL_ID);
if(accessModelID == null) {
@@ -681,7 +681,7 @@
private static boolean canRaiseOverSetQuery(PlanNode setOpNode,
QueryMetadataInterface metadata,
- CapabilitiesFinder capFinder) throws QueryMetadataException, MetaMatrixComponentException {
+ CapabilitiesFinder capFinder) throws QueryMetadataException, TeiidComponentException {
Object modelID = null;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRaiseNull.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRaiseNull.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,43 +20,44 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.NodeFactory;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.NodeFactory;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.util.CommandContext;
+
/**
* Will attempt to raise null nodes to their highest points
*/
public final class RuleRaiseNull implements OptimizerRule {
public PlanNode execute(PlanNode plan, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, RuleStack rules, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
List<PlanNode> nodes = NodeEditor.findAllNodes(plan, NodeConstants.Types.NULL);
@@ -87,7 +88,7 @@
* @return null if the raising should not continue, else the newRoot
*/
PlanNode raiseNullNode(PlanNode rootNode, List<PlanNode> nodes, PlanNode nullNode, QueryMetadataInterface metadata, CapabilitiesFinder capFinder)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
PlanNode parentNode = nullNode.getParent();
@@ -259,13 +260,13 @@
* @param nullNode
* @throws QueryPlannerException
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
static void raiseNullThroughJoin(QueryMetadataInterface metadata,
PlanNode joinNode,
PlanNode nullNode) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Assertion.assertTrue(joinNode.getType() == NodeConstants.Types.JOIN);
Assertion.assertTrue(nullNode.getType() == NodeConstants.Types.NULL);
Assertion.assertTrue(nullNode.getParent() == joinNode);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleRemoveOptionalJoins.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
import java.util.ArrayList;
import java.util.HashSet;
@@ -28,33 +28,33 @@
import java.util.List;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
/**
* Removes optional join nodes if elements originating from that join are not used in the
@@ -70,12 +70,12 @@
AnalysisRecord analysisRecord,
CommandContext context) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
try {
removeOptionalJoinNodes(plan, metadata, capFinder, null);
} catch (QueryResolverException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
return plan;
}
@@ -88,7 +88,7 @@
QueryMetadataInterface metadata,
CapabilitiesFinder capFinder, Set<ElementSymbol> elements) throws QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException, QueryResolverException {
+ TeiidComponentException, QueryResolverException {
if (node.getChildCount() == 0) {
return false;
}
@@ -204,7 +204,7 @@
* @throws QueryPlannerException
*/
private boolean removedJoin(PlanNode joinNode, PlanNode optionalNode,
- Set elements, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException, QueryPlannerException {
+ Set elements, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException, QueryPlannerException {
Set groups = optionalNode.getGroups();
Assertion.isNotNull(elements);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleValidateWhereAll.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/relational/rules/RuleValidateWhereAll.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleValidateWhereAll.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,28 +20,29 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.relational.rules;
+package org.teiid.query.optimizer.relational.rules;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.relational.OptimizerRule;
-import com.metamatrix.query.optimizer.relational.RuleStack;
-import com.metamatrix.query.optimizer.relational.plantree.NodeConstants;
-import com.metamatrix.query.optimizer.relational.plantree.NodeEditor;
-import com.metamatrix.query.optimizer.relational.plantree.PlanNode;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.optimizer.relational.OptimizerRule;
+import org.teiid.query.optimizer.relational.RuleStack;
+import org.teiid.query.optimizer.relational.plantree.NodeConstants;
+import org.teiid.query.optimizer.relational.plantree.NodeEditor;
+import org.teiid.query.optimizer.relational.plantree.PlanNode;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* Validates that the any atomic query being sent to a model where the model
* requires a criteria actually has a criteria. This rule will detect this
@@ -64,7 +65,7 @@
throws
QueryPlannerException,
QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (PlanNode node : NodeEditor.findAllNodes(plan, NodeConstants.Types.ACCESS)) {
Object modelID = RuleRaiseAccess.getModelIDFromAccess(node, metadata);
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/xml (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ContextReplacerVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/ContextReplacerVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ContextReplacerVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
import java.util.Collections;
import java.util.LinkedList;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+
/**
* <p>Walk a tree of language objects and replaces any usage of 'context' syntax
* (implemented as a Function) with it's right argument. The stripped-off
@@ -59,7 +60,7 @@
}
/**
- * @see com.metamatrix.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(com.metamatrix.query.sql.symbol.Expression)
+ * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression)
*/
public Expression replaceExpression(Expression exp) {
if (exp instanceof Function){
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/CriteriaPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/CriteriaPlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/CriteriaPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,32 +20,33 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class CriteriaPlanner {
/**
@@ -59,10 +60,10 @@
* @param criteria Criteria from user's command
* @throws QueryPlannerException for any logical exception detected during planning
* @throws QueryMetadataException if metadata encounters exception
- * @throws MetaMatrixComponentException unexpected exception
+ * @throws TeiidComponentException unexpected exception
*/
static void placeUserCriteria(Criteria criteria, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
for (Iterator conjunctIter = Criteria.separateCriteriaByAnd(criteria).iterator(); conjunctIter.hasNext();) {
@@ -193,7 +194,7 @@
/**
* Removes non-inferred staging table criteria. Places it directly onto the contextCriteria
*/
- static boolean planStagingTableCriteria(Criteria criteria, XMLPlannerEnvironment planEnv) throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ static boolean planStagingTableCriteria(Criteria criteria, XMLPlannerEnvironment planEnv) throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
String rootTempGroupName = getStagingTableForConjunct(criteria, planEnv.getGlobalMetadata());
if (rootTempGroupName == null){
@@ -210,7 +211,7 @@
}
static boolean planRowLimitFunction(Criteria conjunct, Criteria wholeCrit, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
// Check for "rowlimit" or "rowlimitexception" pseudo-function:
// Restrictions
@@ -286,7 +287,7 @@
* @throws QueryPlannerException if conjunct has mixed types
*/
static String getStagingTableForConjunct(Criteria conjunct, QueryMetadataInterface metadata)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
Collection elements = ElementCollectorVisitor.getElements(conjunct, true);
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/HandleNillableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/HandleNillableVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/HandleNillableVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Properties;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Namespace;
-import com.metamatrix.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Namespace;
+import org.teiid.query.mapping.xml.Navigator;
+
/**
* Removes the all the "excluded" nodes from the Mapping XML node tree
*/
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/MarkExcludeVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/MarkExcludeVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,24 +20,25 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.query.mapping.xml.MappingAllNode;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingBaseNode;
-import com.metamatrix.query.mapping.xml.MappingChoiceNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSequenceNode;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.MappingAllNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+
/**
* This vistor marks all the nodes in the Mapping Document to
* "exclude".
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/NameInSourceResolverVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/NameInSourceResolverVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,28 +20,29 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* This visitor resolves the "element" names on the mapping nodes to the planned
* sources defined at same or parent nodes.
@@ -116,9 +117,9 @@
symbol.setType(DataTypeManager.getDataTypeClass(metadata.getElementType(symbol.getMetadataID())));
return symbol;
} catch (QueryMetadataException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
}
@@ -129,19 +130,19 @@
* @param planEnv
*/
public static void resolveElements(MappingDocument doc, XMLPlannerEnvironment planEnv)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
NameInSourceResolverVisitor real = new NameInSourceResolverVisitor(planEnv);
try {
MappingVisitor visitor = new Navigator(true, real);
doc.acceptVisitor(visitor);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getCause() instanceof QueryMetadataException) {
throw (QueryMetadataException)e.getCause();
}
- else if (e.getCause() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getCause();
+ else if (e.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getCause();
}
throw e;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/QueryUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/QueryUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/QueryUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.ArrayList;
import java.util.Collection;
@@ -30,37 +30,38 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* Helper methods for dealing with relational queries while performing XML planning.
*
@@ -93,12 +94,12 @@
* Resolve a command using the metadata in the planner environment.
* @param query The query to resolve
* @param planEnv The planner environment
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryPlannerException
* @since 4.3
*/
static void resolveQuery(Command query, TempMetadataAdapter metadata)
- throws MetaMatrixComponentException, QueryPlannerException {
+ throws TeiidComponentException, QueryPlannerException {
// Run resolver
try {
QueryResolver.resolveCommand(query, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
@@ -112,14 +113,14 @@
* @param query The query to rewrite
* @param planEnv The planner environment
* @throws QueryPlannerException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.3
*/
static Command rewriteQuery(Command query, QueryMetadataInterface metadata, CommandContext context)
- throws QueryPlannerException, MetaMatrixComponentException {
+ throws QueryPlannerException, TeiidComponentException {
try {
return QueryRewriter.rewrite(query, metadata, context);
- } catch(MetaMatrixProcessingException e) {
+ } catch(TeiidProcessingException e) {
throw new QueryPlannerException(e, e.getMessage());
}
}
@@ -132,10 +133,10 @@
* @return QueryNode defining the query transformation of the temp table
* @throws QueryPlannerException for any logical exception detected
* @throws QueryMetadataException if metadata encounters exception
- * @throws MetaMatrixComponentException unexpected exception
+ * @throws TeiidComponentException unexpected exception
*/
static QueryNode getQueryNode(String groupName, QueryMetadataInterface metadata)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException{
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException{
QueryNode queryNode = null;
try {
@@ -160,23 +161,23 @@
}
public static GroupSymbol createResolvedGroup(String groupName, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
GroupSymbol group = new GroupSymbol(groupName);
return createResolvedGroup(group, metadata);
}
public static GroupSymbol createResolvedGroup(GroupSymbol group, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
try {
ResolverUtil.resolveGroup(group, metadata);
return group;
} catch (QueryResolverException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
}
static Command getQueryFromQueryNode(String groupName, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
QueryNode queryNode = QueryUtil.getQueryNode(groupName, planEnv.getGlobalMetadata());
Command command = QueryUtil.getQuery(queryNode);
@@ -184,7 +185,7 @@
}
static void handleBindings(LanguageObject object, QueryNode planNode, XMLPlannerEnvironment planEnv)
- throws QueryResolverException, QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryResolverException, QueryPlannerException, QueryMetadataException, TeiidComponentException {
List parsedBindings = parseBindings(planNode, planEnv);
@@ -194,7 +195,7 @@
}
}
- static List parseBindings(QueryNode planNode, XMLPlannerEnvironment planEnv) throws MetaMatrixComponentException {
+ static List parseBindings(QueryNode planNode, XMLPlannerEnvironment planEnv) throws TeiidComponentException {
Collection bindingsCol = planNode.getBindings();
if (bindingsCol == null) {
return Collections.EMPTY_LIST;
@@ -206,7 +207,7 @@
ElementSymbol binding = (ElementSymbol)QueryParser.getQueryParser().parseExpression((String)bindings.next());
parsedBindings.add(binding);
} catch (QueryParserException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
}
}
return parsedBindings;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ReferenceBindingReplacerVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/ReferenceBindingReplacerVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ReferenceBindingReplacerVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+
/**
* <p>This visitor class will traverse a language object tree, find any Reference
* objects, and replace them with the corresponding parsed Expression which is the
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodeGenaratorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/SourceNodeGenaratorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodeGenaratorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
-import com.metamatrix.query.mapping.xml.MappingBaseNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/SourceNodePlannerVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/SourceNodePlannerVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,36 +29,37 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
-import com.metamatrix.query.sql.visitor.ReferenceCollectorVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.sql.visitor.ReferenceCollectorVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* This visitor will take source node's QueryNode, move the the inputset criteria
* specified on the QueryNode on to the Source Node's query.
@@ -181,7 +182,7 @@
baseQuery.setCriteria(inputSetCriteria);
rsInfo.setCriteriaRaised(true);
} catch (Exception e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
@@ -190,7 +191,7 @@
* if they are returns true; false otherwise
*/
private boolean areBindingsOnlyToNode(QueryNode modifiedNode, MappingSourceNode sourceNode)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
List bindings = QueryUtil.parseBindings(modifiedNode, planEnv);
@@ -226,7 +227,7 @@
* set names in a mapping document.
*/
private GroupSymbol createAlternateGroup(GroupSymbol oldSymbol, MappingSourceNode sourceNode)
- throws QueryMetadataException, MetaMatrixComponentException, QueryResolverException, QueryPlannerException {
+ throws QueryMetadataException, TeiidComponentException, QueryResolverException, QueryPlannerException {
// get elements in the old group
List elements = ResolverUtil.resolveElementsInGroup(oldSymbol, planEnv.getGlobalMetadata());
@@ -301,7 +302,7 @@
* @return true if converted; false otherwise
*/
private boolean convertCriteria(GroupSymbol newGroupSymbol, Query transformationQuery, Criteria criteria, TempMetadataAdapter metadata, Map symbolMap)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
String groupName = newGroupSymbol.getName();
Collection elementsInCriteria = ElementCollectorVisitor.getElements(criteria, true);
@@ -389,14 +390,14 @@
* @return
*/
public static MappingDocument raiseInputSet(MappingDocument doc, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
SourceNodePlannerVisitor real = new SourceNodePlannerVisitor(planEnv);
planWalk(doc, real);
return doc;
}
private static void planWalk(MappingDocument doc, MappingVisitor visitor)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
try {
Navigator walker = new Navigator(true, visitor) {
@@ -420,15 +421,15 @@
};
doc.acceptVisitor(walker);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getCause() instanceof QueryPlannerException) {
throw (QueryPlannerException)e.getCause();
}
else if (e.getCause() instanceof QueryMetadataException) {
throw (QueryMetadataException)e.getCause();
}
- else if (e.getCause() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getCause();
+ else if (e.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getCause();
}
else {
throw e;
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/TagBuilderVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/TagBuilderVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/TagBuilderVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingCommentNode;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.processor.xml.AddCommentInstruction;
-import com.metamatrix.query.processor.xml.AddNodeInstruction;
-import com.metamatrix.query.processor.xml.NodeDescriptor;
-import com.metamatrix.query.processor.xml.ProcessorInstruction;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingCommentNode;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.processor.xml.AddCommentInstruction;
+import org.teiid.query.processor.xml.AddNodeInstruction;
+import org.teiid.query.processor.xml.NodeDescriptor;
+import org.teiid.query.processor.xml.ProcessorInstruction;
+import org.teiid.query.sql.symbol.ElementSymbol;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/ValidateMappedCriteriaVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/ValidateMappedCriteriaVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,22 +28,23 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.mapping.xml.MappingCriteriaNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupsUsedByElementsVisitor;
-import com.metamatrix.query.sql.visitor.StaticSymbolMappingVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupsUsedByElementsVisitor;
+import org.teiid.query.sql.visitor.StaticSymbolMappingVisitor;
+
/**
* Validate the criteria specified on the elements.
*/
@@ -84,7 +85,7 @@
ResolverVisitor.resolveLanguageObject(crit, null, planEnv.getGlobalMetadata());
return crit;
} catch (Exception e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
return null;
@@ -102,20 +103,20 @@
public static void validateAndCollectCriteriaElements(MappingDocument doc, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
try {
ValidateMappedCriteriaVisitor visitor = new ValidateMappedCriteriaVisitor(planEnv);
doc.acceptVisitor(new Navigator(true, visitor));
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getCause() instanceof QueryPlannerException) {
throw (QueryPlannerException)e.getCause();
}
else if (e.getCause() instanceof QueryMetadataException) {
throw (QueryMetadataException)e.getCause();
}
- else if (e.getCause() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getCause();
+ else if (e.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getCause();
}
throw e;
}
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLNodeMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLNodeMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLNodeMappingVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Symbol;
-import com.metamatrix.query.sql.visitor.AbstractSymbolMappingVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.sql.visitor.AbstractSymbolMappingVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This visitor is able to map symbols based on the XML document model:
* given a symbol representing one of the nodes of the document which is
@@ -84,8 +85,8 @@
return null;
}
return elementNode.getSourceNode().getMappedSymbol(new ElementSymbol(symbolName));
- } catch (MetaMatrixComponentException err) {
- throw new MetaMatrixRuntimeException(err);
+ } catch (TeiidComponentException err) {
+ throw new TeiidRuntimeException(err);
}
}
@@ -99,26 +100,26 @@
* that is not mapped to data in a mapping class
*/
public static Criteria convertCriteria(Criteria simpleCrit, MappingDocument rootNode, QueryMetadataInterface metadata)
- throws QueryPlannerException, MetaMatrixComponentException{
+ throws QueryPlannerException, TeiidComponentException{
return (Criteria)convertObject(simpleCrit, rootNode, metadata);
}
public static LanguageObject convertObject(LanguageObject object, MappingDocument rootNode, QueryMetadataInterface metadata)
- throws QueryPlannerException, MetaMatrixComponentException{
+ throws QueryPlannerException, TeiidComponentException{
LanguageObject copy = (LanguageObject)object.clone();
//Don't want to do deep visiting
XMLNodeMappingVisitor mappingVisitor = new XMLNodeMappingVisitor(rootNode, metadata);
try {
PreOrderNavigator.doVisit(copy, mappingVisitor);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
Throwable child = e.getChild();
- if (child instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)child;
+ if (child instanceof TeiidComponentException) {
+ throw (TeiidComponentException)child;
}
- throw new MetaMatrixComponentException(child);
+ throw new TeiidComponentException(child);
}
Collection unmappedSymbols = mappingVisitor.getUnmappedSymbols();
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanToProcessVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanToProcessVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,48 +20,49 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
-import com.metamatrix.query.mapping.xml.InterceptingVisitor;
-import com.metamatrix.query.mapping.xml.MappingAllNode;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingBaseNode;
-import com.metamatrix.query.mapping.xml.MappingChoiceNode;
-import com.metamatrix.query.mapping.xml.MappingCommentNode;
-import com.metamatrix.query.mapping.xml.MappingCriteriaNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingInterceptor;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSequenceNode;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.processor.xml.AbortProcessingInstruction;
-import com.metamatrix.query.processor.xml.AddNodeInstruction;
-import com.metamatrix.query.processor.xml.BlockInstruction;
-import com.metamatrix.query.processor.xml.Condition;
-import com.metamatrix.query.processor.xml.CriteriaCondition;
-import com.metamatrix.query.processor.xml.DefaultCondition;
-import com.metamatrix.query.processor.xml.EndBlockInstruction;
-import com.metamatrix.query.processor.xml.EndDocumentInstruction;
-import com.metamatrix.query.processor.xml.ExecSqlInstruction;
-import com.metamatrix.query.processor.xml.IfInstruction;
-import com.metamatrix.query.processor.xml.InitializeDocumentInstruction;
-import com.metamatrix.query.processor.xml.JoinedWhileInstruction;
-import com.metamatrix.query.processor.xml.ExecStagingTableInstruction;
-import com.metamatrix.query.processor.xml.MoveCursorInstruction;
-import com.metamatrix.query.processor.xml.MoveDocInstruction;
-import com.metamatrix.query.processor.xml.ProcessorInstruction;
-import com.metamatrix.query.processor.xml.Program;
-import com.metamatrix.query.processor.xml.RecurseProgramCondition;
-import com.metamatrix.query.processor.xml.WhileInstruction;
+import org.teiid.query.mapping.xml.InterceptingVisitor;
+import org.teiid.query.mapping.xml.MappingAllNode;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingChoiceNode;
+import org.teiid.query.mapping.xml.MappingCommentNode;
+import org.teiid.query.mapping.xml.MappingCriteriaNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingInterceptor;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSequenceNode;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.processor.xml.AbortProcessingInstruction;
+import org.teiid.query.processor.xml.AddNodeInstruction;
+import org.teiid.query.processor.xml.BlockInstruction;
+import org.teiid.query.processor.xml.Condition;
+import org.teiid.query.processor.xml.CriteriaCondition;
+import org.teiid.query.processor.xml.DefaultCondition;
+import org.teiid.query.processor.xml.EndBlockInstruction;
+import org.teiid.query.processor.xml.EndDocumentInstruction;
+import org.teiid.query.processor.xml.ExecSqlInstruction;
+import org.teiid.query.processor.xml.ExecStagingTableInstruction;
+import org.teiid.query.processor.xml.IfInstruction;
+import org.teiid.query.processor.xml.InitializeDocumentInstruction;
+import org.teiid.query.processor.xml.JoinedWhileInstruction;
+import org.teiid.query.processor.xml.MoveCursorInstruction;
+import org.teiid.query.processor.xml.MoveDocInstruction;
+import org.teiid.query.processor.xml.ProcessorInstruction;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.RecurseProgramCondition;
+import org.teiid.query.processor.xml.WhileInstruction;
+
/**
* This class converts the MappingDocument to a Program which can be executed using the
* Query Processor
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,50 +20,50 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.id.IDGenerator;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingNodeLogger;
+import org.teiid.query.mapping.xml.MappingRecursiveElement;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.CommandPlanner;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.XMLPlan;
+import org.teiid.query.processor.xml.XMLProcessorEnvironment;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingNodeLogger;
-import com.metamatrix.query.mapping.xml.MappingRecursiveElement;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.xml.Program;
-import com.metamatrix.query.processor.xml.XMLPlan;
-import com.metamatrix.query.processor.xml.XMLProcessorEnvironment;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.CommandContext;
/**
- * <p> This prepares an {@link com.metamatrix.query.processor.xml.XMLPlan XMLPlan} from
- * a Mapping Document structure of {@link com.metamatrix.query.mapping.xml.MappingNode MappingNodes}.
+ * <p> This prepares an {@link org.teiid.query.processor.xml.XMLPlan XMLPlan} from
+ * a Mapping Document structure of {@link org.teiid.query.mapping.xml.MappingNode MappingNodes}.
* </p>
*/
public final class XMLPlanner implements CommandPlanner{
@@ -75,10 +75,10 @@
public XMLPlanner() {}
/**
- * @see com.metamatrix.query.optimizer.CommandPlanner#optimize
+ * @see org.teiid.query.optimizer.CommandPlanner#optimize
*/
public ProcessorPlan optimize(Command command,IDGenerator idGenerator,QueryMetadataInterface metadata,CapabilitiesFinder capFinder,AnalysisRecord analysisRecord,CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
XMLPlannerEnvironment env = new XMLPlannerEnvironment(metadata);
@@ -94,10 +94,10 @@
* @return The XML plan returned as an XMLPlan object
* @throws QueryPlannerException
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
static XMLPlan preparePlan(Command command, QueryMetadataInterface metadata, AnalysisRecord analysisRecord, XMLPlannerEnvironment planEnv, IDGenerator idGenerator, CapabilitiesFinder capFinder, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
Query xmlQuery = (Query) command;
boolean debug = analysisRecord.recordDebug();
@@ -159,10 +159,10 @@
* @param metadata QueryMetadataInterface instance
* @throws QueryPlannerException for any logical exception detected during planning
* @throws QueryMetadataException if metadata encounters exception
- * @throws MetaMatrixComponentException unexpected exception
+ * @throws TeiidComponentException unexpected exception
*/
private static void prePlan(XMLPlannerEnvironment planEnv, boolean debug)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
//extract source nodes
planEnv.mappingDoc = SourceNodeGenaratorVisitor.extractSourceNodes(planEnv.mappingDoc);
@@ -267,10 +267,10 @@
* @return Map The hash map of result sets and corresponding order by clauses
* @throws QueryPlannerException
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
private static void placeOrderBys(OrderBy orderBy, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
//prepare fully resolved Order By elements
if (orderBy == null) {
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLPlannerEnvironment.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLPlannerEnvironment.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,27 +20,28 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.processor.xml.Program;
-import com.metamatrix.query.processor.xml.XMLProcessorEnvironment;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.processor.xml.Program;
+import org.teiid.query.processor.xml.XMLProcessorEnvironment;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
+
/**
* This handy little class simply holds data that is sent recursively throughout
* the XMLPlanner. It is useful to define it all here, where more data can be
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLQueryPlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLQueryPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
import java.util.HashMap;
@@ -32,52 +32,53 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingBaseNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.relational.rules.NewCalculateCostUtil;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.visitor.StaticSymbolMappingVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingBaseNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.relational.rules.NewCalculateCostUtil;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.processor.relational.RelationalPlan;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.visitor.StaticSymbolMappingVisitor;
+
public class XMLQueryPlanner {
static void prePlanQueries(MappingDocument doc, final XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
MappingVisitor queryPlanVisitor = new MappingVisitor() {
@@ -98,7 +99,7 @@
}
} catch (Exception e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
@@ -107,7 +108,7 @@
}
static void optimizeQueries(MappingDocument doc, final XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
MappingVisitor queryPlanVisitor = new MappingVisitor() {
public void visit(MappingSourceNode sourceNode) {
@@ -128,7 +129,7 @@
ProcessorPlan queryPlan = optimizePlan(command, planEnv);
rsInfo.setPlan(queryPlan);
} catch (Exception e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
};
@@ -136,20 +137,20 @@
}
private static void planWalk(MappingDocument doc, MappingVisitor visitor)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
try {
Navigator walker = new Navigator(true, visitor);
doc.acceptVisitor(walker);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getCause() instanceof QueryPlannerException) {
throw (QueryPlannerException)e.getCause();
}
else if (e.getCause() instanceof QueryMetadataException) {
throw (QueryMetadataException)e.getCause();
}
- else if (e.getCause() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getCause();
+ else if (e.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getCause();
}
else {
throw e;
@@ -158,7 +159,7 @@
}
static void planQueries(MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
ResultSetInfo rsInfo = sourceNode.getResultSetInfo();
@@ -175,7 +176,7 @@
planQueryWithCriteria(sourceNode, planEnv);
}
} catch (QueryResolverException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
if (rsInfo.getUserRowLimit() != -1) {
@@ -193,7 +194,7 @@
}
static ProcessorPlan optimizePlan(Command query, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
TempMetadataAdapter metadata = planEnv.getGlobalMetadata();
ProcessorPlan plan = QueryOptimizer.optimizePlan(query, metadata, planEnv.idGenerator, planEnv.capFinder, planEnv.analysisRecord, planEnv.context);
@@ -202,7 +203,7 @@
}
static void prepareQuery(MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv, QueryCommand rsQuery)
- throws MetaMatrixComponentException, QueryPlannerException {
+ throws TeiidComponentException, QueryPlannerException {
Collection externalGroups = getExternalGroups(sourceNode);
@@ -260,7 +261,7 @@
}
private static void planQueryWithCriteria(MappingSourceNode contextNode, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, MetaMatrixComponentException, QueryMetadataException, QueryResolverException {
+ throws QueryPlannerException, TeiidComponentException, QueryMetadataException, QueryResolverException {
Map symbolMap = new HashMap();
@@ -374,7 +375,7 @@
}
private static void updateSymbolMap(Map symbolMap, String oldGroup, final String newGroup, QueryMetadataInterface metadata)
- throws QueryResolverException,QueryMetadataException,MetaMatrixComponentException {
+ throws QueryResolverException,QueryMetadataException,TeiidComponentException {
GroupSymbol oldGroupSymbol = new GroupSymbol(oldGroup);
ResolverUtil.resolveGroup(oldGroupSymbol, metadata);
@@ -394,7 +395,7 @@
* @return {@link GroupSymbol} the temptable which has been planned.
*/
static void planStagingTable(String groupName, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
ResultSetInfo rsInfo = planEnv.getStagingTableResultsInfo(groupName);
@@ -411,7 +412,7 @@
* to unload the staging table.
*/
static boolean planStagaingQuery(boolean implicit, String srcGroupName, String stageGroupName, Query query, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
GroupSymbol srcGroup = QueryUtil.createResolvedGroup(srcGroupName, planEnv.getGlobalMetadata());
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLStagaingQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xml/XMLStagaingQueryPlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xml/XMLStagaingQueryPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,26 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xml;
+package org.teiid.query.optimizer.xml;
import java.util.Collection;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.mapping.xml.MappingDocument;
-import com.metamatrix.query.mapping.xml.MappingSourceNode;
-import com.metamatrix.query.mapping.xml.MappingVisitor;
-import com.metamatrix.query.mapping.xml.Navigator;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.optimizer.relational.RelationalPlanner;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.mapping.xml.MappingDocument;
+import org.teiid.query.mapping.xml.MappingSourceNode;
+import org.teiid.query.mapping.xml.MappingVisitor;
+import org.teiid.query.mapping.xml.Navigator;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.optimizer.relational.RelationalPlanner;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+
/**
* This class has code to with planning the automatic XML staging queries.
*/
@@ -47,14 +48,14 @@
static void stageQueries(MappingDocument doc, final XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
MappingVisitor queryPlanVisitor = new MappingVisitor() {
public void visit(MappingSourceNode sourceNode) {
try {
stagePlannedQuery(sourceNode, planEnv);
} catch (Exception e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
};
@@ -62,20 +63,20 @@
}
private static void planWalk(MappingDocument doc, MappingVisitor visitor)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
try {
Navigator walker = new Navigator(true, visitor);
doc.acceptVisitor(walker);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getCause() instanceof QueryPlannerException) {
throw (QueryPlannerException)e.getCause();
}
else if (e.getCause() instanceof QueryMetadataException) {
throw (QueryMetadataException)e.getCause();
}
- else if (e.getCause() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getCause();
+ else if (e.getCause() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getCause();
}
else {
throw e;
@@ -84,7 +85,7 @@
}
static boolean stagePlannedQuery(MappingSourceNode sourceNode, XMLPlannerEnvironment planEnv)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
Option option = planEnv.xmlCommand.getOption();
Copied: trunk/engine/src/main/java/org/teiid/query/optimizer/xquery (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery)
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/xquery/XQueryPlanner.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/optimizer/xquery/XQueryPlanner.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/xquery/XQueryPlanner.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,32 +20,33 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.optimizer.xquery;
+package org.teiid.query.optimizer.xquery;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.CommandPlanner;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.xquery.XQueryPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryPlannerException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.CommandPlanner;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.xquery.XQueryPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.util.CommandContext;
+
/**
* Planner for XQuery execution plans
*/
public class XQueryPlanner implements CommandPlanner {
/**
- * @see com.metamatrix.query.optimizer.CommandPlanner#optimize(Command, com.metamatrix.core.id.IDGenerator, com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder, com.metamatrix.query.analysis.AnalysisRecord, CommandContext)
+ * @see org.teiid.query.optimizer.CommandPlanner#optimize(Command, org.teiid.core.id.IDGenerator, org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.optimizer.capabilities.CapabilitiesFinder, org.teiid.query.analysis.AnalysisRecord, CommandContext)
*/
public ProcessorPlan optimize(Command command, IDGenerator idGenerator, QueryMetadataInterface metadata, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, CommandContext context)
- throws QueryPlannerException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryPlannerException, QueryMetadataException, TeiidComponentException {
return new XQueryPlan((XQuery)command);
}
Copied: trunk/engine/src/main/java/org/teiid/query/parser (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/parser)
Modified: trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/ParseInfo.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/parser/ParseInfo.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
public class ParseInfo {
Modified: trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/QueryParser.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/parser/QueryParser.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
import java.io.StringReader;
+import org.teiid.api.exception.query.QueryParserException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.xquery.XQueryExpression;
+import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.xquery.XQueryExpression;
-import com.metamatrix.query.xquery.saxon.SaxonXQueryExpression;
-
/**
* <p>Converts a SQL-string to an object version of a query. This
* QueryParser can be reused but is NOT thread-safe as the parser uses an
@@ -141,7 +140,7 @@
xquery.setOption(option);
}
return xquery;
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
if(sql.startsWith(XML_OPEN_BRACKET) || sql.startsWith(XQUERY_DECLARE)) {
throw new QueryParserException(e, QueryPlugin.Util.getString("QueryParser.xqueryCompilation")); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/parser/SQLParserUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/parser/SQLParserUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.StringUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.JoinType;
+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.proc.CriteriaSelector;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-
public class SQLParserUtil {
String normalizeStringLiteral(String s) {
Copied: trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/BatchCollector.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchCollector.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,112 @@
+/*
+ * 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 java.util.List;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
+
+public class BatchCollector {
+
+ public interface BatchProducer {
+ /**
+ * Get a batch of results or possibly an Exception.
+ * @return Batch of results
+ * @throws BlockedException indicating next batch is not available yet
+ * @throws TeiidComponentException for non-business rule exception
+ * @throws TeiidProcessingException for business rule exception, related
+ * to user input or modeling
+ */
+ TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException;
+
+ /**
+ * Get list of resolved elements describing output columns for this plan.
+ * @return List of SingleElementSymbol
+ */
+ List getOutputElements();
+ }
+
+ public interface BatchHandler {
+ boolean batchProduced(TupleBatch batch) throws TeiidProcessingException, TeiidComponentException;
+ }
+
+ private BatchProducer sourceNode;
+ private BatchHandler batchHandler;
+
+ private boolean done = false;
+ private TupleBuffer buffer;
+
+ public BatchCollector(BatchProducer sourceNode, TupleBuffer buffer) {
+ this.sourceNode = sourceNode;
+ this.buffer = buffer;
+ }
+
+ public TupleBuffer collectTuples() throws TeiidComponentException, TeiidProcessingException {
+ TupleBatch batch = null;
+ while(!done) {
+ batch = sourceNode.nextBatch();
+
+ flushBatch(batch);
+
+ // Check for termination condition
+ if(batch.getTerminationFlag()) {
+ done = true;
+ buffer.close();
+ break;
+ }
+ }
+ return buffer;
+ }
+
+ public TupleBuffer getTupleBuffer() {
+ return buffer;
+ }
+
+ /**
+ * Flush the batch by giving it to the buffer manager.
+ */
+ private void flushBatch(TupleBatch batch) throws TeiidComponentException, TeiidProcessingException {
+ boolean add = true;
+ if (this.batchHandler != null && (batch.getRowCount() > 0 || batch.getTerminationFlag())) {
+ add = this.batchHandler.batchProduced(batch);
+ }
+ // Add batch
+ if(batch.getRowCount() > 0 || batch.getTerminationFlag()) {
+ buffer.addTupleBatch(batch, add);
+ }
+ }
+
+ public void setBatchHandler(BatchHandler batchHandler) {
+ this.batchHandler = batchHandler;
+ }
+
+ public int getRowCount() {
+ return buffer.getRowCount();
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/BatchIterator.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,191 @@
+/*
+ * 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 java.util.List;
+
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.BatchCollector.BatchProducer;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
+
+/**
+ * A BatchIterator provides an iterator interface to a {@link BatchProducer}.
+ * By setting {@link #setBuffer(TupleBuffer)},
+ * the iterator can copy on read into a {@link TupleBuffer} for repeated reading.
+ *
+ * Note that the saveOnMark buffering only lasts until the next mark is set.
+ */
+public class BatchIterator implements IndexedTupleSource {
+
+ private final BatchProducer source;
+ private boolean saveOnMark;
+ private TupleBuffer buffer;
+ private IndexedTupleSource bufferedTs;
+
+ public BatchIterator(BatchProducer source) {
+ this.source = source;
+ }
+
+ private boolean done;
+ private int currentRow = 1;
+ private TupleBatch currentBatch;
+ private List currentTuple;
+ private int bufferedIndex;
+ private boolean mark;
+
+ @Override
+ public boolean hasNext() throws TeiidComponentException,
+ TeiidProcessingException {
+
+ if (done && this.bufferedTs == null) {
+ return false;
+ }
+ while (currentTuple == null) {
+ if (currentBatch == null) {
+ if (this.bufferedTs != null) {
+ if (this.currentRow <= this.bufferedIndex) {
+ this.bufferedTs.setPosition(currentRow++);
+ this.currentTuple = this.bufferedTs.nextTuple();
+ return true;
+ }
+ if (done) {
+ return false;
+ }
+ }
+ currentBatch = this.source.nextBatch();
+ if (buffer != null && !saveOnMark) {
+ buffer.addTupleBatch(currentBatch, true);
+ bufferedIndex = currentBatch.getEndRow();
+ }
+ }
+
+ if (currentBatch.containsRow(currentRow)) {
+ this.currentTuple = currentBatch.getTuple(currentRow++);
+ } else {
+ done = currentBatch.getTerminationFlag();
+ currentBatch = null;
+ if (done) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ public void setBuffer(TupleBuffer buffer, boolean saveOnMark) {
+ this.buffer = buffer;
+ this.bufferedTs = this.buffer.createIndexedTupleSource();
+ this.saveOnMark = saveOnMark;
+ }
+
+ @Override
+ public void closeSource() {
+ if (this.buffer != null) {
+ this.buffer.remove();
+ this.buffer = null;
+ }
+ }
+
+ @Override
+ public List<SingleElementSymbol> getSchema() {
+ return source.getOutputElements();
+ }
+
+ @Override
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
+ if (currentTuple == null && !hasNext()) {
+ return null;
+ }
+ List result = currentTuple;
+ currentTuple = null;
+ if (mark && saveOnMark && this.currentRow - 1 > this.buffer.getRowCount()) {
+ this.buffer.setRowCount(this.currentRow - 2);
+ this.buffer.addTuple(result);
+ this.bufferedIndex = this.currentRow - 1;
+ }
+ return result;
+ }
+
+ public void reset() {
+ if (this.bufferedTs != null) {
+ mark = false;
+ this.bufferedTs.reset();
+ if (this.currentRow != this.bufferedTs.getCurrentIndex()) {
+ this.currentRow = this.bufferedTs.getCurrentIndex();
+ this.currentTuple = null;
+ }
+ return;
+ }
+ throw new UnsupportedOperationException();
+ }
+
+ public void mark() {
+ if (this.bufferedTs != null) {
+ this.bufferedTs.mark();
+ if (saveOnMark && this.currentRow > this.bufferedIndex) {
+ this.buffer.purge();
+ this.bufferedIndex = 0;
+ }
+ }
+ mark = true;
+ }
+
+ @Override
+ public int getCurrentIndex() {
+ return currentRow;
+ }
+
+ public void setPosition(int position) {
+ if (this.bufferedTs != null) {
+ this.bufferedTs.setPosition(position);
+ this.currentRow = position;
+ }
+ if (this.currentBatch == null && position < this.currentRow) {
+ throw new UnsupportedOperationException("Backwards positioning is not allowed"); //$NON-NLS-1$
+ }
+ this.currentRow = position;
+ this.currentTuple = null;
+ if (this.currentBatch == null || !this.currentBatch.containsRow(position)) {
+ this.currentBatch = null;
+ }
+ }
+
+ @Override
+ public int available() {
+ if (this.currentRow <= this.bufferedIndex) {
+ this.bufferedTs.setPosition(this.currentRow);
+ return this.bufferedTs.available();
+ }
+ if (currentBatch != null) {
+ return currentBatch.getEndRow() - currentRow + 1;
+ }
+ return 0;
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/CollectionTupleSource.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/CollectionTupleSource.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/CollectionTupleSource.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/CollectionTupleSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,79 @@
+/*
+ * 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 java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
+
+public class CollectionTupleSource implements TupleSource {
+
+ private Iterator<? extends List<?>> tuples;
+ private List<SingleElementSymbol> schema;
+
+ public static CollectionTupleSource createUpdateCountTupleSource(int count) {
+ return new CollectionTupleSource(Arrays.asList(Arrays.asList(count)).iterator(), Command.getUpdateCommandSymbol());
+ }
+
+ public static CollectionTupleSource createNullTupleSource(List<SingleElementSymbol> schema) {
+ return new CollectionTupleSource(new ArrayList<List<Object>>(0).iterator(), schema);
+ }
+
+ public CollectionTupleSource(Iterator<? extends List<?>> tuples,
+ List<SingleElementSymbol> schema) {
+ this.tuples = tuples;
+ this.schema = schema;
+ }
+
+ @Override
+ public List<?> nextTuple() {
+ if (tuples.hasNext()) {
+ return tuples.next();
+ }
+ return null;
+ }
+
+ @Override
+ public List<SingleElementSymbol> getSchema() {
+ return schema;
+ }
+
+ @Override
+ public void closeSource() {
+
+ }
+
+ @Override
+ public int available() {
+ if (tuples.hasNext()) {
+ return 1;
+ }
+ return 0;
+ }
+}
\ No newline at end of file
Property changes on: trunk/engine/src/main/java/org/teiid/query/processor/CollectionTupleSource.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Copied: trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorDataManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/ProcessorDataManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,52 @@
+/*
+ * 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 org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
+
+
+public interface ProcessorDataManager {
+
+ TupleSource registerRequest(Object processorId, Command command, String modelName, String connectorBindingId, int nodeID)
+ throws TeiidComponentException, TeiidProcessingException;
+
+ /**
+ * Lookup a value from a cached code table. If the code table is not loaded, it will be
+ * loaded on the first query. Code tables should be cached based on a combination of
+ * the codeTableName, returnElementName, and keyElementName. If the table is not loaded,
+ * a request will be made and the method should throw a BlockedException.
+ */
+ Object lookupCodeValue(CommandContext context,
+ String codeTableName,
+ String returnElementName,
+ String keyElementName,
+ Object keyValue) throws BlockedException,
+ TeiidComponentException, TeiidProcessingException;
+
+ void clearCodeTables();
+}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/ProcessorPlan.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/ProcessorPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,166 @@
+/*
+ * 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.teiid.query.analysis.AnalysisRecord.*;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.processor.BatchCollector.BatchProducer;
+import org.teiid.query.util.CommandContext;
+
+
+/**
+ * <p>This class represents a processor plan. It is generic in that it
+ * abstracts the interface to the plan by the processor, meaning that the
+ * actual implementation of the plan or the types of processing done by the
+ * plan is not important to the processor.</p>
+ * <p>All the implementations of this interface need to implement {@link #clone}
+ * method. The plan is only clonable in the pre or post-processing stage, not
+ * during the processing state (things like program state, result sets, etc).
+ * It's only safe to clone in between query processings. In other words, it's
+ * only safe to call {@link #clone} before the call to {@link #open} or after
+ * the call to {@link #close}.
+ * </p>
+ */
+public abstract class ProcessorPlan implements Cloneable, BatchProducer {
+
+ private List warnings = null;
+
+ private CommandContext context;
+
+ /**
+ * Initialize the plan with some required pieces of data for making
+ * queries. The data manager is used to make queries and the processorID
+ * must be passed with the request so the data manager can find the
+ * processor again.
+ *
+ * @param context Process execution context
+ * @param dataMgr Data manager reference
+ * @param bufferMgr Buffer manager reference
+ */
+ public abstract void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr);
+
+ /**
+ * Get all warnings found while processing this plan. These warnings may
+ * be detected throughout the plan lifetime, which means new ones may arrive
+ * at any time. This method returns all current warnings and clears
+ * the current warnings list. The warnings are in order they were detected.
+ * @return Current list of warnings, never null
+ */
+ public List getAndClearWarnings() {
+ if (warnings == null) {
+ return null;
+ }
+ List copied = warnings;
+ warnings = null;
+ return copied;
+ }
+
+ protected void addWarning(TeiidException warning) {
+ if (warnings == null) {
+ warnings = new ArrayList(1);
+ }
+ warnings.add(warning);
+ }
+
+ /**
+ * Reset a plan so that it can be processed again.
+ */
+ public void reset() {
+ this.warnings = null;
+ }
+
+ /**
+ * Get list of resolved elements describing output columns for this plan.
+ * @return List of SingleElementSymbol
+ */
+ public abstract List getOutputElements();
+
+ /**
+ * Get the processor context, which can be modified.
+ * @return context object
+ */
+ public CommandContext getContext() {
+ return context;
+ }
+
+ public void setContext(CommandContext context) {
+ this.context = context;
+ }
+
+ /**
+ * Open the plan for processing.
+ * @throws TeiidComponentException
+ */
+ public abstract void open() throws TeiidComponentException, TeiidProcessingException;
+
+ /**
+ * Get a batch of results or possibly an Exception.
+ * @return Batch of results
+ * @throws BlockedException indicating next batch is not available yet
+ * @throws TeiidComponentException for non-business rule exception
+ * @throws TeiidProcessingException for business rule exception, related
+ * to user input or modeling
+ */
+ public abstract TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException;
+
+ /**
+ * Close the plan after processing.
+ * @throws TeiidComponentException
+ */
+ public abstract void close() throws TeiidComponentException;
+
+ /**
+ * Return a safe clone of the ProcessorPlan. A ProcessorPlan may only be
+ * safely cloned in between processings. That is, it is only safe to clone
+ * a plan before it is {@link #open opened} or after it is {@link #close
+ * closed}.
+ * @return safe clone of this ProcessorPlan, as long as it is not open for
+ * processing
+ */
+ public abstract ProcessorPlan clone();
+
+ public boolean requiresTransaction(boolean transactionalReads) {
+ return transactionalReads;
+ }
+
+ /**
+ * @see com.metamatrix.query.processor.Describable#getDescriptionProperties()
+ */
+ public PlanNode getDescriptionProperties() {
+ PlanNode props = new PlanNode(this.getClass().getSimpleName());
+ props.addProperty(PROP_OUTPUT_COLS, AnalysisRecord.getOutputColumnProperties(getOutputElements()));
+ return props;
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/QueryProcessor.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/QueryProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,233 @@
+/*
+ * 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 java.util.List;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.util.Assertion;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.logging.MessageLevel;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.processor.BatchCollector.BatchProducer;
+import org.teiid.query.util.CommandContext;
+import org.teiid.resource.cci.DataNotAvailableException;
+
+
+public class QueryProcessor implements BatchProducer {
+
+ public static class ExpiredTimeSliceException extends TeiidRuntimeException {
+
+ }
+
+ private static ExpiredTimeSliceException EXPIRED_TIME_SLICE = new ExpiredTimeSliceException();
+
+ public interface ProcessorFactory {
+ QueryProcessor createQueryProcessor(String query, String recursionGroup, CommandContext commandContext) throws TeiidProcessingException, TeiidComponentException;
+ }
+
+ private CommandContext context;
+ private ProcessorDataManager dataMgr;
+ private BufferManager bufferMgr;
+ private ProcessorPlan processPlan;
+ private boolean initialized = false;
+ private int reserved;
+ /** Flag that marks whether the request has been canceled. */
+ private volatile boolean requestCanceled = false;
+ private static final int DEFAULT_WAIT = 50;
+ private boolean processorClosed = false;
+
+ private boolean nonBlocking = false;
+
+ /**
+ * Construct a processor with all necessary information to process.
+ * @param plan The plan to process
+ * @param context The context that this plan is being processed in
+ * @param bufferMgr The buffer manager that provides access to tuple sources
+ * @param dataMgr The data manager that provides access to get data
+ * @throws TeiidComponentException
+ */
+ public QueryProcessor(ProcessorPlan plan, CommandContext context, BufferManager bufferMgr, ProcessorDataManager dataMgr) throws TeiidComponentException {
+ this.context = context;
+ this.dataMgr = dataMgr;
+ this.processPlan = plan;
+ this.bufferMgr = bufferMgr;
+ // Add data manager to all nodes in tree
+ this.processPlan.initialize(context, this.dataMgr, bufferMgr);
+ }
+
+ public CommandContext getContext() {
+ return context;
+ }
+
+ public Object getProcessID() {
+ return this.context.getProcessorID();
+ }
+
+ public ProcessorPlan getProcessorPlan() {
+ return this.processPlan;
+ }
+
+ public TupleBatch nextBatch()
+ throws BlockedException, TeiidProcessingException, TeiidComponentException {
+
+ while (true) {
+ long wait = DEFAULT_WAIT;
+ try {
+ return nextBatchDirect();
+ } catch (ExpiredTimeSliceException e) {
+ if (!nonBlocking) {
+ throw e;
+ }
+ continue;
+ } catch (DataNotAvailableException e) {
+ if (!nonBlocking) {
+ throw e;
+ }
+ wait = e.getRetryDelay();
+ } catch (BlockedException e) {
+ if (!nonBlocking) {
+ throw e;
+ }
+ }
+ try {
+ Thread.sleep(wait);
+ } catch (InterruptedException err) {
+ throw new TeiidComponentException(err);
+ }
+ }
+ }
+
+ private TupleBatch nextBatchDirect()
+ throws BlockedException, TeiidProcessingException, TeiidComponentException {
+
+ boolean done = false;
+ TupleBatch result = null;
+
+ try {
+ // initialize if necessary
+ if(! initialized) {
+ if (reserved == 0) {
+ reserved = this.bufferMgr.reserveBuffers(this.bufferMgr.getSchemaSize(this.getOutputElements()), BufferReserveMode.FORCE);
+ }
+ // Open the top node for reading
+ processPlan.open();
+ initialized = true;
+ }
+
+ long currentTime = System.currentTimeMillis();
+ Assertion.assertTrue(!processorClosed);
+ while(currentTime < context.getTimeSliceEnd()) {
+ if (requestCanceled) {
+ throw new TeiidProcessingException(QueryExecPlugin.Util.getString("QueryProcessor.request_cancelled", getProcessID())); //$NON-NLS-1$
+ }
+ if (currentTime > context.getTimeoutEnd()) {
+ throw new TeiidProcessingException("Query timed out"); //$NON-NLS-1$
+ }
+ result = processPlan.nextBatch();
+
+ if(result.getTerminationFlag()) {
+ done = true;
+ break;
+ }
+
+ if (result.getRowCount() > 0) {
+ break;
+ }
+
+ }
+ } catch (BlockedException e) {
+ throw e;
+ } catch (TeiidException e) {
+ closeProcessing();
+ if (e instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException)e;
+ }
+ if (e instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e;
+ }
+ throw new TeiidComponentException(e);
+ }
+ if(done) {
+ closeProcessing();
+ }
+ if (result == null) {
+ throw EXPIRED_TIME_SLICE;
+ }
+ return result;
+ }
+
+
+ /**
+ * Close processing and clean everything up. Should only be called by the same thread that called process.
+ */
+ public void closeProcessing() {
+ if (processorClosed) {
+ return;
+ }
+ if (LogManager.isMessageToBeRecorded(LogConstants.CTX_DQP, MessageLevel.DETAIL)) {
+ LogManager.logDetail(LogConstants.CTX_DQP, "QueryProcessor: closing processor"); //$NON-NLS-1$
+ }
+ this.bufferMgr.releaseBuffers(reserved);
+ reserved = 0;
+ processorClosed = true;
+ try {
+ processPlan.close();
+ } catch (TeiidComponentException e1){
+ LogManager.logDetail(LogConstants.CTX_DQP, e1, "Error closing processor"); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public List getOutputElements() {
+ return this.processPlan.getOutputElements();
+ }
+
+ public List<Exception> getAndClearWarnings() {
+ return this.processPlan.getAndClearWarnings();
+ }
+
+ /**
+ * Asynch shutdown of the QueryProcessor, which may trigger exceptions in the processing thread
+ */
+ public void requestCanceled() {
+ this.requestCanceled = true;
+ }
+
+ public BatchCollector createBatchCollector() throws TeiidComponentException {
+ return new BatchCollector(this, this.bufferMgr.createTupleBuffer(this.processPlan.getOutputElements(), context.getConnectionID(), TupleSourceType.PROCESSOR));
+ }
+
+ public void setNonBlocking(boolean nonBlocking) {
+ this.nonBlocking = nonBlocking;
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/TempTableDataManager.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/TempTableDataManager.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/processor/TempTableDataManager.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/processor/TempTableDataManager.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -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.query.processor;
+
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.util.CommandContext;
+
+
+/**
+ * This proxy ProcessorDataManager is used during XML query processing to handle temporary groups
+ * in the document model. Temp groups are materialized during processing, and their tuple sources
+ * are cached, so this proxy shortcuts the need to go to the DataTierManager and immediately
+ * returns the tuple source (synchronously) if a temp group's source is what's being requested.
+ */
+public class TempTableDataManager implements ProcessorDataManager {
+
+ private ProcessorDataManager processorDataManager;
+ private TempTableStore tempTableStore;
+
+ /**
+ * Constructor takes the "real" ProcessorDataManager that this object will be a proxy to,
+ * and will pass most calls through to transparently. Only when a request is registered for
+ * a temp group will this proxy do it's thing. A ProcessorEnvironment is needed to to
+ * access cached information about temp groups
+ * @param processorDataManager the real ProcessorDataManager that this object is a proxy to
+ * @param env a ProcessorEnvironment implementation
+ */
+ public TempTableDataManager(ProcessorDataManager processorDataManager, TempTableStore tempTableStore){
+ this.processorDataManager = processorDataManager;
+ this.tempTableStore = tempTableStore;
+ }
+
+ /**
+ * This is the magic method. If the command is selecting from a temporary group, that
+ * temporary groups tuple source (which is cached in the ProcessorEnvironment) will
+ * be retrieved and immediately (synchronously) delivered to the QueryProcessor.
+ * If a temp group is <i>not</i> being selected from, then this request will be
+ * passed through to the underlying ProcessorDataManager.
+ * @throws TeiidProcessingException
+ */
+ public TupleSource registerRequest(
+ Object processorID,
+ Command command,
+ String modelName,
+ String connectorBindingId, int nodeID)
+ throws TeiidComponentException, TeiidProcessingException {
+
+ if(tempTableStore != null) {
+ TupleSource result = tempTableStore.registerRequest(command);
+ if (result != null) {
+ return result;
+ }
+ }
+ return this.processorDataManager.registerRequest(processorID, command, modelName, connectorBindingId, nodeID);
+ }
+
+ public Object lookupCodeValue(
+ CommandContext context,
+ String codeTableName,
+ String returnElementName,
+ String keyElementName,
+ Object keyValue)
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
+
+ return this.processorDataManager.lookupCodeValue(context, codeTableName, returnElementName, keyElementName, keyValue);
+ }
+
+ @Override
+ public void clearCodeTables() {
+ this.processorDataManager.clearCodeTables();
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/batch (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/batch)
Modified: trunk/engine/src/main/java/org/teiid/query/processor/batch/BatchedUpdatePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/batch/BatchedUpdatePlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/batch/BatchedUpdatePlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,24 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.batch;
+package org.teiid.query.processor.batch;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
/**
@@ -96,7 +96,7 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#initialize(com.metamatrix.query.util.CommandContext, com.metamatrix.query.processor.ProcessorDataManager, com.metamatrix.common.buffer.BufferManager)
+ * @see org.teiid.query.processor.ProcessorPlan#initialize(org.teiid.query.util.CommandContext, org.teiid.query.processor.ProcessorDataManager, org.teiid.common.buffer.BufferManager)
* @since 4.2
*/
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
@@ -110,7 +110,7 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
+ * @see org.teiid.query.processor.ProcessorPlan#getOutputElements()
* @since 4.2
*/
public List getOutputElements() {
@@ -118,20 +118,20 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#open()
+ * @see org.teiid.query.processor.ProcessorPlan#open()
* @since 4.2
*/
- public void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void open() throws TeiidComponentException, TeiidProcessingException {
// It's ok to open() the first plan, as it is not dependent on any prior commands.
// See note for defect 16166 in the nextBatch() method.
openPlan();
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#nextBatch()
+ * @see org.teiid.query.processor.ProcessorPlan#nextBatch()
* @since 4.2
*/
- public TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException {
for (;planIndex < updatePlans.length; planIndex++) {
if (!planOpened[planIndex]) { // Open the plan only once
/* Defect 16166
@@ -159,8 +159,8 @@
return batch;
}
- private void openPlan() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ private void openPlan() throws TeiidComponentException,
+ TeiidProcessingException {
if (this.contexts != null && !this.contexts.isEmpty()) {
CommandContext context = updatePlans[planIndex].getContext();
context.getVariableContext().clear();
@@ -173,10 +173,10 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#close()
+ * @see org.teiid.query.processor.ProcessorPlan#close()
* @since 4.2
*/
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
// if the plan opened but the atomic request got cancelled then close the last plan node.
if (planIndex < updatePlans.length && planOpened[planIndex]) {
updatePlans[planIndex].close();
@@ -185,7 +185,7 @@
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#reset()
+ * @see org.teiid.query.processor.ProcessorPlan#reset()
* @since 4.2
*/
public void reset() {
Copied: trunk/engine/src/main/java/org/teiid/query/processor/proc (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/proc)
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/AssignmentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/AssignmentInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/AssignmentInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,24 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.Arrays;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.util.VariableContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.VariableContext;
/**
* <p> This instruction updates the current variable context with a value for the Variable
@@ -62,10 +62,10 @@
* expected to result in 1 column, 1 row tuple, if more than a row is returned an exception
* is thrown. Also updates the program counter.</p>
* @throws BlockedException
- * @throws MetaMatrixComponentException if error processing command or expression on this instruction
+ * @throws TeiidComponentException if error processing command or expression on this instruction
*/
public void process(ProcedurePlan procEnv) throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
VariableContext varContext = procEnv.getCurrentVariableContext();
Object value = null;
@@ -120,7 +120,7 @@
}
/**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#clone()
+ * @see org.teiid.query.processor.program.ProgramInstruction#clone()
*/
public AssignmentInstruction clone() {
AssignmentInstruction clone = new AssignmentInstruction();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/BreakInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/BreakInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/BreakInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,12 +22,12 @@
/*
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.program.ProgramInstruction;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.processor.program.ProgramInstruction;
/**
* <p>This {@link ProgramInstruction} break from a loop when processed</p>.
@@ -38,7 +38,7 @@
return "BREAK INSTRUCTION"; //$NON-NLS-1$
}
- public void process(ProcedurePlan env) throws MetaMatrixComponentException {
+ public void process(ProcedurePlan env) throws TeiidComponentException {
super.process(env);
env.incrementProgramCounter();
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ContinueInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ContinueInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ContinueInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,14 +22,14 @@
/*
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
import java.util.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.processor.program.*;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.processor.program.*;
/**
* <p>This {@link ProgramInstruction} continue with the next loop when processed</p>.
@@ -39,7 +39,7 @@
return "CONTINUE INSTRUCTION"; //$NON-NLS-1$
}
- public void process(ProcedurePlan env) throws MetaMatrixComponentException {
+ public void process(ProcedurePlan env) throws TeiidComponentException {
Program parentProgram = env.peek();
//find the parent program that contains the loop/while instruction
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/CreateCursorResultSetInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/CreateCursorResultSetInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,17 +22,17 @@
/*
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.program.ProgramInstruction;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.program.ProgramInstruction;
/**
*/
@@ -58,7 +58,7 @@
* only temp groups
*/
public void process(ProcedurePlan procEnv)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
if(procEnv.resultSetExists(rsName)) {
procEnv.removeResults(rsName);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ErrorInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ErrorInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.ProcedureErrorInstructionException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.sql.symbol.Expression;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.sql.symbol.Expression;
/**
* <p> This instruction updates the current variable context with the Variable defined using
@@ -54,7 +54,7 @@
}
/**
- * @see com.metamatrix.query.processor.program.ProgramInstruction#clone()
+ * @see org.teiid.query.processor.program.ProgramInstruction#clone()
*/
public ErrorInstruction clone() {
ErrorInstruction clone = new ErrorInstruction();
@@ -73,8 +73,8 @@
}
@Override
- public void process(ProcedurePlan env) throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ public void process(ProcedurePlan env) throws TeiidComponentException,
+ TeiidProcessingException {
Object value = env.evaluateExpression(expression);
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP,
new Object[] {"Processing RaiseErrorInstruction with the value :", value}); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ExecDynamicSqlInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ExecDynamicSqlInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.Collections;
import java.util.HashMap;
@@ -31,42 +31,42 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.QueryProcessingException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.id.IDGenerator;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.optimizer.QueryOptimizer;
+import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.program.Program;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SetClause;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.id.IDGenerator;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.optimizer.QueryOptimizer;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.program.Program;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
/**
* <p>
@@ -121,7 +121,7 @@
* if this processing the plan throws a currentVarContext
*/
public void process(ProcedurePlan procEnv) throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
VariableContext localContext = procEnv.getCurrentVariableContext();
@@ -192,8 +192,8 @@
CreateCursorResultSetInstruction inst = new CreateCursorResultSetInstruction(CreateCursorResultSetInstruction.RS_NAME, commandPlan) {
@Override
public void process(ProcedurePlan procEnv)
- throws BlockedException, MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException,
+ TeiidProcessingException {
super.process(procEnv);
procEnv.getContext().popCall();
}
@@ -210,7 +210,7 @@
}
procEnv.push(dynamicProgram);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
Object[] params = {dynamicCommand, dynamicCommand.getSql(), e.getMessage()};
throw new QueryProcessingException(e, QueryExecPlugin.Util.getString("ExecDynamicSqlInstruction.couldnt_execute", params)); //$NON-NLS-1$
}
@@ -219,12 +219,12 @@
/**
* @param procEnv
* @param localContext
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException
+ * @throws TeiidComponentException
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException
*/
private void updateContextWithUsingValues(ProcedurePlan procEnv,
- VariableContext localContext) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ VariableContext localContext) throws TeiidComponentException, TeiidProcessingException {
if (dynamicCommand.getUsing() != null
&& !dynamicCommand.getUsing().isEmpty()) {
for (SetClause setClause : dynamicCommand.getUsing().getClauses()) {
@@ -260,11 +260,11 @@
/**
* @param procEnv
* @param command
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryProcessingException
*/
private void validateDynamicCommand(ProcedurePlan procEnv,
- Command command) throws MetaMatrixComponentException,
+ Command command) throws TeiidComponentException,
QueryProcessingException {
// validate project symbols
List dynamicExpectedColumns = dynamicCommand.getAsColumns();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/IfInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/IfInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.processor.program.Program;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.sql.lang.Criteria;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.processor.program.Program;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.sql.lang.Criteria;
/**
* <p>This instruction an holds an if block and an else block and a criteria that determines
@@ -82,11 +82,11 @@
* program stack, and break from the loop. Regardless if whether any criteria
* evaluate to true, this instruction will increment the program counter of the
* current program.
- * @throws MetaMatrixProcessingException
+ * @throws TeiidProcessingException
* @see ProgramInstruction#process(ProcedurePlan)
*/
public void process(ProcedurePlan procEnv)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
boolean evalValue = procEnv.evaluateCriteria(condition);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/LoopInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/LoopInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,22 +22,22 @@
/*
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.program.Program;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.program.Program;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
/**
*/
@@ -52,7 +52,7 @@
this.loopProgram = loopProgram;
}
- public void process(ProcedurePlan procEnv) throws MetaMatrixComponentException {
+ public void process(ProcedurePlan procEnv) throws TeiidComponentException {
List currentRow = procEnv.getCurrentRow(rsName);
VariableContext varContext = procEnv.getCurrentVariableContext();
//set results to the variable context(the cursor.element is treated as variable)
@@ -91,9 +91,9 @@
}
/**
- * @see com.metamatrix.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
+ * @see org.teiid.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
- public boolean testCondition(ProcedurePlan procEnv) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public boolean testCondition(ProcedurePlan procEnv) throws TeiidComponentException, TeiidProcessingException {
if(!procEnv.resultSetExists(rsName)) {
procEnv.executePlan(plan, rsName);
}
@@ -102,16 +102,16 @@
}
/**
- * @see com.metamatrix.query.processor.proc.RepeatedInstruction#getNestedProgram()
+ * @see org.teiid.query.processor.proc.RepeatedInstruction#getNestedProgram()
*/
public Program getNestedProgram() {
return loopProgram;
}
/**
- * @see com.metamatrix.query.processor.proc.RepeatedInstruction#postInstruction(com.metamatrix.query.processor.proc.ProcedureEnvironment)
+ * @see org.teiid.query.processor.proc.RepeatedInstruction#postInstruction(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
- public void postInstruction(ProcedurePlan procEnv) throws MetaMatrixComponentException {
+ public void postInstruction(ProcedurePlan procEnv) throws TeiidComponentException {
procEnv.removeResults(rsName);
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/ProcedurePlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/ProcedurePlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -35,40 +35,40 @@
import java.util.Set;
import java.util.Stack;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.CollectionTupleSource;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.processor.TempTableDataManager;
+import org.teiid.query.processor.program.Program;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.processor.relational.SubqueryAwareEvaluator;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStoreImpl;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.CollectionTupleSource;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.processor.TempTableDataManager;
-import com.metamatrix.query.processor.program.Program;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.processor.relational.SubqueryAwareEvaluator;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
*/
public class ProcedurePlan extends ProcessorPlan {
@@ -171,6 +171,7 @@
//reset program stack
originalProgram.resetProgramCounter();
+ this.tempContext.clear();
programs.clear();
programs.push(originalProgram);
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_DQP, "ProcedurePlan reset"); //$NON-NLS-1$
@@ -180,7 +181,7 @@
return this.dataMgr;
}
- public void open() throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ public void open() throws TeiidProcessingException, TeiidComponentException {
if (!this.evaluatedParams) {
if (this.params != null) {
for (Map.Entry<ElementSymbol, Expression> entry : this.params.entrySet()) {
@@ -214,7 +215,7 @@
* @see ProcessorPlan#nextBatch()
*/
public TupleBatch nextBatch()
- throws MetaMatrixComponentException, MetaMatrixProcessingException, BlockedException {
+ throws TeiidComponentException, TeiidProcessingException, BlockedException {
// Already returned results?
if(done) {
@@ -263,7 +264,7 @@
* count resulting from the procedure execution.
*/
private TupleSource processProcedure()
- throws MetaMatrixComponentException, MetaMatrixProcessingException, BlockedException {
+ throws TeiidComponentException, TeiidProcessingException, BlockedException {
// execute plan
ProgramInstruction inst = null;
@@ -305,7 +306,7 @@
}
public void close()
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
if (!this.cursorStates.isEmpty()) {
List<String> cursors = new ArrayList<String>(this.cursorStates.keySet());
for (String rsName : cursors) {
@@ -414,7 +415,7 @@
}
public CursorState executePlan(ProcessorPlan command, String rsName)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
CursorState state = this.cursorStates.get(rsName.toUpperCase());
if (state == null) {
@@ -445,11 +446,11 @@
}
/**
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @see com.metamatrix.query.processor.program.ProgramEnvironment#pop()
*/
- public void pop() throws MetaMatrixComponentException {
- this.programs.pop();
+ public void pop() throws TeiidComponentException {
+ Program program = this.programs.pop();
if (this.currentVarContext.getParentContext() != null) {
this.currentVarContext = this.currentVarContext.getParentContext();
}
@@ -459,15 +460,16 @@
tempTables.addAll(current);
- for (Iterator i = tempTables.iterator(); i.hasNext();) {
- this.tempTableStore.removeTempTableByName((String)i.next());
+ if (program != originalProgram) {
+ for (Iterator i = tempTables.iterator(); i.hasNext();) {
+ this.tempTableStore.removeTempTableByName((String)i.next());
+ }
}
-
this.tempContext.removeLast();
}
/**
- * @see com.metamatrix.query.processor.program.ProgramEnvironment#push(com.metamatrix.query.processor.program.Program)
+ * @see com.metamatrix.query.processor.program.ProgramEnvironment#push(org.teiid.query.processor.program.Program)
*/
public void push(Program program) {
program.resetProgramCounter();
@@ -487,7 +489,7 @@
/**
* @see com.metamatrix.query.processor.program.ProgramEnvironment#incrementProgramCounter()
*/
- public void incrementProgramCounter() throws MetaMatrixComponentException {
+ public void incrementProgramCounter() throws TeiidComponentException {
Program program = peek();
ProgramInstruction instr = program.getCurrentInstruction();
if (instr instanceof RepeatedInstruction) {
@@ -517,12 +519,12 @@
return (Set)this.tempContext.getLast();
}
- public List getCurrentRow(String rsName) throws MetaMatrixComponentException {
+ public List getCurrentRow(String rsName) throws TeiidComponentException {
return getCursorState(rsName.toUpperCase()).currentRow;
}
public boolean iterateCursor(String rsName)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
String rsKey = rsName.toUpperCase();
@@ -532,15 +534,15 @@
return (state.currentRow != null);
}
- private CursorState getCursorState(String rsKey) throws MetaMatrixComponentException {
+ private CursorState getCursorState(String rsKey) throws TeiidComponentException {
CursorState state = this.cursorStates.get(rsKey);
if (state == null) {
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0037, rsKey));
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0037, rsKey));
}
return state;
}
- public void removeResults(String rsName) throws MetaMatrixComponentException {
+ public void removeResults(String rsName) throws TeiidComponentException {
String rsKey = rsName.toUpperCase();
CursorState state = this.cursorStates.remove(rsKey);
if (state != null) {
@@ -556,7 +558,7 @@
* @return List of elements
* @throws QueryProcessorException if the list of elements is null
*/
- public List getSchema(String rsName) throws MetaMatrixComponentException {
+ public List getSchema(String rsName) throws TeiidComponentException {
// get the tuple source
String rsKey = rsName.toUpperCase();
@@ -611,14 +613,14 @@
return this.tempTableStore;
}
- boolean evaluateCriteria(Criteria condition) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
+ boolean evaluateCriteria(Criteria condition) throws BlockedException, TeiidProcessingException, TeiidComponentException {
evaluator.initialize(getContext(), getDataManager());
boolean result = evaluator.evaluate(condition, Collections.emptyList());
this.evaluator.close();
return result;
}
- Object evaluateExpression(Expression expression) throws BlockedException, MetaMatrixProcessingException, MetaMatrixComponentException {
+ Object evaluateExpression(Expression expression) throws BlockedException, TeiidProcessingException, TeiidComponentException {
evaluator.initialize(getContext(), getDataManager());
Object result = evaluator.evaluate(expression, Collections.emptyList());
this.evaluator.close();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/RepeatedInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/RepeatedInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/RepeatedInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.processor.program.Program;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.program.Program;
+
public interface RepeatedInstruction {
- public boolean testCondition(ProcedurePlan procEnv) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ public boolean testCondition(ProcedurePlan procEnv) throws TeiidComponentException, TeiidProcessingException;
public Program getNestedProgram();
- public void postInstruction(ProcedurePlan procEnv) throws MetaMatrixComponentException;
+ public void postInstruction(ProcedurePlan procEnv) throws TeiidComponentException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/proc/WhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/proc/WhileInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/proc/WhileInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,17 +22,17 @@
/*
*/
-package com.metamatrix.query.processor.proc;
+package org.teiid.query.processor.proc;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.program.Program;
+import org.teiid.query.processor.program.ProgramInstruction;
+import org.teiid.query.sql.lang.Criteria;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.processor.program.Program;
-import com.metamatrix.query.processor.program.ProgramInstruction;
-import com.metamatrix.query.sql.lang.Criteria;
/**
*/
@@ -48,7 +48,7 @@
this.condition = condition;
}
- public void process(ProcedurePlan env) throws MetaMatrixComponentException {
+ public void process(ProcedurePlan env) throws TeiidComponentException {
//do nothing
}
@@ -75,24 +75,24 @@
}
/**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
+ * @throws TeiidProcessingException
+ * @see org.teiid.query.processor.proc.RepeatedInstruction#testCondition(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
- public boolean testCondition(ProcedurePlan procEnv) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public boolean testCondition(ProcedurePlan procEnv) throws TeiidComponentException, TeiidProcessingException {
return procEnv.evaluateCriteria(condition);
}
/**
- * @see com.metamatrix.query.processor.proc.RepeatedInstruction#getNestedProgram()
+ * @see org.teiid.query.processor.proc.RepeatedInstruction#getNestedProgram()
*/
public Program getNestedProgram() {
return whileProgram;
}
/**
- * @see com.metamatrix.query.processor.proc.RepeatedInstruction#postInstruction(com.metamatrix.query.processor.proc.ProcedureEnvironment)
+ * @see org.teiid.query.processor.proc.RepeatedInstruction#postInstruction(com.metamatrix.query.processor.proc.ProcedureEnvironment)
*/
- public void postInstruction(ProcedurePlan procEnv) throws MetaMatrixComponentException {
+ public void postInstruction(ProcedurePlan procEnv) throws TeiidComponentException {
}
}
Copied: trunk/engine/src/main/java/org/teiid/query/processor/program (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/program)
Modified: trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/program/Program.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/program/Program.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.program;
+package org.teiid.query.processor.program;
import java.util.ArrayList;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.query.processor.proc.IfInstruction;
+import org.teiid.query.processor.proc.WhileInstruction;
-import com.metamatrix.query.processor.proc.IfInstruction;
-import com.metamatrix.query.processor.proc.WhileInstruction;
/**
* A program is a sequence of {@link ProgramInstruction ProgramInstruction}. Certain
Modified: trunk/engine/src/main/java/org/teiid/query/processor/program/ProgramInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/program/ProgramInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/program/ProgramInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.program;
+package org.teiid.query.processor.program;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.proc.ProcedurePlan;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.proc.ProcedurePlan;
/**
* <p>Abstract superclass of all program instructions.</p>
@@ -54,7 +54,7 @@
* instructions may add sub programs to the stack or not increment the counter (so that they are executed again.)
*/
public abstract void process(ProcedurePlan env)
- throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ throws TeiidComponentException, TeiidProcessingException;
/**
* Finds all nested plans and returns them.
Copied: trunk/engine/src/main/java/org/teiid/query/processor/relational (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/relational)
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/AccessNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/AccessNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,28 +20,28 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.List;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.util.CommandContext;
public class AccessNode extends RelationalNode {
@@ -88,7 +88,7 @@
}
public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
// Copy command and resolve references if necessary
Command atomicCommand = command;
@@ -110,25 +110,25 @@
}
}
- protected boolean prepareNextCommand(Command atomicCommand) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected boolean prepareNextCommand(Command atomicCommand) throws TeiidComponentException, TeiidProcessingException {
return prepareCommand(atomicCommand, this, this.getContext(), this.getContext().getMetadata());
}
static boolean prepareCommand(Command atomicCommand, RelationalNode node, CommandContext context, QueryMetadataInterface metadata)
- throws ExpressionEvaluationException, MetaMatrixComponentException,
- MetaMatrixProcessingException, CriteriaEvaluationException {
+ throws ExpressionEvaluationException, TeiidComponentException,
+ TeiidProcessingException, CriteriaEvaluationException {
try {
// Defect 16059 - Rewrite the command once the references have been replaced with values.
QueryRewriter.evaluateAndRewrite(atomicCommand, node.getDataManager(), context, metadata);
} catch (QueryValidatorException e) {
- throw new MetaMatrixProcessingException(e, QueryExecPlugin.Util.getString("AccessNode.rewrite_failed", atomicCommand)); //$NON-NLS-1$
+ throw new TeiidProcessingException(e, QueryExecPlugin.Util.getString("AccessNode.rewrite_failed", atomicCommand)); //$NON-NLS-1$
}
return RelationalNodeUtil.shouldExecute(atomicCommand, true);
}
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
while (tupleSource != null || hasNextCommand()) {
//drain the tuple source
@@ -173,7 +173,7 @@
}
private void registerRequest(Command atomicCommand)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
tupleSource = getDataManager().registerRequest(this.getContext().getProcessorID(), atomicCommand, modelName, connectorBindingId, getID());
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/BatchedUpdateNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/BatchedUpdateNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Arrays;
@@ -28,18 +28,19 @@
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
+
/**
* Node that batches commands sent to the DataManager.
* @since 4.2
@@ -79,10 +80,10 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#open()
+ * @see org.teiid.query.processor.relational.RelationalNode#open()
* @since 4.2
*/
- public void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void open() throws TeiidComponentException, TeiidProcessingException {
super.open();
unexecutedCommands = new HashSet<Integer>();
List<Command> commandsToExecute = new ArrayList<Command>(updateCommands.size());
@@ -114,11 +115,11 @@
}
/**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.processor.relational.RelationalNode#nextBatchDirect()
+ * @throws TeiidProcessingException
+ * @see org.teiid.query.processor.relational.RelationalNode#nextBatchDirect()
* @since 4.2
*/
- public TupleBatch nextBatchDirect() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleBatch nextBatchDirect() throws BlockedException, TeiidComponentException, TeiidProcessingException {
int numExpectedCounts = updateCommands.size();
for (;commandCount < numExpectedCounts; commandCount++) {
// If the command at this index was not executed
@@ -131,7 +132,7 @@
addBatchRow(Arrays.asList(new Object[] {tuple.get(0)}));
} else {
// Should never happen since the number of expected results is known
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("BatchedUpdateNode.unexpected_end_of_batch", commandCount, numExpectedCounts)); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("BatchedUpdateNode.unexpected_end_of_batch", commandCount, numExpectedCounts)); //$NON-NLS-1$
}
}
}
@@ -141,7 +142,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#close()
+ * @see org.teiid.query.processor.relational.RelationalNode#close()
* @since 4.2
*/
public void closeDirect() {
@@ -152,7 +153,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#reset()
+ * @see org.teiid.query.processor.relational.RelationalNode#reset()
* @since 4.2
*/
public void reset() {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentAccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentAccessNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentAccessNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Query;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Query;
+
/**
* Takes a query with 1 or more dependent sets from 1 or more sources and creates a series of commands. Dependent sets from the
* same source are treated as a special case. If there are multiple batches from that source, we will create replacement criteria
@@ -50,7 +51,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.AccessNode#close()
+ * @see org.teiid.query.processor.relational.AccessNode#close()
*/
public void closeDirect() {
super.closeDirect();
@@ -90,9 +91,9 @@
}
/**
- * @see com.metamatrix.query.processor.relational.AccessNode#prepareNextCommand(com.metamatrix.query.sql.lang.Command)
+ * @see org.teiid.query.processor.relational.AccessNode#prepareNextCommand(org.teiid.query.sql.lang.Command)
*/
- protected boolean prepareNextCommand(Command atomicCommand) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected boolean prepareNextCommand(Command atomicCommand) throws TeiidComponentException, TeiidProcessingException {
Assertion.assertTrue(atomicCommand instanceof Query);
@@ -136,7 +137,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.AccessNode#hasNextCommand()
+ * @see org.teiid.query.processor.relational.AccessNode#hasNextCommand()
*/
protected boolean hasNextCommand() {
return criteriaProcessor.hasNextCommand();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentCriteriaProcessor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,24 +33,25 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.AbstractSetCriteria;
-import com.metamatrix.query.sql.lang.CollectionValueIterator;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.AbstractSetCriteria;
+import org.teiid.query.sql.lang.CollectionValueIterator;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.util.ValueIterator;
+
public class DependentCriteriaProcessor {
public static class SetState {
@@ -78,7 +79,7 @@
}
public void sort() throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
if (dvs == null) {
if (sortUtility == null) {
List<Expression> sortSymbols = new ArrayList<Expression>(dependentSetStates.size());
@@ -132,7 +133,7 @@
private boolean hasNextCommand;
protected SubqueryAwareEvaluator eval;
- public DependentCriteriaProcessor(int maxSetSize, RelationalNode dependentNode, Criteria dependentCriteria) throws ExpressionEvaluationException, MetaMatrixComponentException {
+ public DependentCriteriaProcessor(int maxSetSize, RelationalNode dependentNode, Criteria dependentCriteria) throws ExpressionEvaluationException, TeiidComponentException {
this.maxSetSize = maxSetSize;
this.dependentNode = dependentNode;
this.dependentCrit = dependentCriteria;
@@ -187,7 +188,7 @@
}
}
- public Criteria prepareCriteria() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public Criteria prepareCriteria() throws TeiidComponentException, TeiidProcessingException {
if (phase == SORT) {
for (TupleState state : dependentState.values()) {
@@ -246,9 +247,9 @@
*
* @param dependentSets
* @param replacementValueIterators
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- private void replaceDependentValueIterators() throws MetaMatrixComponentException {
+ private void replaceDependentValueIterators() throws TeiidComponentException {
for (; currentIndex < sources.size(); currentIndex++) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureAccessNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureAccessNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureAccessNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
+
public class DependentProcedureAccessNode extends AccessNode {
private Criteria inputCriteria;
@@ -52,7 +53,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.PlanExecutionNode#clone()
+ * @see org.teiid.query.processor.relational.PlanExecutionNode#clone()
*/
public Object clone() {
DependentProcedureAccessNode copy = new DependentProcedureAccessNode(getID(), inputCriteria,
@@ -76,8 +77,8 @@
}
@Override
- public void open() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ public void open() throws TeiidComponentException,
+ TeiidProcessingException {
CommandContext context = (CommandContext)getContext().clone();
context.pushVariableContext(new VariableContext());
this.setContext(context);
@@ -86,9 +87,9 @@
}
/**
- * @see com.metamatrix.query.processor.relational.AccessNode#prepareNextCommand(com.metamatrix.query.sql.lang.Command)
+ * @see org.teiid.query.processor.relational.AccessNode#prepareNextCommand(org.teiid.query.sql.lang.Command)
*/
- protected boolean prepareNextCommand(Command atomicCommand) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected boolean prepareNextCommand(Command atomicCommand) throws TeiidComponentException, TeiidProcessingException {
if (this.criteriaProcessor == null) {
this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, (Criteria)inputCriteria.clone(), inputReferences, inputDefaults);
@@ -107,7 +108,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.PlanExecutionNode#hasNextCommand()
+ * @see org.teiid.query.processor.relational.PlanExecutionNode#hasNextCommand()
*/
protected boolean hasNextCommand() {
return criteriaProcessor.hasNextCommand();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureCriteriaProcessor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureCriteriaProcessor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureCriteriaProcessor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.util.VariableContext;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.rewriter.QueryRewriter;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.util.VariableContext;
+
public class DependentProcedureCriteriaProcessor extends DependentCriteriaProcessor {
private List inputReferences;
@@ -48,14 +49,14 @@
public DependentProcedureCriteriaProcessor(RelationalNode dependentNode,
Criteria dependentCriteria,
List references,
- List defaults) throws ExpressionEvaluationException, MetaMatrixComponentException {
+ List defaults) throws ExpressionEvaluationException, TeiidComponentException {
super(1, dependentNode, dependentCriteria);
this.inputDefaults = defaults;
this.inputReferences = references;
}
protected boolean prepareNextCommand(VariableContext context) throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
if (this.critInProgress == null) {
critInProgress = prepareCriteria();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentProcedureExecutionNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentProcedureExecutionNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.util.CommandContext;
+
public class DependentProcedureExecutionNode extends PlanExecutionNode {
private Criteria inputCriteria;
@@ -52,7 +53,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.PlanExecutionNode#clone()
+ * @see org.teiid.query.processor.relational.PlanExecutionNode#clone()
*/
public Object clone() {
DependentProcedureExecutionNode copy = new DependentProcedureExecutionNode(getID(), (Criteria)inputCriteria.clone(),
@@ -76,10 +77,10 @@
}
/**
- * @see com.metamatrix.query.processor.relational.PlanExecutionNode#prepareNextCommand()
+ * @see org.teiid.query.processor.relational.PlanExecutionNode#prepareNextCommand()
*/
protected boolean prepareNextCommand() throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
if (this.criteriaProcessor == null) {
this.criteriaProcessor = new DependentProcedureCriteriaProcessor(this, (Criteria)inputCriteria.clone(), inputReferences, inputDefaults);
@@ -89,7 +90,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.PlanExecutionNode#hasNextCommand()
+ * @see org.teiid.query.processor.relational.PlanExecutionNode#hasNextCommand()
*/
protected boolean hasNextCommand() {
return criteriaProcessor.hasNextCommand();
@@ -103,8 +104,8 @@
}
@Override
- public void open() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ public void open() throws TeiidComponentException,
+ TeiidProcessingException {
super.open();
shareVariableContext(this, this.getProcessorPlan().getContext());
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentValueSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DependentValueSource.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DependentValueSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.HashMap;
import java.util.HashSet;
@@ -28,18 +28,19 @@
import java.util.Set;
import java.util.TreeSet;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.ValueIteratorSource;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.sql.util.ValueIteratorSource;
+
/**
*/
public class DependentValueSource implements
@@ -57,10 +58,10 @@
}
/**
- * @throws MetaMatrixComponentException
- * @see com.metamatrix.query.sql.util.ValueIteratorSource#getValueIterator(com.metamatrix.query.sql.symbol.Expression)
+ * @throws TeiidComponentException
+ * @see org.teiid.query.sql.util.ValueIteratorSource#getValueIterator(org.teiid.query.sql.symbol.Expression)
*/
- public ValueIterator getValueIterator(Expression valueExpression) throws MetaMatrixComponentException {
+ public ValueIterator getValueIterator(Expression valueExpression) throws TeiidComponentException {
IndexedTupleSource its = buffer.createIndexedTupleSource();
int index = 0;
if (valueExpression != null) {
@@ -70,7 +71,7 @@
return new TupleSourceValueIterator(its, index);
}
- public Set<Object> getCachedSet(Expression valueExpression) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public Set<Object> getCachedSet(Expression valueExpression) throws TeiidComponentException, TeiidProcessingException {
Set<Object> result = null;
if (cachedSets != null) {
result = cachedSets.get(valueExpression);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/DuplicateFilter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/DuplicateFilter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/DuplicateFilter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,24 +20,25 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.function.aggregate.AggregateFunction;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.function.aggregate.AggregateFunction;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
/**
*/
public class DuplicateFilter implements AggregateFunction {
@@ -71,7 +72,7 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#initialize(String, Class)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#initialize(String, Class)
*/
public void initialize(Class dataType, Class inputType) {
this.proxy.initialize(dataType, inputType);
@@ -99,10 +100,10 @@
}
/**
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#addInput(Object)
+ * @see org.teiid.query.function.aggregate.AggregateFunction#addInput(Object)
*/
public void addInput(Object input)
- throws FunctionExecutionException, ExpressionEvaluationException, MetaMatrixComponentException {
+ throws FunctionExecutionException, ExpressionEvaluationException, TeiidComponentException {
if(collectionBuffer == null) {
collectionBuffer = mgr.createTupleBuffer(elements, groupName, TupleSourceType.PROCESSOR);
@@ -115,11 +116,11 @@
}
/**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.function.aggregate.AggregateFunction#getResult()
+ * @throws TeiidProcessingException
+ * @see org.teiid.query.function.aggregate.AggregateFunction#getResult()
*/
public Object getResult()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
if(collectionBuffer != null) {
this.collectionBuffer.close();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/GroupingNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/GroupingNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,33 +30,33 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.function.aggregate.AggregateFunction;
+import org.teiid.query.function.aggregate.Avg;
+import org.teiid.query.function.aggregate.ConstantFunction;
+import org.teiid.query.function.aggregate.Count;
+import org.teiid.query.function.aggregate.Max;
+import org.teiid.query.function.aggregate.Min;
+import org.teiid.query.function.aggregate.NullFilter;
+import org.teiid.query.function.aggregate.Sum;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.function.aggregate.AggregateFunction;
-import com.metamatrix.query.function.aggregate.Avg;
-import com.metamatrix.query.function.aggregate.ConstantFunction;
-import com.metamatrix.query.function.aggregate.Count;
-import com.metamatrix.query.function.aggregate.Max;
-import com.metamatrix.query.function.aggregate.Min;
-import com.metamatrix.query.function.aggregate.NullFilter;
-import com.metamatrix.query.function.aggregate.Sum;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.CommandContext;
public class GroupingNode extends RelationalNode {
@@ -199,7 +199,7 @@
}
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
// Take inputs, evaluate expressions, and build initial tuple source
if(this.phase == COLLECTION) {
@@ -229,8 +229,8 @@
private int sourceRow = 1;
@Override
- public List<?> nextTuple() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
while (true) {
if(sourceBatch == null) {
// Read next batch
@@ -296,14 +296,14 @@
}
}
- private void sortPhase() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException {
this.sortBuffer = this.sortUtility.sort();
this.sortBuffer.setForwardOnly(true);
this.groupTupleSource = this.sortBuffer.createIndexedTupleSource();
this.phase = GROUP;
}
- private TupleBatch groupPhase() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private TupleBatch groupPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException {
while(true) {
if (currentGroupTuple == null) {
@@ -382,7 +382,7 @@
}
private void updateAggregates(List tuple)
- throws MetaMatrixComponentException, ExpressionEvaluationException {
+ throws TeiidComponentException, ExpressionEvaluationException {
for(int i=0; i<functions.length; i++) {
Object value = null;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/InsertPlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/InsertPlanExecutionNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/InsertPlanExecutionNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Arrays;
import java.util.List;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.dqp.internal.process.PreparedStatementRequest;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.symbol.Reference;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.symbol.Reference;
public class InsertPlanExecutionNode extends PlanExecutionNode {
@@ -77,7 +77,7 @@
@Override
protected boolean prepareNextCommand() throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
if (this.currentBatch == null) {
this.currentBatch = this.getChildren()[0].nextBatch();
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,29 +20,29 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.SourceState.ImplicitBuffer;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.BufferManager.BufferReserveMode;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.relational.SourceState.ImplicitBuffer;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.util.CommandContext;
/**
* @since 4.2
@@ -121,7 +121,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#reset()
+ * @see org.teiid.query.processor.relational.RelationalNode#reset()
*/
@Override
public void reset() {
@@ -145,7 +145,7 @@
}
public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
// Open left child always
if (!this.leftOpened) {
@@ -162,8 +162,8 @@
this.joinStrategy.initialize(this);
}
- private void openRight() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ private void openRight() throws TeiidComponentException,
+ TeiidProcessingException {
if (!this.rightOpened) {
if (reserved == 0) {
reserved = getBufferManager().reserveBuffers(getBufferManager().getSchemaSize(getOutputElements()), BufferReserveMode.FORCE);
@@ -174,7 +174,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#clone()
+ * @see org.teiid.query.processor.relational.RelationalNode#clone()
* @since 4.2
*/
public Object clone() {
@@ -197,12 +197,12 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#nextBatchDirect()
+ * @see org.teiid.query.processor.relational.RelationalNode#nextBatchDirect()
* @since 4.2
*/
protected TupleBatch nextBatchDirect() throws BlockedException,
- MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ TeiidComponentException,
+ TeiidProcessingException {
if (state == State.LOAD_LEFT) {
if (this.joinType != JoinType.JOIN_FULL_OUTER) {
this.joinStrategy.leftSource.setImplicitBuffer(ImplicitBuffer.NONE);
@@ -231,7 +231,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#getDescriptionProperties()
+ * @see org.teiid.query.processor.relational.RelationalNode#getDescriptionProperties()
* @since 4.2
*/
public PlanNode getDescriptionProperties() {
@@ -264,7 +264,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#getNodeString(java.lang.StringBuffer)
+ * @see org.teiid.query.processor.relational.RelationalNode#getNodeString(java.lang.StringBuffer)
* @since 4.2
*/
protected void getNodeString(StringBuffer str) {
@@ -320,7 +320,7 @@
return this.joinCriteria;
}
- boolean matchesCriteria(List outputTuple) throws BlockedException, MetaMatrixComponentException, CriteriaEvaluationException {
+ boolean matchesCriteria(List outputTuple) throws BlockedException, TeiidComponentException, CriteriaEvaluationException {
return (this.joinCriteria == null || getEvaluator(this.combinedElementMap).evaluate(this.joinCriteria, outputTuple));
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/JoinStrategy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/JoinStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
public abstract class JoinStrategy {
protected JoinNode joinNode;
@@ -60,17 +61,17 @@
this.rightSource.markDistinct(this.joinNode.isRightDistinct());
}
- protected void loadLeft() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected void loadLeft() throws TeiidComponentException, TeiidProcessingException {
}
- protected void loadRight() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected void loadRight() throws TeiidComponentException, TeiidProcessingException {
}
/**
* Output a combined, projected tuple based on tuple parts from the left and right.
* @param leftTuple Left tuple part
* @param rightTuple Right tuple part
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
protected List outputTuple(List leftTuple, List rightTuple) {
List combinedRow = new ArrayList(this.joinNode.getCombinedElementMap().size());
@@ -79,7 +80,7 @@
return combinedRow;
}
- protected abstract void process() throws MetaMatrixComponentException, CriteriaEvaluationException, MetaMatrixProcessingException;
+ protected abstract void process() throws TeiidComponentException, CriteriaEvaluationException, TeiidProcessingException;
public abstract Object clone();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/LimitNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/LimitNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/LimitNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,21 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.Collections;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.sql.symbol.Expression;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.sql.symbol.Expression;
public class LimitNode extends RelationalNode {
@@ -53,8 +53,8 @@
}
protected TupleBatch nextBatchDirect() throws BlockedException,
- MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ TeiidComponentException,
+ TeiidProcessingException {
TupleBatch batch = null; // Can throw BlockedException
// If we haven't reached the offset, then skip rows/batches
if (offsetPhase) {
@@ -106,7 +106,7 @@
return resultBatch;
}
- public void open() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void open() throws TeiidComponentException, TeiidProcessingException {
super.open();
limit = -1;
if (limitExpr != null) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ListNestedSortComparator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ListNestedSortComparator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
-import com.metamatrix.core.util.Assertion;
+import org.teiid.core.util.Assertion;
+
/**
* This class can be used for comparing lists of elements, when the fields to
* be sorted on and the comparison mechanism are dynamically specified. <p>
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/MergeJoinStrategy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/MergeJoinStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.query.processor.relational.SourceState.ImplicitBuffer;
-import com.metamatrix.query.sql.lang.JoinType;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.relational.SourceState.ImplicitBuffer;
+import org.teiid.query.sql.lang.JoinType;
+
/**
* MergeJoinStrategy supports generalized Full, Left Outer, and Inner Joins (containing non-equi join criteria) as long as there
* is at least one equi-join criteria
@@ -99,7 +100,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.JoinStrategy#clone()
+ * @see org.teiid.query.processor.relational.JoinStrategy#clone()
*/
@Override
public Object clone() {
@@ -107,7 +108,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.JoinStrategy#initialize(com.metamatrix.query.processor.relational.JoinNode)
+ * @see org.teiid.query.processor.relational.JoinStrategy#initialize(org.teiid.query.processor.relational.JoinNode)
*/
@Override
public void initialize(JoinNode joinNode) {
@@ -125,7 +126,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.JoinStrategy#close()
+ * @see org.teiid.query.processor.relational.JoinStrategy#close()
*/
@Override
public void close() {
@@ -135,8 +136,8 @@
}
@Override
- protected void process() throws MetaMatrixComponentException,
- CriteriaEvaluationException, MetaMatrixProcessingException {
+ protected void process() throws TeiidComponentException,
+ CriteriaEvaluationException, TeiidProcessingException {
while (this.mergeState != MergeState.DONE) {
while (this.mergeState == MergeState.SCAN) {
@@ -269,8 +270,8 @@
}
}
- protected boolean compareToPrevious(SourceState target) throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ protected boolean compareToPrevious(SourceState target) throws TeiidComponentException,
+ TeiidProcessingException {
if (!target.getIterator().hasNext()) {
target.setMaxProbeMatch(target.getIterator().getCurrentIndex());
return false;
@@ -323,14 +324,14 @@
}
@Override
- protected void loadLeft() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ protected void loadLeft() throws TeiidComponentException,
+ TeiidProcessingException {
this.leftSource.sort(this.processingSortLeft);
}
@Override
- protected void loadRight() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ protected void loadRight() throws TeiidComponentException,
+ TeiidProcessingException {
this.rightSource.sort(this.processingSortRight);
if (this.joinNode.getJoinType() != JoinType.JOIN_FULL_OUTER) {
this.rightSource.setImplicitBuffer(ImplicitBuffer.ON_MARK);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/NestedLoopJoinStrategy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/NestedLoopJoinStrategy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.processor.relational.SourceState.ImplicitBuffer;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.relational.SourceState.ImplicitBuffer;
+
/**
* Nested loop is currently implemented as a degenerate case of merge join.
*
@@ -41,7 +42,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.MergeJoinStrategy#clone()
+ * @see org.teiid.query.processor.relational.MergeJoinStrategy#clone()
*/
@Override
public Object clone() {
@@ -49,7 +50,7 @@
}
/**
- * @see com.metamatrix.query.processor.relational.MergeJoinStrategy#compare(java.util.List, java.util.List, int[], int[])
+ * @see org.teiid.query.processor.relational.MergeJoinStrategy#compare(java.util.List, java.util.List, int[], int[])
*/
@Override
protected int compare(List leftProbe,
@@ -60,13 +61,13 @@
}
@Override
- protected void loadRight() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ protected void loadRight() throws TeiidComponentException,
+ TeiidProcessingException {
this.rightSource.setImplicitBuffer(ImplicitBuffer.FULL);
}
/**
- * @see com.metamatrix.query.processor.relational.MergeJoinStrategy#toString()
+ * @see org.teiid.query.processor.relational.MergeJoinStrategy#toString()
*/
@Override
public String toString() {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/NullNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/NullNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/NullNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+
public class NullNode extends RelationalNode {
public NullNode(int nodeID) {
@@ -32,7 +33,7 @@
}
public TupleBatch nextBatchDirect()
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
this.terminateBatches();
return pullBatch();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PartitionedSortJoin.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/PartitionedSortJoin.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,20 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
/**
* Extends the basic fully sorted merge join to check for conditions necessary
* to not fully sort one of the sides
@@ -87,7 +88,7 @@
this.matchEnd = -1;
}
- public void computeBatchBounds(SourceState state) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void computeBatchBounds(SourceState state) throws TeiidComponentException, TeiidProcessingException {
if (endTuples != null) {
return;
}
@@ -110,15 +111,15 @@
}
@Override
- protected void loadLeft() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ protected void loadLeft() throws TeiidComponentException,
+ TeiidProcessingException {
//always buffer to determine row counts
this.leftSource.getTupleBuffer();
}
@Override
- protected void loadRight() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ protected void loadRight() throws TeiidComponentException,
+ TeiidProcessingException {
this.rightSource.getTupleBuffer();
if (processingSortRight == SortOption.SORT
&& this.leftSource.getRowCount() * 4 < this.rightSource.getRowCount()
@@ -176,8 +177,8 @@
return false;
}
- private void partitionSource() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ private void partitionSource() throws TeiidComponentException,
+ TeiidProcessingException {
if (partitioned) {
return;
}
@@ -220,8 +221,8 @@
}
@Override
- protected void process() throws MetaMatrixComponentException,
- CriteriaEvaluationException, MetaMatrixProcessingException {
+ protected void process() throws TeiidComponentException,
+ CriteriaEvaluationException, TeiidProcessingException {
if (this.processingSortLeft != SortOption.PARTITION && this.processingSortRight != SortOption.PARTITION) {
super.process();
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/PlanExecutionNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/PlanExecutionNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,22 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
//TODO: consolidate with QueryProcessor
public class PlanExecutionNode extends RelationalNode {
@@ -66,7 +66,7 @@
}
public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
super.open();
// Initialize plan for execution
CommandContext subContext = (CommandContext) getContext().clone();
@@ -85,7 +85,7 @@
}
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (!isOpen) {
if (!needsProcessing) {
@@ -129,7 +129,7 @@
}
protected boolean prepareNextCommand() throws BlockedException,
- MetaMatrixComponentException, MetaMatrixProcessingException {
+ TeiidComponentException, TeiidProcessingException {
return true;
}
@@ -140,7 +140,7 @@
public void closeDirect() {
try {
plan.close();
- } catch (MetaMatrixComponentException e1){
+ } catch (TeiidComponentException e1){
LogManager.logDetail(org.teiid.logging.LogConstants.CTX_DQP, e1, "Error closing processor"); //$NON-NLS-1$
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectIntoNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,26 +22,26 @@
/*
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
public class ProjectIntoNode extends RelationalNode {
@@ -101,7 +101,7 @@
* When no more data is available, output batch with single row containing insertCount
*/
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
while(phase == REQUEST_CREATION) {
@@ -175,7 +175,7 @@
return pullBatch();
}
- private void checkExitConditions() throws MetaMatrixComponentException, BlockedException, MetaMatrixProcessingException {
+ private void checkExitConditions() throws TeiidComponentException, BlockedException, TeiidProcessingException {
if (tupleSource != null) {
Integer count = (Integer)tupleSource.nextTuple().get(0);
insertCount += count.intValue();
@@ -190,7 +190,7 @@
}
- private void registerRequest(Command command) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void registerRequest(Command command) throws TeiidComponentException, TeiidProcessingException {
tupleSource = getDataManager().registerRequest(this.getContext().getProcessorID(), command, this.modelName, null, getID());
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/ProjectNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/ProjectNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,26 +30,26 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
public class ProjectNode extends SubqueryAwareRelationalNode {
@@ -146,7 +146,7 @@
}
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
// currentBatch and currentRow hold temporary state saved in the case
// of a BlockedException while evaluating an expression. If that has
@@ -214,7 +214,7 @@
}
private void updateTuple(SelectSymbol symbol, List values, List tuple)
- throws BlockedException, MetaMatrixComponentException, ExpressionEvaluationException {
+ throws BlockedException, TeiidComponentException, ExpressionEvaluationException {
if (symbol instanceof AliasSymbol) {
// First check AliasSymbol itself
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.Collections;
@@ -31,21 +31,21 @@
import java.util.Map;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.BatchCollector.BatchProducer;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.BatchCollector.BatchProducer;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.CommandContext;
public abstract class RelationalNode implements Cloneable, BatchProducer {
@@ -229,7 +229,7 @@
}
public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
for(int i=0; i<children.length; i++) {
if(children[i] != null) {
@@ -245,10 +245,10 @@
* should always call this rather than nextBatchDirect().
* @return
* @throws BlockedException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.2
*/
- public final TupleBatch nextBatch() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ public final TupleBatch nextBatch() throws BlockedException, TeiidComponentException, TeiidProcessingException {
boolean recordStats = this.context != null && (this.context.getCollectNodeStatistics() || this.context.getProcessDebug());
try {
@@ -287,7 +287,7 @@
this.nodeStatistics.collectCumulativeNodeStats(null, RelationalNodeStatistics.BLOCKEDEXCEPTION_STOP);
}
throw e;
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
// stop timer for this batch (MetaMatrixComponentException)
if(recordStats && this.context.getCollectNodeStatistics()) {
this.nodeStatistics.stopBatchTimer();
@@ -300,15 +300,15 @@
* Template method for subclasses to implement.
* @return
* @throws BlockedException
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixProcessingException if exception related to user input occured
+ * @throws TeiidComponentException
+ * @throws TeiidProcessingException if exception related to user input occured
* @since 4.2
*/
protected abstract TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException;
+ throws BlockedException, TeiidComponentException, TeiidProcessingException;
public final void close()
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
if (!this.closed) {
closeDirect();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeStatistics.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNodeStatistics.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeStatistics.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBatch;
+
/**
* @since 4.2
*/
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalNodeUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalNodeUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,24 +20,25 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+
/**
* @since 4.2
*/
@@ -51,12 +52,12 @@
* A null value for criteria is considered to be always true.
* @param criteria
* @return true if the criteria always evaluate to true (e.g. 1 = 1); false otherwise.
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws BlockedException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.2
*/
- private static boolean evaluateCriteria(Criteria criteria) throws CriteriaEvaluationException, MetaMatrixComponentException {
+ private static boolean evaluateCriteria(Criteria criteria) throws CriteriaEvaluationException, TeiidComponentException {
if(criteria == null) {
return true;
}
@@ -70,10 +71,10 @@
* @param command
* @param simplifyCriteria wheter to simplify the criteria of the command if they always evaluate to true
* @return true if this command should be executed by the connector; false otherwise.
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.2
*/
- public static boolean shouldExecute(Command command, boolean simplifyCriteria) throws CriteriaEvaluationException, MetaMatrixComponentException {
+ public static boolean shouldExecute(Command command, boolean simplifyCriteria) throws CriteriaEvaluationException, TeiidComponentException {
int cmdType = command.getType();
Criteria criteria = null;
switch(cmdType) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/RelationalPlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/RelationalPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.util.CommandContext;
/**
*/
@@ -92,7 +92,7 @@
}
public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
this.root.open();
}
@@ -101,19 +101,19 @@
* @see ProcessorPlan#nextBatch()
*/
public TupleBatch nextBatch()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
return this.root.nextBatch();
}
public void close()
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
this.root.close();
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#reset()
+ * @see org.teiid.query.processor.ProcessorPlan#reset()
*/
public void reset() {
super.reset();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SelectNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SelectNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,25 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.util.CommandContext;
public class SelectNode extends SubqueryAwareRelationalNode {
@@ -87,10 +87,10 @@
}
/**
- * @see com.metamatrix.query.processor.relational.RelationalNode#nextBatchDirect()
+ * @see org.teiid.query.processor.relational.RelationalNode#nextBatchDirect()
*/
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
TupleBatch batch = blockedBatch;
if(! blockedOnCriteria && ! blockedOnPrepare) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SortNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,24 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.sql.lang.OrderBy;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.lang.OrderBy;
public class SortNode extends RelationalNode {
@@ -83,7 +83,7 @@
}
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
if(this.phase == SORT) {
sortPhase();
}
@@ -91,7 +91,7 @@
return outputPhase();
}
- private void sortPhase() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void sortPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (this.sortUtility == null) {
this.sortUtility = new SortUtility(new BatchIterator(getChildren()[0]), sortElements,
sortTypes, this.mode, getBufferManager(),
@@ -104,7 +104,7 @@
this.phase = OUTPUT;
}
- private TupleBatch outputPhase() throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ private TupleBatch outputPhase() throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (!this.output.isFinal()) {
this.phase = SORT;
} else {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SortUtility.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,21 +29,21 @@
import java.util.ListIterator;
import java.util.TreeSet;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.BufferManager.BufferReserveMode;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
/**
* Implements several modes of a multi-pass sort.
@@ -145,7 +145,7 @@
}
public TupleBuffer sort()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
if(this.phase == INITIAL_SORT) {
initialSort();
@@ -160,7 +160,7 @@
return this.activeTupleBuffers.get(0);
}
- private TupleBuffer createTupleBuffer() throws MetaMatrixComponentException {
+ private TupleBuffer createTupleBuffer() throws TeiidComponentException {
TupleBuffer tb = bufferManager.createTupleBuffer(this.schema, this.groupName, TupleSourceType.PROCESSOR);
tb.setForwardOnly(true);
return tb;
@@ -169,7 +169,7 @@
/**
* creates sorted sublists stored in tuplebuffers
*/
- protected void initialSort() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected void initialSort() throws TeiidComponentException, TeiidProcessingException {
while(!doneReading) {
if (workingTuples == null) {
if (mode == Mode.SORT) {
@@ -244,7 +244,7 @@
this.phase = MERGE;
}
- protected void mergePhase() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ protected void mergePhase() throws TeiidComponentException, TeiidProcessingException {
while(this.activeTupleBuffers.size() > 1) {
ArrayList<SortedSublist> sublists = new ArrayList<SortedSublist>(activeTupleBuffers.size());
@@ -328,7 +328,7 @@
this.phase = INITIAL_SORT;
}
- private void incrementWorkingTuple(ArrayList<SortedSublist> subLists, SortedSublist sortedSublist) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ private void incrementWorkingTuple(ArrayList<SortedSublist> subLists, SortedSublist sortedSublist) throws TeiidComponentException, TeiidProcessingException {
while (true) {
sortedSublist.tuple = null;
if (sortedSublist.limit < sortedSublist.its.getCurrentIndex()) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SourceState.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SourceState.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.processor.BatchCollector;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy.SortOption;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.sql.lang.OrderBy;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
+import org.teiid.query.processor.relational.SortUtility.Mode;
+import org.teiid.query.sql.lang.OrderBy;
+
class SourceState {
enum ImplicitBuffer {
@@ -85,16 +86,16 @@
return indecies;
}
- TupleBuffer createSourceTupleBuffer() throws MetaMatrixComponentException {
+ TupleBuffer createSourceTupleBuffer() throws TeiidComponentException {
return this.source.getBufferManager().createTupleBuffer(source.getElements(), source.getConnectionID(), TupleSourceType.PROCESSOR);
}
- public List saveNext() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public List saveNext() throws TeiidComponentException, TeiidProcessingException {
this.currentTuple = this.getIterator().nextTuple();
return currentTuple;
}
- public void reset() throws MetaMatrixComponentException {
+ public void reset() throws TeiidComponentException {
this.getIterator().reset();
this.getIterator().mark();
this.currentTuple = null;
@@ -111,11 +112,11 @@
}
}
- public int getRowCount() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public int getRowCount() throws TeiidComponentException, TeiidProcessingException {
return this.getTupleBuffer().getRowCount();
}
- IndexedTupleSource getIterator() throws MetaMatrixComponentException {
+ IndexedTupleSource getIterator() throws TeiidComponentException {
if (this.iterator == null) {
if (this.buffer != null) {
iterator = buffer.createIndexedTupleSource();
@@ -151,7 +152,7 @@
return maxProbeMatch;
}
- public TupleBuffer getTupleBuffer() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public TupleBuffer getTupleBuffer() throws TeiidComponentException, TeiidProcessingException {
if (this.buffer == null) {
if (this.iterator instanceof BatchIterator) {
throw new AssertionError("cannot buffer the source"); //$NON-NLS-1$
@@ -172,7 +173,7 @@
this.distinct |= distinct;
}
- public void sort(SortOption sortOption) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public void sort(SortOption sortOption) throws TeiidComponentException, TeiidProcessingException {
if (sortOption == SortOption.SORT || sortOption == SortOption.SORT_DISTINCT) {
if (this.sortUtility == null) {
TupleSource ts = null;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareEvaluator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareEvaluator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareEvaluator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,29 +20,30 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.processor.BatchCollector;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.ContextReference;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.processor.BatchCollector;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.ContextReference;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
+
/**
* <p>This utility handles the work of processing a subquery; certain types
* of processor nodes will use an instance of this class to do that work.
@@ -93,8 +94,8 @@
@Override
protected ValueIterator evaluateSubquery(SubqueryContainer container,
- List tuple) throws MetaMatrixProcessingException, BlockedException,
- MetaMatrixComponentException {
+ List tuple) throws TeiidProcessingException, BlockedException,
+ TeiidComponentException {
ContextReference ref = (ContextReference)container;
String key = (ref).getContextSymbol();
SubqueryState state = this.subqueries.get(key);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/SubqueryAwareRelationalNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/SubqueryAwareRelationalNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,9 +1,10 @@
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Map;
-import com.metamatrix.query.eval.Evaluator;
+import org.teiid.query.eval.Evaluator;
+
public abstract class SubqueryAwareRelationalNode extends RelationalNode {
private SubqueryAwareEvaluator evaluator;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/TupleSourceValueIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/TupleSourceValueIterator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/TupleSourceValueIterator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.query.sql.util.ValueIterator;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.util.ValueIterator;
+
/**
* A ValueIterator implementation that iterates over the TupleSource
* results of a subquery ProcessorPlan. The plan will
@@ -48,11 +49,11 @@
/**
* @see java.util.Iterator#hasNext()
*/
- public boolean hasNext() throws MetaMatrixComponentException{
+ public boolean hasNext() throws TeiidComponentException{
try {
return tupleSourceIterator.hasNext();
- } catch (MetaMatrixProcessingException err) {
- throw new MetaMatrixComponentException(err, err.getMessage());
+ } catch (TeiidProcessingException err) {
+ throw new TeiidComponentException(err, err.getMessage());
}
}
@@ -60,17 +61,17 @@
* Returns constant Object values, not Expressions.
* @see java.util.Iterator#next()
*/
- public Object next() throws MetaMatrixComponentException{
+ public Object next() throws TeiidComponentException{
try {
return tupleSourceIterator.nextTuple().get(columnIndex);
- } catch (MetaMatrixProcessingException err) {
- throw new MetaMatrixComponentException(err, err.getMessage());
+ } catch (TeiidProcessingException err) {
+ throw new TeiidComponentException(err, err.getMessage());
}
}
/**
* Flags a reset as being needed
- * @see com.metamatrix.query.sql.util.ValueIterator#reset()
+ * @see org.teiid.query.sql.util.ValueIterator#reset()
*/
public void reset() {
this.tupleSourceIterator.reset();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/relational/UnionAllNode.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/relational/UnionAllNode.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.relational;
+package org.teiid.query.processor.relational;
import java.util.Collections;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.buffer.BufferManager.BufferReserveMode;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.util.CommandContext;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.common.buffer.BufferManager.BufferReserveMode;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.util.CommandContext;
+
public class UnionAllNode extends RelationalNode {
private boolean[] sourceDone;
@@ -60,7 +61,7 @@
}
public void open()
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
// Initialize done flags
sourceDone = new boolean[getChildren().length];
@@ -72,7 +73,7 @@
}
public TupleBatch nextBatchDirect()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
// Walk through all children and for each one that isn't done, try to retrieve a batch
// When all sources are done, set the termination flag on that batch
Copied: trunk/engine/src/main/java/org/teiid/query/processor/xml (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/xml)
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/AbortProcessingInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AbortProcessingInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/AbortProcessingInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* This instruction, intended to be reached conditionally (only under certain
@@ -54,13 +54,13 @@
/**
* @see ProcessorInstruction#process(ProcessorEnvironment)
- * @throws MetaMatrixComponentException always
+ * @throws TeiidComponentException always
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, "ABORT processing now."); //$NON-NLS-1$
- throw new MetaMatrixComponentException(DEFAULT_MESSAGE);
+ throw new TeiidComponentException(DEFAULT_MESSAGE);
}
public String toString() {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/AddCommentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddCommentInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/AddCommentInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
* Adds a comment to an element of the document in progress
@@ -53,7 +53,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
DocumentInProgress doc = env.getDocumentInProgress();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/AddNodeInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/AddNodeInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/AddNodeInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -30,13 +30,13 @@
import java.util.Properties;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.sql.symbol.ElementSymbol;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
/**
*/
@@ -86,7 +86,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
DocumentInProgress doc = env.getDocumentInProgress();
boolean success = true;
@@ -142,7 +142,7 @@
String elem = (isElement ? QueryExecPlugin.Util.getString("AddNodeInstruction.element__1" ) : QueryExecPlugin.Util.getString("AddNodeInstruction.attribute__2")); //$NON-NLS-1$ //$NON-NLS-2$
Object[] params = new Object[]{elem, this.descriptor.getQName(), this.descriptor.getNamespaceURI(), this.descriptor.getNamespaceURIs()};
String msg = QueryExecPlugin.Util.getString("AddNodeInstruction.Unable_to_add_xml_{0}_{1},_namespace_{2},_namespace_declarations_{3}_3", params); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
+ throw new TeiidComponentException(msg);
}
env.incrementCurrentProgramCounter();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/BlockInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/BlockInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/BlockInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
*/
@@ -45,11 +45,11 @@
/**
* @see ProcessorInstruction#process(ProcessorEnvironment)
- * @throws MetaMatrixProcessingException if row limit is reached and exception should
+ * @throws TeiidProcessingException if row limit is reached and exception should
* be thrown
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
context = new XMLContext(context);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/Condition.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/Condition.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/Condition.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,10 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
/**
* This is a condition which can be evaluated, and which supplies a
@@ -67,6 +67,6 @@
* XML Processor Plan
*/
public abstract boolean evaluate(XMLProcessorEnvironment env, XMLContext ontext)
- throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ throws TeiidComponentException, TeiidProcessingException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/CriteriaCondition.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/CriteriaCondition.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/CriteriaCondition.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.ArrayList;
import java.util.HashMap;
@@ -28,13 +28,14 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
/**
* A condition based on a sql Criteria Object.
*/
@@ -57,10 +58,10 @@
}
/**
- * @see com.metamatrix.query.processor.xml.Condition#evaluate(Map, List, ProcessorEnvironment)
+ * @see org.teiid.query.processor.xml.Condition#evaluate(Map, List, ProcessorEnvironment)
*/
public boolean evaluate(XMLProcessorEnvironment env, XMLContext context)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
Map elementMap = new HashMap();
List data = new ArrayList();
@@ -80,7 +81,7 @@
try {
return new Evaluator(elementMap, env.getDataManager(), env.getProcessorContext()).evaluate(this.criteria, data);
} catch (CriteriaEvaluationException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/DefaultCondition.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/DefaultCondition.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/DefaultCondition.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
/**
* This condition always evaluates to true, basically is a holder for a
* {@link Program sub Program}, and can therefore be used as the
@@ -45,10 +46,10 @@
/**
* Always returns true
- * @see com.metamatrix.query.processor.xml.Condition#evaluate(Map, List, ProcessorEnvironment)
+ * @see org.teiid.query.processor.xml.Condition#evaluate(Map, List, ProcessorEnvironment)
*/
public boolean evaluate(XMLProcessorEnvironment env, XMLContext context)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
return true;
}
@@ -60,7 +61,7 @@
/**
- * @see com.metamatrix.query.processor.xml.Condition#getResultSetNames()
+ * @see org.teiid.query.processor.xml.Condition#getResultSetNames()
*/
public List getResultSetNames() {
return Collections.EMPTY_LIST;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/DocumentInProgress.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/DocumentInProgress.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.core.TeiidComponentException;
import org.xml.sax.SAXException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
/**
* <p>This represents a document in construction. It maintains a reference
@@ -106,10 +106,10 @@
/**
* This marks the document as finished, requiring no more processing. (It will not,
* however, prevent any more processing from being done.)
- * @throws MetaMatrixComponentException if there is any problem ending the document
+ * @throws TeiidComponentException if there is any problem ending the document
* @see #isFinished
*/
- public void markAsFinished() throws MetaMatrixComponentException;
+ public void markAsFinished() throws TeiidComponentException;
public FileStore getFileStore();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/Element.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/Element.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/Element.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Iterator;
import java.util.LinkedList;
@@ -30,10 +30,10 @@
import javax.xml.transform.sax.TransformerHandler;
+import org.teiid.core.util.Assertion;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
-import com.metamatrix.core.util.Assertion;
class Element{
static final String DEFAULT_ATTRIBUTE_TYPE = "CDATA"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/EndBlockInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndBlockInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/EndBlockInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
* <p>This instruction closes a result set, which closes and removes the TupleSource
@@ -59,7 +59,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
// now that we are done with while loop above this statement; bubble up the context
context = context.getParentContext();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/EndDocumentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/EndDocumentInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/EndDocumentInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
* This instruction marks the current document in progress as
@@ -46,7 +46,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
// Only process this instruction if there are no recursive programs in the
// program stack (don't want to start a new doc in the middle of
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/ExecSqlInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecSqlInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/ExecSqlInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
/**
* Executes a SQL statement, defines a result set.
@@ -46,7 +46,7 @@
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",resultSetName}); //$NON-NLS-1$
PlanExecutor executor = context.getResultExecutor(resultSetName);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/ExecStagingTableInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ExecStagingTableInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/ExecStagingTableInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.Map;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
/**
@@ -55,10 +55,10 @@
}
/**
- * @see com.metamatrix.query.processor.xml.ProcessorInstruction#process(com.metamatrix.query.processor.xml.XMLProcessorEnvironment, com.metamatrix.query.processor.xml.XMLContext)
+ * @see org.teiid.query.processor.xml.ProcessorInstruction#process(org.teiid.query.processor.xml.XMLProcessorEnvironment, org.teiid.query.processor.xml.XMLContext)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
if (!env.isStagingTableLoaded(this.resultSetName)) {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"SQL: Result set DOESN'T exist:",resultSetName}); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/IfInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/IfInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/IfInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.ArrayList;
import java.util.List;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
* <p>This instruction holds a List of Criteria, and for each Criteria there is a
@@ -135,7 +135,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
List thens = this.thenBlocks;
if (this.defaultCondition != null){
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/InitializeDocumentInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/InitializeDocumentInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.util.XMLFormatConstants;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
-import com.metamatrix.query.util.XMLFormatConstants;
/**
* Should be the first instruction of any document. Initializes the encoding
@@ -76,7 +76,7 @@
* @see ProcessorInstruction#getCapabilities(ProcessorEnvironment, DocumentInProgress)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, "DOC begin"); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/JoinedWhileInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/JoinedWhileInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.List;
import java.util.Map;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
/**
* Loop instruction on the result set execute before this instruction.
@@ -59,8 +59,8 @@
*/
public XMLContext process(XMLProcessorEnvironment env,
XMLContext context) throws BlockedException,
- MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ TeiidComponentException,
+ TeiidProcessingException {
List values = context.getCurrentRow(getResultSetName());
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/MoveCursorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveCursorInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/MoveCursorInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
*/
@@ -46,11 +46,11 @@
/**
* @see ProcessorInstruction#process(ProcessorEnvironment)
- * @throws MetaMatrixProcessingException if row limit is reached and exception should
+ * @throws TeiidProcessingException if row limit is reached and exception should
* be thrown
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"NEXT", resultSetName}); //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/MoveDocInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/MoveDocInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/MoveDocInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.util.Assertion;
import org.teiid.logging.LogManager;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
import org.xml.sax.SAXException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
*/
@@ -53,7 +53,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
DocumentInProgress doc = env.getDocumentInProgress();
@@ -63,7 +63,7 @@
try {
doc.moveToParent();
} catch (SAXException err) {
- throw new MetaMatrixComponentException(err, "Failed to move UP in document"); //$NON-NLS-1$
+ throw new TeiidComponentException(err, "Failed to move UP in document"); //$NON-NLS-1$
}
break;
case DOWN:
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/NodeDescriptor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/NodeDescriptor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/NodeDescriptor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.mapping.xml.MappingAttribute;
-import com.metamatrix.query.mapping.xml.MappingElement;
-import com.metamatrix.query.mapping.xml.MappingNode;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.xml.MappingAttribute;
+import org.teiid.query.mapping.xml.MappingElement;
+import org.teiid.query.mapping.xml.MappingNode;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
/**
* THis class contains the information of an element or an attribute.
* @since 4.3
@@ -249,11 +250,11 @@
return descriptor;
}
- public static NodeDescriptor createNodeDescriptor(String name, String namespacePrefix, boolean isElement, String defaultValue, Properties namespaceDeclarations, Properties parentNamespaceDeclarations,boolean isOptional, MappingNode node, String textNormalizationMode) throws MetaMatrixComponentException{
+ public static NodeDescriptor createNodeDescriptor(String name, String namespacePrefix, boolean isElement, String defaultValue, Properties namespaceDeclarations, Properties parentNamespaceDeclarations,boolean isOptional, MappingNode node, String textNormalizationMode) throws TeiidComponentException{
return createNodeDescriptor(name, namespacePrefix, isElement, defaultValue, namespaceDeclarations, parentNamespaceDeclarations, isOptional, node, textNormalizationMode, null, null);
}
- public static NodeDescriptor createNodeDescriptor(String name, String namespacePrefix, boolean isElement, String defaultValue, Properties namespaceDeclarations, Properties parentNamespaceDeclarations,boolean isOptional, MappingNode node, String textNormalizationMode, Class runtimeType, String docBuiltInType) throws MetaMatrixComponentException{
+ public static NodeDescriptor createNodeDescriptor(String name, String namespacePrefix, boolean isElement, String defaultValue, Properties namespaceDeclarations, Properties parentNamespaceDeclarations,boolean isOptional, MappingNode node, String textNormalizationMode, Class runtimeType, String docBuiltInType) throws TeiidComponentException{
//get namespace uri
String uri = null;
if(namespacePrefix == null) {
@@ -287,7 +288,7 @@
uri = MappingNodeConstants.INSTANCES_NAMESPACE;
}else {
String msg = QueryExecPlugin.Util.getString("XMLPlanner.no_uri", new Object[] {namespacePrefix, name}); //$NON-NLS-1$
- throw new MetaMatrixComponentException(msg);
+ throw new TeiidComponentException(msg);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/PlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/PlanExecutor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/PlanExecutor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
/**
* This interface is responsible for executing the queries for the XML processing
* environment.
@@ -39,29 +40,29 @@
* Execute the plan
* @param referenceValues - values for any external references
*/
- public void execute(Map referenceValues) throws MetaMatrixComponentException, BlockedException, MetaMatrixProcessingException;
+ public void execute(Map referenceValues) throws TeiidComponentException, BlockedException, TeiidProcessingException;
/**
* Get the ElementSymbol list which represents the schema of the result set
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- public List getOutputElements() throws MetaMatrixComponentException;
+ public List getOutputElements() throws TeiidComponentException;
/**
* Advance the resultset cursor to next row and retun the row values
* @return values of the row
*/
- public List nextRow() throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ public List nextRow() throws TeiidComponentException, TeiidProcessingException;
/**
* Get the result set values of the current row.
* @return
*/
- public List currentRow() throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ public List currentRow() throws TeiidComponentException, TeiidProcessingException;
/**
* close the plan and cleanup the resultset.
*/
- public void close() throws MetaMatrixComponentException;
+ public void close() throws TeiidComponentException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/ProcessorInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ProcessorInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/ProcessorInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
/**
* <p>Abstract superclass of all XML Processor Instructions.</p>
@@ -46,12 +46,12 @@
* executed again.)
* @param env instance of ProcessorEnvironment which is being used for the processing
* of the XML document model query
- * @throws MetaMatrixComponentException for non-business exception
- * @throws MetaMatrixProcessingException for business exception due to user input or model
+ * @throws TeiidComponentException for non-business exception
+ * @throws TeiidProcessingException for business exception due to user input or model
* @throws BlockedException if data is not available now but may be at a later time
*/
public abstract XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException;
+ throws BlockedException, TeiidComponentException, TeiidProcessingException;
public abstract PlanNode getDescriptionProperties();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/Program.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/Program.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/Program.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.ArrayList;
import java.util.List;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/ProgramUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/ProgramUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/ProgramUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RecurseProgramCondition.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/RecurseProgramCondition.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This special condition handles recursive XML processing. If it evaluates
* to true, the Program it returns is a Program which is already on the program
@@ -57,7 +58,7 @@
/**
- * @see com.metamatrix.query.processor.xml.Condition#isProgramRecursive()
+ * @see org.teiid.query.processor.xml.Condition#isProgramRecursive()
*/
public boolean isProgramRecursive() {
return true;
@@ -66,13 +67,13 @@
/**
* Evaluates to true, unless the termination criteria is true, or unless the recursion
* count limit has been reached
- * @throws MetaMatrixComponentException if it was indicated in the constructor that an
+ * @throws TeiidComponentException if it was indicated in the constructor that an
* exception should be thrown because the recursion count limit was reached, OR if there
* was a problem evaluating the termination condition relational criteria
- * @see com.metamatrix.query.processor.xml.Condition#evaluate(Map, List, ProcessorEnvironment)
+ * @see org.teiid.query.processor.xml.Condition#evaluate(Map, List, ProcessorEnvironment)
*/
public boolean evaluate(XMLProcessorEnvironment env, XMLContext context)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
boolean terminate = false;
@@ -92,7 +93,7 @@
//handle the case of exception on recursion limit reached
if (terminate && this.exceptionOnRecursionLimit){
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0039, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0039));
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0039, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0039));
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/RelationalPlanExecutor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/RelationalPlanExecutor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,27 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.List;
import java.util.Map;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.IndexedTupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.IndexedTupleSource;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
-import com.metamatrix.query.util.CommandContext;
/**
@@ -66,7 +66,7 @@
int currentRowNumber = 0;
public RelationalPlanExecutor (ResultSetInfo resultInfo, CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr)
- throws MetaMatrixComponentException{
+ throws TeiidComponentException{
this.resultInfo = resultInfo;
this.bufferMgr = bufferMgr;
@@ -78,18 +78,18 @@
}
/**
- * @see com.metamatrix.query.processor.xml.PlanExecutor#getOutputElements()
+ * @see org.teiid.query.processor.xml.PlanExecutor#getOutputElements()
*/
- public List getOutputElements() throws MetaMatrixComponentException {
+ public List getOutputElements() throws TeiidComponentException {
ProcessorPlan plan = resultInfo.getPlan();
return plan.getOutputElements();
}
/**
- * @throws MetaMatrixProcessingException
- * @see com.metamatrix.query.processor.xml.PlanExecutor#execute(java.util.Map)
+ * @throws TeiidProcessingException
+ * @see org.teiid.query.processor.xml.PlanExecutor#execute(java.util.Map)
*/
- public void execute(Map referenceValues) throws MetaMatrixComponentException, BlockedException, MetaMatrixProcessingException {
+ public void execute(Map referenceValues) throws TeiidComponentException, BlockedException, TeiidProcessingException {
if (this.tupleSource == null) {
setReferenceValues(referenceValues);
this.tupleSource = new BatchIterator(internalProcessor);
@@ -110,9 +110,9 @@
/**
* Get the next row from the result set
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- public List nextRow() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public List nextRow() throws TeiidComponentException, TeiidProcessingException {
// if we not already closed the tuple source; look for more results.
if (!endOfRows) {
@@ -123,7 +123,7 @@
// check if we walked over the row limit
if (this.currentRow != null && this.resultInfo.getUserRowLimit() > 0 && this.currentRowNumber > this.resultInfo.getUserRowLimit()) {
if (this.resultInfo.exceptionOnRowlimit()) {
- throw new MetaMatrixProcessingException(QueryExecPlugin.Util.getString("row_limit_passed", new Object[] { new Integer(this.resultInfo.getUserRowLimit()), this.resultInfo.getResultSetName()})); //$NON-NLS-1$
+ throw new TeiidProcessingException(QueryExecPlugin.Util.getString("row_limit_passed", new Object[] { new Integer(this.resultInfo.getUserRowLimit()), this.resultInfo.getResultSetName()})); //$NON-NLS-1$
}
// well, we did not throw a exception, that means we need to limit it to current row
this.currentRow = null;
@@ -140,7 +140,7 @@
* Get the current row.
* @return
*/
- public List currentRow() throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public List currentRow() throws TeiidComponentException, TeiidProcessingException {
// automatically forward to the very first row.
if (this.currentRow == null && !endOfRows) {
return nextRow();
@@ -152,7 +152,7 @@
/**
* Close the executor and release all the resources.
*/
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
this.internalProcessor.closeProcessing();
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"closed executor", resultInfo.getResultSetName()}); //$NON-NLS-1$
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/SAXDocumentInProgress.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/SAXDocumentInProgress.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.io.BufferedOutputStream;
import java.util.Iterator;
@@ -33,13 +33,13 @@
import net.sf.saxon.TransformerFactoryImpl;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.core.TeiidComponentException;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.mapping.xml.MappingNodeConstants;
import org.xml.sax.SAXException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.query.mapping.xml.MappingNodeConstants;
/**
* This class is used to build XML document and stream the output as
@@ -55,7 +55,7 @@
private boolean isFormatted = MappingNodeConstants.Defaults.DEFAULT_FORMATTED_DOCUMENT.booleanValue();
private FileStore store;
- public SAXDocumentInProgress(FileStore store) throws MetaMatrixComponentException{
+ public SAXDocumentInProgress(FileStore store) throws TeiidComponentException{
this.store = store;
SAXTransformerFactory factory = new TransformerFactoryImpl();
//TODO use standard jaxp to create factory
@@ -65,20 +65,20 @@
handler = factory.newTransformerHandler();
handler.setResult(new StreamResult(new BufferedOutputStream(store.createOutputStream())));
} catch (Exception e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
transformer = handler.getTransformer();
}
/**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#setDocumentEncoding(java.lang.String)
+ * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentEncoding(java.lang.String)
*/
public void setDocumentEncoding(String documentEncoding) {
this.documentEncoding = documentEncoding;
}
/**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#setDocumentFormat(boolean)
+ * @see org.teiid.query.processor.xml.DocumentInProgress#setDocumentFormat(boolean)
*/
public void setDocumentFormat(boolean isFormatted) {
this.isFormatted = isFormatted;
@@ -89,7 +89,7 @@
* the current object. Need to process the current and child object before moving
* to the parent.
* @throws SAXException
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#moveToParent()
+ * @see org.teiid.query.processor.xml.DocumentInProgress#moveToParent()
*/
public boolean moveToParent() throws SAXException {
showState( "moveToParent - TOP" ); //$NON-NLS-1$
@@ -109,7 +109,7 @@
}
/**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#moveToLastChild()
+ * @see org.teiid.query.processor.xml.DocumentInProgress#moveToLastChild()
*/
public boolean moveToLastChild() {
showState( "moveToLastChild - TOP" ); //$NON-NLS-1$
@@ -236,15 +236,15 @@
}
/**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#addAttribute(java.lang.String, java.lang.String, java.lang.String, boolean)
+ * @see org.teiid.query.processor.xml.DocumentInProgress#addAttribute(java.lang.String, java.lang.String, java.lang.String, boolean)
*/
public boolean addAttribute(NodeDescriptor descriptor, String attributeValue){
return addAttribute(descriptor, attributeValue, currentParent);
}
/**
- * @throws MetaMatrixComponentException
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#addComment(java.lang.String)
+ * @throws TeiidComponentException
+ * @see org.teiid.query.processor.xml.DocumentInProgress#addComment(java.lang.String)
*/
public boolean addComment(String commentText) {
currentParent.setComment(commentText);
@@ -252,20 +252,20 @@
}
/**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#isFinished()
+ * @see org.teiid.query.processor.xml.DocumentInProgress#isFinished()
*/
public boolean isFinished() {
return finished;
}
/**
- * @see com.metamatrix.query.processor.xml.DocumentInProgress#markAsFinished()
+ * @see org.teiid.query.processor.xml.DocumentInProgress#markAsFinished()
*/
- public void markAsFinished() throws MetaMatrixComponentException{
+ public void markAsFinished() throws TeiidComponentException{
try {
endDocument();
} catch (SAXException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
finished = true;
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/WhileInstruction.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/WhileInstruction.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/WhileInstruction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,21 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.util.List;
import java.util.Map;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
import org.teiid.logging.LogManager;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
/**
* Loop instruction on the result set execute before this instruction.
@@ -63,7 +63,7 @@
* @see ProcessorInstruction#process(ProcessorEnvironment)
*/
public XMLContext process(XMLProcessorEnvironment env, XMLContext context)
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws BlockedException, TeiidComponentException, TeiidProcessingException{
List row = context.getCurrentRow(resultSetName);
@@ -99,7 +99,7 @@
protected void pushProgram(XMLProcessorEnvironment env,
XMLContext context,
- List row) throws MetaMatrixComponentException {
+ List row) throws TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_XML_PLAN, new Object[]{"WHILE repeating for result set:",resultSetName,", block program:", blockProgram}); //$NON-NLS-1$ //$NON-NLS-2$
context.setVariableValues(resultSetName, row);
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLContext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLContext.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.util.VariableContext;
+
/**
* A XML context is an object which is passed between all the xml processing instructions.
* context will have all the information possible for the block instructions to execute. It will
@@ -76,13 +77,13 @@
* @param aliasResultName
* @return
*/
- public List getCurrentRow(String aliasResultName) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public List getCurrentRow(String aliasResultName) throws TeiidComponentException, TeiidProcessingException {
PlanExecutor executor = (PlanExecutor)this.resultsMap.get(aliasResultName);
if (executor == null) {
if (this.parentContext != null) {
return this.parentContext.getCurrentRow(aliasResultName);
}
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("results_not_found", aliasResultName)); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("results_not_found", aliasResultName)); //$NON-NLS-1$
}
return executor.currentRow();
}
@@ -91,15 +92,15 @@
* Get the next row from the result set given.
* @param aliasResultName
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- public List getNextRow(String aliasResultName) throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ public List getNextRow(String aliasResultName) throws TeiidComponentException, TeiidProcessingException {
PlanExecutor executor = (PlanExecutor)this.resultsMap.get(aliasResultName);
if (executor == null) {
if (this.parentContext != null) {
return this.parentContext.getNextRow(aliasResultName);
}
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("results_not_found", aliasResultName)); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("results_not_found", aliasResultName)); //$NON-NLS-1$
}
return executor.nextRow();
}
@@ -117,7 +118,7 @@
* Be sure that when removing the results, we do not walk into the parent context
* as there may be another resultset with same name. (recursive condition)
*/
- public void removeResultSet(String resultName) throws MetaMatrixComponentException {
+ public void removeResultSet(String resultName) throws TeiidComponentException {
PlanExecutor executor = (PlanExecutor)this.resultsMap.remove(resultName);
if (executor != null) {
executor.close();
@@ -129,15 +130,15 @@
* not any thing else)
* @param resultName
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
- public List getOutputElements(String resultName) throws MetaMatrixComponentException {
+ public List getOutputElements(String resultName) throws TeiidComponentException {
PlanExecutor executor = (PlanExecutor)this.resultsMap.get(resultName);
if (executor == null) {
if (this.parentContext != null) {
return this.parentContext.getOutputElements(resultName);
}
- throw new MetaMatrixComponentException(QueryExecPlugin.Util.getString("results_not_found", resultName)); //$NON-NLS-1$
+ throw new TeiidComponentException(QueryExecPlugin.Util.getString("results_not_found", resultName)); //$NON-NLS-1$
}
return executor.getOutputElements();
}
@@ -185,7 +186,7 @@
void setVariableValues(String resultSetName,
- List row) throws MetaMatrixComponentException {
+ List row) throws TeiidComponentException {
List elements = getOutputElements(resultSetName);
for (int index = 0; index < elements.size(); index++) {
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLPlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
-import static com.metamatrix.query.analysis.AnalysisRecord.*;
+import static org.teiid.query.analysis.AnalysisRecord.*;
import java.io.IOException;
import java.io.InputStream;
@@ -43,8 +43,27 @@
import javax.xml.parsers.SAXParserFactory;
import org.teiid.client.plan.PlanNode;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.XMLType;
import org.teiid.logging.LogConstants;
import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.TempTableDataManager;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.tempdata.TempTableStore;
+import org.teiid.query.tempdata.TempTableStoreImpl;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
import org.xml.sax.Attributes;
import org.xml.sax.EntityResolver;
import org.xml.sax.ErrorHandler;
@@ -54,25 +73,6 @@
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TempTableDataManager;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.tempdata.TempTableStore;
-import com.metamatrix.query.tempdata.TempTableStoreImpl;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
*
@@ -141,14 +141,14 @@
return output;
}
- public void open() throws MetaMatrixComponentException {
+ public void open() throws TeiidComponentException {
}
/**
* @see ProcessorPlan#nextBatch()
*/
public TupleBatch nextBatch()
- throws MetaMatrixComponentException, MetaMatrixProcessingException, BlockedException {
+ throws TeiidComponentException, TeiidProcessingException, BlockedException {
while(true){
// do the xml processing.
@@ -169,7 +169,7 @@
try {
reader = xml.getCharacterStream();
} catch (SQLException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
try {
validateDoc(reader);
@@ -213,16 +213,16 @@
* The constants in the code are specific to the Apache Xerces parser and must be used
* Known limitiation is when it is attempted to validate against multiple schemas
* @param xmlDoc
- * @throws MetaMatrixComponentException if the document cannot be validated against the schema
+ * @throws TeiidComponentException if the document cannot be validated against the schema
*
*/
- private void validateDoc(Reader xmlStream) throws MetaMatrixComponentException {
+ private void validateDoc(Reader xmlStream) throws TeiidComponentException {
// get the schema
if (xmlSchemas == null || xmlSchemas.isEmpty()){
// if there is no schema no need to validate
// return a warning saying there is no schema
- MetaMatrixException noSchema = new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0042, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0042));
+ TeiidException noSchema = new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0042, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0042));
addWarning(noSchema);
return;
}
@@ -232,7 +232,7 @@
try{
// also find the target name space URIs for the document(s).
nameSpaceMap = getTargetNameSpaces(xmlSchemas);
- } catch(MetaMatrixException me){
+ } catch(TeiidException me){
addWarning(me);
nameSpaceMap = new HashMap();
}
@@ -250,9 +250,9 @@
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaSource", nameSpaceMap.keySet().toArray()); //$NON-NLS-1$
reader = parser.getXMLReader();
} catch (SAXException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
} catch (ParserConfigurationException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
}
// place the schema into the customized entity resolver so that we can
@@ -271,16 +271,16 @@
try{
reader.parse(source);
} catch(SAXException se){
- throw new MetaMatrixComponentException(se);
+ throw new TeiidComponentException(se);
} catch(IOException io){
- throw new MetaMatrixComponentException(io);
+ throw new TeiidComponentException(io);
}
// determine if we have any warnings, errors, or fatal errors and report as necessary
if (errorHandler.hasExceptions()) {
List exceptionList = errorHandler.getExceptionList();
for (Iterator i = exceptionList.iterator(); i.hasNext();) {
- addWarning((MetaMatrixException)i.next());
+ addWarning((TeiidException)i.next());
}
}
}
@@ -317,7 +317,7 @@
* @throws ParserConfigurationException
* @throws IOException
*/
- private HashMap getTargetNameSpaces(Collection<SQLXML> schemas) throws MetaMatrixException {
+ private HashMap getTargetNameSpaces(Collection<SQLXML> schemas) throws TeiidException {
HashMap nameSpaceMap = new HashMap();
SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setNamespaceAware(true);
@@ -325,9 +325,9 @@
try {
parser = spf.newSAXParser();
} catch (ParserConfigurationException err) {
- throw new MetaMatrixException(err);
+ throw new TeiidException(err);
} catch (SAXException err) {
- throw new MetaMatrixException(err);
+ throw new TeiidException(err);
}
PeekContentHandler pch = new PeekContentHandler();
@@ -336,16 +336,16 @@
try {
is = schema.getBinaryStream();
} catch (SQLException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
}
InputSource source = new InputSource(is);
pch.targetNameSpace = null;
try {
parser.parse(source, pch);
} catch (SAXException err) {
- throw new MetaMatrixException(err);
+ throw new TeiidException(err);
} catch (IOException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
} finally {
try {
is.close();
@@ -374,9 +374,9 @@
/**
* Clean up the tuple source when the plan is closed.
- * @see com.metamatrix.query.processor.ProcessorPlan#close()
+ * @see org.teiid.query.processor.ProcessorPlan#close()
*/
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
}
public String toString() {
@@ -415,19 +415,19 @@
* any errors that occur during XML processing
*/
private static class MMErrorHandler implements ErrorHandler{
- ArrayList<MetaMatrixException> exceptionList = null;
+ ArrayList<TeiidException> exceptionList = null;
/**
* Keep track of all the exceptions
*/
- private void addException(MetaMatrixException me) {
+ private void addException(TeiidException me) {
if (exceptionList == null) {
- exceptionList = new ArrayList<MetaMatrixException>();
+ exceptionList = new ArrayList<TeiidException>();
}
exceptionList.add(me);
}
- public List<MetaMatrixException> getExceptionList() {
+ public List<TeiidException> getExceptionList() {
return exceptionList;
}
@@ -436,13 +436,13 @@
}
public void error(SAXParseException ex){
- addException(new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0049, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0048, ex.getMessage())));
+ addException(new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0049, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0048, ex.getMessage())));
}
public void fatalError(SAXParseException ex){
- addException(new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0048, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0048, ex.getMessage())));
+ addException(new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0048, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0048, ex.getMessage())));
}
public void warning(SAXParseException ex){
- addException(new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0049, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0048, ex.getMessage())));
+ addException(new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0049, QueryExecPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0048, ex.getMessage())));
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLProcessorEnvironment.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLProcessorEnvironment.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.util.Collections;
import java.util.HashSet;
@@ -28,16 +28,16 @@
import java.util.LinkedList;
import java.util.Set;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
import org.teiid.logging.LogManager;
import org.teiid.logging.MessageLevel;
+import org.teiid.query.mapping.xml.ResultSetInfo;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.CommandContext;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.query.mapping.xml.ResultSetInfo;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.CommandContext;
public class XMLProcessorEnvironment {
@@ -217,7 +217,7 @@
}
public PlanExecutor createResultExecutor(String resultSetName, ResultSetInfo info)
- throws MetaMatrixComponentException{
+ throws TeiidComponentException{
// cloning the plan inside the resultset is not possible
// because of the dependencies.
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.io.BufferedInputStream;
import java.io.IOException;
@@ -30,17 +30,18 @@
import javax.xml.transform.TransformerException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.FileStore;
-import com.metamatrix.common.buffer.FileStore.FileStoreOutputStream;
-import com.metamatrix.common.types.InputStreamFactory;
-import com.metamatrix.common.types.SQLXMLImpl;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.XMLTranslator;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.FileStore;
+import org.teiid.common.buffer.FileStore.FileStoreOutputStream;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.InputStreamFactory;
+import org.teiid.core.types.SQLXMLImpl;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.XMLTranslator;
+
/**
* Utility methods to be used with the XML and XQuery processing.
*/
@@ -51,7 +52,7 @@
* Documents less than the maxMemorySize will be held directly in memory
*/
public static SQLXMLImpl saveToBufferManager(BufferManager bufferMgr, XMLTranslator translator, int maxMemorySize)
- throws MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws TeiidComponentException, TeiidProcessingException {
boolean success = false;
final FileStore lobBuffer = bufferMgr.createFileStore("xml"); //$NON-NLS-1$
try{
@@ -65,9 +66,9 @@
success = true;
return createSQLXML(lobBuffer);
} catch(IOException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
} catch(TransformerException e) {
- throw new MetaMatrixProcessingException(e);
+ throw new TeiidProcessingException(e);
} finally {
if (!success && lobBuffer != null) {
lobBuffer.remove();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLValueTranslator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xml/XMLValueTranslator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xml/XMLValueTranslator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,20 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xml;
+package org.teiid.query.processor.xml;
import java.math.BigInteger;
import java.sql.Timestamp;
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.query.function.FunctionMethods;
-import com.metamatrix.query.function.source.XMLSystemFunctions;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.TransformationException;
+import org.teiid.query.function.FunctionMethods;
+import org.teiid.query.function.source.XMLSystemFunctions;
+
/**
* This class will make a minimal effort to output xsd formatted values for a given
* built-in type. It will not attempt to narrow or otherwise fit most values into
Copied: trunk/engine/src/main/java/org/teiid/query/processor/xquery (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/processor/xquery)
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xquery/SqlEval.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/SqlEval.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xquery/SqlEval.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xquery;
+package org.teiid.query.processor.xquery;
import java.io.StringReader;
import java.util.ArrayList;
@@ -35,27 +35,27 @@
import javax.xml.transform.sax.SAXSource;
import javax.xml.transform.stream.StreamSource;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.XMLType;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.processor.BatchIterator;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.Symbol;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.xquery.XQuerySQLEvaluator;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.processor.BatchIterator;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.Symbol;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.xquery.XQuerySQLEvaluator;
/**
@@ -73,7 +73,7 @@
private ProcessorDataManager dataManager;
public static Source createSource(TupleSource source)
- throws MetaMatrixProcessingException {
+ throws TeiidProcessingException {
try {
// we only want to return the very first document from the result set
@@ -92,12 +92,12 @@
}
}
} catch (Exception e) {
- throw new MetaMatrixProcessingException(e);
+ throw new TeiidProcessingException(e);
}
return new StreamSource(new StringReader(NO_RESULTS_DOCUMENT));
}
- public static SAXSource createSource(String[] columns, Class[] types, TupleSource source) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ public static SAXSource createSource(String[] columns, Class[] types, TupleSource source) throws TeiidProcessingException, TeiidComponentException {
try {
// get the sax parser and the its XML reader and replace with
@@ -110,9 +110,9 @@
return new SAXSource(new TupleXMLReader(reader), new TupleInputSource(columns, types, source));
} catch (ParserConfigurationException e) {
- throw new MetaMatrixComponentException(e);
+ throw new TeiidComponentException(e);
} catch (SAXException e) {
- throw new MetaMatrixProcessingException(e);
+ throw new TeiidProcessingException(e);
}
}
@@ -124,11 +124,11 @@
}
/**
- * @see com.metamatrix.query.xquery.XQuerySQLEvaluator#executeDynamicSQL(java.lang.String)
+ * @see org.teiid.query.xquery.XQuerySQLEvaluator#executeDynamicSQL(java.lang.String)
* @since 4.3
*/
public Source executeSQL(String sql)
- throws QueryParserException, MetaMatrixProcessingException, MetaMatrixComponentException {
+ throws QueryParserException, TeiidProcessingException, TeiidComponentException {
QueryProcessor processor = context.getQueryProcessorFactory().createQueryProcessor(sql, parentGroup, context);
processor.setNonBlocking(true);
@@ -154,7 +154,7 @@
}
@Override
- public Object getParameterValue(String key) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ public Object getParameterValue(String key) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
String paramName = this.parentGroup + ElementSymbol.SEPARATOR + key;
paramName = paramName.toUpperCase();
Expression expr = this.params.get(paramName);
@@ -199,7 +199,7 @@
/**
* Closes any resources opened during the evaluation
*/
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
if (processors != null) {
for (QueryProcessor processor : processors) {
processor.closeProcessing();
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xquery/TupleInputSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleInputSource.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xquery/TupleInputSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xquery;
+package org.teiid.query.processor.xquery;
import java.util.List;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.AttributesImpl;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.types.DataTypeManager;
/**
@@ -94,9 +94,9 @@
saxHandler.endElement(nsURI, RESULTS, RESULTS);
saxHandler.endDocument();
this.source.closeSource();
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
throw new SAXException(e);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
throw new SAXException(e);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xquery/TupleXMLReader.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/TupleXMLReader.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xquery/TupleXMLReader.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xquery;
+package org.teiid.query.processor.xquery;
import java.io.IOException;
Modified: trunk/engine/src/main/java/org/teiid/query/processor/xquery/XQueryPlan.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/processor/xquery/XQueryPlan.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/processor/xquery/XQueryPlan.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,31 +20,32 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.processor.xquery;
+package org.teiid.query.processor.xquery;
import java.sql.SQLXML;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBatch;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.Streamable;
-import com.metamatrix.common.types.XMLTranslator;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.xml.XMLUtil;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.XMLFormatConstants;
-import com.metamatrix.query.xquery.XQueryExpression;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBatch;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.Streamable;
+import org.teiid.core.types.XMLTranslator;
+import org.teiid.core.types.XMLType;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.processor.xml.XMLUtil;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.XMLFormatConstants;
+import org.teiid.query.xquery.XQueryExpression;
+
/**
* XQuery execution Plan
*/
@@ -76,7 +77,7 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#initialize(com.metamatrix.query.util.CommandContext, com.metamatrix.query.processor.ProcessorDataManager, com.metamatrix.common.buffer.BufferManager)
+ * @see org.teiid.query.processor.ProcessorPlan#initialize(org.teiid.query.util.CommandContext, org.teiid.query.processor.ProcessorDataManager, org.teiid.common.buffer.BufferManager)
*/
public void initialize(CommandContext context, ProcessorDataManager dataMgr, BufferManager bufferMgr) {
setContext(context);
@@ -88,7 +89,7 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#getOutputElements()
+ * @see org.teiid.query.processor.ProcessorPlan#getOutputElements()
*/
public List getOutputElements() {
ArrayList output = new ArrayList(1);
@@ -99,16 +100,16 @@
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#open()
+ * @see org.teiid.query.processor.ProcessorPlan#open()
*/
- public void open() throws MetaMatrixComponentException {
+ public void open() throws TeiidComponentException {
}
/**
- * @see com.metamatrix.query.processor.ProcessorPlan#nextBatch()
+ * @see org.teiid.query.processor.ProcessorPlan#nextBatch()
*/
public TupleBatch nextBatch()
- throws BlockedException, MetaMatrixComponentException, MetaMatrixProcessingException {
+ throws BlockedException, TeiidComponentException, TeiidProcessingException {
XQueryExpression expr = this.xQuery.getCompiledXQuery();
expr.setXMLFormat(xmlFormat);
@@ -139,9 +140,9 @@
* memory "atomically" (from the XQueryEngine layer).
* @param rawResults
* @return
- * @throws MetaMatrixProcessingException
+ * @throws TeiidProcessingException
*/
- private TupleBatch packResultsIntoBatch(XMLTranslator translator) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private TupleBatch packResultsIntoBatch(XMLTranslator translator) throws TeiidComponentException, TeiidProcessingException{
List rows = new ArrayList(1);
List row = new ArrayList(1);
@@ -159,9 +160,9 @@
/**
* Clean up the tuple source when the plan is closed.
- * @see com.metamatrix.query.processor.ProcessorPlan#close()
+ * @see org.teiid.query.processor.ProcessorPlan#close()
*/
- public void close() throws MetaMatrixComponentException {
+ public void close() throws TeiidComponentException {
}
public String toString() {
Copied: trunk/engine/src/main/java/org/teiid/query/report (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/report)
Modified: trunk/engine/src/main/java/org/teiid/query/report/ActivityReport.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/report/ActivityReport.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/report/ActivityReport.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.report;
+package org.teiid.query.report;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* A report holds the output of some activity. The report collects information during the activity, such
* as failures or successes.
Modified: trunk/engine/src/main/java/org/teiid/query/report/ReportItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/report/ReportItem.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/report/ReportItem.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.report;
+package org.teiid.query.report;
import java.io.Serializable;
Copied: trunk/engine/src/main/java/org/teiid/query/resolver/CommandResolver.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/resolver/CommandResolver.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/CommandResolver.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/CommandResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,53 @@
+/*
+ * 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.resolver;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.sql.lang.Command;
+
+
+/**
+ * This is the interface that is implemented for each type of command, telling how
+ * to resolve that command.
+ */
+public interface CommandResolver {
+
+ /**
+ * Resolve the command using the metadata.
+ * @param command The command to resolve
+ * @param metadata Metadata
+ * @param analysis
+ * @param resolveNullLiterals true if the resolver should consider replacing null literals with more appropriate types
+ * @return the TempMetadataStore containing the metadata defined by this command
+ * @throws QueryMetadataException If there is a metadata problem
+ * @throws QueryResolverException If the query cannot be resolved
+ * @throws TeiidComponentException If there is an internal error
+ */
+ void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException;
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/resolver/ProcedureContainerResolver.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/ProcedureContainerResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,237 @@
+/*
+ * 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.resolver;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
+
+
+public abstract class ProcedureContainerResolver implements CommandResolver {
+
+ public abstract void resolveProceduralCommand(Command command,
+ TempMetadataAdapter metadata,
+ AnalysisRecord analysis) throws QueryMetadataException,
+ QueryResolverException,
+ TeiidComponentException;
+
+ /**
+ * Expand a command by finding and attaching all subcommands to the command. If
+ * some initial resolution must be done for this to be accomplished, that is ok,
+ * but it should be kept to a minimum.
+ * @param command The command to expand
+ * @param useMetadataCommands True if resolver should use metadata commands to completely resolve
+ * @param metadata Metadata access
+ * @param analysis The analysis record that will be filled in if doing annotation.
+ *
+ * @throws QueryMetadataException If there is a metadata problem
+ * @throws QueryResolverException If the query cannot be resolved
+ * @throws TeiidComponentException If there is an internal error
+ */
+ public Command expandCommand(ProcedureContainer procCommand, QueryMetadataInterface metadata, AnalysisRecord analysis)
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
+
+ // Resolve group so we can tell whether it is an update procedure
+ GroupSymbol group = procCommand.getGroup();
+
+ Command subCommand = null;
+
+ String plan = getPlan(metadata, procCommand);
+
+ if (plan == null) {
+ return null;
+ }
+
+ QueryParser parser = QueryParser.getQueryParser();
+ try {
+ subCommand = parser.parseCommand(plan);
+ } catch(QueryParserException e) {
+ throw new QueryResolverException(e, ErrorMessageKeys.RESOLVER_0045, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0045, group));
+ }
+
+ if(subCommand instanceof CreateUpdateProcedureCommand){
+ CreateUpdateProcedureCommand cupCommand = (CreateUpdateProcedureCommand)subCommand;
+ //if the subcommand is virtual stored procedure, it must have the same
+ //projected symbol as its parent.
+ if(!cupCommand.isUpdateProcedure()){
+ cupCommand.setProjectedSymbols(procCommand.getProjectedSymbols());
+ }
+
+ cupCommand.setVirtualGroup(procCommand.getGroup());
+ cupCommand.setUserCommand(procCommand);
+ }
+
+ //find the childMetadata using a clean metadata store
+ TempMetadataStore childMetadata = new TempMetadataStore();
+ QueryMetadataInterface resolveMetadata = new TempMetadataAdapter(metadata, childMetadata);
+
+ GroupContext externalGroups = findChildCommandMetadata(procCommand, childMetadata, resolveMetadata);
+
+ QueryResolver.setChildMetadata(subCommand, childMetadata.getData(), externalGroups);
+
+ QueryResolver.resolveCommand(subCommand, Collections.EMPTY_MAP, metadata, analysis);
+
+ return subCommand;
+ }
+
+ /**
+ * For a given resolver, this returns the unparsed command.
+ *
+ * @param metadata
+ * @param group
+ * @return
+ * @throws TeiidComponentException
+ * @throws QueryMetadataException
+ */
+ protected abstract String getPlan(QueryMetadataInterface metadata,
+ GroupSymbol group) throws TeiidComponentException,
+ QueryMetadataException;
+
+ /**
+ * Find all metadata defined by this command for it's children. This metadata should be collected
+ * in the childMetadata object. Typical uses of this are for stored queries that define parameter
+ * variables valid in subcommands. only used for inserts, updates, and deletes
+ * @param metadata Metadata access
+ * @param command The command to find metadata on
+ * @param childMetadata The store to collect child metadata in
+ * @throws QueryMetadataException If there is a metadata problem
+ * @throws QueryResolverException If the query cannot be resolved
+ * @throws TeiidComponentException If there is an internal error
+ */
+ public GroupContext findChildCommandMetadata(ProcedureContainer container, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
+ // get the group on the delete statement
+ GroupSymbol group = container.getGroup();
+ // proceed further if it is a virtual group
+
+ return createChildMetadata(discoveredMetadata, metadata, group);
+ }
+
+ static GroupContext createChildMetadata(
+ TempMetadataStore discoveredMetadata,
+ QueryMetadataInterface metadata, GroupSymbol group)
+ throws QueryMetadataException, TeiidComponentException {
+ GroupContext externalGroups = new GroupContext();
+
+ //Look up elements for the virtual group
+ List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, metadata);
+
+ // Create the INPUT variables
+ List<ElementSymbol> inputElments = new ArrayList<ElementSymbol>(elements.size());
+ for(int i=0; i<elements.size(); i++) {
+ ElementSymbol virtualElmnt = elements.get(i);
+ ElementSymbol inputElement = (ElementSymbol)virtualElmnt.clone();
+ inputElments.add(inputElement);
+ }
+
+ addScalarGroup(ProcedureReservedWords.INPUT, discoveredMetadata, externalGroups, inputElments);
+ addScalarGroup(ProcedureReservedWords.INPUTS, discoveredMetadata, externalGroups, inputElments);
+
+ // Switch type to be boolean for all CHANGING variables
+ List<ElementSymbol> changingElements = new ArrayList<ElementSymbol>(elements.size());
+ for(int i=0; i<elements.size(); i++) {
+ ElementSymbol virtualElmnt = elements.get(i);
+ ElementSymbol changeElement = (ElementSymbol)virtualElmnt.clone();
+ changeElement.setType(DataTypeManager.DefaultDataClasses.BOOLEAN);
+ changingElements.add(changeElement);
+ }
+
+ addScalarGroup(ProcedureReservedWords.CHANGING, discoveredMetadata, externalGroups, changingElements);
+ return externalGroups;
+ }
+
+ /**
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord, boolean)
+ */
+ public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
+
+ ProcedureContainer procCommand = (ProcedureContainer)command;
+
+ resolveGroup(metadata, procCommand);
+
+ resolveProceduralCommand(procCommand, metadata, analysis);
+
+ getPlan(metadata, procCommand);
+ }
+
+ private String getPlan(QueryMetadataInterface metadata, ProcedureContainer procCommand)
+ throws TeiidComponentException, QueryMetadataException,
+ QueryResolverException {
+ if(!procCommand.getGroup().isTempGroupSymbol() && metadata.isVirtualGroup(procCommand.getGroup().getMetadataID())) {
+ String plan = getPlan(metadata, procCommand.getGroup());
+
+ if(plan == null) {
+ throw new QueryResolverException(ErrorMessageKeys.RESOLVER_0009, QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0009, procCommand.getGroup(), procCommand.getClass().getSimpleName()));
+ }
+ return plan;
+ }
+ return null;
+ }
+
+ /**
+ * @param metadata
+ * @param procCommand
+ * @throws TeiidComponentException
+ * @throws QueryResolverException
+ */
+ protected void resolveGroup(TempMetadataAdapter metadata,
+ ProcedureContainer procCommand) throws TeiidComponentException,
+ QueryResolverException {
+ // Resolve group so we can tell whether it is an update procedure
+ GroupSymbol group = procCommand.getGroup();
+ ResolverUtil.resolveGroup(group, metadata);
+ }
+
+ public static GroupSymbol addScalarGroup(String name, TempMetadataStore metadata, GroupContext externalGroups, List symbols) {
+ GroupSymbol variables = new GroupSymbol(name);
+ externalGroups.addGroup(variables);
+ TempMetadataID tid = metadata.addTempGroup(name, symbols);
+ tid.setScalarGroup(true);
+ variables.setMetadataID(tid);
+ return variables;
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/resolver/QueryResolver.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/QueryResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,298 @@
+/*
+ * 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.resolver;
+
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.logging.LogManager;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.resolver.command.BatchedUpdateResolver;
+import org.teiid.query.resolver.command.DeleteResolver;
+import org.teiid.query.resolver.command.DynamicCommandResolver;
+import org.teiid.query.resolver.command.ExecResolver;
+import org.teiid.query.resolver.command.InsertResolver;
+import org.teiid.query.resolver.command.SetQueryResolver;
+import org.teiid.query.resolver.command.SimpleQueryResolver;
+import org.teiid.query.resolver.command.TempTableResolver;
+import org.teiid.query.resolver.command.UpdateProcedureResolver;
+import org.teiid.query.resolver.command.UpdateResolver;
+import org.teiid.query.resolver.command.XMLQueryResolver;
+import org.teiid.query.resolver.command.XQueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
+
+/**
+ * <P>The QueryResolver is used between Parsing and QueryValidation. The SQL queries,
+ * inserts, updates and deletes are parsed and converted into objects. The language
+ * objects have variable names which resolved to fully qualified names using metadata
+ * information. The resolver is also used in transforming the values in language
+ * objects to their variable types defined in metadata.
+ */
+public class QueryResolver {
+
+ private static final CommandResolver SIMPLE_QUERY_RESOLVER = new SimpleQueryResolver();
+ private static final CommandResolver SET_QUERY_RESOLVER = new SetQueryResolver();
+ private static final CommandResolver XML_QUERY_RESOLVER = new XMLQueryResolver();
+ private static final CommandResolver EXEC_RESOLVER = new ExecResolver();
+ private static final CommandResolver INSERT_RESOLVER = new InsertResolver();
+ private static final CommandResolver UPDATE_RESOLVER = new UpdateResolver();
+ private static final CommandResolver DELETE_RESOLVER = new DeleteResolver();
+ private static final CommandResolver UPDATE_PROCEDURE_RESOLVER = new UpdateProcedureResolver();
+ private static final CommandResolver X_QUERY_RESOLVER = new XQueryResolver();
+ private static final CommandResolver BATCHED_UPDATE_RESOLVER = new BatchedUpdateResolver();
+ private static final CommandResolver DYNAMIC_COMMAND_RESOLVER = new DynamicCommandResolver();
+ private static final CommandResolver TEMP_TABLE_RESOLVER = new TempTableResolver();
+
+ public static Command expandCommand(ProcedureContainer proc, QueryMetadataInterface metadata, AnalysisRecord analysisRecord) throws QueryResolverException, QueryMetadataException, TeiidComponentException {
+ ProcedureContainerResolver cr = (ProcedureContainerResolver)chooseResolver(proc, metadata);
+ return cr.expandCommand(proc, metadata, analysisRecord);
+ }
+
+ /**
+ * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
+ * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
+ * @param metadata QueryMetadataInterface the metadata
+ * @param analysis The analysis record which can be used to add anotations and debug information.
+ */
+ public static void resolveCommand(Command command, QueryMetadataInterface metadata, AnalysisRecord analysis)
+ throws QueryResolverException, TeiidComponentException {
+
+ resolveCommand(command, Collections.EMPTY_MAP, metadata, analysis);
+ }
+
+ /**
+ * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
+ * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
+ * @param metadata QueryMetadataInterface the metadata
+ */
+ public static void resolveCommand(Command command, QueryMetadataInterface metadata)
+ throws QueryResolverException, TeiidComponentException {
+
+ resolveCommand(command, Collections.EMPTY_MAP, metadata, AnalysisRecord.createNonRecordingRecord());
+ }
+
+ /**
+ * This implements an algorithm to resolve all the symbols created by the parser into real metadata IDs
+ * @param externalMetadata Map of GroupSymbol to a List of ElementSymbol that identifies
+ * valid external groups that can be resolved against. Any elements resolved against external
+ * groups will be treated as variables
+ * @param metadata QueryMetadataInterface the metadata
+ * @param analysis The analysis record which can be used to add anotations and debug information.
+ * @param command Command the SQL command we are running (Select, Update, Insert, Delete)
+ */
+ public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, QueryMetadataInterface metadata,
+ AnalysisRecord analysis)
+ throws QueryResolverException, TeiidComponentException {
+ return resolveCommand(currentCommand, externalMetadata, metadata, analysis, true);
+ }
+
+ public static TempMetadataStore resolveCommand(Command currentCommand, Map externalMetadata, QueryMetadataInterface metadata,
+ AnalysisRecord analysis, boolean resolveNullLiterals)
+ throws QueryResolverException, TeiidComponentException {
+
+ LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving command", currentCommand}); //$NON-NLS-1$
+
+ TempMetadataAdapter resolverMetadata = null;
+ try {
+ TempMetadataStore rootExternalStore = new TempMetadataStore();
+ if(externalMetadata != null) {
+ for(Iterator iter = externalMetadata.entrySet().iterator(); iter.hasNext();) {
+ Map.Entry entry = (Map.Entry)iter.next();
+ GroupSymbol group = (GroupSymbol) entry.getKey();
+ List elements = (List) entry.getValue();
+ rootExternalStore.addTempGroup(group.getName(), elements);
+ currentCommand.addExternalGroupToContext(group);
+ }
+ }
+ Map tempMetadata = currentCommand.getTemporaryMetadata();
+ if(tempMetadata == null) {
+ currentCommand.setTemporaryMetadata(new HashMap(rootExternalStore.getData()));
+ } else {
+ tempMetadata.putAll(rootExternalStore.getData());
+ }
+
+ TempMetadataStore discoveredMetadata = new TempMetadataStore(currentCommand.getTemporaryMetadata());
+
+ resolverMetadata = new TempMetadataAdapter(metadata, discoveredMetadata);
+
+ // Resolve external groups for command
+ Collection externalGroups = currentCommand.getAllExternalGroups();
+ Iterator extIter = externalGroups.iterator();
+ while(extIter.hasNext()) {
+ GroupSymbol extGroup = (GroupSymbol) extIter.next();
+ Object metadataID = extGroup.getMetadataID();
+ //make sure that the group is resolved and that it is pointing to the appropriate temp group
+ if (metadataID == null || (!(extGroup.getMetadataID() instanceof TempMetadataID) && discoveredMetadata.getTempGroupID(extGroup.getName()) != null)) {
+ metadataID = resolverMetadata.getGroupID(extGroup.getName());
+ extGroup.setMetadataID(metadataID);
+ }
+ }
+
+ CommandResolver resolver = chooseResolver(currentCommand, resolverMetadata);
+
+ // Resolve this command
+ resolver.resolveCommand(currentCommand, resolverMetadata, analysis, resolveNullLiterals);
+ } catch(QueryMetadataException e) {
+ throw new QueryResolverException(e, e.getMessage());
+ }
+
+ // Flag that this command has been resolved.
+ currentCommand.setIsResolved(true);
+
+ return resolverMetadata.getMetadataStore();
+ }
+
+ /**
+ * Method chooseResolver.
+ * @param command
+ * @param metadata
+ * @return CommandResolver
+ */
+ private static CommandResolver chooseResolver(Command command, QueryMetadataInterface metadata)
+ throws QueryResolverException, QueryMetadataException, TeiidComponentException {
+
+ switch(command.getType()) {
+ case Command.TYPE_QUERY:
+ if(command instanceof Query) {
+ if(isXMLQuery((Query)command, metadata)) {
+ return XML_QUERY_RESOLVER;
+ }
+ return SIMPLE_QUERY_RESOLVER;
+ }
+ return SET_QUERY_RESOLVER;
+ case Command.TYPE_INSERT: return INSERT_RESOLVER;
+ case Command.TYPE_UPDATE: return UPDATE_RESOLVER;
+ case Command.TYPE_DELETE: return DELETE_RESOLVER;
+ case Command.TYPE_STORED_PROCEDURE: return EXEC_RESOLVER;
+ case Command.TYPE_UPDATE_PROCEDURE: return UPDATE_PROCEDURE_RESOLVER;
+ case Command.TYPE_XQUERY: return X_QUERY_RESOLVER;
+ case Command.TYPE_BATCHED_UPDATE: return BATCHED_UPDATE_RESOLVER;
+ case Command.TYPE_DYNAMIC: return DYNAMIC_COMMAND_RESOLVER;
+ case Command.TYPE_CREATE: return TEMP_TABLE_RESOLVER;
+ case Command.TYPE_DROP: return TEMP_TABLE_RESOLVER;
+ default:
+ throw new AssertionError("Unknown command type"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Check to verify if the query would return XML results.
+ * @param query the query to check
+ * @param metadata QueryMetadataInterface the metadata
+ */
+ public static boolean isXMLQuery(Query query, QueryMetadataInterface metadata)
+ throws TeiidComponentException, QueryMetadataException, QueryResolverException {
+
+ // Check first group
+ From from = query.getFrom();
+ if(from == null){
+ //select with no from
+ return false;
+ }
+
+ if (from.getClauses().size() != 1) {
+ return false;
+ }
+
+ FromClause clause = (FromClause)from.getClauses().get(0);
+
+ if (!(clause instanceof UnaryFromClause)) {
+ return false;
+ }
+
+ GroupSymbol symbol = ((UnaryFromClause)clause).getGroup();
+
+ ResolverUtil.resolveGroup(symbol, metadata);
+
+ if (symbol.isProcedure()) {
+ return false;
+ }
+
+ Object groupID = ((UnaryFromClause)clause).getGroup().getMetadataID();
+
+ return metadata.isXMLGroup(groupID);
+ }
+
+ /**
+ * Resolve just a criteria. The criteria will be modified so nothing is returned.
+ * @param criteria Criteria to resolve
+ * @param metadata Metadata implementation
+ */
+ public static void resolveCriteria(Criteria criteria, QueryMetadataInterface metadata)
+ throws QueryResolverException, QueryMetadataException, TeiidComponentException {
+
+ ResolverVisitor.resolveLanguageObject(criteria, metadata);
+ }
+
+ public static void setChildMetadata(Command subCommand, Command parent) {
+ Map childMetadataMap = parent.getTemporaryMetadata();
+ GroupContext parentContext = parent.getExternalGroupContexts();
+
+ setChildMetadata(subCommand, childMetadataMap, parentContext);
+ }
+
+ public static void setChildMetadata(Command subCommand, Map parentTempMetadata, GroupContext parentContext) {
+ Map tempMetadata = subCommand.getTemporaryMetadata();
+ if(tempMetadata == null) {
+ subCommand.setTemporaryMetadata(new HashMap(parentTempMetadata));
+ } else {
+ tempMetadata.putAll(parentTempMetadata);
+ }
+
+ subCommand.setExternalGroupContexts(parentContext);
+ }
+
+ public static Map getVariableValues(Command command, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
+
+ CommandResolver resolver = chooseResolver(command, metadata);
+
+ if (resolver instanceof VariableResolver) {
+ return ((VariableResolver)resolver).getVariableValues(command, metadata);
+ }
+
+ return Collections.EMPTY_MAP;
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/resolver/VariableResolver.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/VariableResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,38 @@
+/*
+ * 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.resolver;
+
+import java.util.Map;
+
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.lang.Command;
+
+
+public interface VariableResolver {
+
+ Map getVariableValues(Command command, QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException;
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/resolver/command (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/resolver/command)
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/BatchedUpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/BatchedUpdateResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/BatchedUpdateResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,21 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.Collections;
import java.util.Iterator;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+
/**
* Resolver for BatchedUpdateCommands
* @since 4.2
@@ -42,10 +43,10 @@
public class BatchedUpdateResolver implements CommandResolver {
/**
- * @see com.metamatrix.query.resolver.command.AbstractCommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, boolean, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+ * @see com.metamatrix.query.resolver.command.AbstractCommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, boolean, org.teiid.query.analysis.AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
BatchedUpdateCommand batchedUpdateCommand = (BatchedUpdateCommand) command;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/DeleteResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DeleteResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/DeleteResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,36 +20,37 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.HashSet;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.resolver.ProcedureContainerResolver;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.resolver.ProcedureContainerResolver;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* This class knows how to expand and resolve DELETE commands.
*/
public class DeleteResolver extends ProcedureContainerResolver {
/**
- * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+ * @see org.teiid.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord)
*/
public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
//Cast to known type
Delete delete = (Delete) command;
@@ -64,11 +65,11 @@
* @param metadata
* @param group
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
protected String getPlan(QueryMetadataInterface metadata,
- GroupSymbol group) throws MetaMatrixComponentException,
+ GroupSymbol group) throws TeiidComponentException,
QueryMetadataException {
return metadata.getDeletePlan(group.getMetadataID());
}
@@ -76,7 +77,7 @@
@Override
public GroupContext findChildCommandMetadata(ProcedureContainer container,
TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata) throws QueryMetadataException,
- QueryResolverException, MetaMatrixComponentException {
+ QueryResolverException, TeiidComponentException {
//defect 16451: don't expose input and changing variables to delete procedures
return null;
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/DynamicCommandResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/DynamicCommandResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,39 +20,40 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.SetClause;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
public class DynamicCommandResolver implements CommandResolver {
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
DynamicCommand dynamicCmd = (DynamicCommand)command;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/ExecResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/ExecResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.ArrayList;
import java.util.Collections;
@@ -30,37 +30,37 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.resolver.ProcedureContainerResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.VariableResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.resolver.ProcedureContainerResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.VariableResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
*/
@@ -70,7 +70,7 @@
public Command expandCommand(ProcedureContainer procCommand,
QueryMetadataInterface metadata, AnalysisRecord analysis)
throws QueryMetadataException, QueryResolverException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Command command = super.expandCommand(procCommand, metadata, analysis);
if (command instanceof XQuery) {
XQuery query = (XQuery)command;
@@ -81,11 +81,11 @@
}
/**
- * @see com.metamatrix.query.resolver.CommandResolver#findCommandMetadata(com.metamatrix.query.sql.lang.Command,
- * com.metamatrix.query.metadata.QueryMetadataInterface)
+ * @see org.teiid.query.resolver.CommandResolver#findCommandMetadata(org.teiid.query.sql.lang.Command,
+ * org.teiid.query.metadata.QueryMetadataInterface)
*/
private void findCommandMetadata(Command command, TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
StoredProcedure storedProcedureCommand = (StoredProcedure) command;
@@ -211,7 +211,7 @@
@Override
public GroupContext findChildCommandMetadata(ProcedureContainer container,
TempMetadataStore discoveredMetadata, QueryMetadataInterface metadata) throws QueryMetadataException,
- QueryResolverException, MetaMatrixComponentException {
+ QueryResolverException, TeiidComponentException {
StoredProcedure storedProcedureCommand = (StoredProcedure) container;
@@ -238,10 +238,10 @@
}
/**
- * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+ * @see org.teiid.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord)
*/
public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
findCommandMetadata(command, metadata.getMetadataStore(), metadata);
@@ -287,7 +287,7 @@
}
protected void resolveGroup(TempMetadataAdapter metadata,
- ProcedureContainer procCommand) throws MetaMatrixComponentException,
+ ProcedureContainer procCommand) throws TeiidComponentException,
QueryResolverException {
//Do nothing
}
@@ -315,10 +315,10 @@
}
/**
- * @see com.metamatrix.query.resolver.ProcedureContainerResolver#getPlan(com.metamatrix.query.metadata.QueryMetadataInterface, com.metamatrix.query.sql.symbol.GroupSymbol)
+ * @see org.teiid.query.resolver.ProcedureContainerResolver#getPlan(org.teiid.query.metadata.QueryMetadataInterface, org.teiid.query.sql.symbol.GroupSymbol)
*/
protected String getPlan(QueryMetadataInterface metadata,
- GroupSymbol group) throws MetaMatrixComponentException,
+ GroupSymbol group) throws TeiidComponentException,
QueryMetadataException {
StoredProcedureInfo storedProcedureInfo = metadata.getStoredProcedureInfoForProcedure(group.getCanonicalName());
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/InsertResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/InsertResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.ArrayList;
import java.util.Collection;
@@ -32,32 +32,33 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.resolver.ProcedureContainerResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.VariableResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.resolver.ProcedureContainerResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.VariableResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This class knows how to expand and resolve INSERT commands.
*/
@@ -65,10 +66,10 @@
/**
* Resolve an INSERT. Need to resolve elements, constants, types, etc.
- * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+ * @see org.teiid.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord)
*/
public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
// Cast to known type
@@ -129,7 +130,7 @@
private void resolveVariables(TempMetadataAdapter metadata,
Insert insert,
- Set<GroupSymbol> groups) throws MetaMatrixComponentException,
+ Set<GroupSymbol> groups) throws TeiidComponentException,
QueryResolverException {
try {
resolveList(insert.getVariables(), metadata, null, groups);
@@ -139,7 +140,7 @@
}
private void resolveList(Collection elements, TempMetadataAdapter metadata,
- GroupContext externalGroups, Set<GroupSymbol> groups) throws MetaMatrixComponentException,
+ GroupContext externalGroups, Set<GroupSymbol> groups) throws TeiidComponentException,
QueryResolverException {
for (Iterator i = elements.iterator(); i.hasNext();) {
Expression expr = (Expression)i.next();
@@ -207,20 +208,20 @@
* @param metadata
* @param group
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
protected String getPlan(QueryMetadataInterface metadata,
- GroupSymbol group) throws MetaMatrixComponentException,
+ GroupSymbol group) throws TeiidComponentException,
QueryMetadataException {
return metadata.getInsertPlan(group.getMetadataID());
}
/**
- * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveGroup(com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.sql.lang.ProcedureContainer)
+ * @see org.teiid.query.resolver.ProcedureContainerResolver#resolveGroup(org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.sql.lang.ProcedureContainer)
*/
protected void resolveGroup(TempMetadataAdapter metadata,
- ProcedureContainer procCommand) throws MetaMatrixComponentException,
+ ProcedureContainer procCommand) throws TeiidComponentException,
QueryResolverException {
if (!procCommand.getGroup().isImplicitTempGroupSymbol() || metadata.getMetadataStore().getTempGroupID(procCommand.getGroup().getName()) != null) {
super.resolveGroup(metadata, procCommand);
@@ -228,13 +229,13 @@
}
/**
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryResolverException
* @throws QueryMetadataException
- * @see com.metamatrix.query.resolver.CommandResolver#getVariableValues(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.QueryMetadataInterface)
+ * @see org.teiid.query.resolver.CommandResolver#getVariableValues(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.QueryMetadataInterface)
*/
public Map getVariableValues(Command command,
- QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ QueryMetadataInterface metadata) throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Insert insert = (Insert) command;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/SetQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SetQueryResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/SetQueryResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,33 +28,34 @@
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class SetQueryResolver implements CommandResolver {
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
SetQuery setQuery = (SetQuery) command;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/SimpleQueryResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/SimpleQueryResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,60 +33,60 @@
import java.util.List;
import java.util.Set;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.UnresolvedSymbolDescription;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.navigator.PostOrderNavigator;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.navigator.PostOrderNavigator;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
public class SimpleQueryResolver implements CommandResolver {
private static final String ALL_IN_GROUP_SUFFIX = ".*"; //$NON-NLS-1$
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Query query = (Query) command;
@@ -95,15 +95,15 @@
qrv.visit(query);
ResolverVisitor visitor = (ResolverVisitor)qrv.getVisitor();
visitor.throwException(true);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getChild() instanceof QueryMetadataException) {
throw (QueryMetadataException)e.getChild();
}
if (e.getChild() instanceof QueryResolverException) {
throw (QueryResolverException)e.getChild();
}
- if (e.getChild() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getChild();
+ if (e.getChild() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getChild();
}
throw e;
}
@@ -126,7 +126,7 @@
}
}
- private static GroupSymbol resolveAllInGroup(AllInGroupSymbol allInGroupSymbol, Set<GroupSymbol> groups, QueryMetadataInterface metadata) throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+ private static GroupSymbol resolveAllInGroup(AllInGroupSymbol allInGroupSymbol, Set<GroupSymbol> groups, QueryMetadataInterface metadata) throws QueryResolverException, QueryMetadataException, TeiidComponentException {
String name = allInGroupSymbol.getName();
int index = name.lastIndexOf(ALL_IN_GROUP_SUFFIX);
String groupAlias = name.substring(0, index);
@@ -164,9 +164,9 @@
try {
visitor.throwException(false);
} catch (QueryResolverException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
}
@@ -186,9 +186,9 @@
try {
ResolverUtil.resolveGroup(obj, metadata);
} catch (QueryResolverException err) {
- throw new MetaMatrixRuntimeException(err);
- } catch (MetaMatrixComponentException err) {
- throw new MetaMatrixRuntimeException(err);
+ throw new TeiidRuntimeException(err);
+ } catch (TeiidComponentException err) {
+ throw new TeiidRuntimeException(err);
}
}
@@ -201,9 +201,9 @@
try {
QueryResolver.resolveCommand(command, Collections.EMPTY_MAP, metadata.getMetadata(), analysis, false);
} catch (QueryResolverException err) {
- throw new MetaMatrixRuntimeException(err);
- } catch (MetaMatrixComponentException err) {
- throw new MetaMatrixRuntimeException(err);
+ throw new TeiidRuntimeException(err);
+ } catch (TeiidComponentException err) {
+ throw new TeiidRuntimeException(err);
}
}
@@ -214,13 +214,13 @@
elementSymbols.addAll(resolveSelectableElements(group));
}
obj.setElementSymbols(elementSymbols);
- } catch (MetaMatrixComponentException err) {
- throw new MetaMatrixRuntimeException(err);
+ } catch (TeiidComponentException err) {
+ throw new TeiidRuntimeException(err);
}
}
private List<ElementSymbol> resolveSelectableElements(GroupSymbol group) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
List<ElementSymbol> elements = ResolverUtil.resolveElementsInGroup(group, metadata);
List<ElementSymbol> result = new ArrayList<ElementSymbol>(elements.size());
@@ -245,9 +245,9 @@
obj.setElementSymbols(elements);
} catch (QueryResolverException err) {
- throw new MetaMatrixRuntimeException(err);
- } catch (MetaMatrixComponentException err) {
- throw new MetaMatrixRuntimeException(err);
+ throw new TeiidRuntimeException(err);
+ } catch (TeiidComponentException err) {
+ throw new TeiidRuntimeException(err);
}
}
@@ -260,7 +260,7 @@
//in SELECT or stored procedure execution that returns a single value).
if(projSymbols.size() != 1) {
QueryResolverException qre = new QueryResolverException(QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0032, obj));
- throw new MetaMatrixRuntimeException(qre);
+ throw new TeiidRuntimeException(qre);
}
}
@@ -286,7 +286,7 @@
try {
ResolverUtil.addTempGroup(metadata, obj.getGroupSymbol(), obj.getCommand().getProjectedSymbols(), false);
} catch (QueryResolverException err) {
- throw new MetaMatrixRuntimeException(err);
+ throw new TeiidRuntimeException(err);
}
obj.getGroupSymbol().setMetadataID(metadata.getMetadataStore().getTempGroupID(obj.getGroupSymbol().getName()));
}
@@ -303,14 +303,14 @@
createProcRelational(obj);
}
} catch(QueryResolverException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch(MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
+ } catch(TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
}
private void createProcRelational(UnaryFromClause obj)
- throws MetaMatrixComponentException, QueryMetadataException,
+ throws TeiidComponentException, QueryMetadataException,
QueryResolverException {
GroupSymbol group = obj.getGroup();
String fullName = metadata.getFullName(group.getMetadataID());
@@ -396,7 +396,7 @@
}
/**
- * @see com.metamatrix.query.sql.navigator.PreOrPostOrderNavigator#visit(com.metamatrix.query.sql.lang.Into)
+ * @see org.teiid.query.sql.navigator.PreOrPostOrderNavigator#visit(org.teiid.query.sql.lang.Into)
*/
public void visit(Into obj) {
if (!obj.getGroup().isImplicitTempGroupSymbol()) {
@@ -421,7 +421,7 @@
String msg = QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0046, group.getName());
QueryResolverException qre = new QueryResolverException(ErrorMessageKeys.RESOLVER_0046, msg);
qre.addUnresolvedSymbol(new UnresolvedSymbolDescription(group.toString(), msg));
- throw new MetaMatrixRuntimeException(qre);
+ throw new TeiidRuntimeException(qre);
}
}
discoveredGroups.clear();
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/TempTableResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/TempTableResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/TempTableResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,39 +20,40 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Create;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* @since 5.5
*/
public class TempTableResolver implements CommandResolver {
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
if(command.getType() == Command.TYPE_CREATE) {
Create create = (Create)command;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateProcedureResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateProcedureResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.Arrays;
import java.util.Collections;
@@ -30,57 +30,57 @@
import java.util.List;
import java.util.Map;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.UnresolvedSymbolDescription;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
import org.teiid.logging.LogManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.mapping.relational.QueryNode;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.ProcedureContainerResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.proc.Statement;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.ProcedureContainerResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolveVirtualGroupCriteriaVisitor;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.proc.Statement;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
*/
public class UpdateProcedureResolver implements CommandResolver {
public void resolveVirtualGroupElements(CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
// virtual group on procedure
GroupSymbol virtualGroup = procCommand.getVirtualGroup();
@@ -122,7 +122,7 @@
* Get the command for the transformation query that defines this virtual group.
*/
private Command getQueryTransformCmd(GroupSymbol virtualGroup, QueryMetadataInterface metadata)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Command transformCmd = (Command)metadata.getFromMetadataCache(virtualGroup.getMetadataID(), "transformation/select"); //$NON-NLS-1$
if (transformCmd != null) {
return transformCmd;
@@ -141,10 +141,10 @@
}
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
CreateUpdateProcedureCommand procCommand = (CreateUpdateProcedureCommand) command;
@@ -170,7 +170,7 @@
private void resolveBlock(CreateUpdateProcedureCommand command, Block block, GroupContext externalGroups,
TempMetadataAdapter metadata, boolean isUpdateProcedure, AnalysisRecord analysis)
- throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryResolverException, QueryMetadataException, TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving block", block}); //$NON-NLS-1$
//create a new variable and metadata context for this block so that discovered metadata is not visible else where
@@ -188,7 +188,7 @@
}
private void resolveStatement(CreateUpdateProcedureCommand command, Statement statement, GroupContext externalGroups, GroupSymbol variables, TempMetadataAdapter metadata, boolean isUpdateProcedure, AnalysisRecord analysis)
- throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryResolverException, QueryMetadataException, TeiidComponentException {
LogManager.logTrace(org.teiid.logging.LogConstants.CTX_QUERY_RESOLVER, new Object[]{"Resolving statement", statement}); //$NON-NLS-1$
switch(statement.getType()) {
@@ -326,14 +326,14 @@
}
private TempMetadataStore resolveEmbeddedCommand(TempMetadataAdapter metadata, GroupContext groupContext,
- Command cmd, AnalysisRecord analysis) throws MetaMatrixComponentException,
+ Command cmd, AnalysisRecord analysis) throws TeiidComponentException,
QueryResolverException {
QueryResolver.setChildMetadata(cmd, metadata.getMetadataStore().getData(), groupContext);
return QueryResolver.resolveCommand(cmd, Collections.EMPTY_MAP, metadata.getMetadata(), analysis);
}
- private void collectDeclareVariable(DeclareStatement obj, GroupSymbol variables, TempMetadataAdapter metadata, GroupContext externalGroups) throws QueryResolverException, MetaMatrixComponentException {
+ private void collectDeclareVariable(DeclareStatement obj, GroupSymbol variables, TempMetadataAdapter metadata, GroupContext externalGroups) throws QueryResolverException, TeiidComponentException {
ElementSymbol variable = obj.getVariable();
String typeName = obj.getVariableType();
String varName = variable.getName();
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/UpdateResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/UpdateResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.Collection;
import java.util.HashMap;
@@ -32,34 +32,35 @@
import java.util.Set;
import java.util.Map.Entry;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.resolver.ProcedureContainerResolver;
-import com.metamatrix.query.resolver.VariableResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.resolver.ProcedureContainerResolver;
+import org.teiid.query.resolver.VariableResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* This class knows how to expand and resolve UDPATE commands.
*/
public class UpdateResolver extends ProcedureContainerResolver implements VariableResolver {
/**
- * @see com.metamatrix.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord)
+ * @see org.teiid.query.resolver.ProcedureContainerResolver#resolveProceduralCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord)
*/
public void resolveProceduralCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
//Cast to known type
Update update = (Update) command;
@@ -74,22 +75,22 @@
* @param metadata
* @param group
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
protected String getPlan(QueryMetadataInterface metadata,
- GroupSymbol group) throws MetaMatrixComponentException,
+ GroupSymbol group) throws TeiidComponentException,
QueryMetadataException {
return metadata.getUpdatePlan(group.getMetadataID());
}
/**
- * @see com.metamatrix.query.resolver.VariableResolver#getVariableValues(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.QueryMetadataInterface)
+ * @see org.teiid.query.resolver.VariableResolver#getVariableValues(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.QueryMetadataInterface)
*/
public Map getVariableValues(Command command,
QueryMetadataInterface metadata) throws QueryMetadataException,
QueryResolverException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Map result = new HashMap();
Update update = (Update) command;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XMLQueryResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/XMLQueryResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,45 +28,46 @@
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.StringUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.visitor.CommandCollectorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
*/
public class XMLQueryResolver implements CommandResolver {
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, TempMetadataAdapter, AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
Query query = (Query) command;
@@ -129,10 +130,10 @@
* @param metadata QueryMetadataInterface the metadata(for resolving criteria on temp groups)
* @throws QueryResolverException if resolving order by fails
* @throws QueryMetadataException if resolving fails
- * @throws MetaMatrixComponentException if resolving fails
+ * @throws TeiidComponentException if resolving fails
*/
void resolveXMLSelect(Query query, GroupSymbol group, List validElements, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException, QueryResolverException {
+ throws QueryMetadataException, TeiidComponentException, QueryResolverException {
GroupContext externalGroups = null;
@@ -215,11 +216,11 @@
* @param metadata Metadata interface
* @return Collection of ElementSymbol for each possible valid element
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryResolverException
*/
public static Collection collectValidCriteriaElements(GroupSymbol group, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException, QueryResolverException {
+ throws QueryMetadataException, TeiidComponentException, QueryResolverException {
// Get all groups and elements
List validElements = getElementsInDocument(group, metadata);
@@ -259,7 +260,7 @@
* @throws QueryResolverException if any of the above fail conditions are met
*/
public static void resolveXMLCriteria(Criteria criteria,GroupContext externalGroups, Collection validElements, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException, QueryResolverException {
+ throws QueryMetadataException, TeiidComponentException, QueryResolverException {
// Walk through each element in criteria and check against valid elements
Collection critElems = ElementCollectorVisitor.getElements(criteria, false);
@@ -281,10 +282,10 @@
* @param metadata QueryMetadataInterface the metadata(for resolving criteria on temp groups)
* @throws QueryResolverException if resolving order by fails
* @throws QueryMetadataException if resolving fails
- * @throws MetaMatrixComponentException if resolving fails
+ * @throws TeiidComponentException if resolving fails
*/
static void resolveXMLOrderBy(OrderBy orderBy, GroupContext externalGroups, Collection validElements, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException, QueryResolverException {
+ throws QueryMetadataException, TeiidComponentException, QueryResolverException {
// Walk through each element in OrderBy clause and check against valid elements
Collection orderElems = ElementCollectorVisitor.getElements(orderBy, false);
@@ -303,10 +304,10 @@
* @param metadata
* @throws QueryResolverException
* @throws QueryMetadataException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
*/
static void resolveElement(ElementSymbol elem, Collection validElements, GroupContext externalGroups, QueryMetadataInterface metadata)
- throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryResolverException, QueryMetadataException, TeiidComponentException {
// Get exact matching name
String critElemName = elem.getName();
@@ -396,12 +397,12 @@
}
static List getElementsInDocument(GroupSymbol group, QueryMetadataInterface metadata)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
return ResolverUtil.resolveElementsInGroup(group, metadata);
}
static List getElementsUnderNode(ElementSymbol node, List validElements, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
List elements = new ArrayList();
String nodeName = metadata.getFullName(node.getMetadataID());
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/command/XQueryResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/command/XQueryResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/command/XQueryResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.command;
+package org.teiid.query.resolver.command;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.resolver.CommandResolver;
-import com.metamatrix.query.sql.lang.Command;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.analysis.AnalysisRecord;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.resolver.CommandResolver;
+import org.teiid.query.sql.lang.Command;
+
/**
* Resolves XQueries, which in metamatrix currently involves
* taking the arguments to the doc() functions, adding them as
@@ -44,9 +45,9 @@
public class XQueryResolver implements CommandResolver {
/**
- * @see com.metamatrix.query.resolver.CommandResolver#resolveCommand(com.metamatrix.query.sql.lang.Command, com.metamatrix.query.metadata.TempMetadataAdapter, com.metamatrix.query.analysis.AnalysisRecord, boolean)
+ * @see org.teiid.query.resolver.CommandResolver#resolveCommand(org.teiid.query.sql.lang.Command, org.teiid.query.metadata.TempMetadataAdapter, org.teiid.query.analysis.AnalysisRecord, boolean)
*/
public void resolveCommand(Command command, TempMetadataAdapter metadata, AnalysisRecord analysis, boolean resolveNullLiterals)
- throws QueryMetadataException, QueryResolverException, MetaMatrixComponentException {
+ throws QueryMetadataException, QueryResolverException, TeiidComponentException {
}
}
Copied: trunk/engine/src/main/java/org/teiid/query/resolver/util (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/resolver/util)
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/AccessPattern.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/AccessPattern.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/AccessPattern.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.util;
+package org.teiid.query.resolver.util;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.Set;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
/**
* This class represents both virtual and physical access patterns.
*
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/BindVariableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/BindVariableVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/BindVariableVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,32 +20,32 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.util;
+package org.teiid.query.resolver.util;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.api.exception.query.QueryResolverException;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.parser.QueryParser;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* <p>Given a LanguageObject containing References and the List of String binding
@@ -65,7 +65,7 @@
private List bindings;
private QueryMetadataInterface metadata;
- private MetaMatrixComponentException componentException;
+ private TeiidComponentException componentException;
private QueryResolverException resolverException;
/**
@@ -81,7 +81,7 @@
this.metadata = metadata;
}
- public MetaMatrixComponentException getComponentException() {
+ public TeiidComponentException getComponentException() {
return this.componentException;
}
@@ -89,7 +89,7 @@
return this.resolverException;
}
- private void handleException(MetaMatrixComponentException e) {
+ private void handleException(TeiidComponentException e) {
this.componentException = e;
// Abort the validation process
@@ -105,7 +105,7 @@
/**
* Visit a Reference object and bind it based on the bindings
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(Reference)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(Reference)
*/
public void visit(Reference obj) {
bindReference(obj);
@@ -120,10 +120,10 @@
} catch(QueryParserException e) {
handleException(new QueryResolverException(QueryPlugin.Util.getString(ErrorMessageKeys.RESOLVER_0022), e.getMessage()));
} catch(QueryMetadataException e) {
- handleException(new MetaMatrixComponentException(e, e.getMessage()));
+ handleException(new TeiidComponentException(e, e.getMessage()));
} catch(QueryResolverException e) {
handleException(e);
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -143,7 +143,7 @@
private void bindReference(Reference reference, String binding)
throws QueryParserException, QueryResolverException,
- QueryMetadataException, MetaMatrixComponentException {
+ QueryMetadataException, TeiidComponentException {
// Parse and resolve ref
Expression expr = QueryParser.getQueryParser().parseExpression(binding);
@@ -171,7 +171,7 @@
* @param boundReferencesMap Map to be filled with String group name to List of References
*/
public static void bindReferences(LanguageObject obj, List bindings, QueryMetadataInterface metadata)
- throws QueryResolverException, MetaMatrixComponentException {
+ throws QueryResolverException, TeiidComponentException {
BindVariableVisitor visitor = new BindVariableVisitor(bindings, metadata);
DeepPreOrderNavigator.doVisit(obj, visitor);
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolveVirtualGroupCriteriaVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.util;
+package org.teiid.query.resolver.util;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
*/
public class ResolveVirtualGroupCriteriaVisitor extends LanguageVisitor {
@@ -66,9 +67,9 @@
try {
ResolverVisitor.resolveLanguageObject(element, virtualGroup, metadata);
} catch(QueryResolverException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch(MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
+ } catch(TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
}
}
@@ -82,16 +83,16 @@
try {
ResolverVisitor.resolveLanguageObject(virtualElement, virtualGroup, metadata);
} catch(QueryResolverException e) {
- throw new MetaMatrixRuntimeException(e);
- } catch(MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
+ } catch(TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
}
}
}
public static void resolveCriteria(LanguageObject obj, GroupSymbol virtualGroup, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
if(obj == null) {
return;
}
@@ -101,12 +102,12 @@
try {
PreOrderNavigator.doVisit(obj, resolveVisitor);
- } catch (MetaMatrixRuntimeException e) {
+ } catch (TeiidRuntimeException e) {
if (e.getChild() instanceof QueryResolverException) {
throw (QueryResolverException)e.getChild();
}
- if (e.getChild() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)e.getChild();
+ if (e.getChild() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)e.getChild();
}
throw e;
}
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverUtil.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverUtil.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.util;
+package org.teiid.query.resolver.util;
import java.util.ArrayList;
import java.util.Arrays;
@@ -33,47 +33,48 @@
import java.util.LinkedList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.TransformationException;
-import com.metamatrix.common.types.DataTypeManager.DefaultDataTypes;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.GroupInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.StoredProcedureInfo;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.AbstractCaseExpression;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.UnresolvedSymbolDescription;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.TransformationException;
+import org.teiid.core.types.DataTypeManager.DefaultDataTypes;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.metadata.GroupInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.StoredProcedureInfo;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.AbstractCaseExpression;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* Utilities used during resolution
*/
@@ -312,7 +313,7 @@
* @param isSimpleQuery
*/
public static void resolveOrderBy(OrderBy orderBy, QueryCommand command, QueryMetadataInterface metadata)
- throws QueryResolverException, QueryMetadataException, MetaMatrixComponentException {
+ throws QueryResolverException, QueryMetadataException, TeiidComponentException {
List<SingleElementSymbol> knownElements = command.getProjectedQuery().getSelect().getProjectedSymbols();
@@ -383,7 +384,7 @@
private static int resolveSortKey(List fromClauseGroups, List knownElements,
QueryMetadataInterface metadata, boolean isSimpleQuery,
- String[] knownShortNames, ElementSymbol symbol) throws MetaMatrixComponentException,
+ String[] knownShortNames, ElementSymbol symbol) throws TeiidComponentException,
QueryMetadataException, QueryResolverException {
SingleElementSymbol matchedSymbol = null;
String symbolName = symbol.getName();
@@ -454,10 +455,10 @@
* @throws QueryResolverException if expr is null, parameter is required and no
* default value is defined
* @throws QueryMetadataException for error retrieving metadata
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.3
*/
- public static Expression getDefault(ElementSymbol symbol, QueryMetadataInterface metadata) throws MetaMatrixComponentException, QueryMetadataException, QueryResolverException {
+ public static Expression getDefault(ElementSymbol symbol, QueryMetadataInterface metadata) throws TeiidComponentException, QueryMetadataException, QueryResolverException {
//Check if there is a default value, if so use it
Object mid = symbol.getMetadataID();
Class type = symbol.getType();
@@ -500,13 +501,13 @@
*
*/
public static List<ElementSymbol> resolveElementsInGroup(GroupSymbol group, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
return new ArrayList<ElementSymbol>(getGroupInfo(group, metadata).getSymbolList());
}
static GroupInfo getGroupInfo(GroupSymbol group,
QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
String key = GroupInfo.CACHE_PREFIX + group.getCanonicalName();
GroupInfo groupInfo = (GroupInfo)metadata.getFromMetadataCache(group.getMetadataID(), key);
@@ -551,10 +552,10 @@
* @param groups
* @param flatten
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
- public static List getAccessPatternElementsInGroups(final QueryMetadataInterface metadata, Collection groups, boolean flatten) throws MetaMatrixComponentException, QueryMetadataException {
+ public static List getAccessPatternElementsInGroups(final QueryMetadataInterface metadata, Collection groups, boolean flatten) throws TeiidComponentException, QueryMetadataException {
List accessPatterns = null;
Iterator i = groups.iterator();
while (i.hasNext()){
@@ -598,7 +599,7 @@
}
public static void resolveImplicitTempGroup(TempMetadataAdapter metadata, GroupSymbol symbol, List symbols)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
if (symbol.isImplicitTempGroupSymbol()) {
if (metadata.getMetadataStore().getTempElementElementIDs(symbol.getCanonicalName())==null) {
@@ -692,12 +693,12 @@
* @param groups
* @param metadata
* @return the List of groups that match the given groupContext out of the supplied collection
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @throws QueryMetadataException
*/
public static List<GroupSymbol> findMatchingGroups(String groupContext,
Collection<GroupSymbol> groups,
- QueryMetadataInterface metadata) throws MetaMatrixComponentException,
+ QueryMetadataInterface metadata) throws TeiidComponentException,
QueryMetadataException {
if (groups == null) {
@@ -801,7 +802,7 @@
return result;
}
- public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, MetaMatrixComponentException {
+ public static ResolvedLookup resolveLookup(Function lookup, QueryMetadataInterface metadata) throws QueryResolverException, TeiidComponentException {
Expression[] args = lookup.getArgs();
ResolvedLookup result = new ResolvedLookup();
// Special code to handle setting return type of the lookup function to match the type of the return element
@@ -851,7 +852,7 @@
}
public static void resolveGroup(GroupSymbol symbol, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
if (symbol.getMetadataID() != null){
return;
Modified: trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/resolver/util/ResolverVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/resolver/util/ResolverVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.resolver.util;
+package org.teiid.query.resolver.util;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,42 +31,43 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.UnresolvedSymbolDescription;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.DataTypeManager.DefaultDataClasses;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionForm;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.metadata.GroupInfo;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.GroupContext;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.PostOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.UnresolvedSymbolDescription;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionForm;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.metadata.GroupInfo;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.GroupContext;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.SetClause;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.navigator.PostOrderNavigator;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class ResolverVisitor extends LanguageVisitor {
private static class ElementMatch {
@@ -82,7 +83,7 @@
private Collection<GroupSymbol> groups;
private GroupContext externalContext;
protected QueryMetadataInterface metadata;
- private MetaMatrixComponentException componentException;
+ private TeiidComponentException componentException;
private QueryResolverException resolverException;
private Map<Function, QueryResolverException> unresolvedFunctions;
@@ -106,7 +107,7 @@
resolveElementSymbol(obj);
} catch(QueryMetadataException e) {
handleUnresolvedElement(obj, e.getMessage());
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -119,7 +120,7 @@
}
private void resolveElementSymbol(ElementSymbol elementSymbol)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
// already resolved
if(elementSymbol.getMetadataID() != null) {
@@ -221,7 +222,7 @@
private void resolveAgainstGroups(String elementShortName,
Collection<GroupSymbol> matchedGroups, LinkedList<ElementMatch> matches) throws QueryMetadataException,
- MetaMatrixComponentException {
+ TeiidComponentException {
for (GroupSymbol group : matchedGroups) {
GroupInfo groupInfo = ResolverUtil.getGroupInfo(group, metadata);
@@ -237,7 +238,7 @@
resolveBetweenCriteria(obj);
} catch(QueryResolverException e) {
handleException(e);
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -299,7 +300,7 @@
unresolvedFunctions = new LinkedHashMap<Function, QueryResolverException>();
}
unresolvedFunctions.put(obj, e);
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e);
}
}
@@ -330,7 +331,7 @@
}
}
- public MetaMatrixComponentException getComponentException() {
+ public TeiidComponentException getComponentException() {
return this.componentException;
}
@@ -338,7 +339,7 @@
return this.resolverException;
}
- void handleException(MetaMatrixComponentException e) {
+ void handleException(TeiidComponentException e) {
this.componentException = e;
// Abort the validation process
@@ -353,7 +354,7 @@
}
public void throwException(boolean includeUnresolvedFunctions)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
if(getComponentException() != null) {
throw getComponentException();
}
@@ -372,7 +373,7 @@
* Resolve function such that all functions are resolved and type-safe.
*/
void resolveFunction(Function function, FunctionLibrary library)
- throws QueryResolverException, MetaMatrixComponentException {
+ throws QueryResolverException, TeiidComponentException {
// Check whether this function is already resolved
if(function.getFunctionDescriptor() != null) {
@@ -452,10 +453,10 @@
* @param function
* @param types
* @return
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 4.3
*/
- private FunctionDescriptor findWithImplicitConversions(FunctionLibrary library, Function function, Expression[] args, Class<?>[] types, boolean hasArgWithoutType) throws QueryResolverException, MetaMatrixComponentException {
+ private FunctionDescriptor findWithImplicitConversions(FunctionLibrary library, Function function, Expression[] args, Class<?>[] types, boolean hasArgWithoutType) throws QueryResolverException, TeiidComponentException {
// Try to find implicit conversion path to still perform this function
FunctionDescriptor[] conversions = library.determineNecessaryConversions(function.getName(), function.getType(), types, hasArgWithoutType);
@@ -499,11 +500,11 @@
* </ol>
* @param criteria
* @throws QueryResolverException
- * @throws MetaMatrixComponentException
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
+ * @throws TeiidComponentException
*/
void resolveBetweenCriteria(BetweenCriteria criteria)
- throws QueryResolverException, MetaMatrixComponentException {
+ throws QueryResolverException, TeiidComponentException {
Expression exp = criteria.getExpression();
Expression lower = criteria.getLowerExpression();
@@ -883,17 +884,17 @@
}
public static void resolveLanguageObject(LanguageObject obj, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
ResolverVisitor.resolveLanguageObject(obj, null, metadata);
}
public static void resolveLanguageObject(LanguageObject obj, Collection<GroupSymbol> groups, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
ResolverVisitor.resolveLanguageObject(obj, groups, null, metadata);
}
public static void resolveLanguageObject(LanguageObject obj, Collection<GroupSymbol> groups, GroupContext externalContext, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryResolverException {
+ throws TeiidComponentException, QueryResolverException {
if(obj == null) {
return;
Copied: trunk/engine/src/main/java/org/teiid/query/rewriter (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/rewriter)
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/rewriter/QueryRewriter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.rewriter;
+package org.teiid.query.rewriter;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -41,114 +41,114 @@
import java.util.Set;
import java.util.StringTokenizer;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.api.exception.query.QueryValidatorException;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.Assertion;
+import org.teiid.core.util.TimestampWithTimezone;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.FunctionMethods;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.processor.ProcessorDataManager;
+import org.teiid.query.processor.relational.DependentValueSource;
+import org.teiid.query.resolver.QueryResolver;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.resolver.util.ResolverVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.LanguageObject.Util;
+import org.teiid.query.sql.lang.AbstractSetCriteria;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetClause;
+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.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.TranslatableProcedureContainer;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.PredicateCriteria.Negatable;
+import org.teiid.query.sql.navigator.PostOrderNavigator;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.proc.Statement;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.CriteriaTranslatorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.sql.visitor.ExpressionMappingVisitor;
+import org.teiid.query.sql.visitor.PredicateCollectorVisitor;
+import org.teiid.query.sql.visitor.EvaluatableVisitor.EvaluationLevel;
+import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ErrorMessageKeys;
import org.teiid.resource.cci.SourceSystemFunctions;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.util.TimestampWithTimezone;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionMethods;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.processor.ProcessorDataManager;
-import com.metamatrix.query.processor.relational.DependentValueSource;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.LanguageObject.Util;
-import com.metamatrix.query.sql.lang.AbstractSetCriteria;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.TranslatableProcedureContainer;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.PredicateCriteria.Negatable;
-import com.metamatrix.query.sql.navigator.PostOrderNavigator;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.proc.Statement;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.util.ValueIterator;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.CriteriaTranslatorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.sql.visitor.ExpressionMappingVisitor;
-import com.metamatrix.query.sql.visitor.PredicateCollectorVisitor;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor.EvaluationLevel;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* Rewrites commands and command fragments to a form that is better for planning and execution. There is a current limitation that
@@ -187,14 +187,14 @@
this.procCommand = procCommand;
}
- public static Command evaluateAndRewrite(Command command, ProcessorDataManager dataMgr, CommandContext context, QueryMetadataInterface metadata) throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ public static Command evaluateAndRewrite(Command command, ProcessorDataManager dataMgr, CommandContext context, QueryMetadataInterface metadata) throws TeiidProcessingException, TeiidComponentException {
QueryRewriter queryRewriter = new QueryRewriter(metadata, context, null);
queryRewriter.dataMgr = dataMgr;
queryRewriter.rewriteSubcommands = true;
return queryRewriter.rewriteCommand(command, false);
}
- public static Command rewrite(Command command, CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata, CommandContext context, Map variableValues, int commandType) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ public static Command rewrite(Command command, CreateUpdateProcedureCommand procCommand, QueryMetadataInterface metadata, CommandContext context, Map variableValues, int commandType) throws TeiidComponentException, TeiidProcessingException{
QueryRewriter rewriter = new QueryRewriter(metadata, context, procCommand);
rewriter.rewriteSubcommands = true;
rewriter.variables = variableValues;
@@ -202,7 +202,7 @@
return rewriter.rewriteCommand(command, false);
}
- public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ public static Command rewrite(Command command, QueryMetadataInterface metadata, CommandContext context) throws TeiidComponentException, TeiidProcessingException{
return rewrite(command, null, metadata, context, null, Command.TYPE_UNKNOWN);
}
@@ -214,7 +214,7 @@
* @return
* @throws QueryValidatorException
*/
- private Command rewriteCommand(Command command, boolean removeOrderBy) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Command rewriteCommand(Command command, boolean removeOrderBy) throws TeiidComponentException, TeiidProcessingException{
QueryMetadataInterface oldMetadata = metadata;
CreateUpdateProcedureCommand oldProcCommand = procCommand;
@@ -270,7 +270,7 @@
}
private Command rewriteUpdateProcedure(CreateUpdateProcedureCommand command)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
Map oldVariables = variables;
if (command.getUserCommand() != null) {
variables = QueryResolver.getVariableValues(command.getUserCommand(), metadata);
@@ -286,7 +286,7 @@
}
private Block rewriteBlock(Block block)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
List statements = block.getStatements();
Iterator stmtIter = statements.iterator();
@@ -308,7 +308,7 @@
}
private Object rewriteStatement(Statement statement)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
// evaluate the HAS Criteria on the procedure and rewrite
int stmtType = statement.getType();
@@ -409,7 +409,7 @@
* @param assStmt
* @throws QueryValidatorException
*/
- private void rewriteSubqueryContainer(SubqueryContainer container, boolean removeOrderBy) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private void rewriteSubqueryContainer(SubqueryContainer container, boolean removeOrderBy) throws TeiidComponentException, TeiidProcessingException{
if (rewriteSubcommands && container.getCommand() != null && container.getCommand().getProcessorPlan() == null) {
container.setCommand(rewriteCommand(container.getCommand(), removeOrderBy));
}
@@ -527,7 +527,7 @@
* virtual group.</p>
*/
private Criteria rewriteCriteria(TranslateCriteria transCrit)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
// criteria translated
Criteria translatedCriteria = null;
@@ -582,7 +582,7 @@
// apply any implicit conversions
try {
ResolverVisitor.resolveLanguageObject(translatedCriteria, metadata);
- } catch(MetaMatrixException ex) {
+ } catch(TeiidException ex) {
throw new QueryValidatorException(ex, ErrorMessageKeys.REWRITER_0002, QueryExecPlugin.Util.getString(ErrorMessageKeys.REWRITER_0002, translatedCriteria));
}
@@ -590,7 +590,7 @@
}
private Command rewriteQuery(Query query)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
// Rewrite from clause
From from = query.getFrom();
@@ -647,7 +647,7 @@
* @return
* @throws QueryValidatorException
*/
- private Query rewriteGroupBy(Query query) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Query rewriteGroupBy(Query query) throws TeiidComponentException, TeiidProcessingException{
if (query.getGroupBy() == null) {
return query;
}
@@ -698,8 +698,8 @@
Query outerQuery = null;
try {
outerQuery = QueryRewriter.createInlineViewQuery(new GroupSymbol("X"), query, metadata, query.getSelect().getProjectedSymbols()); //$NON-NLS-1$
- } catch (MetaMatrixException err) {
- throw new MetaMatrixRuntimeException(err);
+ } catch (TeiidException err) {
+ throw new TeiidRuntimeException(err);
}
Iterator iter = outerQuery.getSelect().getProjectedSymbols().iterator();
HashMap<Expression, SingleElementSymbol> expressionMap = new HashMap<Expression, SingleElementSymbol>();
@@ -722,31 +722,31 @@
return query;
}
- private void rewriteExpressions(LanguageObject obj) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private void rewriteExpressions(LanguageObject obj) throws TeiidComponentException, TeiidProcessingException{
if (obj == null) {
return;
}
ExpressionMappingVisitor visitor = new ExpressionMappingVisitor(null) {
/**
- * @see com.metamatrix.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(com.metamatrix.query.sql.symbol.Expression)
+ * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression)
*/
@Override
public Expression replaceExpression(Expression element) {
try {
return rewriteExpressionDirect(element);
- } catch (MetaMatrixException err) {
- throw new MetaMatrixRuntimeException(err);
+ } catch (TeiidException err) {
+ throw new TeiidRuntimeException(err);
}
}
};
try {
PostOrderNavigator.doVisit(obj, visitor);
- } catch (MetaMatrixRuntimeException err) {
- if (err.getChild() instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException)err.getChild();
+ } catch (TeiidRuntimeException err) {
+ if (err.getChild() instanceof TeiidComponentException) {
+ throw (TeiidComponentException)err.getChild();
}
- if (err.getChild() instanceof MetaMatrixProcessingException) {
- throw (MetaMatrixProcessingException)err.getChild();
+ if (err.getChild() instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException)err.getChild();
}
throw err;
}
@@ -757,9 +757,9 @@
* Unrelated order by expressions will cause the creation of nested inline views.
*
* @param query
- * @throws MetaMatrixComponentException, MetaMatrixProcessingException
+ * @throws TeiidComponentException, MetaMatrixProcessingException
*/
- public QueryCommand rewriteOrderBy(QueryCommand queryCommand) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ public QueryCommand rewriteOrderBy(QueryCommand queryCommand) throws TeiidComponentException, TeiidProcessingException{
final OrderBy orderBy = queryCommand.getOrderBy();
if (orderBy == null) {
return queryCommand;
@@ -826,8 +826,8 @@
}
ExpressionMappingVisitor.mapExpressions(orderBy, expressionMap);
//now the order by should only contain element symbols
- } catch (MetaMatrixException err) {
- throw new MetaMatrixRuntimeException(err);
+ } catch (TeiidException err) {
+ throw new TeiidRuntimeException(err);
}
List symbols = top.getSelect().getSymbols();
top.getSelect().setSymbols(symbols.subList(0, originalSymbolCount));
@@ -844,7 +844,7 @@
* @param query
* @throws QueryValidatorException
*/
- private Insert rewriteSelectInto(Query query) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Insert rewriteSelectInto(Query query) throws TeiidComponentException, TeiidProcessingException{
Into into = query.getInto();
try {
List<ElementSymbol> allIntoElements = Util.deepClone(ResolverUtil.resolveElementsInGroup(into.getGroup(), metadata), ElementSymbol.class);
@@ -854,12 +854,12 @@
return correctDatatypes(insert);
} catch (QueryMetadataException err) {
throw new QueryValidatorException(err, err.getMessage());
- } catch (MetaMatrixComponentException err) {
+ } catch (TeiidComponentException err) {
throw new QueryValidatorException(err, err.getMessage());
}
}
- private Insert correctDatatypes(Insert insert) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Insert correctDatatypes(Insert insert) throws TeiidComponentException, TeiidProcessingException{
boolean needsView = false;
for (int i = 0; !needsView && i < insert.getVariables().size(); i++) {
SingleElementSymbol ses = (SingleElementSymbol)insert.getVariables().get(i);
@@ -870,8 +870,8 @@
if (needsView) {
try {
insert.setQueryExpression(createInlineViewQuery(insert.getGroup(), insert.getQueryExpression(), metadata, insert.getVariables()));
- } catch (MetaMatrixException err) {
- throw new MetaMatrixRuntimeException(err);
+ } catch (TeiidException err) {
+ throw new TeiidRuntimeException(err);
}
}
return insert;
@@ -887,7 +887,7 @@
}
private SetQuery rewriteSetQuery(SetQuery setQuery)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
if (setQuery.getProjectedTypes() != null) {
for (QueryCommand command : setQuery.getQueryCommands()) {
@@ -912,7 +912,7 @@
}
private FromClause rewriteFromClause(Query parent, FromClause clause)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
if(clause instanceof JoinPredicate) {
return rewriteJoinPredicate(parent, (JoinPredicate) clause);
} else if (clause instanceof SubqueryFromClause) {
@@ -922,7 +922,7 @@
}
private JoinPredicate rewriteJoinPredicate(Query parent, JoinPredicate predicate)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
List joinCrits = predicate.getJoinCriteria();
if(joinCrits != null && joinCrits.size() > 0) {
//rewrite join crits by rewriting a compound criteria
@@ -961,7 +961,7 @@
* in the procedural language.
* @return The re-written criteria
*/
- public static Criteria rewriteCriteria(Criteria criteria, CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface metadata) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ public static Criteria rewriteCriteria(Criteria criteria, CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException{
return new QueryRewriter(metadata, context, procCommand).rewriteCriteria(criteria);
}
@@ -972,7 +972,7 @@
* in the procedural language.
* @return The re-written criteria
*/
- private Criteria rewriteCriteria(Criteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(Criteria criteria) throws TeiidComponentException, TeiidProcessingException{
if(criteria instanceof CompoundCriteria) {
return rewriteCriteria((CompoundCriteria)criteria, true);
} else if(criteria instanceof NotCriteria) {
@@ -1009,7 +1009,7 @@
}
private Criteria rewriteDependentSetCriteria(DependentSetCriteria dsc)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
if (dataMgr == null) {
return rewriteCriteria(dsc);
}
@@ -1022,8 +1022,8 @@
while (iter.hasNext()) {
values.add(iter.next());
}
- } catch (MetaMatrixComponentException e) {
- throw new MetaMatrixRuntimeException(e);
+ } catch (TeiidComponentException e) {
+ throw new TeiidRuntimeException(e);
}
List<Constant> constants = new ArrayList<Constant>(values.size());
for (Object value : values) {
@@ -1042,7 +1042,7 @@
public static Criteria optimizeCriteria(CompoundCriteria criteria, QueryMetadataInterface metadata) {
try {
return new QueryRewriter(metadata, null, null).rewriteCriteria(criteria, false);
- } catch (MetaMatrixException err) {
+ } catch (TeiidException err) {
//shouldn't happen
return criteria;
}
@@ -1051,7 +1051,7 @@
/** May be simplified if this is an AND and a sub criteria is always
* false or if this is an OR and a sub criteria is always true
*/
- private Criteria rewriteCriteria(CompoundCriteria criteria, boolean rewrite) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(CompoundCriteria criteria, boolean rewrite) throws TeiidComponentException, TeiidProcessingException{
List<Criteria> crits = criteria.getCriteria();
int operator = criteria.getOperator();
@@ -1107,7 +1107,7 @@
}
}
- private Criteria evaluateCriteria(Criteria crit) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria evaluateCriteria(Criteria crit) throws TeiidComponentException, TeiidProcessingException{
if(EvaluatableVisitor.isFullyEvaluatable(crit, true)) {
try {
Boolean eval = new Evaluator(Collections.emptyMap(), this.dataMgr, context).evaluateTVL(crit, Collections.emptyList());
@@ -1130,7 +1130,7 @@
return crit;
}
- private Criteria rewriteCriteria(NotCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(NotCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
Criteria innerCrit = criteria.getCriteria();
if (innerCrit instanceof CompoundCriteria) {
//reduce to only negation of predicates, so that the null/unknown handling criteria is applied appropriately
@@ -1161,7 +1161,7 @@
* @return
* @throws QueryValidatorException
*/
- private Criteria rewriteCriteria(BetweenCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(BetweenCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
CompareCriteria lowerCriteria = new CompareCriteria(criteria.getExpression(),
criteria.isNegated() ? CompareCriteria.LT: CompareCriteria.GE,
criteria.getLowerExpression());
@@ -1175,7 +1175,7 @@
return rewriteCriteria(newCriteria);
}
- private Criteria rewriteCriteria(CompareCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(CompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
Expression rightExpr = rewriteExpressionDirect(criteria.getRightExpression());
criteria.setLeftExpression(leftExpr);
@@ -1228,7 +1228,7 @@
* The thing of primary importance here is that the use of the 'ANY' predicate
* quantifier is replaced with the canonical and equivalent 'SOME'
*/
- private Criteria rewriteCriteria(SubqueryCompareCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(SubqueryCompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
Expression leftExpr = rewriteExpressionDirect(criteria.getLeftExpression());
@@ -1247,7 +1247,7 @@
return criteria;
}
- private Criteria simplifyWithInverse(CompareCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria simplifyWithInverse(CompareCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
Expression leftExpr = criteria.getLeftExpression();
Function leftFunction = (Function) leftExpr;
@@ -1288,7 +1288,7 @@
* @return CompareCriteria
*/
private CompareCriteria simplifyMathematicalCriteria(CompareCriteria criteria)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
Expression leftExpr = criteria.getLeftExpression();
Expression rightExpr = criteria.getRightExpression();
@@ -1421,7 +1421,7 @@
* @throws QueryValidatorException
* @since 4.2
*/
- private Criteria simplifyConvertFunction(CompareCriteria crit) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria simplifyConvertFunction(CompareCriteria crit) throws TeiidComponentException, TeiidProcessingException{
Function leftFunction = (Function) crit.getLeftExpression();
Expression leftExpr = leftFunction.getArgs()[0];
@@ -1480,7 +1480,7 @@
* @throws QueryValidatorException
* @since 4.2
*/
- private Criteria simplifyConvertFunction(SetCriteria crit) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria simplifyConvertFunction(SetCriteria crit) throws TeiidComponentException, TeiidProcessingException{
Function leftFunction = (Function) crit.getExpression();
Expression leftExpr = leftFunction.getArgs()[0];
String leftExprTypeName = DataTypeManager.getDataTypeName(leftExpr.getType());
@@ -1531,7 +1531,7 @@
return rewriteCriteria(crit);
}
- private Criteria simplifyParseFormatFunction(CompareCriteria crit) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria simplifyParseFormatFunction(CompareCriteria crit) throws TeiidComponentException, TeiidProcessingException{
//TODO: this can be relaxed for order preserving operations
if(!(crit.getOperator() == CompareCriteria.EQ || crit.getOperator() == CompareCriteria.NE)) {
return crit;
@@ -1729,7 +1729,7 @@
}
}
- private Criteria rewriteCriteria(MatchCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(MatchCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
criteria.setLeftExpression( rewriteExpressionDirect(criteria.getLeftExpression()));
criteria.setRightExpression( rewriteExpressionDirect(criteria.getRightExpression()));
@@ -1781,7 +1781,7 @@
return FALSE_CRITERIA;
}
- private Criteria rewriteCriteria(AbstractSetCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(AbstractSetCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
criteria.setExpression(rewriteExpressionDirect(criteria.getExpression()));
if (isNull(criteria.getExpression())) {
@@ -1791,7 +1791,7 @@
return criteria;
}
- private Criteria rewriteCriteria(SetCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(SetCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
criteria.setExpression(rewriteExpressionDirect(criteria.getExpression()));
if (isNull(criteria.getExpression())) {
@@ -1830,16 +1830,16 @@
return criteria;
}
- private Criteria rewriteCriteria(IsNullCriteria criteria) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Criteria rewriteCriteria(IsNullCriteria criteria) throws TeiidComponentException, TeiidProcessingException{
criteria.setExpression(rewriteExpressionDirect(criteria.getExpression()));
return criteria;
}
- public static Expression rewriteExpression(Expression expression, CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface metadata) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ public static Expression rewriteExpression(Expression expression, CreateUpdateProcedureCommand procCommand, CommandContext context, QueryMetadataInterface metadata) throws TeiidComponentException, TeiidProcessingException{
return new QueryRewriter(metadata, context, procCommand).rewriteExpressionDirect(expression);
}
- private Expression rewriteExpressionDirect(Expression expression) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Expression rewriteExpressionDirect(Expression expression) throws TeiidComponentException, TeiidProcessingException{
if (expression instanceof Constant) {
return expression;
}
@@ -1917,7 +1917,7 @@
.convertExpression(expression.getExpression(),DataTypeManager.getDataTypeName(expression.getType()), metadata));
} catch (QueryResolverException e) {
//should not happen, so throw as a runtime
- throw new MetaMatrixRuntimeException(e);
+ throw new TeiidRuntimeException(e);
}
}
return expression;
@@ -1938,7 +1938,7 @@
FUNCTION_MAP.put(FunctionLibrary.FORMATTIME.toLowerCase(), 9);
}
- private Expression rewriteFunction(Function function) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Expression rewriteFunction(Function function) throws TeiidComponentException, TeiidProcessingException{
//rewrite alias functions
String functionLowerName = function.getName().toLowerCase();
String actualName =ALIASED_FUNCTIONS.get(functionLowerName);
@@ -2177,7 +2177,7 @@
}
private Expression rewriteCaseExpression(CaseExpression expr)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
List<CompareCriteria> whens = new ArrayList<CompareCriteria>(expr.getWhenCount());
for (Expression expression: (List<Expression>)expr.getWhen()) {
whens.add(new CompareCriteria((Expression)expr.getExpression().clone(), CompareCriteria.EQ, expression));
@@ -2189,7 +2189,7 @@
}
private Expression rewriteCaseExpression(SearchedCaseExpression expr)
- throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ throws TeiidComponentException, TeiidProcessingException{
int whenCount = expr.getWhenCount();
ArrayList<Criteria> whens = new ArrayList<Criteria>(whenCount);
ArrayList<Expression> thens = new ArrayList<Expression>(whenCount);
@@ -2251,7 +2251,7 @@
return expr;
}
- private Command rewriteExec(StoredProcedure storedProcedure) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Command rewriteExec(StoredProcedure storedProcedure) throws TeiidComponentException, TeiidProcessingException{
//After this method, no longer need to display named parameters
storedProcedure.setDisplayNamedParameters(false);
@@ -2262,7 +2262,7 @@
return storedProcedure;
}
- private Insert rewriteInsert(Insert insert) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Insert rewriteInsert(Insert insert) throws TeiidComponentException, TeiidProcessingException{
if ( insert.getQueryExpression() != null ) {
insert.setQueryExpression((QueryCommand)rewriteCommand(insert.getQueryExpression(), true));
@@ -2286,7 +2286,7 @@
QueryMetadataInterface metadata,
List<SingleElementSymbol> actualSymbols) throws QueryMetadataException,
QueryResolverException,
- MetaMatrixComponentException {
+ TeiidComponentException {
Query query = new Query();
Select select = new Select();
query.setSelect(select);
@@ -2373,7 +2373,7 @@
}
}
- private Update rewriteUpdate(Update update) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Update rewriteUpdate(Update update) throws TeiidComponentException, TeiidProcessingException{
if (commandType == Command.TYPE_UPDATE && variables != null) {
SetClauseList newChangeList = new SetClauseList();
for (SetClause entry : update.getChangeList().getClauses()) {
@@ -2405,9 +2405,9 @@
* none of them are changing, then this method returns a false, if all of them
* are changing this returns a true, if some are changing and some are not, then
* that is an invalid case and the method adds to the list of invalid variables.
- * @throws MetaMatrixComponentException, MetaMatrixProcessingException
+ * @throws TeiidComponentException, MetaMatrixProcessingException
*/
- private boolean checkInputVariables(Expression expr) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private boolean checkInputVariables(Expression expr) throws TeiidComponentException, TeiidProcessingException{
Boolean result = null;
for (ElementSymbol var : ElementCollectorVisitor.getElements(expr, false)) {
String grpName = var.getGroupSymbol().getName();
@@ -2432,7 +2432,7 @@
return true;
}
- private Delete rewriteDelete(Delete delete) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Delete rewriteDelete(Delete delete) throws TeiidComponentException, TeiidProcessingException{
// Rewrite criteria
Criteria crit = delete.getCriteria();
if(crit != null) {
@@ -2442,7 +2442,7 @@
return delete;
}
- private Limit rewriteLimitClause(Limit limit) throws MetaMatrixComponentException, MetaMatrixProcessingException{
+ private Limit rewriteLimitClause(Limit limit) throws TeiidComponentException, TeiidProcessingException{
if (limit.getOffset() != null) {
limit.setOffset(rewriteExpressionDirect(limit.getOffset()));
}
Copied: trunk/engine/src/main/java/org/teiid/query/sql/LanguageObject.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageObject.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/LanguageObject.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/LanguageObject.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This is the primary interface for all language objects. It extends a few
+ * key interfaces and adds some additional methods to allow the {@link LanguageVisitor}
+ * to work.
+ */
+public interface LanguageObject extends Serializable, Cloneable {
+
+ /**
+ * Method for accepting a visitor. It is the responsibility of the
+ * language object to call back on the visitor.
+ * @param visitor Visitor being used
+ */
+ void acceptVisitor(LanguageVisitor visitor);
+
+ /**
+ * Implement clone to make objects cloneable.
+ * @return Deep clone of this object
+ */
+ Object clone();
+
+ public static class Util {
+
+ public static <S extends LanguageObject, T extends S> ArrayList<S> deepClone(List<T> collection, Class<S> type) {
+ ArrayList<S> result = new ArrayList<S>(collection.size());
+ for (LanguageObject obj : collection) {
+ result.add(type.cast(obj.clone()));
+ }
+ return result;
+ }
+
+ }
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/LanguageVisitor.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/LanguageVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,133 @@
+/*
+ * 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;
+
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.proc.*;
+import org.teiid.query.sql.symbol.*;
+
+/**
+ * <p>The LanguageVisitor can be used to visit a LanguageObject as if it were a tree
+ * and perform some action on some or all of the language objects that are visited.
+ * The LanguageVisitor is extended to create a concrete visitor and some or all of
+ * the public visit methods should be overridden to provide the visitor functionality.
+ * These public visit methods SHOULD NOT be called directly.</p>
+ */
+public abstract class LanguageVisitor {
+
+ private boolean abort = false;
+
+ public void setAbort(boolean abort) {
+ this.abort = abort;
+ }
+
+ public final boolean shouldAbort() {
+ return abort;
+ }
+
+ // Visitor methods for language objects
+ public void visit(BatchedUpdateCommand obj) {}
+ public void visit(BetweenCriteria obj) {}
+ public void visit(CaseExpression obj) {}
+ public void visit(CompareCriteria obj) {}
+ public void visit(CompoundCriteria obj) {}
+ public void visit(Delete obj) {
+ visit((ProcedureContainer)obj);
+ }
+ public void visit(ExistsCriteria obj) {}
+ public void visit(From obj) {}
+ public void visit(GroupBy obj) {}
+ public void visit(Insert obj) {
+ visit((ProcedureContainer)obj);
+ }
+ public void visit(IsNullCriteria obj) {}
+ public void visit(JoinPredicate obj) {}
+ public void visit(JoinType obj) {}
+ public void visit(Limit obj) {}
+ public void visit(MatchCriteria obj) {}
+ public void visit(NotCriteria obj) {}
+ public void visit(Option obj) {}
+ public void visit(OrderBy obj) {}
+ public void visit(Query obj) {}
+ public void visit(SearchedCaseExpression obj) {}
+ public void visit(Select obj) {}
+ public void visit(SetCriteria obj) {}
+ public void visit(SetQuery obj) {}
+ public void visit(StoredProcedure obj) {
+ visit((ProcedureContainer)obj);
+ }
+ public void visit(SubqueryCompareCriteria obj) {}
+ public void visit(SubqueryFromClause obj) {}
+ public void visit(SubquerySetCriteria obj) {}
+ public void visit(UnaryFromClause obj) {}
+ public void visit(Update obj) {
+ visit((ProcedureContainer)obj);
+ }
+ public void visit(Into obj) {}
+ public void visit(XQuery obj) {}
+ public void visit(DependentSetCriteria obj) {}
+ public void visit(Create obj) {}
+ public void visit(Drop obj) {}
+
+ // Visitor methods for symbol objects
+ public void visit(AggregateSymbol obj) {}
+ public void visit(AliasSymbol obj) {}
+ public void visit(AllInGroupSymbol obj) {}
+ public void visit(AllSymbol obj) {}
+ public void visit(Constant obj) {}
+ public void visit(ElementSymbol obj) {}
+ public void visit(ExpressionSymbol obj) {}
+ public void visit(Function obj) {}
+ public void visit(GroupSymbol obj) {}
+ public void visit(Reference obj) {}
+ public void visit(ScalarSubquery obj) {}
+
+ // Visitor methods for procedure language objects
+ public void visit(AssignmentStatement obj) {}
+ public void visit(Block obj) {}
+ public void visit(CommandStatement obj) {}
+ public void visit(CreateUpdateProcedureCommand obj) {}
+ public void visit(CriteriaSelector obj) {}
+ public void visit(DeclareStatement obj) {
+ visit((AssignmentStatement)obj);
+ }
+ public void visit(HasCriteria obj) {}
+ public void visit(IfStatement obj) {}
+ public void visit(RaiseErrorStatement obj) {
+ visit((AssignmentStatement)obj);
+ }
+ public void visit(TranslateCriteria obj) {}
+ public void visit(BreakStatement obj) {}
+ public void visit(ContinueStatement obj) {}
+ public void visit(WhileStatement obj) {}
+ public void visit(LoopStatement obj) {}
+ public void visit(DynamicCommand obj) {}
+ public void visit(ProcedureContainer obj) {}
+ public void visit(SetClauseList obj) {}
+ public void visit(SetClause obj) {}
+ public void visit(OrderByItem obj) {}
+ public void visit(XMLElement obj) {}
+ public void visit(XMLAttributes obj) {}
+ public void visit(XMLForest obj) {}
+ public void visit(XMLNamespaces obj) {}
+}
Copied: trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/ProcedureReservedWords.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/sql/ProcedureReservedWords.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,81 @@
+/*
+ * 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;
+
+import java.lang.reflect.Field;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.teiid.connector.language.SQLReservedWords;
+
+/**
+ * Special variable names in stored procedure language.
+ */
+public class ProcedureReservedWords {
+
+ @Deprecated
+ public static final String INPUT = SQLReservedWords.INPUT;
+
+ public static final String INPUTS = "INPUTS"; //$NON-NLS-1$
+
+ public static final String ROWS_UPDATED = "ROWS_UPDATED"; //$NON-NLS-1$
+
+ public static final String CHANGING = "CHANGING"; //$NON-NLS-1$
+
+ public static final String VARIABLES = "VARIABLES"; //$NON-NLS-1$
+
+ public static final String DVARS = "DVARS"; //$NON-NLS-1$
+
+ /**
+ * Set of CAPITALIZED reserved words for checking whether a string is a reserved word.
+ */
+ private static final Set<String> RESERVED_WORDS = new HashSet<String>();
+
+ // Initialize RESERVED_WORDS set - This is a poor man's enum. To much legacy code expects the constants to be Strings.
+ static {
+ Field[] fields = SQLReservedWords.class.getDeclaredFields();
+ for (Field field : fields) {
+ if (field.getType() == String.class) {
+ try {
+ RESERVED_WORDS.add((String)field.get(null));
+ } catch (Exception e) {
+ }
+ }
+ }
+ }
+
+ /** Can't construct */
+ private ProcedureReservedWords() {}
+
+ /**
+ * Check whether a string is a procedure reserved word.
+ * @param str String to check
+ * @return True if procedure reserved word, false if not or null
+ */
+ public static final boolean isProcedureReservedWord(String str) {
+ if (str == null) {
+ return false;
+ }
+ return RESERVED_WORDS.contains(str.toUpperCase());
+ }
+}
Copied: trunk/engine/src/main/java/org/teiid/query/sql/lang (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/lang)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/AbstractCompareCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractCompareCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/AbstractCompareCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,11 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.util.ErrorMessageKeys;
/**
* <p>The common functionality of a {@link CompareCriteria} and a
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/AbstractSetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AbstractSetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/AbstractSetCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,10 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.sql.lang.PredicateCriteria.Negatable;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.query.sql.lang.PredicateCriteria.Negatable;
+import org.teiid.query.sql.symbol.Expression;
/**
* This is an abstract class to define some common functionality in the two varieties of
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/AtomicCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/AtomicCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/AtomicCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BatchedUpdateCommand.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/BatchedUpdateCommand.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,14 +28,15 @@
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.util.VariableContext;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.util.VariableContext;
+
/**
* Represents a batch of INSERT, UPDATE, DELETE, and SELECT INTO commands
* @since 4.2
@@ -72,7 +73,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getSubCommands()
+ * @see org.teiid.query.sql.lang.Command#getSubCommands()
*/
public List getSubCommands() {
if(commands == null || commands.size() == 0) {
@@ -100,7 +101,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getType()
+ * @see org.teiid.query.sql.lang.Command#getType()
* @since 4.2
*/
public int getType() {
@@ -108,7 +109,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getProjectedSymbols()
+ * @see org.teiid.query.sql.lang.Command#getProjectedSymbols()
* @since 4.2
*/
public List getProjectedSymbols() {
@@ -137,7 +138,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return false;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/BetweenCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/BetweenCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/BetweenCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.core.util.EquivalenceUtil;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* Represents criteria such as: "<expression> [NOT] BETWEEN <lowerExpression> AND <upperExpression>".
*/
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/CollectionValueIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CollectionValueIterator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/CollectionValueIterator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collection;
import java.util.Iterator;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.sql.util.ValueIterator;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.sql.util.ValueIterator;
+
public class CollectionValueIterator implements ValueIterator {
private Collection vals;
@@ -39,10 +40,10 @@
}
/**
- * @see com.metamatrix.query.sql.util.ValueIterator#hasNext()
+ * @see org.teiid.query.sql.util.ValueIterator#hasNext()
* @since 4.3
*/
- public boolean hasNext() throws MetaMatrixComponentException {
+ public boolean hasNext() throws TeiidComponentException {
if (instance == null) {
this.instance = vals.iterator();
}
@@ -50,10 +51,10 @@
}
/**
- * @see com.metamatrix.query.sql.util.ValueIterator#next()
+ * @see org.teiid.query.sql.util.ValueIterator#next()
* @since 4.3
*/
- public Object next() throws MetaMatrixComponentException {
+ public Object next() throws TeiidComponentException {
if (instance == null) {
this.instance = vals.iterator();
}
@@ -61,7 +62,7 @@
}
/**
- * @see com.metamatrix.query.sql.util.ValueIterator#reset()
+ * @see org.teiid.query.sql.util.ValueIterator#reset()
* @since 4.3
*/
public void reset() {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Command.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Command.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Arrays;
import java.util.Collection;
@@ -31,16 +31,17 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.processor.ProcessorPlan;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.CommandCollectorVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* A Command is an interface for all the language objects that are at the root
* of a language object tree representing a SQL statement. For instance, a
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/CompareCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CompareCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/CompareCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.PredicateCriteria.Negatable;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.PredicateCriteria.Negatable;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* <p>A criteria which represents a simple operator relationship between two expressions.
* There are 6 operator types. Each side of the comparison may be an expression, which
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/CompoundCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/CompoundCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/CompoundCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This class represents a compound criteria for logical expressions. A logical
* expression involves one or more criteria and a logical operator. The valid
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Create.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Create.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Create.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* @since 5.5
*/
@@ -55,7 +56,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getType()
+ * @see org.teiid.query.sql.lang.Command#getType()
* @since 5.5
*/
public int getType() {
@@ -63,7 +64,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#clone()
+ * @see org.teiid.query.sql.lang.Command#clone()
* @since 5.5
*/
public Object clone() {
@@ -76,7 +77,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getProjectedSymbols()
+ * @see org.teiid.query.sql.lang.Command#getProjectedSymbols()
* @since 5.5
*/
public List getProjectedSymbols() {
@@ -84,7 +85,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
* @since 5.5
*/
public boolean areResultsCachable() {
@@ -92,7 +93,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageObject#acceptVisitor(com.metamatrix.query.sql.LanguageVisitor)
+ * @see org.teiid.query.sql.LanguageObject#acceptVisitor(org.teiid.query.sql.LanguageVisitor)
* @since 5.5
*/
public void acceptVisitor(LanguageVisitor visitor) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Criteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Criteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,9 +29,10 @@
import java.util.LinkedList;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* This class represents the criteria clause for a query, which defines
* constraints on the data values to be retrieved for each parameter in the
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Delete.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Delete.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collections;
import java.util.List;
import java.util.Map;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* This class represents a SQL Delete statement of the form:
* "DELETE FROM <group> [WHERE <criteria>]".
@@ -163,7 +164,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.ProcedureContainer#getParameters()
+ * @see org.teiid.query.sql.lang.ProcedureContainer#getParameters()
* @since 5.0
*/
public Map getProcedureParameters() {
@@ -200,7 +201,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return false;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/DependentSetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DependentSetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/DependentSetCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ContextReference;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ContextReference;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* The DependentSetCriteria is missing the value set until it is filled during
* processing. This allows a criteria to contain a dynamic set of values provided
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Drop.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Drop.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Drop.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* @since 5.5
*/
@@ -49,7 +50,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getType()
+ * @see org.teiid.query.sql.lang.Command#getType()
* @since 5.5
*/
public int getType() {
@@ -57,7 +58,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#clone()
+ * @see org.teiid.query.sql.lang.Command#clone()
* @since 5.5
*/
public Object clone() {
@@ -69,7 +70,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getProjectedSymbols()
+ * @see org.teiid.query.sql.lang.Command#getProjectedSymbols()
* @since 5.5
*/
public List getProjectedSymbols() {
@@ -77,7 +78,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
* @since 5.5
*/
public boolean areResultsCachable() {
@@ -85,7 +86,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageObject#acceptVisitor(com.metamatrix.query.sql.LanguageVisitor)
+ * @see org.teiid.query.sql.LanguageObject#acceptVisitor(org.teiid.query.sql.LanguageVisitor)
* @since 5.5
*/
public void acceptVisitor(LanguageVisitor visitor) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/DynamicCommand.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/DynamicCommand.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,21 +20,22 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public class DynamicCommand extends Command {
private Expression sql;
@@ -62,7 +63,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.QueryCommand#clone()
+ * @see org.teiid.query.sql.lang.QueryCommand#clone()
*/
public Object clone() {
DynamicCommand clone = new DynamicCommand();
@@ -92,14 +93,14 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getType()
+ * @see org.teiid.query.sql.lang.Command#getType()
*/
public int getType() {
return Command.TYPE_DYNAMIC;
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getProjectedSymbols()
+ * @see org.teiid.query.sql.lang.Command#getProjectedSymbols()
*
* Once past resolving, an EMPTY set of project columns indicates that the
* project columns of the actual command do not need to be checked during
@@ -118,7 +119,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return false;
@@ -138,7 +139,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageObject#acceptVisitor(com.metamatrix.query.sql.LanguageVisitor)
+ * @see org.teiid.query.sql.LanguageObject#acceptVisitor(org.teiid.query.sql.LanguageVisitor)
*/
public void acceptVisitor(LanguageVisitor visitor) {
visitor.visit(this);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/ExistsCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ExistsCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/ExistsCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ContextReference;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ContextReference;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* This predicate criteria implements the "exists" predicate, which has
* a subquery in it. For example,
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/From.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/From.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.*;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.*;
+
+
/**
* Represents a FROM clause in a SELECT query. The from clause holds a set of
* FROM subclauses. Each FROM subclause can be either a single group
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/FromClause.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/FromClause.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collection;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+
/**
* A FromClause is an interface for subparts held in a FROM clause. One
* type of FromClause is {@link UnaryFromClause}, which is the more common
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/GroupBy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/GroupBy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/GroupBy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,22 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This class represents the GROUP BY clause of a query, which defines the expressions
* that should be used for grouping the results of the query. The groups
@@ -61,7 +62,7 @@
/**
* Constructs an instance of this class from an ordered set of symbols.
- * @param symbols The ordered list of {@link com.metamatrix.query.sql.symbol.ElementSymbol}s
+ * @param symbols The ordered list of {@link org.teiid.query.sql.symbol.ElementSymbol}s
*/
public GroupBy( List symbols ) {
this.symbols = new ArrayList( symbols );
@@ -81,7 +82,7 @@
/**
* Returns an ordered list of the symbols in the GROUP BY
- * @return List of {@link com.metamatrix.query.sql.symbol.ElementSymbol}s
+ * @return List of {@link org.teiid.query.sql.symbol.ElementSymbol}s
*/
public List getSymbols() {
return symbols;
@@ -99,7 +100,7 @@
/**
* Replaces the existing set of symbols with a new collection of symbols
- * @param symbols Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}s
+ * @param symbols Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}s
* to replace current symbols with
*/
public void replaceSymbols( Collection symbols ) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/GroupContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/GroupContext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/GroupContext.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
/**
* A GroupContext represents a set of groups in a hierarchy that determines
* resolving order.
@@ -85,7 +86,7 @@
try {
return super.clone();
} catch (CloneNotSupportedException err) {
- throw new MetaMatrixRuntimeException(err);
+ throw new TeiidRuntimeException(err);
}
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Insert.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Insert.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collection;
import java.util.HashMap;
@@ -29,16 +29,17 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
/**
* Represents a SQL Insert statement of the form:
* "INSERT INTO <group> (<variables>) VALUES <values>".
@@ -118,7 +119,7 @@
/**
* Return an ordered List of variables, may be null if no columns were specified
- * @return List of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return List of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public List getVariables() {
return variables;
@@ -143,7 +144,7 @@
/**
* Returns a list of values to insert
* to be inserted.
- * @return List of {@link com.metamatrix.query.sql.symbol.Expression}s
+ * @return List of {@link org.teiid.query.sql.symbol.Expression}s
*/
public List getValues() {
return this.values;
@@ -151,7 +152,7 @@
/**
* Sets the values to be inserted.
- * @param values List of {@link com.metamatrix.query.sql.symbol.Expression}s
+ * @param values List of {@link org.teiid.query.sql.symbol.Expression}s
*/
public void setValues(List values) {
this.values.clear();
@@ -227,7 +228,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.ProcedureContainer#getParameters()
+ * @see org.teiid.query.sql.lang.ProcedureContainer#getParameters()
* @since 5.0
*/
public Map getProcedureParameters() {
@@ -292,7 +293,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return false;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Into.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Into.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Into.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,14 +22,15 @@
/*
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Rpresent INTO clause in SELECT ... INTO ... clause, which is used to create
* temporary table.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/IsNullCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/IsNullCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/IsNullCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.PredicateCriteria.Negatable;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.core.util.EquivalenceUtil;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.PredicateCriteria.Negatable;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* Represents criteria such as: "<expression> IS NULL".
*/
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/JoinPredicate.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/JoinPredicate.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Represents a subpart of the FROM clause specifying a join within the FROM. It may
* optionally specify criteria for the join, depending on the join type. For example,
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/JoinType.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/JoinType.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/JoinType.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,10 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
/**
* This class represents a join type.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Limit.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Limit.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Limit.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public class Limit implements LanguageObject {
private Expression offset;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/LogicalCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/LogicalCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/LogicalCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
/**
* This class represents a criteria that works by logically combining other
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/MatchCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/MatchCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Arrays;
-import com.metamatrix.api.exception.query.CriteriaEvaluationException;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.PredicateCriteria.Negatable;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.api.exception.query.CriteriaEvaluationException;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.PredicateCriteria.Negatable;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* This class represents a criteria involving a string expression to be matched
* against a string expression match value. The match value may contain a few
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/NotCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/NotCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/NotCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+
/**
* A logical criteria that takes the logical NOT of the contained criteria.
* That is, if the contained criteria returns true, this criteria returns
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Option.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Option.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
/**
* Represents MetaMatrix extension options to normal SQL. Options
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/OrderBy.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderBy.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/OrderBy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Represents the ORDER BY clause of a query. The ORDER BY clause states
* what order the rows of a result should be returned in. Each element
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/OrderByItem.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/OrderByItem.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/OrderByItem.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
public class OrderByItem implements LanguageObject {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/PredicateCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/PredicateCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/PredicateCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/ProcedureContainer.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/ProcedureContainer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Map;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
public abstract class ProcedureContainer extends Command {
private int updateCount = -1;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Query.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Query.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,20 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
/**
* A representation of a data query. A query consists of various parts,
* referred to as clauses. The following list the types of clauses
@@ -417,7 +418,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
if(this.getInto() != null){
@@ -441,7 +442,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.QueryCommand#getProjectedQuery()
+ * @see org.teiid.query.sql.lang.QueryCommand#getProjectedQuery()
*/
@Override
public Query getProjectedQuery() {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/QueryCommand.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/QueryCommand.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SPParameter.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SPParameter.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.io.Serializable;
import java.util.ArrayList;
@@ -29,14 +29,14 @@
import java.util.List;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.core.TeiidException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* Represents a StoredProcedure's parameter for encapsulation in the Query framework
@@ -148,7 +148,7 @@
/**
* Set class type - MetaMatrix runtime types.
- * @param classType See {@link com.metamatrix.common.types.DataTypeManager.DefaultDataClasses}
+ * @param classType See {@link org.teiid.core.types.DataTypeManager.DefaultDataClasses}
* for types
*/
public void setClassType(Class classType){
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Select.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Select.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Select.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.symbol.*;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.symbol.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* This class represents the SELECT clause of a query, which defines what elements
* or expressions are returned from the query.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SetClause.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetClause.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SetClause.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public class SetClause implements LanguageObject {
private static final long serialVersionUID = 8174681510498719451L;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SetClauseList.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetClauseList.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SetClauseList.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public class SetClauseList implements LanguageObject {
private static final long serialVersionUID = 8174681510498719451L;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SetCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,11 +29,12 @@
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* A criteria which is true is the expression's value is a member in a list
* of values. This criteria can be represented as "<expression> IN (<expr>, ...)".
@@ -51,7 +52,7 @@
/**
* Constructs an instance of this class with the membership expression and value expressions
* @param expression The membership expression
- * @param values The set of value {@link com.metamatrix.query.sql.symbol.Expression}s
+ * @param values The set of value {@link org.teiid.query.sql.symbol.Expression}s
*/
public SetCriteria( Expression expression, Collection values ) {
set(expression,values);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SetQuery.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SetQuery.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,26 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.api.exception.query.QueryResolverException;
+import org.teiid.core.TeiidRuntimeException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
/**
* This object acts as a Set operator on multiple Queries - UNION,
* INTERSECT, and EXCEPT can be implemented with this Class
@@ -147,7 +148,7 @@
try {
symbol = new ExpressionSymbol(originalSymbol.getShortName(), ResolverUtil.convertExpression(expr, DataTypeManager.getDataTypeName(type), metadata));
} catch (QueryResolverException err) {
- throw new MetaMatrixRuntimeException(err);
+ throw new TeiidRuntimeException(err);
}
if (!(originalSymbol instanceof ExpressionSymbol)) {
@@ -232,7 +233,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return leftQuery.areResultsCachable() && rightQuery.areResultsCachable();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/StoredProcedure.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/StoredProcedure.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.Collections;
@@ -32,13 +32,13 @@
import java.util.TreeMap;
import org.teiid.client.metadata.ParameterInfo;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* Represents a StoredProcedure statement of the form:
@@ -333,7 +333,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return Query.areResultsCachable(getProjectedSymbols());
@@ -404,7 +404,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.ProcedureContainer#getProcedureParameters()
+ * @see org.teiid.query.sql.lang.ProcedureContainer#getProcedureParameters()
* @since 5.0
*/
public Map getProcedureParameters() {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryCompareCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryCompareCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ContextReference;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ContextReference;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+
/**
* <p>This class implements a quantified comparison predicate. This is
* a criteria which represents a simple operator relationship between an expression and
@@ -214,7 +215,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.AbstractCompareCriteria#getRightExpression()
+ * @see org.teiid.query.sql.lang.AbstractCompareCriteria#getRightExpression()
*/
public Expression getRightExpression() {
return new ScalarSubquery(getCommand());
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryContainer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryContainer.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryContainer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
/**
* This interface defines a common interface for all MetaMatrix SQL objects
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubqueryFromClause.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SubqueryFromClause.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collection;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* A FROM subpart that represents a subquery. For example, the FROM clause:
* "FROM (SELECT a FROM b)" will have a SubqueryFromClause referencing the subquery.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/SubquerySetCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/SubquerySetCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ContextReference;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ContextReference;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* A criteria which is true is the expression's value is a member in a list
* of values returned from a subquery. This criteria can be represented as
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/TranslatableProcedureContainer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/TranslatableProcedureContainer.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/TranslatableProcedureContainer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Map;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Reference;
+
public abstract class TranslatableProcedureContainer extends ProcedureContainer {
private Map<ElementSymbol, Reference> implicitParams;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/UnaryFromClause.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/UnaryFromClause.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.Collection;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* A FROM subpart that represents a single group. For example, the FROM clause:
* "FROM a, b" will have two UnaryFromClause objects, each holding a reference to
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/Update.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/Update.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Represents a SQL Update statement of the form:
* "UPDATE <group> SET <element> = <expression>, ... [WHERE <criteria>]".
@@ -248,14 +249,14 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable(){
return false;
}
/**
- * @see com.metamatrix.query.sql.lang.ProcedureContainer#getProcedureParameters()
+ * @see org.teiid.query.sql.lang.ProcedureContainer#getProcedureParameters()
* @since 5.0
*/
public Map getProcedureParameters() {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/lang/XQuery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/lang/XQuery.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/lang/XQuery.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,19 +20,20 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.lang;
+package org.teiid.query.sql.lang;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.xquery.XQueryExpression;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.xquery.XQueryExpression;
+
/**
* An XQuery command object
*/
@@ -72,14 +73,14 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getType()
+ * @see org.teiid.query.sql.lang.Command#getType()
*/
public int getType() {
return Command.TYPE_XQUERY;
}
/**
- * @see com.metamatrix.query.sql.lang.Command#getProjectedSymbols()
+ * @see org.teiid.query.sql.lang.Command#getProjectedSymbols()
*/
public List getProjectedSymbols() {
List selectList = new ArrayList(1);
@@ -142,7 +143,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
return true;
Copied: trunk/engine/src/main/java/org/teiid/query/sql/navigator (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/navigator)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/AbstractNavigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/AbstractNavigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/AbstractNavigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.navigator;
+package org.teiid.query.sql.navigator;
import java.util.Collection;
import java.util.Iterator;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+
/**
* @since 4.2
*/
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/DeepPostOrderNavigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/DeepPostOrderNavigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/DeepPostOrderNavigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.navigator;
+package org.teiid.query.sql.navigator;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.ScalarSubquery;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/DeepPreOrderNavigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/DeepPreOrderNavigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/DeepPreOrderNavigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.navigator;
+package org.teiid.query.sql.navigator;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.symbol.ScalarSubquery;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/PostOrderNavigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/PostOrderNavigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/PostOrderNavigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,10 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.navigator;
+package org.teiid.query.sql.navigator;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/PreOrPostOrderNavigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrPostOrderNavigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,86 +20,87 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.navigator;
+package org.teiid.query.sql.navigator;
import java.util.Collection;
import java.util.Iterator;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Create;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.BreakStatement;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.ContinueStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.proc.RaiseErrorStatement;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.XMLAttributes;
-import com.metamatrix.query.sql.symbol.XMLElement;
-import com.metamatrix.query.sql.symbol.XMLForest;
-import com.metamatrix.query.sql.symbol.XMLNamespaces;
-import com.metamatrix.query.sql.util.SymbolMap;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetClause;
+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.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.BreakStatement;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.ContinueStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.proc.RaiseErrorStatement;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLElement;
+import org.teiid.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.symbol.XMLNamespaces;
+import org.teiid.query.sql.util.SymbolMap;
+
/**
* @since 4.2
*/
@@ -486,7 +487,7 @@
* NOTE: we specifically don't need to visit the as columns or the using identifiers.
* These will be resolved by the dynamic command resolver instead.
*
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.DynamicCommand)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.DynamicCommand)
*/
public void visit(DynamicCommand obj) {
preVisitVisitor(obj);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrderNavigator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/navigator/PreOrderNavigator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/navigator/PreOrderNavigator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,10 +20,10 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.navigator;
+package org.teiid.query.sql.navigator;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
/**
Copied: trunk/engine/src/main/java/org/teiid/query/sql/proc (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/proc)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/AssignmentStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/AssignmentStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,18 +20,19 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents an assignment statement in the storedprocedure language.
* It extends the <code>Statement</code> that could part of a <code>Block</code>. This
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Block.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/Block.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents a group of <code>Statement</code> objects. The
* statements are stored on this object in the order in which they are added.</p>
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/BreakStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/BreakStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/BreakStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,10 +22,10 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
/**
* <p> This class represents a break statement in the storedprocedure language.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CommandStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/CommandStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents a variable assignment statement in the storedprocedure language.
* It extends the <code>Statement</code> that could part of a block. This statement has
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/ContinueStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/ContinueStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/ContinueStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,10 +22,10 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
/**
* <p> This class represents a continue statement in the storedprocedure language.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CreateUpdateProcedureCommand.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/CreateUpdateProcedureCommand.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.ArrayList;
import java.util.Collections;
@@ -28,13 +28,14 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents a update procedure in the storedprocedure language.
* It extends the <code>Command</code> and represents the command for Insert , Update
@@ -272,7 +273,7 @@
}
/**
- * @see com.metamatrix.query.sql.lang.Command#areResultsCachable()
+ * @see org.teiid.query.sql.lang.Command#areResultsCachable()
*/
public boolean areResultsCachable() {
if(isUpdateProcedure()){
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/CriteriaSelector.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/CriteriaSelector.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/CriteriaSelector.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
+
/**
* <p>This class represents the criteria present on the user's query. The type of
* criteria and the elements on which it is specified are listed in this object,
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/DeclareStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/DeclareStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents a statement used to declare variables in the
* storedprocedure language. It extends the <code>Statement</code> that
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/HasCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/HasCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/HasCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.PredicateCriteria;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.PredicateCriteria;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p>This object represents the criteria used in the stored procedure language
* to determine if a type of criteria is specified on a user's query.</p>
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/IfStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/IfStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/IfStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.sql.lang.Criteria;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents an if-else statement in the storedprocedure language.
* It extends the <code>Statement</code> that could part of a block. This statement has
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/LoopStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/LoopStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/LoopStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,14 +22,15 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents a loop statement in the storedprocedure language
* to cursor through a result set.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/RaiseErrorStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/RaiseErrorStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
/**
* <p> This class represents a error assignment statement in the storedprocedure language.
@@ -71,7 +71,7 @@
/**
- * @see com.metamatrix.query.sql.proc.AssignmentStatement#getType()
+ * @see org.teiid.query.sql.proc.AssignmentStatement#getType()
*/
public int getType() {
return TYPE_ERROR;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/Statement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/Statement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.query.sql.*;
+import org.teiid.query.sql.*;
/**
* <p> This class represents the a statement in the stored procedure language.
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/TranslateCriteria.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/TranslateCriteria.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/TranslateCriteria.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
import java.util.*;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p>This object represents the criteria used in the stored procedure language
* that translates the portion of the user's criteria by doing symbol mapping to
Modified: trunk/engine/src/main/java/org/teiid/query/sql/proc/WhileStatement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/proc/WhileStatement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/proc/WhileStatement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -22,14 +22,15 @@
/*
*/
-package com.metamatrix.query.sql.proc;
+package org.teiid.query.sql.proc;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* <p> This class represents a while statement in the storedprocedure language.
* It extends the <code>Statement</code> that could part of a block. This statement has
Copied: trunk/engine/src/main/java/org/teiid/query/sql/symbol (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/symbol)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AbstractCaseExpression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AbstractCaseExpression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AbstractCaseExpression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public abstract class AbstractCaseExpression implements Expression {
/** The type that this case expression will resolve to. */
@@ -95,7 +96,7 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.Expression#getType()
+ * @see org.teiid.query.sql.symbol.Expression#getType()
*/
public Class getType() {
return type;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AggregateSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AggregateSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.HashMap;
import java.util.HashSet;
@@ -28,13 +28,13 @@
import java.util.Set;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
* <p>An aggregate symbol represents an aggregate function in the SELECT or HAVING clauses. It
@@ -200,7 +200,7 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.ExpressionSymbol#hashCode()
+ * @see org.teiid.query.sql.symbol.ExpressionSymbol#hashCode()
*/
public int hashCode() {
int hasCode = HashCodeUtil.hashCode(aggregate.hashCode(), distinct);
@@ -208,7 +208,7 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.ExpressionSymbol#equals(java.lang.Object)
+ * @see org.teiid.query.sql.symbol.ExpressionSymbol#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (!(obj instanceof AggregateSymbol)) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AliasSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AliasSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AliasSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* An AliasSymbol wraps a SingleElementSymbol and changes it's name. AliasSymbols
* should be used to perform the aliasing of elements in a SELECT clause. They
@@ -114,7 +115,7 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.Symbol#equals(java.lang.Object)
+ * @see org.teiid.query.sql.symbol.Symbol#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AllInGroupSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllInGroupSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.*;
-import com.metamatrix.query.sql.*;
+import org.teiid.query.sql.*;
+
/**
* <p>This is a subclass of Symbol representing <group>.*, which contains all of
* the elements from a single group in the query. The name of this symbol is "group.*",
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/AllSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/AllSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,11 +20,12 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.*;
-import com.metamatrix.query.sql.*;
+import org.teiid.query.sql.*;
+
/**
* <p>This is a subclass of Symbol representing *, which contains all of
* the elements from all groups in the query. The name of this symbol is always "*",
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/CaseExpression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/CaseExpression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/CaseExpression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class CaseExpression extends AbstractCaseExpression {
/**
@@ -74,7 +75,7 @@
/**
*
- * @see com.metamatrix.query.sql.symbol.AbstractCaseExpression#getWhenCount()
+ * @see org.teiid.query.sql.symbol.AbstractCaseExpression#getWhenCount()
*/
public int getWhenCount() {
return (when == null) ? 0 : when.size();
@@ -126,7 +127,7 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.Expression#isResolved()
+ * @see org.teiid.query.sql.symbol.Expression#isResolved()
*/
public boolean isResolved() {
if (!expression.isResolved()) return false;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Constant.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Constant.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.List;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This class represents a literal value in a SQL string. The Constant object has a value
* and a type for that value. In many cases, the type can be derived from the type of the
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ContextReference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ContextReference.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ContextReference.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
public interface ContextReference {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ElementSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ElementSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.query.sql.*;
+import org.teiid.query.sql.*;
/**
* <p>This is a subclass of Symbol representing a single element. An ElementSymbol
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Expression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Expression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Expression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageObject;
/**
* This is the interface for an expression in a SQL string. Expressions can be of several
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ExpressionSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ExpressionSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ExpressionSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.query.sql.*;
+import org.teiid.query.sql.*;
/**
* <p>This is a subclass of Symbol representing an expression in the SELECT clause. The
@@ -115,7 +115,7 @@
/**
- * @see com.metamatrix.query.sql.symbol.Symbol#hashCode()
+ * @see org.teiid.query.sql.symbol.Symbol#hashCode()
*/
public int hashCode() {
if (expression != null) {
@@ -127,7 +127,7 @@
/**
* ExpressionSymbol matching is not based upon the name
*
- * @see com.metamatrix.query.sql.symbol.Symbol#equals(java.lang.Object)
+ * @see org.teiid.query.sql.symbol.Symbol#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
if (this == obj) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Function.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Function.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.function.FunctionDescriptor;
-import com.metamatrix.query.sql.*;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.function.FunctionDescriptor;
+import org.teiid.query.sql.*;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Represents a function in a sql statement. A function is a type of expression.
* Functions have a name and some arguments (0..n). Each argument is also
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/GroupSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/GroupSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,11 +20,11 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
/**
* <p>This is the server's representation of a metadata group symbol. The group
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/MultipleElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/MultipleElementSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/MultipleElementSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.*;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Reference.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Reference.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* This class represents a reference (positional from the user query, or
* to an element from another scope). This reference may resolve to many different values
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/ScalarSubquery.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/ScalarSubquery.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.concurrent.atomic.AtomicInteger;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* This is an Expression implementation that can be used in a SELECT clause.
* It has a subquery Command which must only produce exactly one
@@ -68,14 +69,14 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.Expression#isResolved()
+ * @see org.teiid.query.sql.symbol.Expression#isResolved()
*/
public boolean isResolved() {
return (this.getType() != null);
}
/**
- * @see com.metamatrix.query.sql.symbol.Expression#getType()
+ * @see org.teiid.query.sql.symbol.Expression#getType()
*/
public Class getType() {
if (this.type == null){
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/SearchedCaseExpression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/SearchedCaseExpression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/SearchedCaseExpression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class SearchedCaseExpression extends AbstractCaseExpression {
/**
@@ -49,7 +50,7 @@
/**
*
- * @see com.metamatrix.query.sql.symbol.AbstractCaseExpression#getWhenCount()
+ * @see org.teiid.query.sql.symbol.AbstractCaseExpression#getWhenCount()
*/
public int getWhenCount() {
return (when == null) ? 0 : when.size();
@@ -101,7 +102,7 @@
}
/**
- * @see com.metamatrix.query.sql.symbol.Expression#isResolved()
+ * @see org.teiid.query.sql.symbol.Expression#isResolved()
*/
public boolean isResolved() {
for (int i = 0; i < getWhenCount(); i++) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/SelectSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/SelectSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/SelectSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
/**
* This is the server's representation of a metadata symbol that can be used
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/SingleElementSymbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/SingleElementSymbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/Symbol.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/Symbol.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,14 +20,15 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.util.StringUtil;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* This is the server's representation of a metadata symbol. The only thing
* a symbol has to have is a name. This name relates only to how a symbol is
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/XMLAttributes.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLAttributes.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.List;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Represents XMLATTRIBUTES name value pairs
*/
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLElement.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/XMLElement.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLElement.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.List;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
/**
* Represents XMLATTRIBUTES/XMLFOREST name value pairs
*/
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/XMLForest.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLForest.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.List;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public class XMLForest implements Expression {
private static final long serialVersionUID = -3348922701950966494L;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLNamespaces.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/symbol/XMLNamespaces.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/symbol/XMLNamespaces.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,17 +20,18 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.symbol;
+package org.teiid.query.sql.symbol;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.core.util.EquivalenceUtil;
-import com.metamatrix.core.util.HashCodeUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
+import org.teiid.core.util.EquivalenceUtil;
+import org.teiid.core.util.HashCodeUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+
public class XMLNamespaces implements LanguageObject {
private static final long serialVersionUID = 681076404921001047L;
Copied: trunk/engine/src/main/java/org/teiid/query/sql/util (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/util)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/util/ElementSymbolOptimizer.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ElementSymbolOptimizer.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/util/ElementSymbolOptimizer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,22 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.*;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.*;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.*;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.visitor.CommandCollectorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+
/**
* <p>The ElementSymbolOptimizer can be used to modify the appearance of the elements in a command. The operations will
* be performed on the command and all embedded subcommands, but not any further than that. This
@@ -113,7 +114,7 @@
* @param command Command to convert
*/
public static void optimizeElements(Command command, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException{
+ throws QueryMetadataException, TeiidComponentException{
// Determine commands to optimize
List commandsToOptimize = new ArrayList();
@@ -130,7 +131,7 @@
}
private static boolean isXMLCommand(Command command, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException{
+ throws QueryMetadataException, TeiidComponentException{
// Check groups
Collection groups = GroupCollectorVisitor.getGroups(command, true);
if(groups.size() != 1) {
@@ -161,7 +162,7 @@
Collection groups,
Collection externalGroups,
QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
switch(command.getType()) {
case Command.TYPE_INSERT:
@@ -193,7 +194,7 @@
Collection groups,
Collection externalGroups,
QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
if (isXMLCommand(command, metadata)){
return;
@@ -225,7 +226,7 @@
* Set of GroupSymbols that have an element with that name
*/
private static Map mapShortNamesToGroups(Collection groups, Collection externalGroups, QueryMetadataInterface metadata)
- throws QueryMetadataException, MetaMatrixComponentException {
+ throws QueryMetadataException, TeiidComponentException {
Map result = new HashMap();
Collection allGroups = new ArrayList(groups);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/util/SymbolMap.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/SymbolMap.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/util/SymbolMap.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.ArrayList;
import java.util.Collections;
@@ -29,19 +29,20 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
public class SymbolMap {
private LinkedHashMap<ElementSymbol, Expression> map = new LinkedHashMap<ElementSymbol, Expression>();
@@ -103,7 +104,7 @@
}
public static final SymbolMap createSymbolMap(GroupSymbol virtualGroup,
- List<? extends SingleElementSymbol> projectCols, QueryMetadataInterface metadata) throws QueryMetadataException, MetaMatrixComponentException {
+ List<? extends SingleElementSymbol> projectCols, QueryMetadataInterface metadata) throws QueryMetadataException, TeiidComponentException {
return createSymbolMap(ResolverUtil.resolveElementsInGroup(virtualGroup, metadata), projectCols);
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/UpdateProcedureGenerator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/util/UpdateProcedureGenerator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,25 +20,26 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.proc.*;
-import com.metamatrix.query.sql.symbol.*;
-import com.metamatrix.query.util.ErrorMessageKeys;
-import com.metamatrix.query.validator.UpdateValidationVisitor;
-import com.metamatrix.query.validator.ValidatorReport;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.proc.*;
+import org.teiid.query.sql.symbol.*;
+import org.teiid.query.util.ErrorMessageKeys;
+import org.teiid.query.validator.UpdateValidationVisitor;
+import org.teiid.query.validator.ValidatorReport;
+
/**
* Use existing query transformation to create a simple insert/update/delete procedure.
* Only works for the virtual group that maps to single physical group.
@@ -62,7 +63,7 @@
*/
public static CreateUpdateProcedureCommand createProcedure (
int procedureType, String virtualGroup, Command queryTransformation, QueryMetadataInterface metadata)
- throws MetaMatrixComponentException, QueryMetadataException {
+ throws TeiidComponentException, QueryMetadataException {
// validate that a procedure can be generated
UpdateValidationVisitor updateVisitor = new UpdateValidationVisitor(metadata);
@@ -160,7 +161,7 @@
* @param values Collect each value (INPUT value for respective virtual element)
*/
private static void mapElements(List physicalElements, List virtualElements, String physicalGroup, QueryMetadataInterface metadata, List variables, List values)
- throws MetaMatrixComponentException, QueryMetadataException{
+ throws TeiidComponentException, QueryMetadataException{
if(physicalElements.size()!= virtualElements.size()) {
throw new QueryMetadataException(ErrorMessageKeys.SQL_0018, QueryPlugin.Util.getString(ErrorMessageKeys.SQL_0018));
Modified: trunk/engine/src/main/java/org/teiid/query/sql/util/ValueIterator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIterator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/util/ValueIterator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,9 +20,9 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
+import org.teiid.core.TeiidComponentException;
/**
* <p>Interface for interating through Expressions or values. It may return
@@ -42,23 +42,23 @@
* words, returns <tt>true</tt> if <tt>next</tt> would return a value
* rather than throwing an exception.)
* @return <tt>true</tt> if this ValueIterator has more values.
- * @throws MetaMatrixComponentException indicating a non business-
+ * @throws TeiidComponentException indicating a non business-
* related Exception such as a service or bean being unavailable, or
* a communication failure.
*/
boolean hasNext()
- throws MetaMatrixComponentException;
+ throws TeiidComponentException;
/**
* Returns the next Expression or Object value in the interation.
* @return the next Expression or Object value in the iteration.
- * @throws MetaMatrixComponentException indicating a non business-
+ * @throws TeiidComponentException indicating a non business-
* related Exception such as a service or bean being unavailable, or
* a communication failure.
* @throws NoSuchElementException if iteration has no more elements.
*/
Object next()
- throws MetaMatrixComponentException;
+ throws TeiidComponentException;
/**
* Optional reset method - allows a single instance of a
Modified: trunk/engine/src/main/java/org/teiid/query/sql/util/ValueIteratorSource.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/ValueIteratorSource.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/util/ValueIteratorSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.sql.symbol.Expression;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.sql.symbol.Expression;
+
/**
* The ValueIteratorSource lets a language object that needs a ValueIterator hold this
* reference to the source of the ValueIterator as a reference until the ValueIterator
@@ -43,11 +44,11 @@
* not ready yet, return null to indicate that.
* @param valueExpression The expression we are retrieving an iterator for
* @return ValueIterator if ready, null otherwise
- * @throws MetaMatrixComponentException
+ * @throws TeiidComponentException
* @since 5.0.1
*/
- ValueIterator getValueIterator(Expression valueExpression) throws MetaMatrixComponentException;
+ ValueIterator getValueIterator(Expression valueExpression) throws TeiidComponentException;
- Set<Object> getCachedSet(Expression valueExpression) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ Set<Object> getCachedSet(Expression valueExpression) throws TeiidComponentException, TeiidProcessingException;
}
Modified: trunk/engine/src/main/java/org/teiid/query/sql/util/VariableContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/util/VariableContext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/util/VariableContext.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.util;
+package org.teiid.query.sql.util;
import java.util.HashMap;
import java.util.Map;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class VariableContext {
// map between variables and their values
@@ -59,13 +60,13 @@
}
}
- public Object getGlobalValue(String variable) throws MetaMatrixComponentException {
+ public Object getGlobalValue(String variable) throws TeiidComponentException {
if (this.parentContext != null) {
return this.parentContext.getGlobalValue(variable);
}
Object value = variableMap.get(variable);
if (value == null && !variableMap.containsKey(variable)) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, variable, "No value was available")); //$NON-NLS-1$
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, variable, "No value was available")); //$NON-NLS-1$
}
return value;
}
Copied: trunk/engine/src/main/java/org/teiid/query/sql/visitor (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/sql/visitor)
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/AbstractSymbolMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/AbstractSymbolMappingVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,26 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Symbol;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.SetClause;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Symbol;
+
/**
* <p> This class is used to update LanguageObjects by replacing one set of symbols with
* another. There is one abstract method which must be overridden to define how the
@@ -237,7 +238,7 @@
/* ############### Helper Methods ################## */
/**
- * @see com.metamatrix.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(com.metamatrix.query.sql.symbol.Expression)
+ * @see org.teiid.query.sql.visitor.ExpressionMappingVisitor#replaceExpression(org.teiid.query.sql.symbol.Expression)
*/
@Override
public Expression replaceExpression(Expression element) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/AggregateSymbolCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,20 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.PreOrPostOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.navigator.PreOrPostOrderNavigator;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
public class AggregateSymbolCollectorVisitor extends LanguageVisitor {
public static class AggregateStopNavigator extends PreOrPostOrderNavigator {
@@ -49,7 +50,7 @@
}
/**
- * @see com.metamatrix.query.sql.navigator.PreOrPostOrderNavigator#visit(com.metamatrix.query.sql.symbol.ExpressionSymbol)
+ * @see org.teiid.query.sql.navigator.PreOrPostOrderNavigator#visit(org.teiid.query.sql.symbol.ExpressionSymbol)
*/
@Override
public void visit(ExpressionSymbol obj) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/CommandCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CommandCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/CommandCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,27 +20,28 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.SetQuery;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+
/**
* <p>This visitor class will traverse a language object tree and collect all sub-commands
* it finds. It uses a List to collect the sub-commands in the order they're found.</p>
@@ -56,28 +57,28 @@
/**
* Get the commands collected by the visitor. This should best be called
* after the visitor has been run on the language object tree.
- * @return List of {@link com.metamatrix.query.sql.lang.Command}
+ * @return List of {@link org.teiid.query.sql.lang.Command}
*/
public List<Command> getCommands() {
return this.commands;
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ExistsCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.ExistsCriteria)
*/
public void visit(ExistsCriteria obj) {
this.commands.add(obj.getCommand());
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ScalarSubquery)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ScalarSubquery)
*/
public void visit(ScalarSubquery obj) {
this.commands.add(obj.getCommand());
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubqueryCompareCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubqueryCompareCriteria)
*/
public void visit(SubqueryCompareCriteria obj) {
this.commands.add(obj.getCommand());
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/CorrelatedReferenceCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CorrelatedReferenceCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/CorrelatedReferenceCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.Collection;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.symbol.*;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.*;
+
/**
* <p>This visitor class will traverse a language object tree and collect references that
* correspond to correlated subquery references.</p>
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/CriteriaTranslatorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/CriteriaTranslatorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
@@ -29,20 +29,21 @@
import java.util.List;
import java.util.Map;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.Reference;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.Reference;
+
/**
* <p> This class is used to translate criteria specified on the user's update command against
* the virtual group, the elements on this criteria are replaced by elements on the query
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/ElementCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ElementCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ElementCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* <p>This visitor class will traverse a language object tree and collect all element
* symbol references it finds. It uses a collection to collect the elements in so
@@ -67,7 +68,7 @@
/**
* Get the elements collected by the visitor. This should best be called
* after the visitor has been run on the language object tree.
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public Collection<ElementSymbol> getElements() {
return this.elements;
@@ -133,7 +134,7 @@
* filtered out.
* @param obj Language object
* @param removeDuplicates True to remove duplicates
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public static final Collection<ElementSymbol> getElements(LanguageObject obj, boolean removeDuplicates) {
return ElementCollectorVisitor.getElements(obj, removeDuplicates, false);
@@ -147,7 +148,7 @@
* @param removeDuplicates True to remove duplicates
* @param useDeepIteration indicates whether or not to iterate into nested
* subqueries of the query
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public static final Collection<ElementSymbol> getElements(LanguageObject obj, boolean removeDuplicates, boolean useDeepIteration) {
if(obj == null) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/EvaluatableVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/EvaluatableVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -23,30 +23,31 @@
/**
*
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.TreeSet;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+
/**
* <p>This visitor class will traverse a language object tree, and determine
* if the current expression can be evaluated</p>
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ExpressionMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ExpressionMappingVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
@@ -30,38 +30,39 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.XMLAttributes;
-import com.metamatrix.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetClause;
+import org.teiid.query.sql.lang.SetCriteria;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLForest;
+
/**
* It is important to use a Post Navigator with this class,
* otherwise a replacement containing itself will not work
@@ -133,7 +134,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.symbol.AliasSymbol)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.symbol.AliasSymbol)
*/
public void visit(AliasSymbol obj) {
Expression replacement = replaceExpression(obj.getSymbol());
@@ -150,7 +151,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(BetweenCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(BetweenCriteria)
*/
public void visit(BetweenCriteria obj) {
obj.setExpression( replaceExpression(obj.getExpression()) );
@@ -174,7 +175,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(CompareCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(CompareCriteria)
*/
public void visit(CompareCriteria obj) {
obj.setLeftExpression( replaceExpression(obj.getLeftExpression()) );
@@ -182,7 +183,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(Function)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(Function)
*/
public void visit(Function obj) {
Expression[] args = obj.getArgs();
@@ -194,14 +195,14 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(IsNullCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(IsNullCriteria)
*/
public void visit(IsNullCriteria obj) {
obj.setExpression( replaceExpression(obj.getExpression()) );
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(MatchCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(MatchCriteria)
*/
public void visit(MatchCriteria obj) {
obj.setLeftExpression( replaceExpression(obj.getLeftExpression()) );
@@ -221,7 +222,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(SetCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(SetCriteria)
*/
public void visit(SetCriteria obj) {
obj.setExpression( replaceExpression(obj.getExpression()) );
@@ -240,14 +241,14 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubqueryCompareCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubqueryCompareCriteria)
*/
public void visit(SubqueryCompareCriteria obj) {
obj.setLeftExpression( replaceExpression(obj.getLeftExpression()) );
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubquerySetCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubquerySetCriteria)
*/
public void visit(SubquerySetCriteria obj) {
obj.setExpression( replaceExpression(obj.getExpression()) );
@@ -339,7 +340,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.proc.AssignmentStatement)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.proc.AssignmentStatement)
* @since 5.0
*/
public void visit(AssignmentStatement obj) {
@@ -349,7 +350,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.Insert)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.Insert)
* @since 5.0
*/
public void visit(Insert obj) {
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/FunctionCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/FunctionCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/FunctionCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,20 +20,21 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* <p>This visitor class will traverse a language object tree and collect all Function
* references it finds. It uses a collection to collect the Functions in so
@@ -79,7 +80,7 @@
/**
* Get the elements collected by the visitor. This should best be called
* after the visitor has been run on the language object tree.
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public Collection getFunctions() {
return this.functions;
@@ -125,7 +126,7 @@
* filtered out.
* @param obj Language object
* @param removeDuplicates True to remove duplicates
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public static final Collection getFunctions(LanguageObject obj, boolean removeDuplicates) {
return getFunctions(obj, removeDuplicates, false);
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/GroupCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/GroupCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/GroupCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,23 +20,24 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* <p>This visitor class will traverse a language object tree and collect all group
* symbol references it finds. It uses a collection to collect the groups in so
@@ -73,7 +74,7 @@
/**
* Get the groups collected by the visitor. This should best be called
* after the visitor has been run on the language object tree.
- * @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.GroupSymbol}
*/
public Collection<GroupSymbol> getGroups() {
return this.groups;
@@ -143,7 +144,7 @@
* filtered out.
* @param obj Language object
* @param removeDuplicates True to remove duplicates
- * @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.GroupSymbol}
*/
public static Collection<GroupSymbol> getGroups(LanguageObject obj, boolean removeDuplicates) {
Collection<GroupSymbol> groups = null;
@@ -178,7 +179,7 @@
* filtered out.
* @param obj Language object
* @param removeDuplicates True to remove duplicates
- * @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.GroupSymbol}
*/
public static Collection<GroupSymbol> getGroupsIgnoreInlineViews(LanguageObject obj, boolean removeDuplicates) {
Collection<GroupSymbol> groups = null;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/GroupsUsedByElementsVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/GroupsUsedByElementsVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/GroupsUsedByElementsVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.GroupSymbol;
+
public class GroupsUsedByElementsVisitor {
/**
@@ -49,7 +50,7 @@
* Helper to quickly get the groups from obj in a collection. Duplicates
* are removed.
* @param obj Language object
- * @return Collection of {@link com.metamatrix.query.sql.symbol.GroupSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.GroupSymbol}
*/
public static final Set<GroupSymbol> getGroups(LanguageObject obj) {
Set<GroupSymbol> groups = new HashSet<GroupSymbol>();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/PredicateCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/PredicateCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/PredicateCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,26 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+
/**
* <p>Walk a tree of language objects and collect any predicate criteria that are found.
* A predicate criteria is of the following types: </p>
*
* <ul>
- * <li>{@link com.metamatrix.query.sql.lang.CompareCriteria} CompareCriteria</li>
- * <li>{@link com.metamatrix.query.sql.lang.MatchCriteria} MatchCriteria</li>
- * <li>{@link com.metamatrix.query.sql.lang.SetCriteria} SetCriteria</li>
- * <li>{@link com.metamatrix.query.sql.lang.SubquerySetCriteria} SubquerySetCriteria</li>
- * <li>{@link com.metamatrix.query.sql.lang.IsNullCriteria} IsNullCriteria</li>
+ * <li>{@link org.teiid.query.sql.lang.CompareCriteria} CompareCriteria</li>
+ * <li>{@link org.teiid.query.sql.lang.MatchCriteria} MatchCriteria</li>
+ * <li>{@link org.teiid.query.sql.lang.SetCriteria} SetCriteria</li>
+ * <li>{@link org.teiid.query.sql.lang.SubquerySetCriteria} SubquerySetCriteria</li>
+ * <li>{@link org.teiid.query.sql.lang.IsNullCriteria} IsNullCriteria</li>
* </ul>
*/
public class PredicateCollectorVisitor extends LanguageVisitor {
@@ -109,14 +110,14 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.ExistsCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.ExistsCriteria)
*/
public void visit(ExistsCriteria obj) {
this.predicates.add(obj);
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubqueryCompareCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubqueryCompareCriteria)
*/
public void visit(SubqueryCompareCriteria obj) {
this.predicates.add(obj);
@@ -133,7 +134,7 @@
/**
* Get a collection of predicates discovered while visiting.
- * @return Collection of {@link com.metamatrix.query.sql.lang.PredicateCriteria} subclasses.
+ * @return Collection of {@link org.teiid.query.sql.lang.PredicateCriteria} subclasses.
*/
public Collection getPredicates() {
return this.predicates;
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/ReferenceCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ReferenceCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ReferenceCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,16 +20,17 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Reference;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.Reference;
+
/**
* <p>This visitor class will traverse a language object tree and collect all
* references it finds. </p>
@@ -45,7 +46,7 @@
/**
* Get the references collected by the visitor. This should best be called
* after the visitor has been run on the language object tree.
- * @return Collection of {@link com.metamatrix.query.sql.symbol.ElementSymbol}
+ * @return Collection of {@link org.teiid.query.sql.symbol.ElementSymbol}
*/
public List<Reference> getReferences() {
return this.references;
@@ -63,7 +64,7 @@
/**
* Helper to quickly get the references from obj in a collection.
* @param obj Language object
- * @return List of {@link com.metamatrix.query.sql.symbol.Reference}
+ * @return List of {@link org.teiid.query.sql.symbol.Reference}
*/
public static List<Reference> getReferences(LanguageObject obj) {
ReferenceCollectorVisitor visitor = new ReferenceCollectorVisitor();
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/SQLStringVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/SQLStringVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Arrays;
@@ -31,90 +31,90 @@
import org.teiid.connector.language.SQLReservedWords;
import org.teiid.connector.language.SQLReservedWords.Tokens;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.StringUtil;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.From;
+import org.teiid.query.sql.lang.FromClause;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.JoinPredicate;
+import org.teiid.query.sql.lang.JoinType;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.PredicateCriteria;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.SPParameter;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetClause;
+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.StoredProcedure;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryFromClause;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.UnaryFromClause;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.XQuery;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.Block;
+import org.teiid.query.sql.proc.BreakStatement;
+import org.teiid.query.sql.proc.CommandStatement;
+import org.teiid.query.sql.proc.ContinueStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.LoopStatement;
+import org.teiid.query.sql.proc.RaiseErrorStatement;
+import org.teiid.query.sql.proc.Statement;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.AliasSymbol;
+import org.teiid.query.sql.symbol.AllInGroupSymbol;
+import org.teiid.query.sql.symbol.AllSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.symbol.SelectSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLElement;
+import org.teiid.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.symbol.XMLNamespaces;
+import org.teiid.query.sql.symbol.XMLNamespaces.NamespaceItem;
import org.teiid.resource.cci.SourceSystemFunctions;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.StringUtil;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Create;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.From;
-import com.metamatrix.query.sql.lang.FromClause;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.JoinPredicate;
-import com.metamatrix.query.sql.lang.JoinType;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.PredicateCriteria;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.SPParameter;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.StoredProcedure;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryFromClause;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.UnaryFromClause;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.XQuery;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.Block;
-import com.metamatrix.query.sql.proc.BreakStatement;
-import com.metamatrix.query.sql.proc.CommandStatement;
-import com.metamatrix.query.sql.proc.ContinueStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.LoopStatement;
-import com.metamatrix.query.sql.proc.RaiseErrorStatement;
-import com.metamatrix.query.sql.proc.Statement;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.AllInGroupSymbol;
-import com.metamatrix.query.sql.symbol.AllSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.symbol.SelectSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.XMLAttributes;
-import com.metamatrix.query.sql.symbol.XMLElement;
-import com.metamatrix.query.sql.symbol.XMLForest;
-import com.metamatrix.query.sql.symbol.XMLNamespaces;
-import com.metamatrix.query.sql.symbol.XMLNamespaces.NamespaceItem;
/**
* <p>The SQLStringVisitor will visit a set of language objects and return the
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/StaticSymbolMappingVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/StaticSymbolMappingVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/StaticSymbolMappingVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.Map;
-import com.metamatrix.core.util.Assertion;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.navigator.DeepPreOrderNavigator;
-import com.metamatrix.query.sql.symbol.Symbol;
+import org.teiid.core.util.Assertion;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.navigator.DeepPreOrderNavigator;
+import org.teiid.query.sql.symbol.Symbol;
+
/**
* <p> This class is used to update LanguageObjects by replacing the virtual elements/
* groups present in them with their physical counterparts. It is currently used only
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/ValueIteratorProviderCollectorVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.sql.visitor;
+package org.teiid.query.sql.visitor;
import java.util.ArrayList;
import java.util.Collection;
@@ -28,15 +28,16 @@
import java.util.LinkedList;
import java.util.List;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.ExistsCriteria;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubqueryContainer;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.ScalarSubquery;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.ExistsCriteria;
+import org.teiid.query.sql.lang.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubqueryContainer;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.ScalarSubquery;
+
/**
* <p>This visitor class will traverse a language object tree and collect all language
* objects that implement {@link com.metamatrix.sql.util.ValueIteratorProvider. These
Copied: trunk/engine/src/main/java/org/teiid/query/tempdata (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/tempdata)
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStore.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStore.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,33 +20,34 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.tempdata;
+package org.teiid.query.tempdata;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.sql.lang.Command;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.sql.lang.Command;
+
/**
* @since 5.5
*/
public interface TempTableStore {
- void removeTempTables() throws MetaMatrixComponentException;
+ void removeTempTables() throws TeiidComponentException;
TempMetadataStore getMetadataStore();
- public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, MetaMatrixProcessingException;
+ public TupleSource registerRequest(Command command) throws TeiidComponentException, TeiidProcessingException;
public boolean hasTempTable(Command command);
public Set getAllTempTables();
- public void removeTempTableByName(String tempTableName) throws MetaMatrixComponentException;
+ public void removeTempTableByName(String tempTableName) throws TeiidComponentException;
public TupleBuffer getTupleSourceID(String tempTableName);
}
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStoreImpl.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/tempdata/TempTableStoreImpl.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTableStoreImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.tempdata;
+package org.teiid.query.tempdata;
import java.util.ArrayList;
import java.util.Arrays;
@@ -30,38 +30,39 @@
import java.util.Map;
import java.util.Set;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryProcessingException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.buffer.TupleBuffer;
-import com.metamatrix.common.buffer.TupleSource;
-import com.metamatrix.common.buffer.BufferManager.TupleSourceType;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.processor.CollectionTupleSource;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Create;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.ProcedureContainer;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryProcessingException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.common.buffer.TupleBuffer;
+import org.teiid.common.buffer.TupleSource;
+import org.teiid.common.buffer.BufferManager.TupleSourceType;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.processor.CollectionTupleSource;
+import org.teiid.query.processor.relational.RelationalNode;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Create;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.ProcedureContainer;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+
/**
* @since 5.5
*/
@@ -79,7 +80,7 @@
private boolean done;
private List<?> currentTuple;
- private UpdateTupleSource(String groupKey, TupleBuffer tsId, Criteria crit) throws MetaMatrixComponentException {
+ private UpdateTupleSource(String groupKey, TupleBuffer tsId, Criteria crit) throws TeiidComponentException {
this.groupKey = groupKey;
this.oldBuffer = tsId;
this.ts = tsId.createIndexedTupleSource();
@@ -91,8 +92,8 @@
}
@Override
- public List<?> nextTuple() throws MetaMatrixComponentException,
- MetaMatrixProcessingException {
+ public List<?> nextTuple() throws TeiidComponentException,
+ TeiidProcessingException {
if (done) {
return null;
}
@@ -113,13 +114,13 @@
return Arrays.asList(updateCount);
}
- protected void addTuple(List<?> tuple) throws MetaMatrixComponentException {
+ protected void addTuple(List<?> tuple) throws TeiidComponentException {
newBuffer.addTuple(tuple);
}
- protected abstract void tuplePassed(List<?> tuple) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException;
+ protected abstract void tuplePassed(List<?> tuple) throws ExpressionEvaluationException, BlockedException, TeiidComponentException;
- protected abstract void tupleFailed(List<?> tuple) throws MetaMatrixComponentException;
+ protected abstract void tupleFailed(List<?> tuple) throws TeiidComponentException;
@Override
public List<SingleElementSymbol> getSchema() {
@@ -149,7 +150,7 @@
this.parentTempTableStore = parentTempTableStore;
}
- public void addTempTable(String tempTableName, List columns, boolean removeExistingTable) throws MetaMatrixComponentException, QueryProcessingException{
+ public void addTempTable(String tempTableName, List columns, boolean removeExistingTable) throws TeiidComponentException, QueryProcessingException{
if(tempMetadataStore.getTempGroupID(tempTableName) != null) {
if(!removeExistingTable) {
throw new QueryProcessingException(QueryExecPlugin.Util.getString("TempTableStore.table_exist_error", tempTableName));//$NON-NLS-1$
@@ -165,7 +166,7 @@
groupToTupleSourceID.put(tempTableName, tupleBuffer);
}
- public void removeTempTableByName(String tempTableName) throws MetaMatrixComponentException {
+ public void removeTempTableByName(String tempTableName) throws TeiidComponentException {
tempMetadataStore.removeTempGroup(tempTableName);
TupleBuffer tsId = this.groupToTupleSourceID.remove(tempTableName);
if(tsId != null) {
@@ -177,7 +178,7 @@
return tempMetadataStore;
}
- public TupleSource registerRequest(Command command) throws MetaMatrixComponentException, ExpressionEvaluationException, QueryProcessingException{
+ public TupleSource registerRequest(Command command) throws TeiidComponentException, ExpressionEvaluationException, QueryProcessingException{
if (command instanceof Query) {
Query query = (Query)command;
GroupSymbol group = (GroupSymbol)query.getFrom().getGroups().get(0);
@@ -204,7 +205,7 @@
@Override
protected void tuplePassed(List<?> tuple)
throws ExpressionEvaluationException,
- BlockedException, MetaMatrixComponentException {
+ BlockedException, TeiidComponentException {
List<Object> newTuple = new ArrayList<Object>(tuple);
for (Map.Entry<ElementSymbol, Expression> entry : update.getChangeList().getClauseMap().entrySet()) {
newTuple.set((Integer)lookup.get(entry.getKey()), eval.evaluate(entry.getValue(), tuple));
@@ -213,7 +214,7 @@
addTuple(newTuple);
}
- protected void tupleFailed(java.util.List<?> tuple) throws MetaMatrixComponentException {
+ protected void tupleFailed(java.util.List<?> tuple) throws TeiidComponentException {
addTuple(tuple);
}
};
@@ -230,11 +231,11 @@
@Override
protected void tuplePassed(List<?> tuple)
throws ExpressionEvaluationException,
- BlockedException, MetaMatrixComponentException {
+ BlockedException, TeiidComponentException {
updateCount++;
}
- protected void tupleFailed(java.util.List<?> tuple) throws MetaMatrixComponentException {
+ protected void tupleFailed(java.util.List<?> tuple) throws TeiidComponentException {
addTuple(tuple);
}
};
@@ -252,13 +253,13 @@
return null;
}
- public void removeTempTables() throws MetaMatrixComponentException{
+ public void removeTempTables() throws TeiidComponentException{
for (String name : new ArrayList<String>( groupToTupleSourceID.keySet() )) {
removeTempTableByName(name);
}
}
- private TupleBuffer getTupleSourceID(String tempTableID, Command command) throws MetaMatrixComponentException, QueryProcessingException{
+ private TupleBuffer getTupleSourceID(String tempTableID, Command command) throws TeiidComponentException, QueryProcessingException{
TupleBuffer tsID = groupToTupleSourceID.get(tempTableID);
if(tsID != null) {
return tsID;
@@ -285,7 +286,7 @@
return groupToTupleSourceID.get(tempTableID);
}
- private TupleSource addTuple(Insert insert, TupleBuffer tsId) throws MetaMatrixComponentException, ExpressionEvaluationException {
+ private TupleSource addTuple(Insert insert, TupleBuffer tsId) throws TeiidComponentException, ExpressionEvaluationException {
GroupSymbol group = insert.getGroup();
int tuplesAdded = 0;
try {
@@ -301,13 +302,13 @@
tuplesAdded = tuples.size();
} catch (QueryMetadataException err) {
- throw new MetaMatrixComponentException(err);
+ throw new TeiidComponentException(err);
}
return CollectionTupleSource.createUpdateCountTupleSource(tuplesAdded);
}
- public static List<List<Object>> getBulkRows(Insert insert, List<ElementSymbol> elements) throws ExpressionEvaluationException, BlockedException, MetaMatrixComponentException {
+ public static List<List<Object>> getBulkRows(Insert insert, List<ElementSymbol> elements) throws ExpressionEvaluationException, BlockedException, TeiidComponentException {
int bulkRowCount = 1;
if (insert.isBulk()) {
Constant c = (Constant)insert.getValues().get(0);
Copied: trunk/engine/src/main/java/org/teiid/query/util (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/util)
Modified: trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/CommandContext.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/util/CommandContext.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.util;
+package org.teiid.query.util;
import java.io.Serializable;
import java.util.LinkedList;
@@ -29,20 +29,21 @@
import java.util.Set;
import java.util.TimeZone;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryProcessingException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.core.util.ArgCheck;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.eval.SecurityFunctionEvaluator;
-import com.metamatrix.query.execution.QueryExecPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.relational.PlanToProcessConverter;
-import com.metamatrix.query.processor.QueryProcessor;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.util.VariableContext;
+import org.teiid.api.exception.query.QueryProcessingException;
+import org.teiid.common.buffer.BufferManager;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.util.ArgCheck;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.eval.SecurityFunctionEvaluator;
+import org.teiid.query.execution.QueryExecPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.optimizer.relational.PlanToProcessConverter;
+import org.teiid.query.processor.QueryProcessor;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.util.VariableContext;
+
/**
* Defines the context that a command is processing in. For example, this defines
* who is processing the command and why. Also, this class (or subclasses) provide
@@ -398,13 +399,13 @@
this.variableContext = toPush;
}
- public Object getFromContext(Expression expression) throws MetaMatrixComponentException {
+ public Object getFromContext(Expression expression) throws TeiidComponentException {
if (variableContext == null || !(expression instanceof ElementSymbol)) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
}
Object value = variableContext.getValue((ElementSymbol)expression);
if (value == null && !variableContext.containsVariable((ElementSymbol)expression)) {
- throw new MetaMatrixComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
+ throw new TeiidComponentException(ErrorMessageKeys.PROCESSOR_0033, QueryPlugin.Util.getString(ErrorMessageKeys.PROCESSOR_0033, expression, "No value was available")); //$NON-NLS-1$
}
return value;
}
Modified: trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/ContextProperties.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/util/ContextProperties.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.util;
+package org.teiid.query.util;
/**
* Defines constants that are used within the DQP, provided to the query engine as
Modified: trunk/engine/src/main/java/org/teiid/query/util/ErrorMessageKeys.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/ErrorMessageKeys.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/util/ErrorMessageKeys.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -24,7 +24,7 @@
* Date: Apr 3, 2003
* Time: 11:01:10 AM
*/
-package com.metamatrix.query.util;
+package org.teiid.query.util;
/**
* LogMessageKeys.
Modified: trunk/engine/src/main/java/org/teiid/query/util/Permutation.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/Permutation.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/util/Permutation.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,13 +20,14 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.util;
+package org.teiid.query.util;
import java.util.Iterator;
import java.util.NoSuchElementException;
-import com.metamatrix.core.util.ArgCheck;
+import org.teiid.core.util.ArgCheck;
+
public class Permutation {
private Object[] items;
Modified: trunk/engine/src/main/java/org/teiid/query/util/XMLFormatConstants.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/util/XMLFormatConstants.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/util/XMLFormatConstants.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.util;
+package org.teiid.query.util;
/**
Copied: trunk/engine/src/main/java/org/teiid/query/validator (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/validator)
Modified: trunk/engine/src/main/java/org/teiid/query/validator/AbstractValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/AbstractValidationVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/AbstractValidationVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,27 +20,28 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.symbol.ElementSymbol;
+
public class AbstractValidationVisitor extends LanguageVisitor {
// Exception handling
- private MetaMatrixComponentException exception;
+ private TeiidComponentException exception;
private LanguageObject exceptionObject;
// Validation error handling
@@ -84,17 +85,17 @@
this.report.addItem(new ValidatorFailure(message, invalidObjs));
}
- protected void handleException(MetaMatrixException e) {
+ protected void handleException(TeiidException e) {
handleException(e, null);
}
- protected void handleException(MetaMatrixException e, LanguageObject obj) {
+ protected void handleException(TeiidException e, LanguageObject obj) {
// Store exception information
this.exceptionObject = obj;
- if(e instanceof MetaMatrixComponentException) {
- this.exception = (MetaMatrixComponentException) e;
+ if(e instanceof TeiidComponentException) {
+ this.exception = (TeiidComponentException) e;
} else {
- this.exception = new MetaMatrixComponentException(e);
+ this.exception = new TeiidComponentException(e);
}
// Abort the validation process
@@ -103,7 +104,7 @@
// ######################### Report results info #########################
- public MetaMatrixComponentException getException() {
+ public TeiidComponentException getException() {
return this.exception;
}
@@ -145,7 +146,7 @@
}
} catch(QueryMetadataException e) {
handleException(e, symbol);
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e, symbol);
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/AggregateValidationVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/AggregateValidationVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,27 +20,27 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.Collection;
import java.util.Set;
import org.teiid.connector.language.SQLReservedWords;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.CaseExpression;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.SearchedCaseExpression;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.CaseExpression;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.SearchedCaseExpression;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
/**
Modified: trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/UpdateValidationVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/UpdateValidationVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,22 +20,23 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.metadata.TempMetadataID;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.query.sql.symbol.*;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.core.TeiidException;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.metadata.TempMetadataID;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.symbol.*;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
+
/**
* <p> This visitor is used to validate updates through virtual groups. The command defining
* the virtual group is always a <code>Query</code>. This object visits various parts of
@@ -193,7 +194,7 @@
}
}
}
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
handleException(e);
}
}
@@ -220,7 +221,7 @@
// this method should only be executed if the element is a required element
// and none of cases above are true
handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0010, element));
- } catch(MetaMatrixException e) {
+ } catch(TeiidException e) {
handleException(e);
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidationVisitor.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.ArrayList;
import java.util.Collection;
@@ -33,87 +33,87 @@
import javax.xml.xpath.XPathExpressionException;
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.FunctionExecutionException;
+import org.teiid.api.exception.query.QueryMetadataException;
+import org.teiid.api.exception.query.QueryValidatorException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.eval.Evaluator;
+import org.teiid.query.function.FunctionLibrary;
+import org.teiid.query.function.source.XMLSystemFunctions;
+import org.teiid.query.metadata.SupportConstants;
+import org.teiid.query.resolver.util.ResolverUtil;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.LanguageVisitor;
+import org.teiid.query.sql.ProcedureReservedWords;
+import org.teiid.query.sql.lang.BatchedUpdateCommand;
+import org.teiid.query.sql.lang.BetweenCriteria;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.lang.CompareCriteria;
+import org.teiid.query.sql.lang.CompoundCriteria;
+import org.teiid.query.sql.lang.Criteria;
+import org.teiid.query.sql.lang.Delete;
+import org.teiid.query.sql.lang.DependentSetCriteria;
+import org.teiid.query.sql.lang.Drop;
+import org.teiid.query.sql.lang.DynamicCommand;
+import org.teiid.query.sql.lang.GroupBy;
+import org.teiid.query.sql.lang.Insert;
+import org.teiid.query.sql.lang.Into;
+import org.teiid.query.sql.lang.IsNullCriteria;
+import org.teiid.query.sql.lang.Limit;
+import org.teiid.query.sql.lang.MatchCriteria;
+import org.teiid.query.sql.lang.NotCriteria;
+import org.teiid.query.sql.lang.Option;
+import org.teiid.query.sql.lang.OrderBy;
+import org.teiid.query.sql.lang.OrderByItem;
+import org.teiid.query.sql.lang.Query;
+import org.teiid.query.sql.lang.QueryCommand;
+import org.teiid.query.sql.lang.Select;
+import org.teiid.query.sql.lang.SetClause;
+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.SubqueryCompareCriteria;
+import org.teiid.query.sql.lang.SubquerySetCriteria;
+import org.teiid.query.sql.lang.Update;
+import org.teiid.query.sql.lang.SetQuery.Operation;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.proc.AssignmentStatement;
+import org.teiid.query.sql.proc.CreateUpdateProcedureCommand;
+import org.teiid.query.sql.proc.CriteriaSelector;
+import org.teiid.query.sql.proc.DeclareStatement;
+import org.teiid.query.sql.proc.HasCriteria;
+import org.teiid.query.sql.proc.IfStatement;
+import org.teiid.query.sql.proc.TranslateCriteria;
+import org.teiid.query.sql.proc.WhileStatement;
+import org.teiid.query.sql.symbol.AbstractCaseExpression;
+import org.teiid.query.sql.symbol.AggregateSymbol;
+import org.teiid.query.sql.symbol.Constant;
+import org.teiid.query.sql.symbol.ElementSymbol;
+import org.teiid.query.sql.symbol.Expression;
+import org.teiid.query.sql.symbol.ExpressionSymbol;
+import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.sql.symbol.GroupSymbol;
+import org.teiid.query.sql.symbol.Reference;
+import org.teiid.query.sql.symbol.SingleElementSymbol;
+import org.teiid.query.sql.symbol.XMLAttributes;
+import org.teiid.query.sql.symbol.XMLForest;
+import org.teiid.query.sql.util.SymbolMap;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor;
+import org.teiid.query.sql.visitor.CommandCollectorVisitor;
+import org.teiid.query.sql.visitor.ElementCollectorVisitor;
+import org.teiid.query.sql.visitor.EvaluatableVisitor;
+import org.teiid.query.sql.visitor.FunctionCollectorVisitor;
+import org.teiid.query.sql.visitor.GroupCollectorVisitor;
+import org.teiid.query.sql.visitor.PredicateCollectorVisitor;
+import org.teiid.query.sql.visitor.SQLStringVisitor;
+import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.util.ErrorMessageKeys;
import org.teiid.resource.cci.SourceSystemFunctions;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.source.XMLSystemFunctions;
-import com.metamatrix.query.metadata.SupportConstants;
-import com.metamatrix.query.resolver.util.ResolverUtil;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.LanguageVisitor;
-import com.metamatrix.query.sql.ProcedureReservedWords;
-import com.metamatrix.query.sql.lang.BatchedUpdateCommand;
-import com.metamatrix.query.sql.lang.BetweenCriteria;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.CompareCriteria;
-import com.metamatrix.query.sql.lang.CompoundCriteria;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.lang.Delete;
-import com.metamatrix.query.sql.lang.DependentSetCriteria;
-import com.metamatrix.query.sql.lang.Drop;
-import com.metamatrix.query.sql.lang.DynamicCommand;
-import com.metamatrix.query.sql.lang.GroupBy;
-import com.metamatrix.query.sql.lang.Insert;
-import com.metamatrix.query.sql.lang.Into;
-import com.metamatrix.query.sql.lang.IsNullCriteria;
-import com.metamatrix.query.sql.lang.Limit;
-import com.metamatrix.query.sql.lang.MatchCriteria;
-import com.metamatrix.query.sql.lang.NotCriteria;
-import com.metamatrix.query.sql.lang.Option;
-import com.metamatrix.query.sql.lang.OrderBy;
-import com.metamatrix.query.sql.lang.OrderByItem;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.lang.QueryCommand;
-import com.metamatrix.query.sql.lang.Select;
-import com.metamatrix.query.sql.lang.SetClause;
-import com.metamatrix.query.sql.lang.SetClauseList;
-import com.metamatrix.query.sql.lang.SetCriteria;
-import com.metamatrix.query.sql.lang.SetQuery;
-import com.metamatrix.query.sql.lang.SubqueryCompareCriteria;
-import com.metamatrix.query.sql.lang.SubquerySetCriteria;
-import com.metamatrix.query.sql.lang.Update;
-import com.metamatrix.query.sql.lang.SetQuery.Operation;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.proc.AssignmentStatement;
-import com.metamatrix.query.sql.proc.CreateUpdateProcedureCommand;
-import com.metamatrix.query.sql.proc.CriteriaSelector;
-import com.metamatrix.query.sql.proc.DeclareStatement;
-import com.metamatrix.query.sql.proc.HasCriteria;
-import com.metamatrix.query.sql.proc.IfStatement;
-import com.metamatrix.query.sql.proc.TranslateCriteria;
-import com.metamatrix.query.sql.proc.WhileStatement;
-import com.metamatrix.query.sql.symbol.AbstractCaseExpression;
-import com.metamatrix.query.sql.symbol.AggregateSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-import com.metamatrix.query.sql.symbol.Function;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.Reference;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.sql.symbol.XMLAttributes;
-import com.metamatrix.query.sql.symbol.XMLForest;
-import com.metamatrix.query.sql.util.SymbolMap;
-import com.metamatrix.query.sql.visitor.AggregateSymbolCollectorVisitor;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ElementCollectorVisitor;
-import com.metamatrix.query.sql.visitor.EvaluatableVisitor;
-import com.metamatrix.query.sql.visitor.FunctionCollectorVisitor;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.sql.visitor.PredicateCollectorVisitor;
-import com.metamatrix.query.sql.visitor.SQLStringVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.util.ErrorMessageKeys;
public class ValidationVisitor extends AbstractValidationVisitor {
@@ -200,7 +200,7 @@
}
} catch (QueryMetadataException e) {
handleException(e);
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e);
}
}
@@ -293,9 +293,9 @@
if(ValidationVisitor.isNonComparable(resolvedLookup.getKeyElement())) {
handleValidationError(QueryPlugin.Util.getString("ValidationVisitor.invalid_lookup_key", resolvedLookup.getKeyElement()), resolvedLookup.getKeyElement()); //$NON-NLS-1$
}
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e, obj);
- } catch (MetaMatrixProcessingException e) {
+ } catch (TeiidProcessingException e) {
handleException(e, obj);
}
} else if (obj.getFunctionDescriptor().getName().equalsIgnoreCase(FunctionLibrary.CONTEXT)) {
@@ -691,7 +691,7 @@
if(! getMetadata().groupSupports(groupSymbol.getMetadataID(), SupportConstants.Group.UPDATE)) {
handleValidationError(QueryPlugin.Util.getString(ErrorMessageKeys.VALIDATOR_0033, SQLStringVisitor.getSQLString(groupSymbol)), groupSymbol);
}
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e, groupSymbol);
}
}
@@ -804,7 +804,7 @@
}
}
}// end of while
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e, obj);
}
}
@@ -869,7 +869,7 @@
}
}
}// end of while
- } catch(MetaMatrixComponentException e) {
+ } catch(TeiidComponentException e) {
handleException(e, update);
}
@@ -919,7 +919,7 @@
continue;
}
}
- } catch (MetaMatrixComponentException e) {
+ } catch (TeiidComponentException e) {
handleException(e, query);
}
}
@@ -964,7 +964,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.BetweenCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.BetweenCriteria)
* @since 4.3
*/
public void visit(BetweenCriteria obj) {
@@ -975,7 +975,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.IsNullCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.IsNullCriteria)
* @since 4.3
*/
public void visit(IsNullCriteria obj) {
@@ -983,7 +983,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.MatchCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.MatchCriteria)
* @since 4.3
*/
public void visit(MatchCriteria obj) {
@@ -991,7 +991,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.NotCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.NotCriteria)
* @since 4.3
*/
public void visit(NotCriteria obj) {
@@ -999,7 +999,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SetCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SetCriteria)
* @since 4.3
*/
public void visit(SetCriteria obj) {
@@ -1010,7 +1010,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.SubqueryCompareCriteria)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.SubqueryCompareCriteria)
* @since 4.3
*/
public void visit(SubqueryCompareCriteria obj) {
@@ -1041,7 +1041,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.DynamicCommand)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.DynamicCommand)
*/
public void visit(DynamicCommand obj) {
if (obj.getIntoGroup() != null) {
@@ -1053,7 +1053,7 @@
}
/**
- * @see com.metamatrix.query.sql.LanguageVisitor#visit(com.metamatrix.query.sql.lang.Drop)
+ * @see org.teiid.query.sql.LanguageVisitor#visit(org.teiid.query.sql.lang.Drop)
*/
public void visit(Drop drop) {
if (!drop.getTable().isTempTable()) {
Modified: trunk/engine/src/main/java/org/teiid/query/validator/Validator.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/Validator.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/Validator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,29 +20,30 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.Iterator;
import java.util.Map;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.Command;
+import org.teiid.query.sql.navigator.PreOrderNavigator;
+import org.teiid.query.sql.visitor.CommandCollectorVisitor;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.navigator.PreOrderNavigator;
-import com.metamatrix.query.sql.visitor.CommandCollectorVisitor;
public class Validator {
- public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata) throws MetaMatrixComponentException {
+ public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata) throws TeiidComponentException {
ValidatorReport report1 = Validator.validate(object, metadata, new ValidationVisitor());
return report1;
}
public static final ValidatorReport validate(LanguageObject object, QueryMetadataInterface metadata, AbstractValidationVisitor visitor)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
// Construct combined runtime / query metadata if necessary
if(object instanceof Command) {
@@ -71,7 +72,7 @@
}
private static final void executeValidation(LanguageObject object, final QueryMetadataInterface metadata, final AbstractValidationVisitor visitor)
- throws MetaMatrixComponentException {
+ throws TeiidComponentException {
// Reset visitor
visitor.reset();
@@ -92,7 +93,7 @@
object.acceptVisitor(nav);
// If an error occurred, throw an exception
- MetaMatrixComponentException e = visitor.getException();
+ TeiidComponentException e = visitor.getException();
if(e != null) {
throw e;
}
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidatorFailure.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidatorFailure.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidatorFailure.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.*;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.report.ReportItem;
+import org.teiid.query.report.ReportItem;
+import org.teiid.query.sql.LanguageObject;
+
public class ValidatorFailure extends ReportItem {
public static final String VALIDATOR_FAILURE = "ValidatorFailure"; //$NON-NLS-1$
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidatorReport.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/validator/ValidatorReport.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidatorReport.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,15 +20,16 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.validator;
+package org.teiid.query.validator;
import java.util.Collection;
import java.util.Iterator;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.report.ActivityReport;
-import com.metamatrix.query.util.ErrorMessageKeys;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.report.ActivityReport;
+import org.teiid.query.util.ErrorMessageKeys;
+
public class ValidatorReport extends ActivityReport {
public static final String VALIDATOR_REPORT = "Validator Report"; //$NON-NLS-1$
Copied: trunk/engine/src/main/java/org/teiid/query/xquery/XQueryExpression.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/xquery/XQueryExpression.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/xquery/XQueryExpression.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/XQueryExpression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,70 @@
+/*
+ * 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.xquery;
+
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.XMLTranslator;
+
+/**
+ * An XQueryExpression - the object representation of
+ * a compiled XQuery. Must be thread-safe and immutable.
+ */
+public interface XQueryExpression {
+
+ /**
+ * Return the compiled XQueryExpression - the result of this
+ * call should be used as a parameter to the
+ * {@link #getDocumentNames getDocumentNames} and
+ * {@link #evaluateXQuery evaluateXQuery} methods.
+ * A null return value is interpreted to mean that XQueries
+ * are not supported by this engine at all.
+ * @param xQueryString the original XQuery String
+ * @throws TeiidProcessingException if xQueryString is
+ * invalid and fails to compile
+ */
+ public void compileXQuery(String xQueryString)
+ throws TeiidProcessingException;
+
+
+ /**
+ * Evaluate the XQuery and return results. A null return
+ * value is interpreted to mean that XQueries are not supported
+ * by this engine.
+ * @param compiledXQuery compiled XQueryExpression
+ * @throws TeiidProcessingException if xQueryString is
+ * invalid and fails to compile
+ */
+ public XMLTranslator evaluateXQuery(XQuerySQLEvaluator sqlEval)
+ throws TeiidProcessingException, TeiidComponentException;
+
+
+ /**
+ * This method sets whether the documents should be returned in compact
+ * format (no extraneous whitespace). Non-compact format is more human-readable
+ * (and bigger). Additional formats may be possible in future.
+ * @param xmlFormat A string giving the format in which xml results need to be returned
+ */
+ public void setXMLFormat(String xmlFormat);
+
+}
Copied: trunk/engine/src/main/java/org/teiid/query/xquery/XQuerySQLEvaluator.java (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/xquery/XQuerySQLEvaluator.java)
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/xquery/XQuerySQLEvaluator.java (rev 0)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/XQuerySQLEvaluator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -0,0 +1,55 @@
+/*
+ * 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.xquery;
+
+import javax.xml.transform.Source;
+
+import org.teiid.api.exception.query.ExpressionEvaluationException;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.common.buffer.BlockedException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+
+
+
+/**
+ * @since 4.3
+ */
+public interface XQuerySQLEvaluator {
+
+ /**
+ * Execute a SQL string that returns an XML result
+ * @param sql SQL string, typically an EXEC against an xml service or virtual document
+ * @throws QueryParserException If sql parameter is not sql
+ * @throws TeiidProcessingException If execution of the sql fails due to a bad query
+ * @throws TeiidComponentException If execution of the sql fails due to an internal failure
+ */
+ Source executeSQL(String sql) throws QueryParserException, TeiidProcessingException, TeiidComponentException;
+
+ /**
+ * Closes any resources opened during the evaluation
+ */
+ void close() throws TeiidComponentException ;
+
+ Object getParameterValue(String key) throws ExpressionEvaluationException, BlockedException, TeiidComponentException;
+}
Copied: trunk/engine/src/main/java/org/teiid/query/xquery/saxon (from rev 2112, trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon)
Modified: trunk/engine/src/main/java/org/teiid/query/xquery/saxon/DocFunctionURIResolver.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/DocFunctionURIResolver.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/saxon/DocFunctionURIResolver.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.xquery.saxon;
+package org.teiid.query.xquery.saxon;
import java.util.Map;
@@ -29,10 +29,11 @@
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.query.xquery.XQuerySQLEvaluator;
+import org.teiid.api.exception.query.QueryParserException;
+import org.teiid.query.xquery.XQuerySQLEvaluator;
+
/**
* A URI resolver for XQuery 'doc' function. This resolver is knows
* how to handle SQL calls from this URI, such that it can execute the
Modified: trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/query/xquery/saxon/SaxonXQueryExpression.java 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/java/org/teiid/query/xquery/saxon/SaxonXQueryExpression.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,7 +20,7 @@
* 02110-1301 USA.
*/
-package com.metamatrix.query.xquery.saxon;
+package org.teiid.query.xquery.saxon;
import java.io.Writer;
import java.sql.SQLException;
@@ -37,6 +37,14 @@
import javax.xml.transform.TransformerException;
import javax.xml.transform.stream.StreamResult;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidProcessingException;
+import org.teiid.core.types.XMLTranslator;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.util.XMLFormatConstants;
+import org.teiid.query.xquery.XQueryExpression;
+import org.teiid.query.xquery.XQuerySQLEvaluator;
+
import net.sf.saxon.Configuration;
import net.sf.saxon.om.NodeInfo;
import net.sf.saxon.query.DynamicQueryContext;
@@ -44,13 +52,6 @@
import net.sf.saxon.query.StaticQueryContext;
import net.sf.saxon.trans.XPathException;
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.common.types.XMLTranslator;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.util.XMLFormatConstants;
-import com.metamatrix.query.xquery.XQueryExpression;
-import com.metamatrix.query.xquery.XQuerySQLEvaluator;
/**
* Saxon implementation of MetaMatrix XQueryExpression
@@ -83,7 +84,7 @@
* @see com.metamatrix.query.xquery.XQueryEngine#compileXQuery(java.lang.String)
*/
public void compileXQuery(String xQueryString)
- throws MetaMatrixProcessingException{
+ throws TeiidProcessingException{
this.xQueryString = xQueryString;
@@ -95,7 +96,7 @@
try {
this.xQuery = context.compileQuery(xQueryString);
}catch(XPathException e) {
- throw new MetaMatrixProcessingException(e);
+ throw new TeiidProcessingException(e);
}
// Scrape parameter names from xquery prolog
@@ -118,10 +119,10 @@
}
/**
- * @see com.metamatrix.query.xquery.XQueryEngine#evaluateXQuery(com.metamatrix.query.xquery.XQueryExpression)
+ * @see com.metamatrix.query.xquery.XQueryEngine#evaluateXQuery(org.teiid.query.xquery.XQueryExpression)
*/
public XMLTranslator evaluateXQuery(XQuerySQLEvaluator sqlEval)
- throws MetaMatrixProcessingException, MetaMatrixComponentException {
+ throws TeiidProcessingException, TeiidComponentException {
Configuration config = new Configuration();
DynamicQueryContext dynamicContext = new DynamicQueryContext(config);
@@ -138,7 +139,7 @@
try {
value = ((SQLXML)value).getSource(null);
} catch (SQLException e) {
- throw new MetaMatrixProcessingException(e);
+ throw new TeiidProcessingException(e);
}
}
dynamicContext.setParameter(entry.getKey(), value);
@@ -157,15 +158,15 @@
}
cause = nestedCause;
}
- if(cause instanceof MetaMatrixProcessingException) {
- throw (MetaMatrixProcessingException) cause;
- } else if(cause instanceof MetaMatrixComponentException) {
- throw (MetaMatrixComponentException) cause;
+ if(cause instanceof TeiidProcessingException) {
+ throw (TeiidProcessingException) cause;
+ } else if(cause instanceof TeiidComponentException) {
+ throw (TeiidComponentException) cause;
}
if (cause instanceof RuntimeException) {
- throw new MetaMatrixComponentException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_xquery")); //$NON-NLS-1$
+ throw new TeiidComponentException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_xquery")); //$NON-NLS-1$
}
- throw new MetaMatrixProcessingException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_xquery")); //$NON-NLS-1$
+ throw new TeiidProcessingException(e, QueryPlugin.Util.getString("SaxonXQueryExpression.bad_xquery")); //$NON-NLS-1$
}
// Read results
@@ -189,7 +190,7 @@
};
}
}
- throw new MetaMatrixProcessingException(QueryPlugin.Util.getString("wrong_result_type")); //$NON-NLS-1$
+ throw new TeiidProcessingException(QueryPlugin.Util.getString("wrong_result_type")); //$NON-NLS-1$
}
/**
Copied: trunk/engine/src/main/java/org/teiid/vdb/runtime (from rev 2113, trunk/engine/src/main/java/com/metamatrix/vdb/runtime)
Modified: trunk/engine/src/main/java/org/teiid/vdb/runtime/VDBKey.java
===================================================================
--- trunk/engine/src/main/java/com/metamatrix/vdb/runtime/VDBKey.java 2010-05-11 16:40:58 UTC (rev 2113)
+++ trunk/engine/src/main/java/org/teiid/vdb/runtime/VDBKey.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -20,12 +20,13 @@
* 02110-1301 USA.
*/
-package com.metamatrix.vdb.runtime;
+package org.teiid.vdb.runtime;
import java.io.Serializable;
-import com.metamatrix.core.util.HashCodeUtil;
+import org.teiid.core.util.HashCodeUtil;
+
public class VDBKey implements Serializable{
private static final long serialVersionUID = -7249750823144856081L;
Copied: trunk/engine/src/main/javacc/org (from rev 2112, trunk/engine/src/main/javacc/com)
Copied: trunk/engine/src/main/javacc/org/teiid (from rev 2112, trunk/engine/src/main/javacc/com/metamatrix)
Modified: trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj
===================================================================
--- trunk/engine/src/main/javacc/com/metamatrix/query/parser/SQLParser.jj 2010-05-11 03:40:11 UTC (rev 2112)
+++ trunk/engine/src/main/javacc/org/teiid/query/parser/SQLParser.jj 2010-05-11 22:01:58 UTC (rev 2117)
@@ -11,16 +11,16 @@
PARSER_BEGIN(SQLParser)
-package com.metamatrix.query.parser;
+package org.teiid.query.parser;
import java.math.BigInteger;
import java.util.*;
-import com.metamatrix.common.types.*;
-import com.metamatrix.query.QueryPlugin;
-import com.metamatrix.query.sql.LanguageObject;
-import com.metamatrix.query.sql.lang.*;
-import com.metamatrix.query.sql.proc.*;
-import com.metamatrix.query.sql.symbol.*;
+import org.teiid.core.types.*;
+import org.teiid.query.QueryPlugin;
+import org.teiid.query.sql.LanguageObject;
+import org.teiid.query.sql.lang.*;
+import org.teiid.query.sql.proc.*;
+import org.teiid.query.sql.symbol.*;
/**
* <p>The SQLParser is a JavaCC-generated parser that reads a SQL string and produces a
Copied: trunk/engine/src/main/resources/org/teiid/dqp (from rev 2112, trunk/engine/src/main/resources/com/metamatrix/dqp)
Copied: trunk/engine/src/main/resources/org/teiid/query (from rev 2112, trunk/engine/src/main/resources/com/metamatrix/query)
Deleted: trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/BufferManagerFactory.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,66 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.buffer.impl.BufferManagerImpl;
-import com.metamatrix.common.buffer.impl.MemoryStorageManager;
-
-/**
- * <p>Factory for BufferManager instances. One method will get
- * a server buffer manager, as it should be instantiated in a running
- * MetaMatrix server. That BufferManager is configured mostly by the
- * passed in properties.</p>
- *
- * <p>The other method returns a stand-alone, in-memory buffer manager. This
- * is typically used for either in-memory testing or any time the
- * query processor component is not expected to run out of memory, such as
- * within the modeler.</p>
- */
-public class BufferManagerFactory {
-
- private static BufferManager INSTANCE;
-
- /**
- * Helper to get a buffer manager all set up for unmanaged standalone use. This is
- * typically used for testing or when memory is not an issue.
- * @return BufferManager ready for use
- */
- public static BufferManager getStandaloneBufferManager() {
- if (INSTANCE == null) {
- BufferManagerImpl bufferMgr = new BufferManagerImpl();
- try {
- bufferMgr.initialize();
- } catch (MetaMatrixComponentException e) {
- throw new RuntimeException(e);
- }
-
- // Add unmanaged memory storage manager
- bufferMgr.setStorageManager(new MemoryStorageManager());
- INSTANCE = bufferMgr;
- }
-
- return INSTANCE;
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBatch.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBatch.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBatch.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,56 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-
-public class TestTupleBatch extends TestCase {
-
- public TestTupleBatch(String name) {
- super(name);
- }
-
- public TupleBatch exampleBatch(int rowBegin, int numRows, int numColumns) {
- List rows = new ArrayList();
- for(int i=0; i<numRows; i++) {
- List row = new ArrayList();
- for(int j=0; j<numColumns; j++) {
- row.add("data-" + (rowBegin + i) + "-" + j); //$NON-NLS-1$ //$NON-NLS-2$
- }
- rows.add(row);
- }
- return new TupleBatch(rowBegin, rows);
- }
-
- /*
- * Test for void TupleBatch(int, List)
- */
- public void testTupleBatch() {
- exampleBatch(0, 10, 2);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/common/buffer/TestTupleBuffer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,85 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.common.buffer;
-
-import static org.junit.Assert.*;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-
-public class TestTupleBuffer {
-
- @Test public void testForwardOnly() throws Exception {
- ElementSymbol x = new ElementSymbol("x"); //$NON-NLS-1$
- x.setType(DataTypeManager.DefaultDataClasses.INTEGER);
- List<ElementSymbol> schema = Arrays.asList(x);
- TupleBuffer tb = new TupleBuffer(new BatchManager() {
-
- @Override
- public void remove() {
-
- }
-
- @Override
- public ManagedBatch createManagedBatch(final TupleBatch batch)
- throws MetaMatrixComponentException {
- return new ManagedBatch() {
-
- @Override
- public void remove() {
-
- }
-
- @Override
- public TupleBatch getBatch(boolean cache, String[] types)
- throws MetaMatrixComponentException {
- return batch;
- }
- };
- }
- }, "x", schema, 32); //$NON-NLS-1$
- tb.setForwardOnly(true);
- tb.addTuple(Arrays.asList(1));
- TupleBatch batch = tb.getBatch(1);
- assertTrue(!batch.getTerminationFlag());
- assertEquals(1, batch.getBeginRow());
- try {
- tb.getBatch(1);
- fail("expected exception"); //$NON-NLS-1$
- } catch (AssertionError e) {
-
- }
- tb.addTuple(Arrays.asList(1));
- tb.close();
- batch = tb.getBatch(2);
- assertTrue(batch.getTerminationFlag());
- assertEquals(2, batch.getBeginRow());
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,1175 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Properties;
-
-import org.junit.Test;
-import org.teiid.connector.language.SQLReservedWords;
-
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.unittest.TimestampUtil;
-import com.metamatrix.query.util.CommandContext;
-
-public class TestFunction {
-
- private void helpConcat(String s1, String s2, Object expected) {
- Object actual = FunctionMethods.concat(s1, s2);
- assertEquals("concat(" + s1 + ", " + s2 + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpTrim(String str, boolean left, Object expected) {
- Object actual = null;
- if (left) {
- actual = FunctionMethods.leftTrim(str);
- assertEquals("ltrim(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- actual = FunctionMethods.rightTrim(str);
- assertEquals("rtrim(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- public static void helpLeft(String str, int count, Object expected) throws FunctionExecutionException {
- Object actual = FunctionMethods.left(str, new Integer(count));
- assertEquals("left(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static void helpRight(String str, int count, Object expected) throws FunctionExecutionException {
- Object actual = FunctionMethods.right(str, new Integer(count));
- assertEquals("right(" + str + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static void helpReplace(String str, String sub, String replace, Object expected) {
- Object actual = FunctionMethods.replace(str, sub, replace);
- assertEquals("replace(" + str + "," + sub + "," + replace + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public static void helpSubstring(String str, Integer start, Integer length, Object expected) {
- Object actual = FunctionMethods.substring(str, start, length);
- assertEquals("substring(" + str + "," + start + "," + length + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- public static void helpSubstring(String str, Integer start, Object expected) {
- Object actual = FunctionMethods.substring(str, start);
- assertEquals("substring(" + str + "," + start + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpConvert(Object src, String tgtType, Object expected) throws FunctionExecutionException {
- Object actual = FunctionMethods.convert(src, tgtType);
- assertEquals("convert(" + src + "," + tgtType + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpConvertFail(Object src, String tgtType) {
- try {
- FunctionMethods.convert(src, tgtType);
- fail("Expected convert(" + src + "," + tgtType + ") to throw FunctionExecutionException, but it did not."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } catch (FunctionExecutionException e) {
- }
- }
-
- public static void helpTestInitCap(String input, String expected) {
- String actual = (String) FunctionMethods.initCap(input);
- assertEquals("Didn't get expected result from initCap", expected, actual); //$NON-NLS-1$
- }
-
- public static void helpTestLpad(String input, int length, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.lpad(input, new Integer(length));
- assertEquals("Didn't get expected result from lpad", expected, actual); //$NON-NLS-1$
- }
-
- public static void helpTestLpad(String input, int length, String pad, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.lpad(input, new Integer(length), pad);
- assertEquals("Didn't get expected result from lpad", expected, actual); //$NON-NLS-1$
- }
-
- public static void helpTestRpad(String input, int length, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.rpad(input, new Integer(length));
- assertEquals("Didn't get expected result from rpad", expected, actual); //$NON-NLS-1$
- }
-
- public static void helpTestRpad(String input, int length, String c, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.rpad(input, new Integer(length), c);
- assertEquals("Didn't get expected result from rpad", expected, actual); //$NON-NLS-1$
- }
-
- public static void helpTestTranslate(String input, String src, String dest, String expected) throws FunctionExecutionException {
- String actual = (String) FunctionMethods.translate(input, src, dest);
- assertEquals("Didn't get expected result from translate", expected, actual); //$NON-NLS-1$
- }
-
- public static void helpTestLocate(String locateString, String input, int expectedLocation) {
- Integer location = (Integer) FunctionMethods.locate(locateString, input);
- int actualLocation = location.intValue();
- assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
- }
-
- public static void helpTestLocate(String locateString, String input, Integer start, int expectedLocation) {
- Integer location = (Integer) FunctionMethods.locate(locateString, input, start);
- int actualLocation = location.intValue();
- assertEquals("Didn't get expected result from locate", expectedLocation, actualLocation); //$NON-NLS-1$
- }
-
- public static void helpTestRound(Integer number, Integer places, Object expected) {
- Object actual = FunctionMethods.round(number, places);
- assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpTestRound(Float number, Integer places, Object expected) {
- Object actual = FunctionMethods.round(number, places);
- assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpTestRound(Double number, Integer places, Object expected) {
- Object actual = FunctionMethods.round(number, places);
- assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpTestRound(BigDecimal number, Integer places, Object expected) {
- Object actual = FunctionMethods.round(number, places);
- assertEquals("round(" + number + "," + places + ") failed.", expected, actual); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- public static void helpTestHour1(String timeStr, int expected) {
- Time t = Time.valueOf(timeStr);
- Object actual = FunctionMethods.hour(t);
- assertEquals("hour(" + t + ") failed", new Integer(expected), actual); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static void helpTestHour2(String timestampStr, int expected) {
- Timestamp ts = Timestamp.valueOf(timestampStr);
- Object actual = FunctionMethods.hour(ts);
- assertEquals("hour(" + ts + ") failed", new Integer(expected), actual); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public static void helpTestTimestampCreate(java.sql.Date date, Time time, String expected) {
- Object actual = FunctionMethods.timestampCreate(date, time);
- assertEquals("timestampCreate(" + date + ", " + time + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- expected, actual.toString());
- }
-
- public static void helpTestTimestampDiff(String intervalType, Timestamp timeStamp1, Timestamp timeStamp2, Long expected) {
- Object actual = FunctionMethods.timestampDiff(intervalType, timeStamp1, timeStamp2);
- assertEquals("timestampDiff(" + intervalType + ", " + timeStamp1 + ", " + timeStamp2 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- expected, actual);
-
- // test reverse - should be
- Long expected2 = new Long(0 - expected.longValue());
- Object actual2 = FunctionMethods.timestampDiff(intervalType, timeStamp2, timeStamp1);
- assertEquals("timestampDiff(" + intervalType + ", " + timeStamp2 + ", " + timeStamp1 + ") failed", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- expected2, actual2);
- }
-
- public static void helpTestParseTimestamp(String tsStr, String format, String expected) throws FunctionExecutionException {
- Object actual = FunctionMethods.parseTimestamp(tsStr, format);
- assertEquals("parseTimestamp(" + tsStr + ", " + format + ") failed", expected.toString(), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new Constant(actual).toString());
- }
-
- // ################################## ACTUAL TESTS ################################
-
- // ------------------------------ CONCAT ------------------------------
-
- @Test public void testConcat1() throws Exception {
- helpConcat("x", "y", "xy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testConcat5() throws Exception {
- helpConcat("", "", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // ------------------------------ TRIM ------------------------------
-
- @Test public void testTrim3() throws Exception {
- helpTrim("", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim4() throws Exception {
- helpTrim("", false, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim5() throws Exception {
- helpTrim("x", true, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim6() throws Exception {
- helpTrim("x", false, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim7() throws Exception {
- helpTrim(" x", true, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim8() throws Exception {
- helpTrim(" x ", true, "x "); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim9() throws Exception {
- helpTrim("x ", false, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim10() throws Exception {
- helpTrim(" x x ", false, " x x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim11() throws Exception {
- helpTrim(" ", true, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testTrim12() throws Exception {
- helpTrim(" ", false, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // ------------------------------ LEFT ------------------------------
-
- @Test public void testLeft1() throws Exception {
- helpLeft("abcd", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLeft2() throws Exception {
- helpLeft("abcd", 3, "abc"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLeft4() throws Exception {
- helpLeft("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLeft5() throws Exception {
- helpLeft("", 2, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLeft6() throws Exception {
- helpLeft("abcd", 5, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLeft7() throws Exception {
- helpLeft("abcd", 4, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // ------------------------------ RIGHT ------------------------------
-
- @Test public void testRight1() throws Exception {
- helpRight("abcd", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRight2() throws Exception {
- helpRight("abcd", 3, "bcd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRight4() throws Exception {
- helpRight("", 0, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRight5() throws Exception {
- helpRight("", 2, ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRight6() throws Exception {
- helpRight("abcd", 5, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRight7() throws Exception {
- helpRight("abcd", 4, "abcd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // ------------------------------ SUBSTRING ------------------------------
-
- @Test public void testSubstring1() throws Exception {
- helpSubstring("abc", new Integer(1), new Integer(1), "a"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring2() throws Exception {
- helpSubstring("abc", new Integer(2), new Integer(2), "bc"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring3() throws Exception {
- helpSubstring("abc", new Integer(3), new Integer(3), "c"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring4() throws Exception {
- helpSubstring("abc", new Integer(3), new Integer(0), ""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring6() throws Exception {
- helpSubstring("abc", new Integer(3), "c"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring7() throws Exception {
- helpSubstring("abc", new Integer(1), "abc"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring8() throws Exception {
- helpSubstring("abc", new Integer(-1), "c"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring9() throws Exception {
- helpSubstring("abc", new Integer(-3), "abc"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring10() throws Exception {
- helpSubstring("abc", new Integer(-4), null); //$NON-NLS-1$
- }
-
- @Test public void testSubstring11() throws Exception {
- helpSubstring("abc", new Integer(-1), new Integer(2), "c"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring12() throws Exception {
- helpSubstring("abc", new Integer(-3), new Integer(2), "ab"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testSubstring13() throws Exception {
- helpSubstring("abc", new Integer(0), new Integer(2), "ab"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-
- // ------------------------------ REPLACE ------------------------------
-
- @Test public void testReplace1() throws Exception {
- helpReplace("", "x", "y", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace2() throws Exception {
- helpReplace("", "", "z", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace3() throws Exception {
- helpReplace("x", "x", "y", "y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace4() throws Exception {
- helpReplace("xx", "x", "y", "yy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace5() throws Exception {
- helpReplace("x x", "x", "y", "y y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace6() throws Exception {
- helpReplace("x x", "x", "", " "); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace7() throws Exception {
- helpReplace("x x", "x", "yz", "yz yz"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testReplace8() throws Exception {
- helpReplace("xx xx", "xx", "y", "y y"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- // ------------------------------ CONVERT ------------------------------
-
- @Test public void testConvertStringBoolean1() throws Exception {
- helpConvert("true", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringBoolean2() throws Exception {
- helpConvert("false", "boolean", Boolean.FALSE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringBoolean3() throws Exception {
- helpConvert("x", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringBoolean4() throws Exception {
- helpConvert("TrUe", "boolean", Boolean.TRUE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringBoolean5() throws Exception {
- helpConvert("FAlsE", "boolean", Boolean.FALSE); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringChar1() throws Exception {
- helpConvert("a", "char", new Character('a')); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringChar2() throws Exception {
- helpConvert("xx", "char", new Character('x')); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringByte1() throws Exception {
- helpConvert("5", "byte", new Byte((byte) 5)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringShort1() throws Exception {
- helpConvert("5", "short", new Short((short) 5)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringInteger1() throws Exception {
- helpConvert("5", "integer", new Integer(5)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- // Integer > Integer.MAX_VALUE - should fail
- @Test public void testConvertStringInteger2() throws Exception {
- helpConvertFail("" + Integer.MAX_VALUE + "1", "integer"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testConvertStringInteger3() throws Exception {
- helpConvertFail("5.99", "integer"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringLong1() throws Exception {
- helpConvert("5", "long", new Long(5)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringBigInteger1() throws Exception {
- helpConvert("5", "biginteger", new BigInteger("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testConvertStringBigInteger2() throws Exception {
- String bigInt = "" + Integer.MAX_VALUE + "111"; //$NON-NLS-1$ //$NON-NLS-2$
- helpConvert(bigInt, "biginteger", new BigInteger(bigInt)); //$NON-NLS-1$
- }
-
- @Test public void testConvertStringFloat1() throws Exception {
- helpConvert("5.2", "float", new Float(5.2f)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringDouble1() throws Exception {
- helpConvert("5.2", "double", new Double(5.2d)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertStringBigDecimal1() throws Exception {
- helpConvert("5.2", "bigdecimal", new BigDecimal("5.2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testConvertDoubleBigInteger() throws Exception {
- helpConvert(new Double(1.0d), "biginteger", new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertFloatBigInteger() throws Exception {
- helpConvert(new Float(1.0), "biginteger", new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertBigDecimalBigInteger() throws Exception {
- helpConvert(new BigDecimal("1.0"), "biginteger", new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testConvertDoubleLong() throws Exception {
- helpConvert(new Double(1.0d), "long", new Long("1")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testConvertTimestampString() throws Exception {
- Timestamp ts = TimestampUtil.createTimestamp(103, 7, 22, 22, 43, 53, 3333333);
- helpConvert(ts, "string", "2003-08-22 22:43:53.003333333"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testAscii2() throws Exception {
- Integer code = FunctionMethods.ascii(" "); //$NON-NLS-1$
- assertEquals("Didn't get expected code", 32, code.intValue()); //$NON-NLS-1$
- }
-
- @Test public void testAscii4() throws Exception {
- assertNull(FunctionMethods.ascii("")); //$NON-NLS-1$
- }
-
- @Test public void testAscii5() throws Exception {
- Integer code = FunctionMethods.ascii("abc"); //$NON-NLS-1$
- assertEquals("Didn't get expected code", 97, code.intValue()); //$NON-NLS-1$
- }
-
- @Test public void testChr1() throws Exception {
- Character chr = (Character) FunctionMethods.chr(new Integer(32));
- assertEquals("Didn't get expected character", ' ', chr.charValue()); //$NON-NLS-1$
- }
-
- @Test public void testNvl1() throws Exception {
- String ret = (String) FunctionMethods.ifnull("x", "y"); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("Didn't get expected value", "x", ret); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testNvl2() throws Exception {
- String ret = (String) FunctionMethods.ifnull(null, "y"); //$NON-NLS-1$
- assertEquals("Didn't get expected value", "y", ret); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testNvl3() throws Exception {
- String ret = (String) FunctionMethods.ifnull(null, null);
- assertEquals("Didn't get expected value", null, ret); //$NON-NLS-1$
- }
-
- @Test public void testInitCap2() throws Exception {
- helpTestInitCap("abc", "Abc"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInitCap3() throws Exception {
- helpTestInitCap(" test some\tweird\rspaces\nhere", " Test Some\tWeird\rSpaces\nHere"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInitCap4() throws Exception {
- helpTestInitCap("x y ", "X Y "); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInitCap5() throws Exception {
- helpTestInitCap("cows are FUN", "Cows Are Fun"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLpad1() throws Exception {
- helpTestLpad("x", 4, " x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLpad3() throws Exception {
- helpTestLpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLpad4() throws Exception {
- helpTestLpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLpad5() throws Exception {
- helpTestLpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testLpad6() throws Exception {
- helpTestLpad("10", 6, "0", "000010"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testLpad7() throws Exception {
- helpTestLpad("x", 4, "yq", "qyqx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testRpad1() throws Exception {
- helpTestRpad("x", 4, "x "); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRpad3() throws Exception {
- helpTestRpad("x", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRpad4() throws Exception {
- helpTestRpad("xx", 1, "x"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRpad5() throws Exception {
- helpTestRpad("", 4, "x", "xxxx"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testRpad6() throws Exception {
- helpTestRpad("10", 6, "0", "100000"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testTranslate1() throws Exception {
- helpTestTranslate("This is my test", "ty", "yt", "This is mt yesy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testTranslate2() throws Exception {
- helpTestTranslate("", "ty", "yt", ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testTranslate3() throws Exception {
- try {
- FunctionMethods.translate("test", "x", "yz"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- fail("Did not get expected exception on differing src and dest lengths"); //$NON-NLS-1$
- } catch (FunctionExecutionException e) {
- }
- }
-
- @Test public void testTranslate4() throws Exception {
- helpTestTranslate("test", "xy", "ab", "test"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testLocate1() throws Exception {
- helpTestLocate(",", "Metamatrix, John Quincy", 11); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate2() throws Exception {
- helpTestLocate(" ", "Metamatrix, John Quincy", 12); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate3() throws Exception {
- helpTestLocate("x", "xx", 1); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate4() throws Exception {
- helpTestLocate("y", "xx", 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate5() throws Exception {
- helpTestLocate("b", "abab", 3, 4); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate6() throws Exception {
- helpTestLocate("z", "abab", 0, 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate7() throws Exception {
- helpTestLocate("z", "abab", null, 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testLocate8() throws Exception {
- helpTestLocate("z", "abab", -1, 0); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testBitand() throws Exception {
- // Both values are integers
- Integer result = (Integer) FunctionMethods.bitand(new Integer(0xFFF), new Integer(0x0F0));
- assertNotNull("Result should not be null", result); //$NON-NLS-1$
- assertEquals("result should be 0x0F0", 0x0F0, result.intValue()); //$NON-NLS-1$
- }
-
- @Test public void testBitor() throws Exception {
- // Both values are integers
- Integer result = (Integer) FunctionMethods.bitor(new Integer(0xFFF), new Integer(0x0F0));
- assertNotNull("Result should not be null", result); //$NON-NLS-1$
- assertEquals("result should be 0xFFF", 0xFFF, result.intValue()); //$NON-NLS-1$
- }
-
- @Test public void testBitxor() throws Exception {
- // Both values are integers
- Integer result = (Integer) FunctionMethods.bitxor(new Integer(0xFFF), new Integer(0x0F0));
- assertNotNull("Result should not be null", result); //$NON-NLS-1$
- assertEquals("result should be 0xF0F", 0xF0F, result.intValue()); //$NON-NLS-1$
- }
-
- @Test public void testBitnot() throws Exception {
- // Both values are integers
- Integer result = FunctionMethods.bitnot(0xF0F);
- assertNotNull("Result should not be null", result); //$NON-NLS-1$
- assertEquals("result should be 0xFFFFF0F0", 0xFFFFF0F0, result.intValue()); //$NON-NLS-1$
- }
-
- @Test public void testRoundInteger1() throws Exception {
- helpTestRound(new Integer(1928), new Integer(0), new Integer(1928));
- }
-
- @Test public void testRoundInteger2() throws Exception {
- helpTestRound(new Integer(1928), new Integer(-1), new Integer(1930));
- }
-
- @Test public void testRoundInteger3() throws Exception {
- helpTestRound(new Integer(1928), new Integer(-2), new Integer(1900));
- }
-
- @Test public void testRoundInteger4() throws Exception {
- helpTestRound(new Integer(1928), new Integer(-3), new Integer(2000));
- }
-
- @Test public void testRoundInteger5() throws Exception {
- helpTestRound(new Integer(1928), new Integer(-4), new Integer(0));
- }
-
- @Test public void testRoundInteger6() throws Exception {
- helpTestRound(new Integer(1928), new Integer(-5), new Integer(0));
- }
-
- @Test public void testRoundInteger7() throws Exception {
- helpTestRound(new Integer(1928), new Integer(1), new Integer(1928));
- }
-
- @Test public void testRoundFloat1() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(4), new Float(123.456F));
- }
-
- @Test public void testRoundFloat2() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(3), new Float(123.456F));
- }
-
- @Test public void testRoundFloat3() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(2), new Float(123.46F));
- }
-
- @Test public void testRoundFloat4() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(1), new Float(123.5F));
- }
-
- @Test public void testRoundFloat5() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(0), new Float(123F));
- }
-
- @Test public void testRoundFloat6() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(-1), new Float(120F));
- }
-
- @Test public void testRoundFloat7() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(-2), new Float(100F));
- }
-
- @Test public void testRoundFloat8() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(-3), new Float(0F));
- }
-
- @Test public void testRoundFloat9() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(-4), new Float(0F));
- }
-
- @Test public void testRoundFloat10() throws Exception {
- helpTestRound(new Float(123.456F), new Integer(4000), new Float(123.456F));
- }
-
- @Test public void testRoundDouble1() throws Exception {
- helpTestRound(new Double(123.456), new Integer(4), new Double(123.456));
- }
-
- @Test public void testRoundDouble2() throws Exception {
- helpTestRound(new Double(123.456), new Integer(3), new Double(123.456));
- }
-
- @Test public void testRoundDouble3() throws Exception {
- helpTestRound(new Double(123.456), new Integer(2), new Double(123.46));
- }
-
- @Test public void testRoundDouble4() throws Exception {
- helpTestRound(new Double(123.456), new Integer(1), new Double(123.5));
- }
-
- @Test public void testRoundDouble5() throws Exception {
- helpTestRound(new Double(123.456), new Integer(0), new Double(123));
- }
-
- @Test public void testRoundDouble6() throws Exception {
- helpTestRound(new Double(123.456), new Integer(-1), new Double(120));
- }
-
- @Test public void testRoundDouble7() throws Exception {
- helpTestRound(new Double(123.456), new Integer(-2), new Double(100));
- }
-
- @Test public void testRoundDouble8() throws Exception {
- helpTestRound(new Double(123.456), new Integer(-3), new Double(0));
- }
-
- @Test public void testRoundDouble9() throws Exception {
- helpTestRound(new Double(123.456), new Integer(-4), new Double(0));
- }
-
- @Test public void testRoundDouble10() throws Exception {
- helpTestRound(new Double(-3.5), new Integer(0), new Double(-4));
- }
-
- @Test public void testRoundBigDecimal1() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(4), new BigDecimal("123.456")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal2() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(3), new BigDecimal("123.456")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal3() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(2), new BigDecimal("123.460")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal4() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(1), new BigDecimal("123.500")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal5() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(0), new BigDecimal("123.000")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal6() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(-1), new BigDecimal("120.000")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal7() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(-2), new BigDecimal("100.000")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal8() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(-3), new BigDecimal("0.000")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testRoundBigDecimal9() throws Exception {
- helpTestRound(new BigDecimal("123.456"), new Integer(-4), new BigDecimal("0.000")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testHour1() throws Exception {
- helpTestHour1("00:00:00", 0); //$NON-NLS-1$
- }
-
- @Test public void testHour2() throws Exception {
- helpTestHour1("11:00:00", 11); //$NON-NLS-1$
- }
-
- @Test public void testHour3() throws Exception {
- helpTestHour1("12:00:00", 12); //$NON-NLS-1$
- }
-
- @Test public void testHour4() throws Exception {
- helpTestHour1("13:00:00", 13); //$NON-NLS-1$
- }
-
- @Test public void testHour5() throws Exception {
- helpTestHour1("23:59:59", 23); //$NON-NLS-1$
- }
-
- @Test public void testHour6() throws Exception {
- helpTestHour2("2002-01-01 00:00:00", 0); //$NON-NLS-1$
- }
-
- @Test public void testHour7() throws Exception {
- helpTestHour2("2002-01-01 11:00:00", 11); //$NON-NLS-1$
- }
-
- @Test public void testHour8() throws Exception {
- helpTestHour2("2002-01-01 12:00:00", 12); //$NON-NLS-1$
- }
-
- @Test public void testHour9() throws Exception {
- helpTestHour2("2002-01-01 13:00:00", 13); //$NON-NLS-1$
- }
-
- @Test public void testHour10() throws Exception {
- helpTestHour2("2002-01-01 23:59:59", 23); //$NON-NLS-1$
- }
-
- @Test public void testTimestampCreate1() throws Exception {
- helpTestTimestampCreate(TimestampUtil.createDate(103, 11, 1), TimestampUtil.createTime(23, 59, 59), "2003-12-01 23:59:59.0"); //$NON-NLS-1$
- }
-
- @Test public void testTimestampAdd2() throws Exception {
- assertEquals(TimestampUtil.createTimestamp(103, 11, 1, 18, 20, 30, 0), FunctionMethods.timestampAdd(SQLReservedWords.SQL_TSI_HOUR, 3, TimestampUtil.createTimestamp(103, 11, 1, 15, 20, 30, 0)));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 1),
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100000000),
- new Long(99999999));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_2() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- // 1 day (8.64 x 10^10 nanos) and 1 nano
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 2),
- TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 3),
- new Long(86400000000001L));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_3() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- // 1 day (8.64 x 10^10 nanos) less 1 nano
- TimestampUtil.createTimestamp((2001-1900), 5, 22, 3, 9, 35, 2),
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 3),
- new Long(-86399999999999L));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_4() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 1),
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 0, 0, 0, 3),
- new Long(00000002));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_5() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 1),
- TimestampUtil.createTimestamp((2004-1900), 5, 22, 0, 0, 0, 10),
- new Long(9));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_6() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 2),
- TimestampUtil.createTimestamp((2001-1900), 5, 22, 0, 0, 0, 3),
- new Long(1));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_7() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- // 1 nano diff
- TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
- TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
- new Long(1));
- }
-
- @Test public void testTimestampDiffTimeStamp_FracSec_8() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_FRAC_SECOND,
- // 1 nano diff
- TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 3),
- TimestampUtil.createTimestamp((2004-1900), 5, 22, 3, 9, 35, 2),
- new Long(-1));
- }
-
- @Test public void testTimestampDiffTimeStamp_Min_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
- TimestampUtil.createTimestamp(0, 0, 0, 2, 34, 12, 0),
- TimestampUtil.createTimestamp(0, 0, 0, 12, 0, 0, 0),
- new Long(565));
- }
-
- @Test public void testTimestampDiffTimeStamp_Min_2() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
- TimestampUtil.createTimestamp((2001-1900), 0, 0, 2, 0, 0, 0),
- TimestampUtil.createTimestamp((2001-1900), 0, 0, 0, 33, 12, 0),
- new Long(-86));
- }
-
- @Test public void testTimestampDiffTimeStamp_Min_3() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
- TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 65497),
- TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 483219),
- new Long(4277));
- }
-
- @Test public void testTimestampDiffTimeStamp_Min_4() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
- TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 07, 58, 0),
- TimestampUtil.createTimestamp((2001-1900), 8, 29, 11, 25, 42, 0),
- new Long(4277));
- }
-
- @Test public void testTimestampDiffTimeStamp_Min_5() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MINUTE,
- TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 1),
- TimestampUtil.createTimestamp((2001-1900), 8, 26, 12, 0, 0, 0),
- new Long(0));
- }
-
- @Test public void testTimestampDiffTimeStamp_Hour_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR,
- TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 0, 0, 0),
- TimestampUtil.createTimestamp((2004-1900), 8, 26, 12, 59, 59, 999999999),
- new Long(0));
- }
-
- @Test public void testTimestampDiffTimeStamp_Week_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_WEEK,
- TimestampUtil.createTimestamp((2001-1900), 5, 21, 3, 9, 35, 100),
- TimestampUtil.createTimestamp((2001-1900), 4, 2, 5, 19, 35, 500),
- new Long(-7));
- }
-
- @Test public void testTimestampDiffTimeStamp_Month_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
- TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 0),
- TimestampUtil.createTimestamp((2004-1900), 11, 20, 12, 0, 0, 0),
- new Long(7));
- }
-
- @Test public void testTimestampDiffTimeStamp_Month_2() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
- TimestampUtil.createTimestamp((2004-1900), 5, 1, 0, 0, 0, 1000000),
- TimestampUtil.createTimestamp((2004-1900), 11, 1, 12, 0, 0, 1),
- new Long(6));
- }
-
- @Test public void testTimestampDiffTimeStamp_Month_3() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
- TimestampUtil.createTimestamp((2004-1900), 4, 19, 0, 0, 0, 1),
- TimestampUtil.createTimestamp((2004-1900), 11, 18, 12, 0, 0, 1000000),
- new Long(7));
- }
-
- @Test public void testTimestampDiffTimeStamp_Month_4() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
- TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 0, 1000000),
- TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
- new Long(7));
- }
-
- @Test public void testTimestampDiffTimeStamp_Month_5() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
- TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
- TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 0, 0),
- new Long(7));
- }
-
- @Test public void testTimestampDiffTimeStamp_Month_6() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_MONTH,
- TimestampUtil.createTimestamp((2004-1900), 4, 1, 0, 0, 1, 0),
- TimestampUtil.createTimestamp((2004-1900), 11, 1, 0, 0, 2, 0),
- new Long(7));
- }
-
- @Test public void testTimestampDiffTimeStamp_Day_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
- TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
- TimestampUtil.createTimestamp((2004-1900), 3, 1, 0, 0, 0, 0),
- new Long(31));
- }
-
- @Test public void testTimestampDiffTimeStamp_Day_2() throws Exception {
- // Leap year
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_DAY,
- TimestampUtil.createTimestamp((2004-1900), 1, 1, 0, 0, 0, 0),
- TimestampUtil.createTimestamp((2004-1900), 2, 1, 0, 0, 0, 0),
- new Long(29));
- }
-
- @Test public void testTimestampDiffTime_Hour_1() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
- TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(
- TimestampUtil.createTime(5, 5, 36).getTime()), new Long(2));
- }
-
- @Test public void testTimestampDiffTime_Hour_2() throws Exception {
- helpTestTimestampDiff(SQLReservedWords.SQL_TSI_HOUR, new Timestamp(
- TimestampUtil.createTime(5, 0, 30).getTime()), new Timestamp(
- TimestampUtil.createTime(3, 0, 31).getTime()), new Long(-1));
- }
-
- @Test public void testParseTimestamp1() throws Exception {
- helpTestParseTimestamp("1993-04-24 3:59:59 PM", "yyyy-MM-dd hh:mm:ss aa", "{ts'1993-04-24 15:59:59.0'}"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- }
-
- public void helpTestModifyTimeZone(String tsStr, String tzStart, String tzEnd, String expectedStr) throws Exception {
- Timestamp ts = tsStr != null ? Timestamp.valueOf(tsStr) : null;
- Timestamp actual = null;
-
- if(tzStart == null) {
- actual = (Timestamp) FunctionMethods.modifyTimeZone(new CommandContext(), ts, tzEnd);
- } else {
- actual = (Timestamp) FunctionMethods.modifyTimeZone(ts, tzStart, tzEnd);
- }
-
- String actualStr = null;
- if(actual != null) {
- actualStr = actual.toString();
- }
- assertEquals("Did not get expected output timestamp", expectedStr, actualStr); //$NON-NLS-1$
- }
-
- /*
- * The following test results may look odd, but it is due to the parsing of the initial date, which is done
- * against the system default timezone (not the startTz shown below). The fianl date value is also being read
- * against the default timezone and not the endTz shown.
- */
- @Test public void testModifyTimeZoneGMT() throws Exception {
- helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "GMT+00:00", "GMT-01:00", "2004-10-03 16:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testModifyTimeZoneGMTPartialHour() throws Exception {
- helpTestModifyTimeZone("2004-10-03 15:30:59.123456789", "GMT+00:00", "GMT-01:45", "2004-10-03 17:15:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testModifyTimeZoneNamedTZ() throws Exception {
- helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "America/New_York", "America/Chicago", "2004-10-03 16:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testModifyTimeZoneNamedTZ2() throws Exception {
- helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "America/Chicago", "America/New_York", "2004-10-03 14:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testModifyTimeZoneStartLocal() throws Exception {
- helpTestModifyTimeZone("2004-10-03 15:19:59.123456789", "America/Chicago", "America/Los_Angeles", "2004-10-03 17:19:59.123456789"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- // case 2458
- @Test public void testCurrentDate() throws Exception {
-
- Date curDate = (Date)FunctionMethods.currentDate();
-
- Calendar cal1 = Calendar.getInstance();
- cal1.setTime(curDate);
-
- assertEquals(cal1.get(Calendar.HOUR_OF_DAY), 0);
- assertEquals(cal1.get(Calendar.MINUTE), 0);
- assertEquals(cal1.get(Calendar.SECOND), 0);
- assertEquals(cal1.get(Calendar.MILLISECOND), 0);
-
- }
-
- // case 2458
- @Test public void testCurrentTime() throws Exception {
-
- Time curDate = (Time)FunctionMethods.currentTime();
-
- Calendar cal1 = Calendar.getInstance();
- cal1.setTime(curDate);
-
- // can not test the current time without making a copy of current "time"
- // so check the normalization of the date to unix epoch
- assertEquals(cal1.get(Calendar.YEAR), 1970);
- assertEquals(cal1.get(Calendar.MONTH), Calendar.JANUARY);
- assertEquals(cal1.get(Calendar.DATE), 1);
-
- }
-
- @Test public void testRand() throws Exception {
- Double d = (Double)FunctionMethods.rand(new CommandContext(), new Integer(100));
- assertEquals(new Double(0.7220096548596434), d);
-
- try {
- FunctionMethods.rand(new CommandContext(), new Double(34.5));
- fail("should have failed to take a double"); //$NON-NLS-1$
- } catch (FunctionExecutionException e) {
- }
-
- FunctionMethods.rand(new CommandContext());
- }
-
- @Test public void testEnv() throws Exception {
- Properties p = new Properties();
- String envProperty = "EnvProperty"; //$NON-NLS-1$
- String systemProperty = "SystemProperty"; //$NON-NLS-1$
- p.setProperty(envProperty.toLowerCase(), envProperty);
-
- // set an environment property
- CommandContext context = new CommandContext();
- context.setEnvironmentProperties(p);
-
- // set the system property
- System.setProperty(systemProperty, systemProperty);
- System.setProperty(systemProperty.toLowerCase(), systemProperty+"_lowercase"); //$NON-NLS-1$
-
- assertEquals(envProperty, FunctionMethods.env(context, envProperty));
- assertEquals(systemProperty, FunctionMethods.env(context, systemProperty));
- assertEquals(systemProperty+"_lowercase", FunctionMethods.env(context, systemProperty.toUpperCase())); //$NON-NLS-1$
- }
-
- @Test(expected=FunctionExecutionException.class) public void testParseIntStrictness() throws Exception {
- FunctionMethods.parseInteger("a 1 a", "#"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testParseDateStrictness() throws Exception {
- assertEquals(TimestampUtil.createTimestamp(108, 0, 1, 0, 0, 0, 0), FunctionMethods.parseTimestamp(" 2007-13-01", "yyyy-MM")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testParseTimeWhitespace() throws Exception {
- assertEquals(TimestampUtil.createTime(15, 0, 0), FunctionMethods.parseTimestamp(" 15:00:00 ", "HH:mm:ss")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testMod() {
- assertEquals(new BigDecimal("-1.1"), FunctionMethods.mod(new BigDecimal("-3.1"), new BigDecimal("2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testMod1() {
- assertEquals(new BigDecimal("-1.1"), FunctionMethods.mod(new BigDecimal("-3.1"), new BigDecimal("-2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testMod2() {
- assertEquals(-40, FunctionMethods.mod(-340, 60), 0);
- }
-
- @Test public void testMod3() {
- assertEquals(-40, FunctionMethods.mod(-340, -60), 0);
- }
-
- @Test public void testMod4() {
- assertEquals(new BigInteger("-1"), FunctionMethods.mod(new BigInteger("-3"), new BigInteger("2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testMod5() {
- assertEquals(new BigInteger("-1"), FunctionMethods.mod(new BigInteger("-3"), new BigInteger("-2"))); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionDescriptorImpl.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,117 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function;
-
-import java.lang.reflect.Method;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-
-public class TestFunctionDescriptorImpl extends TestCase {
-
- /**
- * Constructor for TestFunctionDescriptorImpl.
- * @param name
- */
- public TestFunctionDescriptorImpl(String name) {
- super(name);
- }
-
- /**
- * Find the invocation method for a function.
- * @param source The function metadata source, which knows how to obtain the invocation class
- * @param invocationClass The class to invoke for this function
- * @param invocationMethod The method to invoke for this function
- * @param numArgs Number of arguments in method
- * @throws NoSuchMethodException
- * @throws SecurityException
- */
- private Method lookupMethod(String invocationClass, String invocationMethod, int numArgs) throws SecurityException, NoSuchMethodException {
- // Build signature
- Class[] objectSignature = new Class[numArgs];
- for(int i=0; i<numArgs; i++) {
- objectSignature[i] = Integer.TYPE;
- }
-
- // Find Method
- Method method = null;
- try {
- Class methodClass = Class.forName(invocationClass);
- method = methodClass.getMethod(invocationMethod, objectSignature);
- } catch(ClassNotFoundException e) {
- // Failed to load class, so can't load method - this will fail at invocation time.
- // We don't fail here because this situation can occur in the modeler, which does
- // not have the function jar files. The modeler never invokes, so this isn't a
- // problem.
- return null;
- }
-
- // Validate method
- if(! FunctionTree.isValidMethod(method)) {
- return null;
- }
- return method;
- }
-
- public void test1() throws Exception {
- FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN, //$NON-NLS-1$
- new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
- DataTypeManager.DefaultDataClasses.INTEGER,
- lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2) , false, true, FunctionMethod.DETERMINISTIC); //$NON-NLS-1$ //$NON-NLS-2$
-
- UnitTestUtil.helpTestEquivalence(0, f1, f1);
- }
-
- public void test2() throws Exception {
- FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
- new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
- DataTypeManager.DefaultDataClasses.INTEGER,
- lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
-
- FunctionDescriptor f2 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
- new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
- DataTypeManager.DefaultDataClasses.INTEGER,
- lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
-
- UnitTestUtil.helpTestEquivalence(0, f1, f2);
- }
-
- public void test3() throws Exception {
- FunctionDescriptor f1 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
- new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
- DataTypeManager.DefaultDataClasses.INTEGER,
- lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, false, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
-
-
- FunctionDescriptor f2 = new FunctionDescriptor("+", FunctionMethod.CAN_PUSHDOWN,//$NON-NLS-1$
- new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, DataTypeManager.DefaultDataClasses.INTEGER },
- DataTypeManager.DefaultDataClasses.INTEGER,
- lookupMethod("com.metamatrix.query.function.FunctionMethods", "plus", 2), false, true, FunctionMethod.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
-
- assertNotSame("objects should not be equal", f1, f2); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionLibrary.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,1374 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function;
-
-import static org.junit.Assert.*;
-
-import java.math.BigDecimal;
-import java.math.BigInteger;
-import java.sql.Date;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.TimeZone;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-import org.teiid.connector.language.SQLReservedWords;
-import org.teiid.resource.cci.SourceSystemFunctions;
-
-import com.metamatrix.api.exception.query.FunctionExecutionException;
-import com.metamatrix.common.buffer.BufferManagerFactory;
-import com.metamatrix.common.types.ClobType;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.common.types.NullType;
-import com.metamatrix.common.types.XMLType;
-import com.metamatrix.common.util.TimestampWithTimezone;
-import com.metamatrix.core.util.ObjectConverterUtil;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.unittest.TimestampUtil;
-import com.metamatrix.query.util.CommandContext;
-
-@SuppressWarnings("nls")
-public class TestFunctionLibrary {
-
- // These are just used as shorthand convenience to make unit tests more readable below
- private static final Class<String> T_STRING = DataTypeManager.DefaultDataClasses.STRING;
- private static final Class<Integer> T_INTEGER = DataTypeManager.DefaultDataClasses.INTEGER;
- private static final Class<BigInteger> T_BIG_INTEGER = DataTypeManager.DefaultDataClasses.BIG_INTEGER;
- private static final Class<BigDecimal> T_BIG_DECIMAL = DataTypeManager.DefaultDataClasses.BIG_DECIMAL;
- private static final Class<Long> T_LONG = DataTypeManager.DefaultDataClasses.LONG;
- private static final Class<Float> T_FLOAT = DataTypeManager.DefaultDataClasses.FLOAT;
- private static final Class<Double> T_DOUBLE = DataTypeManager.DefaultDataClasses.DOUBLE;
- private static final Class<NullType> T_NULL = DataTypeManager.DefaultDataClasses.NULL;
- private static final Class<Time> T_TIME = DataTypeManager.DefaultDataClasses.TIME;
- private static final Class<Date> T_DATE = DataTypeManager.DefaultDataClasses.DATE;
- private static final Class<Timestamp> T_TIMESTAMP = DataTypeManager.DefaultDataClasses.TIMESTAMP;
-
- private FunctionLibrary library = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(Collections.EMPTY_LIST)));
-
- @Before public void setUp() {
- TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00")); //$NON-NLS-1$
- }
-
- @After public void tearDown() {
- TimestampWithTimezone.resetCalendar(null);
- }
-
- // ################################## TEST HELPERS ################################
-
- private FunctionDescriptor helpCreateDescriptor(String name, Class[] types) {
- final String fname = name;
- final Class[] ftypes = types;
- return new FunctionDescriptor() {
- public String getName() {
- return fname;
- }
- public int getPushdown() {
- return FunctionMethod.CAN_PUSHDOWN;
- }
- public Class[] getTypes() {
- return ftypes;
- }
- public Class getReturnType() {
- return null;
- }
-
- public String toString() {
- StringBuffer str = new StringBuffer(fname);
- str.append("("); //$NON-NLS-1$
- for(int i=0; i<ftypes.length; i++) {
- if(ftypes[i] != null) {
- str.append(ftypes[i].getName());
- } else {
- str.append("null"); //$NON-NLS-1$
- }
- if(i<(ftypes.length-1)) {
- str.append(", "); //$NON-NLS-1$
- }
- }
- return str.toString();
- }
- public boolean requiresContext() {
- return false;
- }
- public boolean isNullDependent() {
- return true;
- }
-
- };
- }
-
- private void helpFindFunction(String fname, Class[] types, FunctionDescriptor expected) {
- FunctionDescriptor actual = library.findFunction(fname, types);
-
- assertEquals("Function names do not match: ", expected.getName().toLowerCase(), actual.getName().toLowerCase()); //$NON-NLS-1$
- assertEquals("Arg lengths do not match: ", expected.getTypes().length, actual.getTypes().length); //$NON-NLS-1$
- }
-
- private void helpFindFunctionFail(String fname, Class[] types) {
- FunctionDescriptor actual = library.findFunction(fname, types);
- assertNull("Function was found but should not have been: " + actual, actual); //$NON-NLS-1$
- }
-
- private void helpFindConversions(String fname, Class[] types, FunctionDescriptor[] expected) {
-
- FunctionDescriptor[] actual = library.determineNecessaryConversions(fname, null, types, false);
-
- if(expected == null) {
- if(actual != null) {
- fail("Expected to find no conversion for " + fname + Arrays.asList(types) + " but found: " + Arrays.asList(actual)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } else {
- if(actual == null) {
- fail("Expected to find conversion for " + fname + Arrays.asList(types) + " but found none"); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- // Compare returned descriptors with expected descriptor
- for(int i=0; i<expected.length; i++) {
- if(expected[i] == null) {
- if(actual[i] != null) {
- fail("Expected no conversion at index " + i + ", but found: " + actual[i]); //$NON-NLS-1$ //$NON-NLS-2$
- }
- } else {
- if(actual[i] == null) {
- fail("Expected conversion at index " + i + ", but found none."); //$NON-NLS-1$ //$NON-NLS-2$
- } else {
- assertEquals("Expected conversion function names do not match: ", expected[i].getName(), actual[i].getName()); //$NON-NLS-1$
- assertEquals("Expected conversion arg lengths do not match: ", expected[i].getTypes().length, actual[i].getTypes().length); //$NON-NLS-1$
- }
- }
- }
- }
- }
- }
-
- private void helpFindForm(String fname, int numArgs) {
- FunctionForm form = library.findFunctionForm(fname, numArgs);
- assertNotNull("Failed to find function '" + fname + "' with " + numArgs + " args", form); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- assertEquals("Function names do not match: ", fname.toUpperCase(), form.getName().toUpperCase()); //$NON-NLS-1$
- assertEquals("Arg lengths do not match: ", numArgs, form.getArgNames().size()); //$NON-NLS-1$
- }
-
- private void helpInvokeMethod(String fname, Object[] inputs, Object expectedOutput) {
- try {
- helpInvokeMethod(fname, null, inputs, null, expectedOutput);
- } catch (Exception err) {
- throw new RuntimeException(err);
- }
- }
-
- private void helpInvokeMethod(String fname, Class[] types, Object[] inputs, CommandContext context, Object expectedOutput) throws FunctionExecutionException {
- Object actualOutput = helpInvokeMethod(fname, types, inputs, context);
- assertEquals("Actual function output not equal to expected: ", expectedOutput, actualOutput); //$NON-NLS-1$
- }
-
- private Object helpInvokeMethod(String fname, Class[] types,
- Object[] inputs, CommandContext context)
- throws FunctionExecutionException {
- if (types == null) {
- // Build type signature
- types = new Class[inputs.length];
- for(int i=0; i<inputs.length; i++) {
- types[i] = DataTypeManager.determineDataTypeClass(inputs[i]);
- }
- }
- if (context == null) {
- context = new CommandContext();
- }
- Object actualOutput = null;
- // Find function descriptor
- FunctionDescriptor descriptor = library.findFunction(fname, types);
- if (descriptor.requiresContext()) {
- // Invoke function with inputs
- Object[] in = new Object[inputs.length+1];
- in[0] = context;
- for (int i = 0; i < inputs.length; i++) {
- in[i+1] = inputs[i];
- }
- actualOutput = descriptor.invokeFunction(in);
- }
- else {
- // Invoke function with inputs
- actualOutput = descriptor.invokeFunction(inputs);
- }
- return actualOutput;
- }
-
- private void helpInvokeMethodFail(String fname, Object[] inputs) {
- helpInvokeMethodFail(fname, null, inputs);
- }
-
- private void helpInvokeMethodFail(String fname, Class<?> types[], Object[] inputs) {
- try {
- helpInvokeMethod(fname, types, inputs, null);
- fail("expected exception"); //$NON-NLS-1$
- } catch (FunctionExecutionException err) {
- }
- }
- // ################################## ACTUAL TESTS ################################
-
- @Test public void testFindFunction1() {
- helpFindFunction("convert", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }) );
- }
-
- @Test public void testFindFunction2() {
- helpFindFunction("cast", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor(FunctionLibrary.CAST, new Class[] { T_INTEGER, T_STRING }) );
- }
-
- @Test public void testFindFunction3() {
- helpFindFunction("curdate", new Class[0], //$NON-NLS-1$
- helpCreateDescriptor("curdate", new Class[0])); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction4() {
- helpFindFunctionFail("curdate", new Class[] { T_INTEGER }); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction5() {
- helpFindFunction("+", new Class[] { T_INTEGER, T_INTEGER }, //$NON-NLS-1$
- helpCreateDescriptor("+", new Class[] { T_INTEGER, T_INTEGER }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction6() {
- helpFindFunctionFail("+", new Class[] {T_INTEGER, T_FLOAT}); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction7() {
- helpFindFunctionFail("+", new Class[] {T_INTEGER, T_FLOAT, T_INTEGER}); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction8() {
- helpFindFunctionFail("+", new Class[] {T_INTEGER}); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction9() {
- helpFindFunctionFail("+", new Class[] {T_INTEGER, T_NULL }); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction10() {
- helpFindFunction("substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
- helpCreateDescriptor("substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction11() {
- helpFindFunction("substring", new Class[] { T_STRING, T_INTEGER }, //$NON-NLS-1$
- helpCreateDescriptor("substring", new Class[] { T_STRING, T_INTEGER }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction12() {
- helpFindFunction("context", new Class[] { T_STRING, T_INTEGER }, //$NON-NLS-1$
- helpCreateDescriptor("context", new Class[] { T_STRING, T_INTEGER }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction12a() {
- helpFindFunction("rowlimit", new Class[] { T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("rowlimit", new Class[] { T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction12b() {
- helpFindFunction("rowlimitexception", new Class[] { T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("rowlimitexception", new Class[] { T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFind0ArgConversion1() {
- helpFindConversions(
- "curdate", new Class[] {}, //$NON-NLS-1$
- new FunctionDescriptor[0] );
- }
-
- @Test public void testFind0ArgConversion2() {
- helpFindConversions(
- "curdate", new Class[] { T_INTEGER }, //$NON-NLS-1$
- null );
- }
-
- @Test public void testFind1ArgConversion1() {
- helpFindConversions(
- "length", new Class[] { T_STRING }, //$NON-NLS-1$
- new FunctionDescriptor[1] );
- }
-
- @Test public void testFind1ArgConversion2() {
- helpFindConversions(
- "length", new Class[] { T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING })
- } );
- }
-
- @Test public void testFind1ArgConversion3() {
- helpFindConversions(
- "length", new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.TIMESTAMP, T_STRING })
- } );
- }
-
- @Test public void testFind2ArgConversion1() {
- helpFindConversions(
- "+", new Class[] { T_INTEGER, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[2] );
- }
-
- @Test public void testFind2ArgConversion2() {
- helpFindConversions(
- "+", new Class[] { T_INTEGER, T_FLOAT }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_FLOAT, T_STRING }) } );
- }
-
- @Test public void testFind2ArgConversion3() {
- helpFindConversions(
- "+", new Class[] { T_FLOAT, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_FLOAT, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }) } );
- }
-
- @Test public void testFind2ArgConversion4() {
- helpFindConversions(
- "+", new Class[] { T_STRING, T_FLOAT }, //$NON-NLS-1$
- null );
- }
-
- @Test public void testFind2ArgConversion5() {
- helpFindConversions(
- "+", new Class[] { T_NULL, T_NULL }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) } );
- }
-
- @Test public void testFind2ArgConversion6() {
- helpFindConversions(
- "+", new Class[] { T_NULL, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- null } );
- }
-
- @Test public void testFind2ArgConversion7() {
- helpFindConversions(
- "+", new Class[] { T_INTEGER, T_NULL }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- null,
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) } );
- }
-
- @Test public void testFind3ArgConversion1() {
- helpFindConversions(
- "substring", new Class[] { T_STRING, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[3] );
- }
-
- @Test public void testFind3ArgConversion2() {
- helpFindConversions(
- "substring", new Class[] { T_INTEGER, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }),
- null,
- null
- } );
- }
-
- @Test public void testFind3ArgConversion3() {
- helpFindConversions(
- "substring", new Class[] { T_INTEGER, T_INTEGER, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_INTEGER, T_STRING }),
- null,
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING })
- } );
- }
-
- @Test public void testFind3ArgConversion4() {
- helpFindConversions(
- "substring", new Class[] { T_STRING, T_INTEGER, DataTypeManager.DefaultDataClasses.TIMESTAMP }, //$NON-NLS-1$
- null );
- }
-
- @Test public void testFind3ArgConversion5() {
- helpFindConversions(
- "substring", new Class[] { T_STRING, DataTypeManager.DefaultDataClasses.SHORT, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- null,
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING })
- } );
- }
-
- @Test public void testFind3ArgConversion6() {
- helpFindConversions(
- "substring", new Class[] { T_INTEGER, DataTypeManager.DefaultDataClasses.SHORT, DataTypeManager.DefaultDataClasses.SHORT }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.INTEGER, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { DataTypeManager.DefaultDataClasses.SHORT, T_STRING })
- } );
- }
-
- @Test public void testFind3ArgConversion7() {
- helpFindConversions(
- "substring", new Class[] { T_NULL, T_INTEGER, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- null,
- null }
- );
- }
-
- @Test public void testFind3ArgConversion8() {
- helpFindConversions(
- "substring", new Class[] { T_NULL, T_NULL, T_INTEGER }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- null }
- );
- }
-
- @Test public void testFind3ArgConversion9() {
- helpFindConversions(
- "substring", new Class[] { T_NULL, T_NULL, T_NULL }, //$NON-NLS-1$
- new FunctionDescriptor[] {
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }),
- helpCreateDescriptor(FunctionLibrary.CONVERT, new Class[] { T_NULL, T_STRING }) }
- );
- }
-
- // Walk through all functions by metadata
- @Test public void testEnumerateForms() {
- Collection categories = library.getFunctionCategories();
- Iterator catIter = categories.iterator();
- while(catIter.hasNext()) {
- String category = (String) catIter.next();
- //System.out.println("Category: " + category);
-
- Collection functions = library.getFunctionForms(category);
- Iterator functionIter = functions.iterator();
- while(functionIter.hasNext()) {
- FunctionForm form = (FunctionForm) functionIter.next();
- //System.out.println("\tFunction: " + form.getDisplayString());
-
- // Lookup this form
- helpFindForm(form.getName(), form.getArgNames().size());
- }
- }
- }
-
- @Test public void testFindForm1() {
- helpFindForm("convert", 2); //$NON-NLS-1$
- }
-
- @Test public void testFindForm2() {
- helpFindForm("locate", 2); //$NON-NLS-1$
- }
-
- @Test public void testFindForm3() {
- helpFindForm("locate", 3); //$NON-NLS-1$
- }
-
- @Test public void testFindForm4() {
- helpFindForm("substring", 2); //$NON-NLS-1$
- }
-
- @Test public void testFindForm5() {
- helpFindForm("substring", 3); //$NON-NLS-1$
- }
-
- @Test public void testFindForm6() {
- helpFindForm("now", 0); //$NON-NLS-1$
- }
-
- @Test public void testInvokePlus1() {
- helpInvokeMethod("+", new Object[] { new Integer(3), new Integer(2) }, new Integer(5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokePlus2() {
- helpInvokeMethod("+", new Object[] { new Long(3), new Long(2) }, new Long(5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokePlus3() {
- helpInvokeMethod("+", new Object[] { new Float(3), new Float(2) }, new Float(5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokePlus4() {
- helpInvokeMethod("+", new Object[] { new Double(3), new Double(2) }, new Double(5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokePlus5() {
- helpInvokeMethod("+", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokePlus6() {
- helpInvokeMethod("+", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("5")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeMinus1() {
- helpInvokeMethod("-", new Object[] { new Integer(3), new Integer(2) }, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMinus2() {
- helpInvokeMethod("-", new Object[] { new Long(3), new Long(2) }, new Long(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMinus3() {
- helpInvokeMethod("-", new Object[] { new Float(3), new Float(2) }, new Float(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMinus4() {
- helpInvokeMethod("-", new Object[] { new Double(3), new Double(2) }, new Double(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMinus5() {
- helpInvokeMethod("-", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeMinus6() {
- helpInvokeMethod("-", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeMultiply1() {
- helpInvokeMethod("*", new Object[] { new Integer(3), new Integer(2) }, new Integer(6)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMultiply2() {
- helpInvokeMethod("*", new Object[] { new Long(3), new Long(2) }, new Long(6)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMultiply3() {
- helpInvokeMethod("*", new Object[] { new Float(3), new Float(2) }, new Float(6)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMultiply4() {
- helpInvokeMethod("*", new Object[] { new Double(3), new Double(2) }, new Double(6)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMultiply5() {
- helpInvokeMethod("*", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("6")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeMultiply6() {
- helpInvokeMethod("*", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("6")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeDivide1() {
- helpInvokeMethod("/", new Object[] { new Integer(3), new Integer(2) }, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDivide2() {
- helpInvokeMethod("/", new Object[] { new Long(3), new Long(2) }, new Long(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDivide3() {
- helpInvokeMethod("/", new Object[] { new Float(3), new Float(2) }, new Float(1.5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDivide4() {
- helpInvokeMethod("/", new Object[] { new Double(3), new Double(2) }, new Double(1.5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDivide5() {
- helpInvokeMethod("/", new Object[] { new BigInteger("3"), new BigInteger("2") }, new BigInteger("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- // one digit precision
- @Test public void testInvokeDivide6() {
- helpInvokeMethod("/", new Object[] { new BigDecimal("3"), new BigDecimal("2") }, new BigDecimal("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeDivide7() throws Exception {
- helpInvokeMethodFail("/", new Object[] { new Float("3"), new Float("0") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeDivideMod() {
- helpInvokeMethod("mod", new Object[] { new BigDecimal("3.1"), new BigDecimal("2") }, new BigDecimal("1.1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeAbs1() {
- helpInvokeMethod("abs", new Object[] { new Integer(-3) }, new Integer(3)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAbs2() {
- helpInvokeMethod("abs", new Object[] { new Long(-3) }, new Long(3)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAbs3() {
- helpInvokeMethod("abs", new Object[] { new Float(-3) }, new Float(3)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAbs4() {
- helpInvokeMethod("abs", new Object[] { new Double(-3) }, new Double(3)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAbs5() {
- helpInvokeMethod("abs", new Object[] { new BigInteger("-3") }, new BigInteger("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeAbs6() {
- helpInvokeMethod("abs", new Object[] { new BigDecimal("-3") }, new BigDecimal("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeAcos() {
- helpInvokeMethod("acos", new Object[] { new Double(0.05) }, new Double(1.5207754699891267)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAsin() {
- helpInvokeMethod("asin", new Object[] { new Double(0.05) }, new Double(0.050020856805770016)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAtan() {
- helpInvokeMethod("atan", new Object[] { new Double(0.05) }, new Double(0.049958395721942765)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAtan2() {
- helpInvokeMethod("atan2", new Object[] { new Double(0.05), new Double(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAtanBigDecimal() {
- helpInvokeMethod("atan", new Object[] { new BigDecimal(0.05) }, new Double(0.049958395721942765)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAtan2BigDecimal() {
- helpInvokeMethod("atan2", new Object[] { new BigDecimal(0.05), new BigDecimal(0.07) }, new Double(0.6202494859828215)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeCos() {
- helpInvokeMethod("cos", new Object[] { new Double(1.57) }, new Double(7.963267107332633E-4)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeCot() {
- helpInvokeMethod("cot", new Object[] { new Double(1.57) }, new Double(7.963269632231926E-4)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDegrees() {
- helpInvokeMethod("degrees", new Object[] { new Double(1.57) }, new Double(89.95437383553926)); //$NON-NLS-1$
- }
-
- @Test public void testInvokePI() {
- helpInvokeMethod("pi", new Object[] { }, new Double(3.141592653589793)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeRadians() {
- helpInvokeMethod("radians", new Object[] { new Double(89.95437383553926) }, new Double(1.57)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeSin() {
- helpInvokeMethod("sin", new Object[] { new Double(1.57) }, new Double(0.9999996829318346)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeTan() {
- helpInvokeMethod("tan", new Object[] { new Double(0.785) }, new Double(0.9992039901050427)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeAscii() {
- helpInvokeMethod("ascii", new Object[] { " " }, new Integer(32)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInvokeChr() {
- helpInvokeMethod("chr", new Object[] { new Integer(32) }, new Character(' ')); //$NON-NLS-1$
- }
-
- @Test public void testInvokeNvl() {
- helpInvokeMethod("nvl", new Object[] { new Integer(5), new Integer(10) }, new Integer(5) ); //$NON-NLS-1$
- }
-
- @Test public void testInvokeConcatOperator() {
- helpInvokeMethod("||", new Object[] { "a", "b" }, "ab" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeInitcap() {
- helpInvokeMethod("initcap", new Object[] { "my test\ndata" }, "My Test\nData" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeLpad1() {
- helpInvokeMethod("lpad", new Object[] { "x", new Integer(3) }, " x" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeLpad2() {
- helpInvokeMethod("lpad", new Object[] { "x", new Integer(3), "y" }, "yyx" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeRpad1() {
- helpInvokeMethod("rpad", new Object[] { "x", new Integer(3) }, "x " ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeRpad2() {
- helpInvokeMethod("rpad", new Object[] { "x", new Integer(3), "y" }, "xyy" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeTranslate() {
- helpInvokeMethod("translate", new Object[] { "ababcd", "ad", "da" }, "dbdbca" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- }
-
- @Test public void testFindFunction13() {
- helpFindFunction("formatTime", new Class[] { T_TIME, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatTime", new Class[] { T_TIME, T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction14() {
- helpFindFunction("formatDate", new Class[] { T_DATE, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatDate", new Class[] { T_DATE, T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction15() {
- helpFindFunction("formatTimestamp", new Class[] { T_TIMESTAMP, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatTimestamp", new Class[] { T_TIMESTAMP, T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction16() {
- helpFindFunction("parseTime", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseTime", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction17() {
- helpFindFunction("parseDate", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseDate", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction18() {
- helpFindFunction("parseTimestamp", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseTimestamp", new Class[] { T_STRING, T_STRING }) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFunction19() {
- helpFindFunction("env", new Class[] {T_STRING}, //$NON-NLS-1$
- helpCreateDescriptor("env", new Class[] {T_STRING})); //$NON-NLS-1$
- }
-
- @Test public void testInvokeFormatTimestamp1() {
- helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("mm/dd/yy h:mm a") }, "04/05/03 3:04 AM"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatTimestamp2() {
- helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("yyyy-mm-dd k:mm a z") }, "2003-04-05 3:04 AM GMT-06:00"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatTimestamp3() {
- helpInvokeMethod("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("yyyy-mm-dd hh:mm:ss.SSSS") }, "2003-04-05 03:04:12.0000"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatTimestampFail() throws Exception {
- helpInvokeMethodFail("formatTimestamp", new Object[] {TimestampUtil.createTimestamp(103, 2, 5, 3, 4, 12, 255), new String("mm/dd/nn h:mm a") }); //$NON-NLS-1$
- }
-
- @Test public void testInvokeParseTimestamp1() {
- helpInvokeMethod("parseTimestamp", new Object[] {new String("05 Mar 2003 03:12:23 CST"), new String("dd MMM yyyy HH:mm:ss z") }, TimestampUtil.createTimestamp(103, 2, 5, 3, 12, 23, 0)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeParseTimestamp2() {
- helpInvokeMethod("parseTimestamp", new Object[] {new String("05 Mar 2003 03:12:23.333"), new String("dd MMM yyyy HH:mm:ss.SSS") }, TimestampUtil.createTimestamp(103, 2, 5, 3, 12, 23, 333*1000000)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testFindFormatInteger() {
- helpFindFunction("formatInteger", new Class[] { T_INTEGER, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatInteger", new Class[] { T_INTEGER, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFormatFloat() {
- helpFindFunction("formatFloat", new Class[] { T_FLOAT, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatFloat", new Class[] { T_FLOAT, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFormatDouble() {
- helpFindFunction("formatDouble", new Class[] { T_DOUBLE, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatDouble", new Class[] { T_DOUBLE, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFormatLong() {
- helpFindFunction("formatLong", new Class[] { T_LONG, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatLong", new Class[] { T_LONG, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFormatBigInteger() {
- helpFindFunction("formatBigInteger", new Class[] { T_BIG_INTEGER, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatBigInteger", new Class[] { T_BIG_INTEGER, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindFormatBigDecimal() {
- helpFindFunction("formatBigDecimal", new Class[] { T_BIG_DECIMAL, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("formatBigDecimal", new Class[] { T_BIG_DECIMAL, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindParseInteger() {
- helpFindFunction("parseInteger", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseInteger", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindParseLong() {
- helpFindFunction("parseLong", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseLong", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindParseDouble() {
- helpFindFunction("parseDouble", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseDouble", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
- }
- @Test public void testFindParseFloat() {
- helpFindFunction("parseFloat", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseFloat", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindParseBigInteger() {
- helpFindFunction("parseBigInteger", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseBigInteger", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testFindParseBigDecimal() {
- helpFindFunction("parseBigDecimal", new Class[] { T_STRING, T_STRING }, //$NON-NLS-1$
- helpCreateDescriptor("parseBigDecimal", new Class[] { T_STRING, T_STRING}) ); //$NON-NLS-1$
- }
-
- @Test public void testInvokeParseInteger() {
- helpInvokeMethod("parseInteger", new Object[] {new String("-1234"), new String("######")}, new Integer(-1234)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeParseLong() {
- helpInvokeMethod("parseLong", new Object[] {new String("123456"), new String("######.##")}, new Long(123456)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeParseDouble() {
- helpInvokeMethod("parseDouble", new Object[] {new String("123456.78"), new String("#####.#")}, new Double(123456.78)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeParseFloat() {
- helpInvokeMethod("parseFloat", new Object[] {new String("1234.56"), new String("####.###")}, new Float(1234.56)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeParseBigInteger() {
- helpInvokeMethod("parseBigInteger", new Object[] {new String("12345678"), new String("###,###")}, new BigInteger("12345678")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeParseBigDecimal() {
- helpInvokeMethod("parseBigDecimal", new Object[] {new String("1234.56"), new String("#####")}, new BigDecimal("1234.56")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeFormatInteger() {
- helpInvokeMethod("formatInteger", new Object[] {new Integer(-1234), new String("######")}, "-1234"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatLong() {
- helpInvokeMethod("formatLong", new Object[] {new Long(123456788), new String("##,###,#")}, "1,2,3,4,5,6,7,8,8"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatDouble() {
- helpInvokeMethod("formatDouble", new Object[] {new Double(1234.67), new String("####.##")}, "1234.67"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatFloat() {
- helpInvokeMethod("formatFloat", new Object[] {new Float(1234.67), new String("###.###")}, "1234.67"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFormatBigInteger() {
- helpInvokeMethod("formatBigInteger", new Object[] {new BigInteger("45"), new String("###.###")}, "45"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeFormatBigDecimal() {
- helpInvokeMethod("formatBigDecimal", new Object[] {new BigDecimal("1234.56"), new String("###.###")}, "1234.56"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokeQuarter1() {
- // 2003-5-15
- helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 4, 15)}, new Integer(2)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeQuarter2() {
- // 2003-5-1
- helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 3, 31)}, new Integer(2)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeQuarter3() {
- // 2003-1-31
- helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 0, 31)}, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeQuarter4() {
- // 2003-9-30
- helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 8, 30)}, new Integer(3)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeQuarter5() {
- // 2003-12-31
- helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 11, 31)}, new Integer(4)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeQuarter6() {
- //bad date such as 2003-13-45
- helpInvokeMethod("quarter", new Object[] {TimestampUtil.createDate(103, 12, 45)}, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeIfNull() {
- helpInvokeMethod("ifnull", new Object[] {new Integer(5), new Integer(10)}, new Integer(5)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeLower() {
- helpInvokeMethod("lower", new Object[] {new String("LOWER")}, new String("lower")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeUpper() {
- helpInvokeMethod("upper", new Object[] {new String("upper")}, new String("UPPER")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeRepeat() {
- helpInvokeMethod("repeat", new Object[] {new String("cat"), new Integer(3)}, new String("catcatcat")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeChar() {
- helpInvokeMethod("char", new Object[] {new Integer(32) }, new Character(' ')); //$NON-NLS-1$
- }
-
- /** normal input */
- @Test public void testInvokeInsert1() {
- helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(4), //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(2), new String("cat")}, new String("Dowcatown")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** empty string2 */
- @Test public void testInvokeInsert2() {
- helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(4), //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(2), new String("")}, new String("Dowown")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** empty string1 with start = 1 and length = 0, so result is just string2 */
- @Test public void testInvokeInsert3() {
- helpInvokeMethod("insert", new Object[] {new String(""), new Integer(1), //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(0), new String("cat")}, new String("cat")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** should fail, with start > string1.length() */
- @Test public void testInvokeInsert4() throws Exception {
- helpInvokeMethodFail("insert", new Object[] {new String(""), new Integer(2), //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(0), new String("cat")}); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** should fail, with length > 0 and input string1.length() = 0 */
- @Test public void testInvokeInsert5() throws Exception {
- helpInvokeMethodFail("insert", new Object[] {new String(""), new Integer(1), //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(1), new String("cat")}); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /** (length + start) > string1.length(), then just append str2 starting at start position */
- @Test public void testInvokeInsert6() {
- helpInvokeMethod("insert", new Object[] {new String("Downtown"), new Integer(7), //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(5), new String("cat")}, new String("Downtocat")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInvokeTimestampAddDate_ignore_case() {
- helpInvokeMethod("timestampAdd", new Object[] {"sql_TSI_day", //$NON-NLS-1$ //$NON-NLS-2$
- new Integer(28), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(103, 5, 12).getTime()));
- }
-
- /** date + month --> count=18, inteval=month, result should be 2004-11-15 */
- @Test public void testInvokeTimestampAddDate2() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
- new Integer(18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 10, 15).getTime()));
- }
-
- /** date + month --> count=-18, inteval=month, result should be 2001-11-15 */
- @Test public void testInvokeTimestampAddDate2a() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MONTH, //$NON-NLS-1$
- new Integer(-18), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(101, 10, 15).getTime()));
- }
-
- /** date + week --> count=6, inteval=week, result should be 2003-04-03 */
- @Test public void testInvokeTimestampAddDate3() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
- new Integer(-6), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(103, 3, 3).getTime()));
- }
-
- /** date + quarter --> count=3, inteval=quarter, result should be 2004-2-15 */
- @Test public void testInvokeTimestampAddDate4() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_QUARTER, //$NON-NLS-1$
- new Integer(3), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(104, 1, 15).getTime()));
- }
-
- /** date + year --> count=-1, inteval=year, result should be 2002-5-15 */
- @Test public void testInvokeTimestampAddDate5() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_YEAR, //$NON-NLS-1$
- new Integer(-1), new Timestamp(TimestampUtil.createDate(103, 4, 15).getTime())}, new Timestamp(TimestampUtil.createDate(102, 4, 15).getTime()));
- }
-
- /** time + minute --> count=23, inteval=3, result should be 03:32:12 */
- @Test public void testInvokeTimestampAddTime1() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_MINUTE, //$NON-NLS-1$
- new Integer(23), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 32, 12).getTime()));
- }
-
- /** time + hour --> count=21, inteval=4, result should be 00:09:12 and overflow */
- @Test public void testInvokeTimestampAddTime2() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
- new Integer(21), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 0, 9, 12, 0));
- }
-
- /** time + hour --> count=2, inteval=4, result should be 01:12:12*/
- @Test public void testInvokeTimestampAddTime3() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
- new Integer(2), new Timestamp(TimestampUtil.createTime(23, 12, 12).getTime())}, TimestampUtil.createTimestamp(70, 0, 2, 1, 12, 12, 0));
- }
-
- /** time + second --> count=23, inteval=2, result should be 03:10:01 */
- @Test public void testInvokeTimestampAddTime4() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
- new Integer(49), new Timestamp(TimestampUtil.createTime(3, 9, 12).getTime())}, new Timestamp(TimestampUtil.createTime(3, 10, 1).getTime()));
- }
-
- /** timestamp + second --> count=23, inteval=2, result should be 2003-05-15 03:09:35.100 */
- @Test public void testInvokeTimestampAddTimestamp1() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_SECOND, //$NON-NLS-1$
- new Integer(23), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)},
- TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 35, 100));
- }
-
- /** timestamp + nanos --> count=1, inteval=1, result should be 2003-05-15 03:09:12.000000101 */
- @Test public void testInvokeTimestampAddTimestamp2() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
- new Integer(1), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 100)},
- TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 12, 101));
- }
-
- /** timestamp + nanos --> count=2100000000, inteval=1, result should be 2003-05-15 03:10:01.100000003
- * with increase in second and minutes, because second already at 59 sec originally
- */
- @Test public void testInvokeTimestampAddTimestamp3() {
- helpInvokeMethod("timestampAdd", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
- new Integer(2100000000), TimestampUtil.createTimestamp(103, 4, 15, 3, 9, 59, 1)},
- TimestampUtil.createTimestamp(103, 4, 15, 3, 10, 1, 100000003));
- }
-
- /** time --> interval=hour, time1 = 03:04:45, time2= 05:05:36 return = 2 */
- @Test public void testInvokeTimestampDiffTime1() {
- helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_HOUR, //$NON-NLS-1$
- new Timestamp(TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(TimestampUtil.createTime(5, 5, 36).getTime()) },
- new Long(2));
- }
-
- @Test public void testInvokeTimestampDiffTime1_ignorecase() {
- helpInvokeMethod("timestampDiff", new Object[] {"SQL_tsi_HOUR", //$NON-NLS-1$ //$NON-NLS-2$
- new Timestamp(TimestampUtil.createTime(3, 4, 45).getTime()), new Timestamp(TimestampUtil.createTime(5, 5, 36).getTime()) },
- new Long(2));
- }
-
- /**
- * timestamp --> interval=week, time1 = 2002-06-21 03:09:35.100,
- * time2= 2003-05-02 05:19:35.500 return = 45
- */
- @Test public void testInvokeTimestampDiffTimestamp1() {
- helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_WEEK, //$NON-NLS-1$
- TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100), TimestampUtil.createTimestamp(103, 4, 2, 5, 19, 35, 500) },
- new Long(45));
- }
-
- /**
- * timestamp --> interval=frac_second, time1 = 2002-06-21 03:09:35.000000001,
- * time2= 2002-06-21 03:09:35.100000000 return = 999999999
- */
- @Test public void testInvokeTimestampDiffTimestamp2() {
- helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
- TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 1), TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 100000000) },
- new Long(99999999));
- }
-
- /**
- * timestamp --> interval=frac_second, time1 = 2002-06-21 03:09:35.000000002,
- * time2= 2002-06-22 03:09:35.000000001 return =
- */
- @Test public void testInvokeTimestampDiffTimestamp3() {
- helpInvokeMethod("timestampDiff", new Object[] {SQLReservedWords.SQL_TSI_FRAC_SECOND, //$NON-NLS-1$
- TimestampUtil.createTimestamp(102, 5, 21, 3, 9, 35, 2), TimestampUtil.createTimestamp(102, 5, 22, 3, 9, 35, 1) },
- new Long(86399999999999L));
- }
-
- @Test public void testInvokeTimestampCreate1() {
- helpInvokeMethod("timestampCreate", new Object[] {TimestampUtil.createDate(103, 4, 15), //$NON-NLS-1$
- TimestampUtil.createTime(23, 59, 59)},
- TimestampUtil.createTimestamp(103, 4, 15, 23, 59, 59, 0));
- }
-
- @Test public void testInvokeBitand() {
- helpInvokeMethod("bitand", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0x0F0)); //$NON-NLS-1$
- }
- @Test public void testInvokeBitor() {
- helpInvokeMethod("bitor", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0xFFF)); //$NON-NLS-1$
- }
- @Test public void testInvokeBitxor() {
- helpInvokeMethod("bitxor", new Object[] {new Integer(0xFFF), new Integer(0x0F0)}, new Integer(0xF0F)); //$NON-NLS-1$
- }
- @Test public void testInvokeBitnot() {
- helpInvokeMethod("bitnot", new Object[] {new Integer(0xF0F)}, new Integer(0xFFFFF0F0)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeRound1() {
- helpInvokeMethod("round", new Object[] {new Integer(123), new Integer(-1)}, new Integer(120)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeRound2() {
- helpInvokeMethod("round", new Object[] {new Float(123.456), new Integer(2)}, new Float(123.46)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeRound3() {
- helpInvokeMethod("round", new Object[] {new Double(123.456), new Integer(2)}, new Double(123.46)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeRound4() {
- helpInvokeMethod("round", new Object[] {new BigDecimal("123.456"), new Integer(2)}, new BigDecimal("123.460")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- /** defect 10941 */
- @Test public void testInvokeConvertTime() {
- helpInvokeMethod("convert", new Object[] {"05:00:00", "time"}, TimestampUtil.createTime(5, 0, 0)); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeXpath1() {
- helpInvokeMethod("xpathValue", //$NON-NLS-1$
- new Object[] {
- "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b><c>test</c></b></a>", //$NON-NLS-1$
- "a/b/c"}, //$NON-NLS-1$
- "test"); //$NON-NLS-1$
- }
-
- @Test public void testInvokeXpathWithNill() {
- helpInvokeMethod("xpathValue", //$NON-NLS-1$
- new Object[] {
- "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><b xsi:nil=\"true\"/></a>", //$NON-NLS-1$
- "//*[local-name()='b' and not(@*[local-name()='nil' and string()='true'])]"}, //$NON-NLS-1$
- null);
- }
-
- @Test public void testInvokeXpathWithNill1() {
- helpInvokeMethod("xpathValue", //$NON-NLS-1$
- new Object[] {
- "<?xml version=\"1.0\" encoding=\"utf-8\" ?><a><b>value</b></a>", //$NON-NLS-1$
- "//*[local-name()='b' and not(@*[local-name()='nil' and string()='true'])]"}, //$NON-NLS-1$
- "value"); //$NON-NLS-1$
- }
-
- @Test public void testInvokeModifyTimeZone() {
- Timestamp ts = Timestamp.valueOf("2004-10-03 23:59:59.123"); //$NON-NLS-1$
- Timestamp out = Timestamp.valueOf("2004-10-03 22:59:59.123"); //$NON-NLS-1$
- helpInvokeMethod("modifyTimeZone", new Object[] {ts, "America/Chicago", "America/New_York" }, out); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- // TimestampWithTimezone has a static copy the default timezone object which makes this test not execute properly
- public void defer_testInvokeModifyTimeZoneFromLocal() {
- Timestamp ts = Timestamp.valueOf("2004-10-03 23:59:59.123"); //$NON-NLS-1$
- Timestamp out = Timestamp.valueOf("2004-10-03 21:59:59.123"); //$NON-NLS-1$
- helpInvokeMethod("modifyTimeZone", new Object[] {ts, "America/New_York" }, out); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInvokeRand() throws Exception {
- helpInvokeMethod("rand", new Object[] {new Integer(100)}, new Double(0.7220096548596434)); //$NON-NLS-1$
- // this does not actually fail but returns a result
- assertNotNull(helpInvokeMethod("rand", new Class[] {Integer.class}, new Object[] {null}, null)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeUser() throws Exception {
- CommandContext c = new CommandContext();
- c.setUserName("foodude"); //$NON-NLS-1$
- helpInvokeMethod("user", new Class[] {}, new Object[] {}, c, "foodude"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testInvokeEnv() throws Exception {
- CommandContext c = new CommandContext();
- Properties props = new Properties();
- props.setProperty("env_test", "env_value"); //$NON-NLS-1$ //$NON-NLS-2$
- c.setEnvironmentProperties(props);
- helpInvokeMethod("env", new Class[] {String.class}, new Object[] {"env_test"}, c, "env_value"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- helpInvokeMethod("env", new Class[] {String.class}, new Object[] {null}, c, null); //$NON-NLS-1$
- }
-
- @Test public void testInvokeCommandPayload() throws Exception {
- CommandContext c = new CommandContext();
- c.setCommandPayload("payload_too heavy"); //$NON-NLS-1$
- helpInvokeMethod("commandpayload", new Class[] {}, new Object[] {}, c, "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$
- helpInvokeMethod("commandpayload", new Class[] {String.class}, new Object[] {null}, c, null); //$NON-NLS-1$
- Properties props = new Properties();
- props.setProperty("payload", "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$
- c.setCommandPayload(props);
- helpInvokeMethod("commandpayload", new Class[] {String.class}, new Object[] {"payload"}, c, "payload_too heavy"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testNullDependent() {
- FunctionDescriptor actual = library.findFunction("concat2", new Class[] {String.class, String.class}); //$NON-NLS-1$
- assertTrue(actual.isNullDependent());
-
- actual = library.findFunction("concat", new Class[] {String.class, String.class}); //$NON-NLS-1$
- assertFalse(actual.isNullDependent());
- }
-
- @Test public void testInvokeCeiling() {
- helpInvokeMethod("ceiling", new Object[] { new Double("3.14") }, new Double("4")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeFloor() {
- helpInvokeMethod("floor", new Object[] { new Double("3.14") }, new Double("3")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeExp() {
- helpInvokeMethod("exp", new Object[] { new Double("0") }, new Double("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeLog() {
- helpInvokeMethod("log", new Object[] { new Double("1") }, new Double("0")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeLog10() {
- helpInvokeMethod("log10", new Object[] { new Double("10") }, new Double("1")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeLog10Error() throws Exception {
- helpInvokeMethodFail("log10", new Object[] { new Double("0") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokePower() {
- helpInvokeMethod("power", new Object[] { new Double("10"), new Double("2") }, new Double("100")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- @Test public void testInvokePower1() {
- helpInvokeMethod("power", new Object[] { new BigDecimal("10"), new Integer(2) }, new BigDecimal("100")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeSqrt() {
- helpInvokeMethod("sqrt", new Object[] { new Double("4")}, new Double("2")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-
- @Test public void testInvokeDayName() {
- for (int i = 0; i < FunctionMethods.dayNames.length; i++) {
- Date time = TimestampUtil.createDate(100, 0, i + 2);
- helpInvokeMethod("dayName", new Object[] { time }, FunctionMethods.dayNames[i]); //$NON-NLS-1$
- }
- }
-
- @Test public void testInvokeDayOfMonth() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("dayOfMonth", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDayOfWeek() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("dayOfWeek", new Object[] { time }, new Integer(7)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeDayOfYear() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 2, 1, 2, 3, 4);
- helpInvokeMethod("dayOfYear", new Object[] { time }, new Integer(2)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMonth() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("month", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeMonthName() {
- for (int i = 0; i < FunctionMethods.monthNames.length; i++) {
- Date time = TimestampUtil.createDate(100, i, 1);
- helpInvokeMethod("monthName", new Object[] { time }, FunctionMethods.monthNames[i]); //$NON-NLS-1$
- }
- }
-
- @Test public void testInvokeMinute() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("minute", new Object[] { time }, new Integer(2)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeSecond() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("second", new Object[] { time }, new Integer(3)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeWeek() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("week", new Object[] { time }, new Integer(1)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeYear() {
- Timestamp time = TimestampUtil.createTimestamp(100, 0, 1, 1, 2, 3, 4);
- helpInvokeMethod("year", new Object[] { time }, new Integer(2000)); //$NON-NLS-1$
- }
-
- @Test public void testInvokeCoalesce() {
- helpInvokeMethod(FunctionLibrary.COALESCE, new Object[] { Integer.valueOf(0), Integer.valueOf(1), Integer.valueOf(2) }, Integer.valueOf(0));
- }
-
- @Test public void testInvokeCoalesce1() {
- helpInvokeMethod(FunctionLibrary.COALESCE, new Object[] { null, null}, null);
- }
-
- @Test public void testInvokeNull() throws Exception {
- helpInvokeMethod(SourceSystemFunctions.LTRIM, new Class[] {DataTypeManager.DefaultDataClasses.STRING}, new Object[] { null }, null, null);
- }
-
- @Test public void testInvokeNull1() throws Exception {
- helpInvokeMethod(SourceSystemFunctions.CONCAT, new Class[] {DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING}, new Object[] { null, String.valueOf(1) }, null, null);
- }
-
- @Test public void testInvokeXslTransform() throws Exception {
- CommandContext c = new CommandContext();
- c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
- ClobType result = (ClobType)helpInvokeMethod("xsltransform", new Class[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML},
- new Object[] {DataTypeManager.transformValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML),
- DataTypeManager.transformValue("<?xml version=\"1.0\" encoding=\"UTF-8\"?><xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\"><xsl:template match=\"@*|node()\"><xsl:copy><xsl:apply-templates select=\"@*|node()\"/></xsl:copy></xsl:template><xsl:template match=\"Quantity\"/></xsl:stylesheet>", DataTypeManager.DefaultDataClasses.XML)}, c);
-
- String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
- assertEquals("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name></Item></Items></Catalog></Catalogs>", xml);
- }
-
- @Test public void testInvokeXmlConcat() throws Exception {
- CommandContext c = new CommandContext();
- c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
- XMLType result = (XMLType)helpInvokeMethod("xmlconcat", new Class[] {DataTypeManager.DefaultDataClasses.XML, DataTypeManager.DefaultDataClasses.XML},
- new Object[] {DataTypeManager.transformValue("<bar/>", DataTypeManager.DefaultDataClasses.XML), DataTypeManager.transformValue("<Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", DataTypeManager.DefaultDataClasses.XML)}, c);
-
- String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
- assertEquals("<bar/><Catalogs xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"><Catalog><Items><Item ItemID=\"001\"><Name>Lamp</Name><Quantity>5</Quantity></Item></Items></Catalog></Catalogs>", xml);
- }
-
- @Test public void testInvokeXmlComment() throws Exception {
- CommandContext c = new CommandContext();
- c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
- XMLType result = (XMLType)helpInvokeMethod("xmlcomment", new Class[] {DataTypeManager.DefaultDataClasses.STRING},
- new Object[] {"comment"}, c);
-
- String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
- assertEquals("<!--comment-->", xml);
- }
-
- @Test public void testInvokeXpathQuery() throws Exception {
- CommandContext c = new CommandContext();
- c.setBufferManager(BufferManagerFactory.getStandaloneBufferManager());
- XMLType result = (XMLType)helpInvokeMethod("xpathquery", new Class[] {DataTypeManager.DefaultDataClasses.STRING, DataTypeManager.DefaultDataClasses.STRING},
- new Object[] {"<foo><bar>1</bar><bar>2</bar></foo>", "/foo/bar"}, c);
-
- String xml = ObjectConverterUtil.convertToString(result.getCharacterStream());
- assertEquals("<bar>1</bar><bar>2</bar>", xml);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionMetadataReader.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionMetadataReader.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionMetadataReader.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.List;
-
-import com.metamatrix.core.util.UnitTestUtil;
-import com.metamatrix.query.function.metadata.FunctionMetadataReader;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.metadata.FunctionParameter;
-
-import junit.framework.TestCase;
-
-public class TestFunctionMetadataReader extends TestCase {
-
- public void testLoadFunctionMethods() throws Exception {
-
- List<FunctionMethod> fns = FunctionMetadataReader.loadFunctionMethods(new FileInputStream(UnitTestUtil.getTestDataPath()+File.separator+"udf.xmi"));
-
- assertEquals(3, fns.size());
-
- for (FunctionMethod m:fns) {
- if (m.getName().equals("GetSystemProperty")) {
- assertEquals("MyFunctions", m.getCategory());
- assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
- assertEquals("getProperty", m.getInvocationMethod());
- assertEquals(FunctionMethod.CAN_PUSHDOWN, m.getPushdown());
- assertEquals(FunctionMethod.DETERMINISTIC, m.getDeterministic());
- assertNull(m.getDescription());
-
- assertEquals(1, m.getInputParameterCount());
- FunctionParameter in = m.getInputParameters()[0];
- assertEquals("prop", in.getName());
- assertEquals("string", in.getType());
- assertNull(in.getDescription());
-
- assertNotNull(m.getOutputParameter());
- assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
- assertEquals("string", m.getOutputParameter().getType());
-
- }
- else if (m.getName().equals("getpushdown")) {
- assertEquals("MyFunctions", m.getCategory());
- assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
- assertEquals("getPropertyNoArgs", m.getInvocationMethod());
- assertEquals(FunctionMethod.CANNOT_PUSHDOWN, m.getPushdown());
- assertEquals(FunctionMethod.DETERMINISTIC, m.getDeterministic());
- assertNull(m.getDescription());
-
- assertEquals(0, m.getInputParameterCount());
-
- assertNotNull(m.getOutputParameter());
- assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
- assertEquals("string", m.getOutputParameter().getType());
- }
- else if (m.getName().equals("getxyz")) {
- assertEquals("MyFunctions", m.getCategory());
- assertEquals("com.metamatrix.dqp.embedded.udf.MyFunctions", m.getInvocationClass());
- assertEquals("getPropertyNoArgs", m.getInvocationMethod());
- assertEquals(FunctionMethod.CAN_PUSHDOWN, m.getPushdown());
- assertEquals(FunctionMethod.NONDETERMINISTIC, m.getDeterministic());
- assertNull(m.getDescription());
-
- assertEquals(0, m.getInputParameterCount());
-
- assertNotNull(m.getOutputParameter());
- assertEquals(FunctionParameter.OUTPUT_PARAMETER_NAME, m.getOutputParameter().getName());
- assertEquals("string", m.getOutputParameter().getType());
- }
- else {
- fail("unknown method");
- }
- }
-
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestFunctionTree.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,155 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.mockito.Mockito;
-import org.teiid.logging.LogManager;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.function.metadata.FunctionCategoryConstants;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.metadata.FunctionParameter;
-import com.metamatrix.query.function.source.SystemSource;
-
-public class TestFunctionTree extends TestCase {
-
- // ################################## FRAMEWORK ################################
-
- public TestFunctionTree(String name) {
- super(name);
- }
-
- // ################################## TEST HELPERS ################################
-
- // ################################## ACTUAL TESTS ################################
-
- /**
- * Walk through all functions by metadata and verify that we can look
- * each one up by signature
- */
- public void testWalkTree() {
- SystemSource source = new SystemSource();
- FunctionTree ft = new FunctionTree(source);
-
- Collection categories = ft.getCategories();
- Iterator catIter = categories.iterator();
- while(catIter.hasNext()) {
- String category = (String) catIter.next();
- LogManager.logInfo("test", "Category: " + category); //$NON-NLS-1$ //$NON-NLS-2$
-
- Collection functions = ft.getFunctionForms(category);
- Iterator functionIter = functions.iterator();
- while(functionIter.hasNext()) {
- FunctionForm form = (FunctionForm) functionIter.next();
- LogManager.logInfo("test", "\tFunction: " + form.getDisplayString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-
- /**
- * Test what happens when a function is loaded that does not have a class in the
- * classpath. This *should* be ok as long as the function is not invoked.
- */
- public void testUnloadableFunction() {
- // Create dummy source
- FunctionMetadataSource dummySource = new FunctionMetadataSource() {
- public Collection getFunctionMethods() {
- // Build dummy method
- FunctionMethod method = new FunctionMethod(
- "dummy", null, "no category", "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new FunctionParameter[0],
- new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) ); //$NON-NLS-1$
-
- // Wrap method in a list
- List methods = new ArrayList();
- methods.add(method);
- return methods;
- }
-
- public Class getInvocationClass(String className) throws ClassNotFoundException {
- throw new ClassNotFoundException("Could not find class " + className); //$NON-NLS-1$
- }
- };
-
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(dummySource.getFunctionMethods())));
- }
-
- public void testNullCategory() {
- FunctionMetadataSource fms = Mockito.mock(FunctionMetadataSource.class);
- Mockito.stub(fms.getFunctionMethods()).toReturn(Arrays.asList(new FunctionMethod(
- "dummy", null, null, FunctionMethod.MUST_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new FunctionParameter[0],
- new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING) //$NON-NLS-1$
- )));
- FunctionTree ft = new FunctionTree(fms);
- assertEquals(1, ft.getFunctionForms(FunctionCategoryConstants.MISCELLANEOUS).size());
- }
-
-/*
-
-//DEBUGGING CODE - this will print out the tree root in readable form
-//(This code will either have to be pasted in to FunctionTree class, or
-//somehow the Map treeRoot must be gotten from the FunctionTree)
-
- private static void debugPrintTreeRoot(Map treeRoot){
- System.out.println("<!><!><!><!><!><!><!><!><!><!><!><!>");
- System.out.println("FunctionTree treeRoot");
- StringBuffer s = new StringBuffer();
- debugPrintNode(treeRoot, 0, s);
- System.out.println(s.toString());
- System.out.println("<!><!><!><!><!><!><!><!><!><!><!><!>");
- }
-
- private static void debugPrintNode(Map node, int depth, StringBuffer s){
- Iterator i = node.entrySet().iterator();
- Map.Entry anEntry = null;
- while(i.hasNext()) {
- anEntry = (Map.Entry)i.next();
- appendLine(s, depth, "Key: " + anEntry.getKey());
- Object value = anEntry.getValue();
- if (value instanceof Map){
- s.append(" Map... ");
- debugPrintNode((Map)value, depth + 1, s);
- } else {
- s.append(" Value: " + value);
- }
- }
- }
-
- private static void appendLine(StringBuffer s, int depth, String value){
- s.append("\n");
- for (int i = 0; i< depth; i++){
- s.append(" ");
- }
- s.append(value);
- }
-*/
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/function/TestResolvedFunctions.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,96 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.function;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.ExpressionEvaluationException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.common.buffer.BlockedException;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.eval.Evaluator;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestResolvedFunctions extends TestCase {
-
- public void testPowerIntegers() throws Exception {
-
- String sql = "power(10, 10)"; //$NON-NLS-1$
-
- //BigInteger is a closer match here since the second argument matches
- assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, getFunctionResult(sql).getClass());
- }
-
- public void testPowerDoubles() throws Exception {
-
- String sql = "power(10.01, 10.01)"; //$NON-NLS-1$
-
- assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
- }
-
- public void testPowerFloats() throws Exception {
-
- String sql = "power(convert(10.01, float), convert(10.01, float))"; //$NON-NLS-1$
-
- //since the second argument cannot be converted to an integer, the result is a double
- assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
- }
-
- public void testPowerBigInteger() throws Exception {
-
- String sql = "power(convert(10.01, BigInteger), 10)"; //$NON-NLS-1$
-
- assertEquals(DataTypeManager.DefaultDataClasses.BIG_INTEGER, getFunctionResult(sql).getClass());
- }
-
- //there should only be one signature for ceiling. The float argument will be converted to a double
- public void testCeilingFloat() throws Exception {
-
- String sql = "ceiling(convert(10.01, float))"; //$NON-NLS-1$
-
- assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
- }
-
- //same as above
- public void testFloorFloat() throws Exception {
-
- String sql = "floor(convert(10.01, float))"; //$NON-NLS-1$
-
- assertEquals(DataTypeManager.DefaultDataClasses.DOUBLE, getFunctionResult(sql).getClass());
- }
-
- private Object getFunctionResult(String sql) throws QueryParserException,
- ExpressionEvaluationException,
- BlockedException,
- MetaMatrixComponentException, QueryResolverException {
- Expression expr = QueryParser.getQueryParser().parseExpression(sql);
- ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1Cached());
- return Evaluator.evaluate(expr);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/FakeFunctionMetadataSource.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,64 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import com.metamatrix.query.function.FunctionMetadataSource;
-import com.metamatrix.query.function.metadata.FunctionMethod;
-import com.metamatrix.query.function.metadata.FunctionParameter;
-
-public class FakeFunctionMetadataSource implements FunctionMetadataSource {
-
- public Collection getFunctionMethods() {
- List methods = new ArrayList();
- methods.add(new FunctionMethod("xyz", "", "misc", FunctionMethod.MUST_PUSHDOWN, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- FakeFunctionMetadataSource.class.getName(), "xyz", //$NON-NLS-1$
- new FunctionParameter[0],
- new FunctionParameter("out", "integer"))); //$NON-NLS-1$ //$NON-NLS-2$
-
- FunctionParameter p1 = new FunctionParameter("astring", "string"); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionParameter result = new FunctionParameter("trimstring", "string"); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionMethod method = new FunctionMethod("MYRTRIM", "", "", FakeFunctionMetadataSource.class.getName(), "myrtrim", new FunctionParameter[] {p1}, result); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- method.setPushdown(FunctionMethod.CAN_PUSHDOWN);
- methods.add(method);
- return methods;
- }
-
- public Class getInvocationClass(String className) throws ClassNotFoundException {
- return Class.forName(className);
- }
-
- // dummy function
- public static Object xyz() {
- return null;
- }
-
- /** defect 15348*/
- public static Object myrtrim(Object astring) {
- String string = (String)astring;
- return string.trim();
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/InlineViewCase.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/InlineViewCase.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/InlineViewCase.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,45 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import java.util.List;
-import java.util.Set;
-
-public class InlineViewCase {
- public String name;
- public String userQuery;
- public String optimizedQuery;
- public Set<String> sourceQueries;
- public List<List<Object>> expectedResults;
-
- public String getFullyQualifiedQuery() {
- return optimizedQuery;
- }
- public InlineViewCase(String name, String userQuery, String optimizedQuery, Set<String> sourceQueries, List expectedResults) {
- this.name = name;
- this.userQuery = userQuery;
- this.optimizedQuery = optimizedQuery;
- this.sourceQueries = sourceQueries;
- this.expectedResults = expectedResults;
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAccessPatterns.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,294 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import org.junit.Test;
-
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.validator.TestValidator;
-
-
-public class TestAccessPatterns {
-
- /**
- * The virtual access patterns should get satisfied
- */
- @Test public void testVirtualAccessPatternPassing() {
- String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1 and e1='2'"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT test.\"group\".e0, test.\"group\".e2 FROM test.\"group\" WHERE (test.\"group\".e0 = 1) AND (test.\"group\".e1 = '2')"}); //$NON-NLS-1$
- }
-
- @Test public void testVirtualAccessPatternPassing1() {
- String sql = "delete from vm1.g37 where e1 = 1"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
- }
-
- @Test public void testVirtualAccessPatternFailing() {
- String sql = "SELECT e0, e2 FROM vTest.vGroup2 where e0=1"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testVirtualAccessPatternFailing1() {
- String sql = "delete from vm1.g37"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testAccessPattern1() throws Exception {
- String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2'"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql,
- TestValidator.exampleMetadata4(),
- new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
- }
-
- @Test public void testAccessPattern2() {
- String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testAccessPattern3() {
- String sql = "SELECT e0, e2 FROM vTest.vGroup where e0=1 and e2='2'"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testAccessPattern4() throws Exception {
- String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT g_0.e0, g_0.e2 FROM test.\"group\" AS g_0 WHERE (g_0.e0 = 1) AND (g_0.e1 = '2')"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testAccessPattern5() {
- String sql = "(SELECT e0, e2 FROM vTest.vGroup where e0=1 and e1='2') union all (SELECT e0, e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testAccessPattern6() {
- String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1 and e1='2')"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), new String[] {"SELECT e1, e0, e2 FROM test.\"group\""}); //$NON-NLS-1$
- }
-
- @Test public void testAccessPattern7() {
- String sql = "SELECT e0, e2 FROM test.group where e1 IN (SELECT e2 FROM vTest.vGroup where e0=1)"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testAccessPattern8() {
- String sql = "SELECT e0, e2 FROM vTest.vGroup"; //$NON-NLS-1$
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata4(), null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- /**
- * Tests two access nodes, each with access patterns, but one already
- * satisfied by user criteria - the other should be made dependent
- */
- @Test public void testNodesBothHaveAccessPatterns1() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g2 where pm4.g2.e5 = 'abc' and pm4.g1.e1 = pm4.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
- }
-
- /**
- * Tests two access nodes, each with access patterns, but one already
- * satisfied by user criteria - the other should be made dependent
- * (same query written slightly different).
- */
- @Test public void testNodesBothHaveAccessPatterns1a() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g2, pm4.g1 where pm4.g2.e1 = pm4.g1.e1 and pm4.g2.e5 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE g_0.e5 = 'abc'"}, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- TestDependentJoins.checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
- }
-
- /**
- * Self join - tests that both access nodes are satisfied by the select
- * criteria (therefore merge join should be used)
- */
- @Test public void testSelfJoinAccessPatterns() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm4.g1.e1 from pm4.g1, pm4.g1 as g1A where pm4.g1.e1 = 'abc' and g1A.e1 = 'abc' and pm4.g1.e2 = g1A.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g1A.e2 FROM pm4.g1 AS g1A WHERE g1A.e1 = 'abc'", "SELECT pm4.g1.e2, pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testAccessPatternsFails() {
- TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2, pm4.g2 as g2A where pm4.g2.e2 = 123 and pm4.g2.e1 = g2A.e5", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, null, null,
- TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testAccessPatternsFails2() {
- TestOptimizer.helpPlan("select pm4.g2.e1 from pm4.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, null, null,
- TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testUnionWithAccessPatternFails() {
- TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1 where pm4.g1.e2 = 1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testUnionWithAccessPatternFails2() {
- TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION select pm4.g1.e1 from pm4.g1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- @Test public void testUnionWithAccessPattern() {
- TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testUnionWithAccessPattern2() {
- TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1 UNION ALL select pm4.g1.e1 from pm4.g1 where pm4.g1.e1 = 'abc' and pm4.g1.e2 = 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e1 FROM pm4.g1 WHERE (pm4.g1.e1 = 'abc') AND (pm4.g1.e2 = 1)" }); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testAccessPatternPartialMatch() throws Exception {
- TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 and pm4.g2.e2 = 123", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- new String[] { "SELECT g_0.e1 FROM pm4.g2 AS g_0 WHERE (g_0.e2 = 123) AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Similar to the query above, except the OR instead of an AND produces a
- * completely different query plan which can't satisfy the access pattern.
- * @see #testAccessPatternPartialMatch
- */
- @Test public void testAccessPatternFails3() {
- TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e1 or pm4.g2.e2 = 123", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, null, null,
- TestOptimizer.SHOULD_FAIL);
- }
-
- /**
- * Access patterns on models that support joins requires that the access patterns are satisfied prior to
- * RulePlanJoins
- */
- @Test public void testAccessPatternsGroupsInSameModelFails() {
- TestOptimizer.helpPlan("select pm5.g1.e1 from pm5.g1, pm5.g2 where pm5.g1.e1 = pm5.g2.e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, null, null, TestOptimizer.SHOULD_FAIL);
- }
-
- // ==================================================================================
- // ACCESS PATTERNS
- // ==================================================================================
-
- @Test public void testPushingCriteriaThroughFrameAccessPattern0() {
- TestOptimizer.helpPlan("select * from vm1.g9 where vm1.g9.e1='abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- /**
- * pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
- */
- @Test public void testPushingCriteriaThroughFrameAccessPattern1() {
- TestOptimizer.helpPlan("select * from vm1.g1, vm1.g10 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g10.e1", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
- null, TestOptimizer.SHOULD_FAIL );
- }
-
- @Test public void testPushingCriteriaThroughFrameAccessPattern2() {
- TestOptimizer.helpPlan("select e1 from vm1.g11 where vm1.g11.e1='abc' and vm1.g11.e2=123", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm4.g2.e1 FROM pm4.g2 WHERE (pm4.g2.e1 = 'abc') AND (pm4.g2.e2 = 123)" }); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughFrameAccessPattern3() {
- TestOptimizer.helpPlan("select * from vm1.g1, vm1.g9 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g9.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm4.g1.e1 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'"} ); //$NON-NLS-1$
- }
-
- /**
- * pm4.g2.e5 or pm4.g2.e2 also need to be in criteria
- */
- @Test public void testPushingCriteriaThroughFrameAccessPattern4() {
- TestOptimizer.helpPlan("select * from vm1.g10 where vm1.g10.e1='abc'", FakeMetadataFactory.example1Cached(), null, TestOptimizer.getGenericFinder(), //$NON-NLS-1$
- null, TestOptimizer.SHOULD_FAIL );
- }
-
- /**
- * TODO: in this case we should perform a criteria optimization to create set criteria
- */
- @Test public void testCase6425() {
- String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e1 = '2'"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] {"SELECT e1 FROM pm4.g1 WHERE (e1 = '1') OR (e1 = '2')"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testCase6425_2() {
- String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR (e1 = '2' AND e2 = 3)"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, new String[] {"SELECT e1 FROM pm4.g1 WHERE (e1 = '1') OR ((e1 = '2') AND (e2 = 3))"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testCase6425_4() throws Exception {
- String sql = "SELECT e1 FROM pm4.g1 WHERE e1 = '1' OR e2 = '2'"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- TestOptimizer.helpPlan(sql, metadata, null, TestOptimizer.ComparisonMode.FAILED_PLANNING);
- }
-
- /*
- * Criteria was preventing rule choose dependent from creating the appropriate dependent join
- */
- @Test public void testMultiAccessPatternWithCriteria() throws Exception {
- String sql = "SELECT pm1.g1.* FROM pm4.g1, pm5.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1 and pm5.g1.e1 = pm1.g1.e1 and pm5.g1.e2 like '%x' "; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- TestOptimizer.helpPlan(sql, metadata,
- new String[] {
- "SELECT g_0.e2, g_0.e1 FROM pm5.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", //$NON-NLS-1$
- "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$
- "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)" }, TestOptimizer.getGenericFinder(false), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAggregatePushdown.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,840 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-
-import org.junit.Test;
-
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestAggregatePushdown {
-
- public static BasicSourceCapabilities getAggregateCapabilities() {
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- return caps;
- }
-
- public static CapabilitiesFinder getAggregatesFinder() {
- return new DefaultCapabilitiesFinder(getAggregateCapabilities());
- }
-
- @Test public void testCase6327() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- String sql = "SELECT a12.intkey AS REGION_NBR, SUM(a11.intnum) AS WJXBFS1 FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey WHERE a11.stringkey = 0 GROUP BY a12.intkey"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT SUM(a11.intnum) FROM bqt1.smalla AS a11 WHERE a11.stringkey = '0' HAVING COUNT(*) > 0", "SELECT a12.intkey FROM bqt2.smalla AS a12 WHERE a12.stringkey = '0' group by a12.intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Note that intnum is retrieved from each source
- *
- * Note also that this test shows that the max aggregate is not placed on the bqt2 query since it would be on one of the group by expressions
- */
- @Test public void testAggregateOfJoinExpression() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- String sql = "SELECT a12.intkey, MAX(a12.stringkey), SUM(a11.intnum+a12.intnum) FROM bqt1.smalla AS a11 INNER JOIN bqt2.smalla AS a12 ON a11.stringkey = a12.stringkey GROUP BY a12.intkey"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.stringkey, g_0.intkey, g_0.intnum FROM bqt2.smalla AS g_0 GROUP BY g_0.stringkey, g_0.intkey, g_0.intnum", "SELECT g_0.stringkey, g_0.intnum FROM bqt1.smalla AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Note that even though this grouping is join invariant, we still do not remove the top level group by
- * since we are not checking the uniqueness of the x side join expressions
- */
- @Test public void testInvariantAggregate() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- String sql = "SELECT max(y.e2) from pm1.g1 x, pm2.g1 y where x.e3 = y.e3 group by y.e3"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT g_0.e3 FROM pm1.g1 AS g_0", "SELECT g_0.e3, MAX(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e3"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test of an aggregate nested in an expression symbol
- */
- @Test public void testCase6211() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- String sql = "select sum(a11.intnum) Profit, (sum(a11.intnum) / sum(a11.floatnum)) WJXBFS2 from bqt1.smalla a11 join bqt2.smallb a12 on a11.intkey=a12.intkey group by a12.intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.intkey, SUM(g_0.intnum), SUM(g_0.floatnum) FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey", "SELECT g_0.intkey FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Note that until we can test the other side cardinality, we cannot fully push the group node
- */
- @Test public void testAggregatePushdown1() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleAggregatesCached();
- String sql = "SELECT o_dealerid, o_productid, sum(o_amount) FROM m1.order, m1.dealer, m2.product " + //$NON-NLS-1$
- "WHERE o_dealerid=d_dealerid AND o_productid=p_productid AND d_state = 'CA' AND p_divid = 100 " + //$NON-NLS-1$
- "GROUP BY o_dealerid, o_productid"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, getAggregatesFinder(),
- new String[] {"SELECT DISTINCT g_0.p_productid AS c_0 FROM m2.product AS g_0 WHERE g_0.p_divid = 100 ORDER BY c_0", "SELECT DISTINCT g_0.o_productid AS c_0, g_0.o_dealerid AS c_1, SUM(g_0.o_amount) AS c_2 FROM m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.o_dealerid = g_1.d_dealerid) AND (g_1.d_state = 'CA') AND (g_0.o_productid IN (<dependent values>)) GROUP BY g_0.o_productid, g_0.o_dealerid ORDER BY c_0"}, //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testAggregatePushdown2() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleAggregatesCached();
- String sql = "SELECT o_dealerid, o_productid, sum(o_amount) FROM m1.order, m1.dealer, m2.product " + //$NON-NLS-1$
- "WHERE o_dealerid=d_dealerid AND o_productid=p_productid AND d_state = 'CA' AND p_divid = 100 " + //$NON-NLS-1$
- "GROUP BY o_dealerid, o_productid having max(o_amount) < 100"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, getAggregatesFinder(),
- new String[] {"SELECT DISTINCT g_0.p_productid AS c_0 FROM m2.product AS g_0 WHERE g_0.p_divid = 100 ORDER BY c_0", "SELECT DISTINCT g_0.o_productid AS c_0, g_0.o_dealerid AS c_1, MAX(g_0.o_amount) AS c_2, SUM(g_0.o_amount) AS c_3 FROM m1.\"order\" AS g_0, m1.dealer AS g_1 WHERE (g_0.o_dealerid = g_1.d_dealerid) AND (g_1.d_state = 'CA') AND (g_0.o_productid IN (<dependent values>)) GROUP BY g_0.o_productid, g_0.o_dealerid ORDER BY c_0"}, //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Average requires the creation of staged sum and count aggregates
- */
- @Test public void testAvgAggregate() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- String sql = "SELECT avg(y.e2) from pm1.g1 x, pm2.g1 y where x.e3 = y.e3 group by x.e2, y.e1"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1, SUM(g_0.e2), COUNT(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e3, g_0.e1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCountAggregate() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- String sql = "SELECT count(y.e2) from pm1.g1 x, pm2.g1 y where x.e3 = y.e3 group by x.e2, y.e1"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0 GROUP BY g_0.e3, g_0.e2", "SELECT g_0.e3, g_0.e1, COUNT(g_0.e2) FROM pm2.g1 AS g_0 GROUP BY g_0.e3, g_0.e1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOuterJoinPreventsPushdown() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- String sql = "SELECT count(y.e2) from pm1.g1 x left outer join pm2.g1 y on x.e3 = y.e3 group by x.e2, y.e1"; //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0", "SELECT g_0.e3, g_0.e1, g_0.e2 FROM pm2.g1 AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test to ensure count(*) isn't mistakenly pushed to either side, but that
- * grouping can still be.
- */
- @Test public void testCase5724() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "select count(*), a.intnum from bqt1.smalla as a, bqt2.smallb as b where a.intkey = b.intkey group by a.intnum", //$NON-NLS-1$
- metadata, null, capFinder,
- new String[] {
- "SELECT a.intkey, a.intnum FROM bqt1.smalla AS a group by a.intkey, a.intnum", "SELECT b.intkey FROM bqt2.smallb AS b"}, //$NON-NLS-1$ //$NON-NLS-2$
- true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCase6210() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- caps.setFunctionSupport("/", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- String sql = "select a11.intkey ITEM_ID, sum(a11.intnum) WJXBFS1 from bqt1.smalla a11 join bqt2.smalla a12 on (a11.stringkey = a12.stringkey) join bqt2.smallb a13 on (a11.intkey = a13.intkey) where a13.intnum in (10) group by a11.intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_0.stringkey FROM bqt2.smalla AS g_0", "SELECT g_0.stringkey, g_0.intkey, SUM(g_0.intnum) FROM bqt1.smalla AS g_0 GROUP BY g_0.stringkey, g_0.intkey", "SELECT g_0.intkey FROM bqt2.smallb AS g_0 WHERE g_0.intnum = 10"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testNoGroupAggregatePushdown() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, false);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "select count(*) from bqt1.smalla", //$NON-NLS-1$
- metadata, null, capFinder,
- new String[] {
- "SELECT count(*) from bqt1.smalla"}, //$NON-NLS-1$
- true);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testNoHavingAggregate() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "select stringkey, max(intkey) from bqt1.smalla group by stringkey having count(intkey) = 1", //$NON-NLS-1$
- metadata, null, capFinder,
- new String[] {
- "SELECT COUNT(g_0.intkey), g_0.stringkey, MAX(g_0.intkey) FROM bqt1.smalla AS g_0 GROUP BY g_0.stringkey"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testHavingCriteriaPushDown() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select X.e1 FROM vm1.g1 X group by X.e1 having X.e1 = 1 and sum(X.e2) = 2", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE pm1.g1.e1 = '1'"}, true); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testBusObjQuestion1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
-
- capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
- capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
- capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
-
- String sql = "SELECT Q1.S, Q2.C, Q1.PRODUCT, Q1.REGION AS Q1R, Q2.REGION AS Q2R FROM " + //$NON-NLS-1$
- "(SELECT SUM(SALES) AS S, REGION, PRODUCT FROM DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT) Q1 " + //$NON-NLS-1$
- "FULL OUTER JOIN " + //$NON-NLS-1$
- "(SELECT SUM(COSTS) AS C, REGION FROM ORACLE_TABLE WHERE \"YEAR\" = '1999' GROUP BY REGION) Q2 " + //$NON-NLS-1$
- "ON Q1.REGION = Q2.REGION"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT REGION, SUM(SALES), PRODUCT FROM db2model.DB2_TABLE WHERE PRODUCT IN ('GUNS', 'TOYS', 'VIDEOTAPES') GROUP BY REGION, PRODUCT", //$NON-NLS-1$
- "SELECT REGION, SUM(COSTS) FROM oraclemodel.Oracle_table WHERE \"YEAR\" = '1999' GROUP BY REGION"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testBusObjQuestion2() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
-
- capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
- capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
- capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
-
- String sql = "SELECT SUM(F.SALES), G.REGION, T.YEAR " + //$NON-NLS-1$
- "FROM SALES F, GEOGRAPHY G, msModel.TIME T " + //$NON-NLS-1$
- "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + //$NON-NLS-1$
- "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + //$NON-NLS-1$
- "GROUP BY G.REGION, T.YEAR"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
- "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
- "SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 1, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testBusObjQuestion2Hint() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
-
- capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
- capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
- capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
-
- String sql = "SELECT SUM(F.SALES), G.REGION, T.YEAR " + //$NON-NLS-1$
- "FROM SALES F MAKEDEP, GEOGRAPHY G, msModel.TIME T " + //$NON-NLS-1$
- "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + //$NON-NLS-1$
- "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + //$NON-NLS-1$
- "GROUP BY G.REGION, T.YEAR"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT g_0.\"MONTH\", g_0.\"YEAR\" FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999'", //$NON-NLS-1$
- "SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_0.CITY AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0 WHERE (g_0.\"MONTH\" IN (<dependent values>)) AND (g_0.CITY IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_0.CITY ORDER BY c_0, c_1", //$NON-NLS-1$
- "SELECT g_0.CITY, g_0.REGION FROM oraclemodel.GEOGRAPHY AS g_0 WHERE g_0.REGION IN ('BORDEAUX', 'POLINESIA')"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 1, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testBusObjQuestion2HintVariation() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
-
- capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
- capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
- capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
-
- String sql = "SELECT SUM(F.SALES), G.REGION, T.YEAR " + //$NON-NLS-1$
- "FROM SALES F MAKEDEP, GEOGRAPHY2 G, msModel.TIME T " + //$NON-NLS-1$
- "WHERE (F.CITY = G.CITY) AND (F.MONTH = T.MONTH) " + //$NON-NLS-1$
- "AND G.REGION IN ('BORDEAUX', 'POLINESIA') AND T.YEAR = '1999' " + //$NON-NLS-1$
- "GROUP BY G.REGION, T.YEAR"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT DISTINCT g_0.\"MONTH\" AS c_0, g_1.REGION AS c_1, SUM(g_0.SALES) AS c_2 FROM db2model.SALES AS g_0, db2model.GEOGRAPHY2 AS g_1 WHERE (g_0.CITY = g_1.CITY) AND (g_1.REGION IN ('BORDEAUX', 'POLINESIA')) AND (g_0.\"MONTH\" IN (<dependent values>)) GROUP BY g_0.\"MONTH\", g_1.REGION ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.\"MONTH\" AS c_0, g_0.\"YEAR\" AS c_1 FROM msModel.\"TIME\" AS g_0 WHERE g_0.\"YEAR\" = '1999' ORDER BY c_0"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testBusObjQuestion3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, true);
-
- capFinder.addCapabilities("db2model", caps); //$NON-NLS-1$
- capFinder.addCapabilities("oraclemodel", caps); //$NON-NLS-1$
- capFinder.addCapabilities("msmodel", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.exampleBusObj();
-
- String sql = "select sum(c0), sum(b0), c1, b2 FROM db2Table, OraTable where c2=b2 group by c1, b2"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT c2, c1, c0 FROM db2model.DB2TABLE", //$NON-NLS-1$
- "SELECT DISTINCT b2, sum(b0) FROM oraclemodel.OraTable GROUP BY b2 ORDER BY b2"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushDownOverUnion() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select e1, max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm1.g2) y group by e1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT v_0.c_0, MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0) AS v_0 GROUP BY v_0.c_0", //$NON-NLS-1$
- "SELECT v_0.c_0, MAX(v_0.c_1) FROM (SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm1.g2 AS g_0) AS v_0 GROUP BY v_0.c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testPushDownOverUnion1() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm1.g2) z", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT MAX(v_0.c_0) FROM (SELECT g_0.e2 AS c_0 FROM pm1.g2 AS g_0) AS v_0 HAVING COUNT(*) > 0", //$NON-NLS-1$
- "SELECT MAX(v_0.c_0) FROM (SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0) AS v_0 HAVING COUNT(*) > 0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- /**
- * We won't do the pushdown here since the aggregate depends upon the cardinality
- */
- @Test public void testPushDownOverUnion2() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select count(e2) from (select e1, e2 from pm1.g1 union select e1, e2 from pm1.g2) z", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT g_0.e1, g_0.e2 FROM pm1.g2 AS g_0", //$NON-NLS-1$
- "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testPushDownOverUnionMixed() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getAggregateCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select max(e2) from (select e1, e2 from pm1.g1 union all select e1, e2 from pm2.g2) z", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT MAX(v_0.c_0) FROM (SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0) AS v_0 HAVING COUNT(*) > 0", //$NON-NLS-1$
- "SELECT g_0.e2 FROM pm2.g2 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAnsiJoinPushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAnsiJoinPushdown.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestAnsiJoinPushdown.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,57 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import org.junit.Test;
-
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestAnsiJoinPushdown {
-
- /**
- * See {@link TestOptimizer.testPushMultiGroupCriteria}
- *
- * Notice that the non-join criteria is still in the on clause.
- */
- @Test public void testAnsiInnerJoin() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_ANSI_JOIN, true);
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "select pm2.g1.e1 from pm2.g1, pm2.g2 where pm2.g1.e1 = pm2.g2.e1 and (pm2.g1.e2 = 1 OR pm2.g2.e2 = 2) and pm2.g2.e3 = 1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null,
- capFinder,
- new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 INNER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND ((g_0.e2 = 1) OR (g_1.e2 = 2)) WHERE g_1.e3 = TRUE" }, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestComparableMetadataPushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestComparableMetadataPushdown.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestComparableMetadataPushdown.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,78 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import org.junit.Test;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.validator.TestValidator;
-
-public class TestComparableMetadataPushdown {
-
- @Test public void testCantPushSort() throws Exception {
- String sql = "select e3, e2 from test.group order by e3, e2"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- capFinder.addCapabilities("test", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
- new String[] {"SELECT g_0.e3, g_0.e2 FROM test.\"group\" AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCantPushGroupBy() throws Exception {
- String sql = "select e3, e2 from test.group group by e3, e2"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- capFinder.addCapabilities("test", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
- new String[] {"SELECT g_0.e3, g_0.e2 FROM test.\"group\" AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCantPushDup() throws Exception {
- String sql = "select distinct e3, e2 from test.group"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- capFinder.addCapabilities("test", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
- new String[] {"SELECT g_0.e3, g_0.e2 FROM test.\"group\" AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCantPushSetOp() throws Exception {
- String sql = "select e3, e2 from test.group union select e0, e1 from test.group2"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- capFinder.addCapabilities("test", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, TestValidator.exampleMetadata(),
- new String[] {"SELECT test.\"group\".e3, test.\"group\".e2 FROM test.\"group\"", "SELECT test.group2.e0, test.group2.e1 FROM test.group2"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestDependentJoins.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,811 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import junit.framework.TestCase;
-
-import org.teiid.metadata.TransformationMetadata;
-
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.rules.RuleChooseDependent;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.DependentAccessNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-
-
-public class TestDependentJoins extends TestCase {
-
- static void checkDependentGroups(ProcessorPlan plan, String[] groups) {
- if(! (plan instanceof RelationalPlan)) {
- return;
- }
-
- // Collect all the group names (uppercase) for all the dependent groups in the plan
- Set depGroups = new HashSet();
- getDependentGroups(((RelationalPlan)plan).getRootNode(), depGroups);
-
- // Check that all the expected groups exist in depGroups
- Set expectedGroups = new HashSet();
- for(int i=0; i<groups.length; i++) {
- expectedGroups.add(groups[i].toUpperCase());
- }
-
- assertEquals("Expected groups were not made dependent", expectedGroups, depGroups); //$NON-NLS-1$
- }
-
- static void getDependentGroups(RelationalNode node, Set depGroups) {
- if(node instanceof DependentAccessNode) {
- DependentAccessNode accessNode = (DependentAccessNode)node;
- Command depCommand = accessNode.getCommand();
- Collection groupSymbols = GroupCollectorVisitor.getGroups(depCommand, true);
- Iterator groupIter = groupSymbols.iterator();
- while(groupIter.hasNext()) {
- GroupSymbol group = (GroupSymbol) groupIter.next();
- depGroups.add(group.getName().toUpperCase());
- }
- }
-
- // Recurse through children
- RelationalNode[] children = node.getChildren();
- for(int i=0; i<children.length; i++) {
- if(children[i] != null) {
- getDependentGroups(node.getChildren()[i], depGroups);
- }
- }
- }
-
- private void checkNotDependentGroups(ProcessorPlan plan, String[] groups) {
- if(! (plan instanceof RelationalPlan)) {
- return;
- }
-
- // Collect all the group names (uppercase) for all the dependent groups in the plan
- Set notDepGroups = new HashSet();
- getNotDependentGroups(((RelationalPlan)plan).getRootNode(), notDepGroups);
-
- // Check that all the expected groups exist in depGroups
- Set expectedGroups = new HashSet();
- for(int i=0; i<groups.length; i++) {
- expectedGroups.add(groups[i].toUpperCase());
- }
-
- assertEquals("Expected groups were made dependent", expectedGroups, notDepGroups); //$NON-NLS-1$
- }
-
- private void getNotDependentGroups(RelationalNode node, Set notDepGroups) {
- if(node instanceof AccessNode && !(node instanceof DependentAccessNode)) {
- AccessNode accessNode = (AccessNode)node;
- Command depCommand = accessNode.getCommand();
- Collection groupSymbols = GroupCollectorVisitor.getGroups(depCommand, true);
- Iterator groupIter = groupSymbols.iterator();
- while(groupIter.hasNext()) {
- GroupSymbol group = (GroupSymbol) groupIter.next();
- notDepGroups.add(group.getName().toUpperCase());
- }
- }
-
- // Recurse through children
- RelationalNode[] children = node.getChildren();
- for(int i=0; i<children.length; i++) {
- if(children[i] != null) {
- getNotDependentGroups(node.getChildren()[i], notDepGroups);
- }
- }
- }
-
- public void testOptionMakeDep1() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm2.g1 where pm1.g1.e1 = pm2.g1.e1 option makedep pm2.g1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm2.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- checkDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
- checkNotDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testOptionMakeDep2() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1, pm2.g1.e1 from pm1.g1 MAKEDEP INNER JOIN pm2.g1 MAKENOTDEP ON pm1.g1.e1 = pm2.g1.e1", FakeMetadataFactory.example1Cached(), null, capFinder, //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm2.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
- checkNotDependentGroups(plan, new String[] {"pm2.g1"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testDepJoinHintForceLeft() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g1", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g2 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
- }
-
- public void testDepJoinHintForceRight() throws Exception {
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g2", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
- }
-
- public void testDepJoinMultiGroupBaseline() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select vm1.g4.*, pm1.g3.e1 FROM vm1.g4, pm1.g3 where pm1.g3.e1=vm1.g4.e1", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
- "SELECT pm1.g3.e1 FROM pm1.g3" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[0]);
- }
-
- public void testDepJoinMultiGroupForceOther() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select vm1.g4.*, pm1.g3.e1 FROM vm1.g4, pm1.g3 where pm1.g3.e1=vm1.g4.e1 option makedep pm1.g2", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
- }
-
- public void testDepJoinHintForceLeft_NotDep() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g1 makenotdep pm1.g2", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g2 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
- checkNotDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
- }
-
- public void testDepJoinHintForceRight_NotDep() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select * FROM vm1.g4 option makedep pm1.g2 makenotdep pm1.g1", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
- checkNotDependentGroups(plan, new String[] {"pm1.g1"}); //$NON-NLS-1$
- }
-
- public void testDepJoinMultiGroupForceOther_NotDep() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select vm1.g4.*, pm1.g3.e1 FROM vm1.g4, pm1.g3 where pm1.g3.e1=vm1.g4.e1 option makedep pm1.g2 makenotdep pm1.g1, pm1.g3", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkDependentGroups(plan, new String[] {"pm1.g2"}); //$NON-NLS-1$
- checkNotDependentGroups(plan, new String[] {"pm1.g1", "pm1.g3"}); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Test that access node with unsatisfied access pattern is made dependent
- */
- public void testMakeDependentAccessPattern1() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm1.g1.e1 = pm4.g1.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
- }
-
- /**
- * Test that access node with unsatisfied access pattern is made dependent
- * (Same query written slightly different way)
- */
- public void testMakeDependentAccessPattern1a() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm4.g1, pm1.g1 where pm4.g1.e1 = pm1.g1.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
- }
-
- /**
- * Test that access node with unsatisfied access pattern is made dependent
- */
- public void testMakeDependentAccessPattern2() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm4.g1.e2 = 1 and pm1.g1.e1 = pm4.g1.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm4.g1 AS g_0 WHERE (g_0.e2 = 1) AND (g_0.e1 IN (<dependent values>))", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[] {"pm4.g1"}); //$NON-NLS-1$
- }
-
- /**
- * Test that second access pattern of access node is chosen to make
- * dependent with
- */
- public void testMakeDependentAccessPattern3() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g2 where pm1.g1.e1 = pm4.g2.e5", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e5 FROM pm4.g2 AS g_0 WHERE g_0.e5 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.getGenericFinder(false), TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[] {"pm4.g2"}); //$NON-NLS-1$
- }
-
- /**
- * This case actually tests the dead-tie case - either access node could
- * be made dependent, but merge join is used since no access pattern
- * needs to be fulfilled and there is no cost info available for either source
- */
- public void testPushSelectAndMakeDependentAccessPattern1() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm4.g1.e1 = 'abc' and pm1.g1.e1 = 'abc' and pm1.g1.e2 = pm4.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", "SELECT pm4.g1.e2 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[0]);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * This case actually tests the dead-tie case - either access node could
- * be made dependent, but merge join is used since no access pattern
- * needs to be fulfilled and there is no cost info available for either source
- * (Same query written slightly different)
- */
- public void testPushSelectAndMakeDependentAccessPattern1a() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm4.g1, pm1.g1 where pm4.g1.e2 = pm1.g1.e2 and pm4.g1.e1 = 'abc' and pm1.g1.e1 = 'abc'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", "SELECT pm4.g1.e2 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[0]);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Tests that it is enforced if an access node can't be made dependent
- * because of it's (already-satisfied) access pattern - merge join is used
- */
- public void testPushSelectAndMakeDependentAccessPattern2() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g1.e1 from pm1.g1, pm4.g1 where pm4.g1.e1 = 'abc' and pm1.g1.e2 = pm4.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1", "SELECT pm4.g1.e2 FROM pm4.g1 WHERE pm4.g1.e1 = 'abc'" }, TestOptimizer.getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- checkDependentGroups(plan, new String[0] );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Should use dependent join since one access node is "strong" */
- public void testUseMergeJoin1() throws Exception {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(10));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject obj = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- obj.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Should not use a dependent join since neither access node is "strong" */
- public void testUseMergeJoin2() throws Exception {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject obj = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- obj.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1));
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, TestOptimizer.ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** should have one dependent joins */
- public void testMultiMergeJoin3() throws Exception {
- // Create query
- String sql = "SELECT pm1.g2.e1 FROM pm1.g3, pm1.g2, pm1.g1 WHERE pm1.g2.e1 = pm1.g3.e1 AND pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1 ));
- FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g2 AS g_0", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testMultiMergeJoin2() throws Exception {
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
- FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e1 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>)", "SELECT g_0.e1 FROM pm1.g1 AS g_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Defect 13448
- * should be one merge join and one dependent join
- * Unlike the above tests, here the model pm1 supports ORDER BY.
- */
- public void testMultiMergeJoin5_defect13448() throws Exception {
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g1.e1 = pm1.g3.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
- FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g3 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testMergeJoinVirtualGroups() throws Exception {
- String sql = "SELECT vm1.g1.e1 FROM vm1.g1, vm1.g2a WHERE vm1.g1.e1 = vm1.g2a.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0" }, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testRLMCase2077() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
- FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT g_0.StringKey FROM BQT1.SmallA AS g_0 WHERE g_0.StringKey IN (<dependent values>)", "SELECT g_0.STRINGKEY, g_0.STRINGNUM, g_0.IntKey FROM BQT2.SmallA AS g_0"}, //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- public void testRLMCase2077_2() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- TransformationMetadata metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
- FakeMetadataFactory.setCardinality("bqt2.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "SELECT table1comp.IntKey, table1comp.key1, BQT1.SmallA.StringKey FROM (SELECT t1.*, (STRINGKEY || STRINGNUM) AS key1 FROM BQT2.SmallA AS t1) AS table1comp, BQT1.SmallA WHERE table1comp.key1 = BQT1.SmallA.StringKey AND table1comp.key1 = BQT1.SmallA.StringNum", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT g_0.STRINGKEY, g_0.STRINGNUM, g_0.IntKey FROM BQT2.SmallA AS g_0", "SELECT g_0.StringKey, g_0.StringNum FROM BQT1.SmallA AS g_0 WHERE (g_0.StringKey IN (<dependent values>)) AND (g_0.StringNum IN (<dependent values>))"}, //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestExpressionsInGroupBy.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestExpressionsInGroupBy.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestExpressionsInGroupBy.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,453 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-/**
- * expressions in group use lacks robust support in MySQL, PostGres, and Derby Expressions and it's nothing more than syntactic sugar for an inline view,
- * a new approach was taken to use inline views rather than a non ANSI group by construct.
- *
- * Later we can add a connector binding property to support non-select expressions in group by.
- */
-public class TestExpressionsInGroupBy extends TestCase {
-
- public void testCase1565() throws Exception {
- // Create query
- String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM bqt1.smalla) as y GROUP BY x"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { "SELECT convert(TimestampValue, date), COUNT(*) FROM bqt1.smalla GROUP BY convert(TimestampValue, date)" }, //$NON-NLS-1$
- true);
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- // Merge across multiple virtual groups - should be same outcome as testCase1565
- public void testCase1565_2() throws Exception {
- // Create query
- String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM (SELECT TimestampValue from bqt1.smalla) as z) as y GROUP BY x"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { "SELECT convert(TimestampValue, date), COUNT(*) FROM bqt1.smalla GROUP BY convert(TimestampValue, date)" }, //$NON-NLS-1$
- true);
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- // Merge across multiple virtual groups above the physical
- public void testCase1565_3() throws Exception {
- String sql = "SELECT x, COUNT(*) FROM (SELECT convert(TimestampValue, date) AS x FROM (SELECT TimestampValue from bqt1.smalla) as z) as y GROUP BY x"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, TestOptimizer.getGenericFinder(),
- new String[] { "SELECT TimestampValue FROM bqt1.smalla" }, //$NON-NLS-1$
- true);
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- // Test what happens when not all the functions in the virtual SELECT can be pushed
- public void testCase1565_4() throws Exception {
- // Create query
- String sql = "SELECT x, y FROM (SELECT convert(TimestampValue, date) as x, length(stringkey) as y from bqt1.smalla) as z GROUP BY x, y"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { "SELECT TimestampValue, stringkey FROM bqt1.smalla" }, //$NON-NLS-1$
- true);
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- // Test nested functions
- public void testCase1565_5() throws Exception {
- // Create query
- String sql = "SELECT x, COUNT(*) FROM (SELECT convert(intkey + 5, string) AS x FROM bqt1.smalla) as y GROUP BY x"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { "SELECT intkey FROM bqt1.smalla" }, //$NON-NLS-1$
- true);
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- // SELECT SUM(x) FROM (SELECT IntKey+1 AS x FROM BQT1.SmallA) AS g
- public void testAggregateNoGroupByWithNestedFunction() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT SUM(x) FROM (SELECT IntKey+1 AS x FROM BQT1.SmallA) AS g", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] { "SELECT IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Without inline view support the agg is not pushed down
- */
- public void testFunctionInGroupBy() {
- String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT CASE WHEN BQT1.SmallA.IntKey >= 5000 THEN '5000 +' ELSE '0-999' END, BQT1.SmallA.IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test what happens when we have a CASE in the GROUP BY and source has aggregate capability but
- * does not have CASE capability. Should not be able to push down GROUP BY.
- *
- * @since 4.2
- */
- public void testFunctionInGroupByCantPush() {
- String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, false);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test what happens when we have a CASE in the GROUP BY and source has aggregate capability but
- * does not have CASE capability. Should not be able to push down GROUP BY.
- *
- * @since 4.2
- */
- public void testFunctionInGroupByHavingCantPush() {
- String sql = "SELECT sum (IntKey), case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "FROM BQT1.SmallA GROUP BY case when IntKey>=5000 then '5000 +' else '0-999' end " + //$NON-NLS-1$
- "HAVING case when IntKey>=5000 then '5000 +' else '0-999' end = '5000 +'"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, false);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
- /**
- * Test what happens when we have a CASE in the GROUP BY and source has aggregate capability but
- * does not have CASE capability. Should not be able to push down GROUP BY.
- *
- * @since 4.2
- */
- public void testFunctionInGroupByCantPushRewritten() {
- String sql = "SELECT SUM(IntKey), c FROM (SELECT IntKey, case when IntKey>=5000 then '5000 +' else '0-999' end AS c FROM BQT1.SmallA) AS temp GROUP BY c"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, false);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testFunctionOfAggregateCantPush2() {
- String sql = "SELECT SUM(length(StringKey || 'x')) + 1 AS x FROM BQT1.SmallA GROUP BY StringKey || 'x' HAVING space(MAX(length((StringKey || 'x') || 'y'))) = ' '"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT StringKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
-
- public void testDontPushGroupByUnsupportedFunction() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(
- "SELECT e2 as x FROM pm1.g1 GROUP BY upper(e1), e2", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestInlineView.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,304 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Test;
-
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestInlineView {
-
- public static QueryMetadataInterface createInlineViewMetadata(FakeCapabilitiesFinder capFinder) {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- caps.setFunctionSupport("case", true); //$NON-NLS-1$
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- return metadata;
- }
-
- @Test public void testANSIJoinInlineView() throws Exception {
- runTest(createANSIJoinInlineView());
- }
-
- @Test public void testInlineView() throws Exception {
- runTest(createInlineView());
- }
-
- @Test public void testInlineViewWithDistinctAndOrderBy() throws Exception {
- runTest(createInlineViewWithDistinctAndOrderBy());
- }
-
- @Test public void testInlineViewOfVirtual() throws Exception{
- runTest(createInlineViewOfVirtual());
- }
-
- @Test public void testInlineViewWithOuterOrderAndGroup() throws Exception {
- runTest(createInlineViewWithOuterOrderAndGroup());
- }
-
- @Test public void testInlineViewsInUnions() throws Exception {
- runTest(crateInlineViewsInUnions());
- }
-
- @Test public void testUnionInInlineView() throws Exception{
- runTest(createUnionInInlineView());
- }
-
- public static InlineViewCase createANSIJoinInlineView() throws Exception {
- String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.intkey) AS c_0 FROM bqt1.smalla AS g_0 WHERE g_0.intkey = 1 GROUP BY g_0.intkey) AS v_0 LEFT OUTER JOIN bqt1.smallb AS g_1 ON v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
- List row1 = new ArrayList();
- row1.add(new Integer(1));
- expectedResults.add(row1);
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testANSIJoinInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
-
- }
-
- public static InlineViewCase createInlineView() throws Exception {
- String userQuery = "select bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa from (select count(bqt1.smalla.intkey) as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb, bqt1.smallb " + //$NON-NLS-1$
- "where bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.intkey = 1 and bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb.aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa = bqt1.smallb.intkey"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT COUNT(g_0.intkey) AS c_0 FROM bqt1.smalla AS g_0 WHERE g_0.intkey = 1 GROUP BY g_0.intkey) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_0 = g_1.intkey"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
- List row1 = new ArrayList();
- row1.add(new Integer(1));
- expectedResults.add(row1);
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
- }
-
- public static InlineViewCase createInlineViewWithDistinctAndOrderBy() throws Exception {
- String userQuery = "select Q1.a from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_0 FROM (SELECT DISTINCT COUNT(g_0.intkey) AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING ((COUNT(g_0.intkey) + g_0.intkey) = 2) AND (COUNT(g_0.intkey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
- List row1 = new ArrayList();
- row1.add(new Integer(1));
- expectedResults.add(row1);
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testInlineViewWithDistinctAndOrderBy", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
-
- }
-
- public static InlineViewCase createInlineViewOfVirtual() throws Exception{
- String userQuery = "select q1.A from (select count(intkey) as a, intkey, stringkey from vqt.smalla group by intkey, stringkey) q1 inner join vqt.smallb as q2 on q1.intkey = q2.a12345 where q1.a = 2"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_0.c_1 FROM (SELECT g_0.IntKey AS c_0, COUNT(g_0.IntKey) AS c_1 FROM BQT1.SmallA AS g_0 GROUP BY g_0.IntKey, g_0.StringKey HAVING COUNT(g_0.IntKey) = 2) AS v_0, BQT1.SmallA AS g_1 WHERE v_0.c_0 = Concat(g_1.StringKey, g_1.StringNum)"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testInlineViewOfVirtual", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
- }
-
- public static InlineViewCase createInlineViewWithOuterOrderAndGroup() throws Exception {
- String userQuery = "select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b"; //$NON-NLS-1$
- String optimizedQuery = "SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.intkey) AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING ((COUNT(g_0.intkey) + g_0.intkey) = 2) AND (COUNT(g_0.intkey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0 ORDER BY c_0"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
- List row1 = new ArrayList();
- row1.add(new Integer(1));
- expectedResults.add(row1);
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testInlineViewWithOuterOrderAndGroup", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
- }
-
- public static InlineViewCase crateInlineViewsInUnions() throws Exception {
- String userQuery = "select q1.a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)"; //$NON-NLS-1$
- String optimizedQuery = "SELECT v_1.c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
- List row1 = new ArrayList();
- row1.add(new Integer(1));
- expectedResults.add(row1);
- List row2 = new ArrayList();
- row2.add(new Integer(1));
- expectedResults.add(row2);
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testInlineViewsInUnions", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
-
- }
-
- public static InlineViewCase createUnionInInlineView() throws Exception{
-
- String userQuery = "select t1.intkey from (select case when q1.a=1 then 2 else 1 end as a from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 left outer join bqt1.smallb on q1.a = bqt1.smallb.intkey where q1.intkey = 1 union all (select count(Q1.a) b from (select distinct count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey order by bqt1.smalla.intkey) q1 inner join bqt1.smallb as q2 on q1.intkey = q2.intkey where q1.a = 1 and q1.a + q1.intkey = 2 group by Q1.a order by b)) as q3, bqt1.smallb as t1 where q3.a = t1.intkey order by t1.intkey"; //$NON-NLS-1$
- String optimizedQuery = "SELECT g_4.intkey AS c_0 FROM (SELECT CASE WHEN v_1.c_0 = 1 THEN 2 ELSE 1 END AS c_0 FROM (SELECT COUNT(g_2.intkey) AS c_0 FROM bqt1.smalla AS g_2 WHERE g_2.intkey = 1 GROUP BY g_2.intkey) AS v_1 LEFT OUTER JOIN bqt1.smallb AS g_3 ON v_1.c_0 = g_3.intkey UNION ALL SELECT COUNT(v_0.c_0) AS c_0 FROM (SELECT DISTINCT COUNT(g_0.IntKey) AS c_0, g_0.IntKey AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.IntKey HAVING ((COUNT(g_0.IntKey) + g_0.IntKey) = 2) AND (COUNT(g_0.IntKey) = 1)) AS v_0, bqt1.smallb AS g_1 WHERE v_0.c_1 = g_1.intkey GROUP BY v_0.c_0) AS v_2, bqt1.smallb AS g_4 WHERE v_2.c_0 = g_4.intkey ORDER BY c_0"; //$NON-NLS-1$
-
- List expectedResults = new ArrayList();
- List row1 = new ArrayList();
- row1.add(new Integer(1));
- expectedResults.add(row1);
- List row2 = new ArrayList();
- row2.add(new Integer(2));
- expectedResults.add(row2);
-
- Set<String> sourceQueries = new HashSet<String>();
- sourceQueries.add("oracle"); //$NON-NLS-1$
- /*
- * fails in db2 since the intkey column is in the database as a decimal
- */
- //sourceQueries.add("db2"); //$NON-NLS-1$
- sourceQueries.add("sybase"); //$NON-NLS-1$
- sourceQueries.add("sqlserver"); //$NON-NLS-1$
- sourceQueries.add("mysql"); //$NON-NLS-1$
- sourceQueries.add("postgres"); //$NON-NLS-1$
- return new InlineViewCase("testUnionInInlineView", userQuery, optimizedQuery, //$NON-NLS-1$
- sourceQueries, expectedResults);
-
- }
-
- protected void runTest(InlineViewCase testCase) throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = TestOptimizer.helpPlan(testCase.userQuery, metadata, null, capFinder, new String[] {testCase.optimizedQuery}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testAliasCreationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select a, b from (select distinct count(intNum) a, count(stringKey), bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intkey) q1 order by q1.a", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT a, b FROM (SELECT DISTINCT COUNT(intNum) AS a, COUNT(stringKey) AS count1, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intkey) AS q1 ORDER BY a"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testAliasPreservationWithInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select q1.a + 1, q1.b from (select count(bqt1.smalla.intNum) as a, bqt1.smalla.intkey as b from bqt1.smalla group by bqt1.smalla.intNum, bqt1.smalla.intkey order by b) q1 where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT (q1.a + 1), q1.b FROM (SELECT COUNT(bqt1.smalla.intNum) AS a, bqt1.smalla.intkey AS b FROM bqt1.smalla GROUP BY bqt1.smalla.intNum, bqt1.smalla.intkey HAVING COUNT(bqt1.smalla.intNum) = 1) AS q1"}, true); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Order by's will be added to the atomic queries
- */
- @Test public void testCrossSourceInlineView() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- QueryMetadataInterface metadata = createInlineViewMetadata(capFinder);
-
- ProcessorPlan plan = helpPlan("select * from (select count(bqt1.smalla.intkey) as a, bqt1.smalla.intkey from bqt1.smalla group by bqt1.smalla.intkey) q1 inner join (select count(bqt2.smallb.intkey) as a, bqt2.smallb.intkey from bqt2.smallb group by bqt2.smallb.intkey) as q2 on q1.intkey = q2.intkey where q1.a = 1", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt2.smallb AS g_0 GROUP BY g_0.intkey) AS v_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intkey AS c_0, COUNT(g_0.intkey) AS c_1 FROM bqt1.smalla AS g_0 GROUP BY g_0.intkey HAVING COUNT(g_0.intkey) = 1) AS v_0 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinOptimization.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,926 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.junit.Test;
-import org.teiid.resource.cci.SourceSystemFunctions;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryMetadataException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.rules.JoinUtil;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.ResolverVisitor;
-import com.metamatrix.query.sql.lang.Criteria;
-import com.metamatrix.query.sql.symbol.Expression;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-
-public class TestJoinOptimization {
-
- /**
- * Single group criteria should get pushed and be eligible for copy criteria
- */
- @Test public void testInnerJoinPushAndCopyNonJoinCriteria() {
- String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla inner join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt2.smalla.intkey = 1)"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla WHERE bqt1.smalla.intkey = 1", "SELECT bqt2.smalla.intkey FROM bqt2.smalla WHERE bqt2.smalla.intkey = 1"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Single group criteria should get pushed when it is on the inner side
- */
- @Test public void testOuterJoinPushNonJoinCriteria() {
- String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt2.smalla.stringkey = 1)"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0 ORDER BY c_0", "SELECT g_0.intkey AS c_0 FROM bqt2.smalla AS g_0 WHERE g_0.stringkey = '1' ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Single group criteria should not be pushed when it is on the outer side
- */
- @Test public void testOuterJoinPushNonJoinCriteriaA() {
- String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.stringkey = 1)"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt2.smalla AS g_0 ORDER BY c_0", "SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOuterJoinPushNonJoinCriteria_Case5547() {
- String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (1=1)"; //$NON-NLS-1$
- String BQT1 = "BQT1"; //$NON-NLS-1$
- String BQT2 = "BQT2"; //$NON-NLS-1$
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
-
- // === Must set the ORDER BY prop on the capabilities object to TRUE
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities(BQT1, caps);
- capFinder.addCapabilities(BQT2, caps);
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null,
- capFinder,
- new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla", "SELECT BQT2.SmallA.IntKey FROM bqt2.smalla"}, true ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
-
- /**
- * Single group criteria should not be pushed when it is used in a full outer join
- * Note that the join has also degraded into a cross join rather than an outer join
- */
- @Test public void testFullOuterJoinPushNonJoinCriteria() {
- String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla full outer join bqt2.smalla on (bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.stringkey = 1 and bqt2.smalla.stringkey = 1)"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM bqt2.smalla AS g_0 ORDER BY c_0", "SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Copy criteria should still work here even though the join criteria has an implicit type conversion because
- * the equality operation on the select criteria can be used.
- */
- @Test public void testCopyCriteriaWithFunction1() {
- String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla, bqt2.smalla where bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = 1"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey FROM bqt1.smalla WHERE bqt1.smalla.stringkey = '1'", "SELECT bqt2.smalla.intkey FROM bqt2.smalla WHERE bqt2.smalla.intkey = 1"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Copy criteria should not work here as the join criteria has an implicit convert and the where criteria is a non-equality predicate
- */
- @Test public void testCopyCriteriaWithFunction2() {
- String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla, bqt2.smalla where bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey <> 1"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey FROM bqt2.smalla AS g_0 WHERE g_0.intkey <> 1", "SELECT g_0.stringkey AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * The intkey criteria should not be copied above to bqt1.smalla since the criteria is comming from the inner side in the join below
- */
- @Test public void testInvalidCopyCriteria() {
- String sql = "select bqt1.smalla.intkey from bqt1.smalla inner join (select bqt3.smalla.intkey from bqt2.smalla left outer join bqt3.smalla on bqt2.smalla.intkey = bqt3.smalla.intkey and bqt3.smalla.intkey = 1) foo on bqt1.smalla.intkey = foo.intkey"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey FROM bqt3.smalla AS g_0 WHERE g_0.intkey = 1", "SELECT g_0.intkey FROM bqt2.smalla AS g_0", "SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /*
- * Note that the criteria does not get copied to the outer side.
- */
- @Test public void testCopyCriteriaFromInnerSide() throws Exception {
- String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join (select bqt3.smalla.intkey from bqt3.smalla where bqt3.smalla.intkey = 1) foo on bqt1.smalla.intkey = foo.intkey"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey FROM bqt3.smalla AS g_0 WHERE g_0.intkey = 1", "SELECT g_0.intkey FROM bqt1.smalla AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check to ensure that the full outer join does not get merged since the where criteria cannot be moved
- */
- @Test public void testFullOuterJoinPreservation() {
- String sql = "select bqt2.mediumb.intkey from bqt2.mediumb full outer join (select bqt2.smallb.intkey from bqt2.smalla left outer join bqt2.smallb on bqt2.smalla.intkey = bqt2.smallb.intkey where bqt2.smalla.stringkey = 1) foo on bqt2.mediumb.intkey = foo.intkey"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {"SELECT g_1.intkey FROM bqt2.smalla AS g_0 LEFT OUTER JOIN bqt2.smallb AS g_1 ON g_0.intkey = g_1.intkey WHERE g_0.stringkey = '1'", "SELECT g_0.intkey AS c_0 FROM bqt2.mediumb AS g_0 ORDER BY c_0"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Same as above but with a 0 group criteria
- */
- @Test public void testFullOuterJoinPreservation1() {
- String sql = "select bqt2.mediumb.intkey from bqt2.mediumb full outer join (select bqt2.smallb.intkey from bqt2.smalla inner join bqt2.smallb on bqt2.smalla.intkey = bqt2.smallb.intkey where ? = 1) foo on bqt2.mediumb.intkey = foo.intkey"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt2.mediumb AS g_0 ORDER BY c_0", "SELECT g_1.intkey FROM bqt2.smalla AS g_0, bqt2.smallb AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (? = 1)"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Same as above but with a left outer join
- */
- @Test public void testOuterJoinPreservation() {
- String sql = "select bqt2.mediumb.intkey from bqt2.mediumb left outer join (select bqt2.smallb.intkey from bqt2.smalla inner join bqt2.smallb on bqt2.smalla.intkey = bqt2.smallb.intkey where ? = 1) foo on bqt2.mediumb.intkey = foo.intkey"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT g_0.intkey AS c_0 FROM bqt2.mediumb AS g_0 ORDER BY c_0", "SELECT g_1.intkey FROM bqt2.smalla AS g_0, bqt2.smallb AS g_1 WHERE (g_0.intkey = g_1.intkey) AND (? = 1)"}); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCopyCriteriaCreatesFalseCriteria() {
- String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla, bqt2.smalla where bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = 1 and bqt1.smalla.stringkey = '2'"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {});
-
- TestOptimizer.checkNodeTypes(plan, TestRuleRaiseNull.FULLY_NULL);
- }
-
- @Test public void testPushNonJoinCriteriaWithFalse() {
- String sql = "select bqt1.smalla.intkey, bqt2.smalla.intkey from bqt1.smalla left outer join bqt2.smalla on (bqt1.smalla.stringkey = bqt2.smalla.intkey and bqt2.smalla.intkey = null)"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {"SELECT bqt1.smalla.intkey, null FROM bqt1.smalla"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testPushMultiGroupJoinCriteria() throws Exception {
- String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla right outer join (bqt1.smallb cross join (bqt1.mediuma cross join bqt1.mediumb)) on bqt1.smalla.stringkey = bqt1.smallb.stringkey" //$NON-NLS-1$
- +" where bqt1.smallb.intkey + bqt1.mediuma.intkey + bqt1.mediumb.intkey = 1"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_3.intkey, g_0.intkey FROM ((bqt1.smallb AS g_0 CROSS JOIN bqt1.mediuma AS g_1) INNER JOIN bqt1.mediumb AS g_2 ON ((g_0.intkey + g_1.intkey) + g_2.intkey) = 1) LEFT OUTER JOIN bqt1.smalla AS g_3 ON g_3.stringkey = g_0.stringkey"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Since the multigroup criteria spans the inner side, it should not be pushed.
- */
- @Test public void testPushMultiGroupJoinCriteria1() {
- String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla right outer join (bqt1.smallb cross join (bqt1.mediuma cross join bqt1.mediumb)) on bqt1.smalla.stringkey = bqt1.smallb.stringkey" //$NON-NLS-1$
- +" where bqt1.smalla.intkey + bqt1.mediuma.intkey + bqt1.mediumb.intkey is null"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_3.intkey, g_0.intkey FROM ((bqt1.smallb AS g_0 CROSS JOIN bqt1.mediuma AS g_1) CROSS JOIN bqt1.mediumb AS g_2) LEFT OUTER JOIN bqt1.smalla AS g_3 ON g_3.stringkey = g_0.stringkey WHERE ((g_3.intkey + g_1.intkey) + g_2.intkey) IS NULL"}, true); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Since the multigroup criteria is not null dependent, it should get pushed.
- */
- @Test public void testPushMultiGroupJoinCriteria2() {
- String sql = "select bqt1.smalla.intkey, bqt1.smallb.intkey from bqt1.smalla right outer join (bqt1.smallb cross join (bqt1.mediuma cross join bqt1.mediumb)) on bqt1.smalla.stringkey = bqt1.smallb.stringkey" //$NON-NLS-1$
- +" where bqt1.smalla.intkey + bqt1.mediuma.intkey + bqt1.mediumb.intkey = 1"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT g_3.intkey, g_2.intkey FROM bqt1.mediuma AS g_0, bqt1.mediumb AS g_1, bqt1.smallb AS g_2, bqt1.smalla AS g_3 WHERE (g_3.stringkey = g_2.stringkey) AND (((g_3.intkey + g_0.intkey) + g_1.intkey) = 1)"}, true); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
-
- /**
- * Having criteria should not be considered as regular criteria (unless it contains no aggregate expressions).
- */
- @Test public void testHavingCriteriaNotUsedAsJoinCriteria() {
- String sql = "select bqt1.smalla.intkey, max(bqt1.smallb.intkey) from bqt1.smalla, bqt1.smallb where bqt1.smalla.intkey = bqt1.smallb.intnum group by bqt1.smallb.intkey, bqt1.smalla.intkey having max(bqt1.smallb.intkey) = bqt1.smalla.intkey"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT bqt1.smalla.intkey, MAX(bqt1.smallb.intkey) FROM bqt1.smalla, bqt1.smallb WHERE bqt1.smalla.intkey = bqt1.smallb.intnum GROUP BY bqt1.smallb.intkey, bqt1.smalla.intkey HAVING MAX(bqt1.smallb.intkey) = bqt1.smalla.intkey"}, true); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Ensure that subqueries not initially pushable to the source still get replaced
- */
- @Test public void testSubqueryReplacement() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X left outer join vm1.g1 Y on Y.e1 = X.e1 where Y.e3 in (select e3 FROM vm1.g1) or Y.e3 IS NULL", metadata, null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 AS g1__1 LEFT OUTER JOIN pm1.g1 ON pm1.g1.e1 = g1__1.e1 WHERE (pm1.g1.e3 IN (SELECT pm1.g1.e3 FROM pm1.g1)) OR (pm1.g1.e3 IS NULL)"}, true); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testRulePushNonJoinCriteriaPreservesOuterJoin() throws Exception {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select b.intkey from (select intkey from bqt1.smalla) a left outer join (select intkey from bqt1.smallb) b on (1 = 1)"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- new String[]{"SELECT g_1.intkey FROM bqt1.smalla AS g_0 LEFT OUTER JOIN bqt1.smallb AS g_1 ON 1 = 1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOuterToInnerJoinConversion() {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smallb.intnum = 1)"}); //$NON-NLS-1$
- }
-
- //same as above, but with a right outer join
- @Test public void testOuterToInnerJoinConversion1() {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select bqt1.smalla.intkey from bqt1.smalla right outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb, bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = 1)"}); //$NON-NLS-1$
- }
-
- @Test public void testOuterToInnerJoinConversion2() {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smallb.intnum = 1"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smallb LEFT OUTER JOIN bqt1.smalla ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smallb.intnum = 1"}); //$NON-NLS-1$
- }
-
- @Test public void testOuterToInnerJoinConversion3() {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = 1"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey WHERE bqt1.smalla.intnum = 1"}); //$NON-NLS-1$
- }
-
- /**
- * non-depenent criteria on each side of a full outer creates an inner join
- */
- @Test public void testOuterToInnerJoinConversion4() {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select bqt1.smalla.intkey from bqt1.smalla full outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where bqt1.smalla.intnum = bqt1.smallb.intnum"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, metadata, new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla, bqt1.smallb WHERE (bqt1.smalla.intkey = bqt1.smallb.intkey) AND (bqt1.smalla.intnum = bqt1.smallb.intnum)"}); //$NON-NLS-1$
- }
-
- /**
- * Since concat2 is null dependent the join will not be changed
- */
- @Test public void testOuterToInnerJoinConversionNullDependent() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setFunctionSupport("concat2", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- String sql = "select bqt1.smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (bqt1.smalla.intkey = bqt1.smallb.intkey) where concat2(bqt1.smallb.intnum, '1') = 1"; //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, metadata, null, capFinder, new String[]{"SELECT bqt1.smallb.intnum, bqt1.smalla.intkey FROM bqt1.smalla LEFT OUTER JOIN bqt1.smallb ON bqt1.smalla.intkey = bqt1.smallb.intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
- }
-
- @Test public void testInlineViewToHaving() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "select x.y, x.intkey from (select max(intnum) y, intkey from bqt1.smalla group by intkey) x where x.y = 1"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[]{"SELECT MAX(intnum), intkey FROM bqt1.smalla GROUP BY intkey HAVING MAX(intnum) = 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * <p>In RuleBreakMultiJoin terminology:
- * If any of the regions contains a group with any unsatisfied access patterns, one
- * of those access patterns could be satisfied by arranging for a dependent join,
- * provided that group has join criteria which covers the column(s) in an access
- * pattern, and which joins the group to group(s) in other region(s). The task, then,
- * is to ensure that an ordering isn't picked which makes such a dependent join
- * impossible.</p>
- *
- * <p>A physical group can have zero or more access patterns; each access pattern can have one
- * or more columns. So a group could implicitly be dependent on one or more other physical
- * groups in one or more other regions. A table can be used to illustrate the potential
- * complexity of access patterns:
- * <pre>
- * Region with | Target
- * Access Patterns| Regions
- * -------------------------
- * Reg3 | Reg1, Reg2
- * Reg3 | Reg4
- * Reg1 | Reg2
- * Reg4 | Reg3
- * </pre></p>
- *
- * This tests now passes with RulePlanJoins
- */
- @Test public void testPathologicalAccessPatternCaseCase2976Defect19018() throws Exception{
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
-
- // add single access pattern to pm1.g4 containing elements e1, e2, and e3
- FakeMetadataStore store = metadata.getStore();
- FakeMetadataObject pm4g1 = store.findObject("pm4.g1", FakeMetadataObject.GROUP);//$NON-NLS-1$
- List elementIDs = metadata.getElementIDsInGroupID(pm4g1);
- elementIDs.remove(2);
- FakeMetadataObject pm4g1ap1 = FakeMetadataFactory.createAccessPattern("pm4.g1.ap1", pm4g1, elementIDs); //e1,e2,e4 //$NON-NLS-1$
- store.addObject(pm4g1ap1);
-
- String sql = "SELECT pm1.g1.e1, pm2.g1.e1, pm4.g1.e1 " +//$NON-NLS-1$
- "FROM pm1.g1, pm2.g1, pm4.g1 WHERE " +//$NON-NLS-1$
- "pm1.g1.e1 = pm4.g1.e1 AND pm2.g1.e2 = pm4.g1.e2 AND pm1.g1.e4 = pm2.g1.e4 " +//$NON-NLS-1$
- "AND pm4.g1.e4 = 3.2";//$NON-NLS-1$
-
- String[] expected = new String[] {"SELECT g_0.e4 AS c_0, g_0.e1 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1 FROM pm4.g1 AS g_0 WHERE (g_0.e4 = 3.2) AND (g_0.e1 IN (<dependent values>)) AND (g_0.e2 IN (<dependent values>)) ORDER BY c_0, c_1", //$NON-NLS-1$
- "SELECT g_0.e4 AS c_0, g_0.e2 AS c_1, g_0.e1 AS c_2 FROM pm2.g1 AS g_0 ORDER BY c_0",//$NON-NLS-1$
- };
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, expected, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * non-null dependent criteria should get pushed down
- */
- @Test public void testPushMultiGroupCriteriaOuterJoin() {
- String sql = "select m.intkey, m.intnum, s.intkey, s.intnum from BQT2.mediuma m left outer join BQT2.smalla s on m.intkey = s.intkey where not (m.intkey + s.intnum = 26)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {
- "SELECT m.intkey, m.intnum, s.intkey, s.intnum FROM BQT2.mediuma AS m, BQT2.smalla AS s WHERE (m.intkey = s.intkey) AND (NOT ((m.intkey + s.intnum) = 26))" }, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- }
-
- /**
- * Assumes that pm1.g1 is the only inner group
- */
- private void helpTestNullDependentVisitor(String critSQL,
- boolean dependent) throws QueryParserException,
- QueryResolverException,
- QueryMetadataException,
- MetaMatrixComponentException {
- List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
- innerGroups.add(new GroupSymbol("pm1.g1")); //$NON-NLS-1$
-
- Criteria crit = QueryParser.getQueryParser().parseCriteria(critSQL);
-
- QueryResolver.resolveCriteria(crit, FakeMetadataFactory.example1Cached());
-
- assertEquals(dependent, JoinUtil.isNullDependent(FakeMetadataFactory.example1Cached(), innerGroups, crit));
- }
-
- private void helpTestNullDependent(String expressionSQL,
- boolean dependent) throws QueryParserException,
- QueryResolverException,
- QueryMetadataException,
- MetaMatrixComponentException {
- List<GroupSymbol> innerGroups = new ArrayList<GroupSymbol>();
- innerGroups.add(new GroupSymbol("pm1.g1")); //$NON-NLS-1$
-
- Expression expr = QueryParser.getQueryParser().parseExpression(expressionSQL);
-
- ResolverVisitor.resolveLanguageObject(expr, FakeMetadataFactory.example1Cached());
-
- assertEquals(dependent, JoinUtil.isNullDependent(FakeMetadataFactory.example1Cached(), innerGroups, expr));
- }
-
- @Test public void testNullDependentVisitor() throws Exception {
- helpTestNullDependentVisitor("nvl(pm1.g1.e1, 1) = 1", true); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor1() throws Exception {
- helpTestNullDependentVisitor("ifnull(pm1.g1.e1, 1) = 1", true); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor2() throws Exception {
- helpTestNullDependentVisitor("rand(pm1.g1.e2) = 1", true); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor3() throws Exception {
- helpTestNullDependentVisitor("concat2(pm1.g1.e1, pm1.g1.e2) = '1'", false); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor4() throws Exception {
- helpTestNullDependentVisitor("nvl(pm1.g2.e1, 1) = 1", true); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor5() throws Exception {
- helpTestNullDependentVisitor("pm1.g1.e1 is null", true); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor6() throws Exception {
- helpTestNullDependentVisitor("pm1.g1.e1 is not null", false); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor7() throws Exception {
- helpTestNullDependentVisitor("pm1.g2.e1 is not null", true); //$NON-NLS-1$
- }
-
- //this is an important test, the or causes this criteria to be null dependent
- @Test public void testNullDependentVisitor8() throws Exception {
- helpTestNullDependentVisitor("pm1.g1.e1 = 1 or pm1.g2.e1 = 1", true); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor9() throws Exception {
- helpTestNullDependentVisitor("pm1.g1.e1 = 1 or pm1.g1.e2 = 2", false); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor10() throws Exception {
- helpTestNullDependentVisitor("pm1.g1.e1 in (1, pm1.g2.e1)", false); //$NON-NLS-1$
- }
-
- @Test public void testNullDependentVisitor11() throws Exception {
- helpTestNullDependentVisitor("pm1.g2.e1 in (1, pm1.g1.e1)", true); //$NON-NLS-1$
- }
-
- @Test public void testIsNullDependent() throws Exception {
- helpTestNullDependent("pm1.g1.e2 + 1", false); //$NON-NLS-1$
- }
-
- @Test public void testIsNullDependent1() throws Exception {
- helpTestNullDependent("pm1.g2.e2 + 1", true); //$NON-NLS-1$
- }
-
- /**
- * The criteria will still get pushed to appropriate location, and
- * the other side of the join will be removed
- */
- @Test public void testCriteriaPushedWithUnionJoin() throws Exception {
- String sql = "select * from pm1.g1 union join pm1.g2 where g1.e1 = 1"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = '1'" }, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- /**
- * union joins allow RuleRemoveVirtual to still take effect
- */
- @Test public void testCriteriaPushedWithUnionJoin1() throws Exception {
- String sql = "select vm1.g1.e1 from vm1.g1 union join vm1.g2 where g2.e1 = 1"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] {
- "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = '1') AND (g_1.e1 = '1')" }, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- /**
- * null-dependent expressions should prevent merging of virtual layers
- */
- @Test public void testNullDependentPreventsMerge() throws Exception {
- String sql = "select x from pm1.g1 left outer join (select nvl(e2, 1) x from pm1.g2) y on e2 = x"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setFunctionSupport(SourceSystemFunctions.IFNULL, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] {
- "SELECT v_0.c_0 FROM pm1.g1 AS g_0 LEFT OUTER JOIN (SELECT ifnull(g_1.e2, 1) AS c_0 FROM pm1.g2 AS g_1) AS v_0 ON g_0.e2 = v_0.c_0" }, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- }
-
- /**
- * RuleCopyCriteria will remove the first join criteria and the source doesn't support the * function. However we still
- * want the join to be pushed since it originally contained proper criteria.
- */
- @Test public void testCopyCriteriaJoinPushed() throws Exception {
- String sql = "select pm1.g1.e1 from pm1.g1, pm1.g2 where pm1.g1.e1 = pm1.g2.e1 and pm1.g1.e1 = 5 and pm1.g1.e2 * 5 = pm1.g2.e2"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,metadata,
- new String[] { "SELECT g_0.e2, g_1.e2, g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = '5') AND (g_1.e1 = '5')" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinPushdownRestrictions.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinPushdownRestrictions.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,143 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import org.junit.Test;
-import org.teiid.resource.cci.ConnectorCapabilities.SupportedJoinCriteria;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestJoinPushdownRestrictions {
-
- @Test public void testThetaRestriction() throws Exception {
- String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 + pm1.g2.e2 = 5)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.ANY);
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e2 + g_1.e2) = 5"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testEquiRestriction() throws Exception {
- String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 < pm1.g2.e2)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.EQUI);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e2 < g_1.e2"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testKeyRestriction() throws Exception {
- String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 = pm1.g2.e2)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.KEY);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm1.g2 AS g_0 ORDER BY c_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
-
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.EQUI);
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2, g_1.e2 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e2 = g_1.e2"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testKeyPasses() throws Exception {
- String sql = "select a.e1, b.e1 from pm4.g1 a, pm4.g2 b where a.e1 = b.e1 and a.e2 = b.e2"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.KEY);
- capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example4(),
- new String[] {"SELECT g_0.e1, g_1.e1 FROM pm4.g1 AS g_0, pm4.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e2 = g_1.e2)"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCrossJoinWithRestriction() throws Exception {
- String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1, pm1.g2"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testOuterRestriction() throws Exception {
- String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 inner join pm1.g2 on (pm1.g1.e2 + pm1.g2.e2 = 5)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.ANY);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2 FROM pm1.g2 AS g_0", "SELECT g_0.e2 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testCriteriaRestrictionWithNonJoinCriteria() throws Exception {
- String sql = "select pm1.g1.e2, pm1.g2.e2 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e2 = pm1.g2.e2 and pm1.g2.e1 = 'hello')"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setSourceProperty(Capability.JOIN_CRITERIA_ALLOWED, SupportedJoinCriteria.THETA);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm1.g2 AS g_0 WHERE g_0.e1 = 'hello' ORDER BY c_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestJoinWithFunction.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,437 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2009 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * 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 com.metamatrix.query.optimizer;
-
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.query.QueryParserException;
-import com.metamatrix.api.exception.query.QueryResolverException;
-import com.metamatrix.api.exception.query.QueryValidatorException;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.symbol.AliasSymbol;
-import com.metamatrix.query.sql.symbol.Constant;
-import com.metamatrix.query.sql.symbol.ExpressionSymbol;
-
-/**
- * <p><code>TestCase</code> to cover planning and optimization of JOINs which
- * use a scalar function as a symbol or as part of the JOIN criteria.</p>
- *
- * <p>All tests should verify and validate that the scalar function is being
- * pushed/merged with the correct layer of the plan. For example, if a
- * non-deterministic function is being merged with a parent node the resulting
- * query may alter the final result set. Most specifically, if the function is
- * executed too late during the processing of a command, the results may be
- * different than if it were executed earlier during processing.</p>
- * @since 6.0
- */
-public class TestJoinWithFunction extends TestCase {
-
- /**
- * <p>Test the use of a non-deterministic function on a user command that
- * performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed on the result returned from the JOIN and
- * is expected to be executed for each row of the final result set.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- */
- public void testNonDeterministicPostJoin() throws Exception {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. RandomTop is the use of RAND() on
- * the user command and should result in unique random numbers for each
- * row in the JOINed output.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, RAND() AS RandomTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- // The user command should result in two atomic commands
- String[] expected = new String[] {
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- };
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * <p>Test the use of a non-deterministic function on the source command of a JOIN
- * defined by a user command which performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed on the result that will be used for one side
- * of the JOIN. The function should only be executed for each row of the the result
- * set returned from the left-side of the JOIN which should result in the same return
- * value for multiple rows of the final result set after the JOIN is completed. For
- * example, if the left-side query is expected to return one row and the right-side
- * query will return three rows which match the JOIN criteria for the one row on the
- * left-side then the expected result should be that the function be executed once to
- * represent the one row from the left-side and the function's return value will be
- * repeated for each of the three post-JOINed results.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- */
- public void testNonDeterministicPreJoin() throws Exception {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. TopRandom is the use of RAND() on
- * the user command while RandomLeft is the use of RAND() within a
- * source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- // The user command should result in two atomic commands
- String[] expected = new String[] {
- "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- };
-
- // create a plan and assert our atomic queries
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * <p>Test the use of a non-deterministic function on the sub-command of a user
- * command and the user command itself, which performs a JOIN of two sources.</p>
- *
- * <p>This test combines the PostJoin and PreJoin test cases.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- * @see #testNonDeterministicPostJoin
- * @see #testNonDeterministicPreJoin
- */
- public void testNonDeterministicPrePostJoin() throws Exception {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, RAND() AS RandomLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. TopRandom is the use of RAND() on
- * the user command while RandomLeft is the use of RAND() within a
- * source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.RandomLeft, RAND() AS RandomTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- // The user command should result in two atomic commands
- String[] expected = new String[] {
- "SELECT g_0.e1, g_0.e2, g_0.e3, g_0.e4 FROM pm1.g1 AS g_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- };
-
- // create a plan and assert our atomic queries
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * <p>Test the use of a deterministic function on the user command which
- * performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed prior to the JOIN being executed and should
- * result in the projected symbol becoming a constant.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- */
- public void testDeterministicPostJoin() throws Exception {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
- * the user command and should result in 10 for each row in the JOINed
- * output.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- // The user command should result in two atomic commands
- String[] expected = new String[] {
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- };
-
- // create a plan and assert our atomic queries
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- /*
- * Retrieve root nodes elements to assert that a constant has
- * has replaced the SQRT() function.
- */
- List<?> elem = ((RelationalPlan) plan).getRootNode().getElements();
- Constant expectedConst = new Constant(new Double(10.0));
- assertEquals("Did not get expected constant value for SqrtTop in root node of plan: ", //$NON-NLS-1$
- expectedConst,
- ((ExpressionSymbol) ((AliasSymbol) elem.get(8)).getSymbol()).getExpression() // should be a AliasSymbol containing an expression
- );
- }
-
- /**
- * <p>The function should be executed prior to the JOIN being executed and should
- * result in the projected symbol becoming a constant.</p>
-
- * <p>Test the use of a deterministic function on the source command of a JOIN
- * defined by a user command which performs a JOIN of two sources.</p>
- *
- * <p>The function should be executed prior to the commands from either side of the
- * JOIN being executed and merged into user command prior to the JOIN actually being
- * executed.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- */
- public void testDeterministicPreJoin() throws Exception {
- // source query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // source query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. SqrtLeft is the use of SQRT()
- * within a source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- // The user command should result in two atomic commands
- String[] expected = new String[] {
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- };
-
- // create a plan and assert our atomic queries
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- /*
- * Retrieve root nodes elements to assert that a constant has
- * has replaced the SQRT() function.
- */
- List<?> elem = ((RelationalPlan) plan).getRootNode().getElements();
- Constant expectedConst = new Constant(new Double(10.0));
- assertEquals("Did not get expected constant value for SqrtLeft in root node of plan: ", //$NON-NLS-1$
- expectedConst,
- ((ExpressionSymbol)elem.get(8)).getExpression() // should be a AliasSymbol containing an expression
- );
- }
-
- /**
- * <p>Test the use of a deterministic function on the sub-command of a user
- * command and the user command itself, which performs a JOIN of two sources.</p>
- *
- * <p>This test combines the PostJoin and PreJoin test cases.</p>
- * @throws MetaMatrixComponentException
- * @throws QueryValidatorException
- * @throws QueryResolverException
- * @throws QueryParserException
- * @see #testDeterministicPostJoin
- * @see #testDeterministicPreJoin
- */
- public void testDeterministicPrePostJoin() throws Exception {
- // sub-query for one side of a JOIN
- String leftQuery = "SELECT pm1.g1.e1 as ID, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4, SQRT(100) AS SqrtLeft " //$NON-NLS-1$
- + "FROM pm1.g1"; //$NON-NLS-1$
- // sub-query for other side of a JOIN
- String rightQuery = "SELECT pm2.g2.e1 as ID, pm2.g2.e2, pm2.g2.e3, pm2.g2.e4 " //$NON-NLS-1$
- + "FROM pm2.g2"; //$NON-NLS-1$
-
- // User Command
- /*
- * Return everything from the JOIN. SqrtTop is the use of SQRT(100) on
- * the user command while SqrtLeft is the use of SQRT() within a
- * source node.
- */
- String sql = "SELECT l.ID, l.e2, l.e3, l.e4, r.ID, r.e2, r.e3, r.e4, l.SqrtLeft, SQRT(100) AS SqrtTop " + //$NON-NLS-1$
- "FROM (" + leftQuery + ") AS l, " + //$NON-NLS-1$ //$NON-NLS-2$
- "(" + rightQuery + ") AS r " + //$NON-NLS-1$ //$NON-NLS-2$
- "WHERE l.ID = r.ID"; //$NON-NLS-1$
-
- // The user command should result in two atomic commands
- String[] expected = new String[] {
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm1.g1 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0, g_0.e2 AS c_1, g_0.e3 AS c_2, g_0.e4 AS c_3 FROM pm2.g2 AS g_0 ORDER BY c_0", //$NON-NLS-1$
- };
-
- // create a plan and assert our atomic queries
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, TestOptimizer.example1(), expected,
- ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] { 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- /*
- * Retrieve root nodes elements to assert that a constant has
- * replaced the SQRT() function for both SqrtTop and SqrtLeft.
- */
- List<?> elem = ((RelationalPlan) plan).getRootNode().getElements();
- Constant expectedConst = new Constant(new Double(10.0));
- assertEquals("Did not get expected constant value for SqrtLeft in root node of plan: ", //$NON-NLS-1$
- expectedConst,
- ((ExpressionSymbol) elem.get(8)).getExpression() // should be a AliasSymbol containing an expression
- );
- assertEquals("Did not get expected constant value for SqrtTop in root node of plan: ", //$NON-NLS-1$
- expectedConst,
- ((ExpressionSymbol) ((AliasSymbol) elem.get(9)).getSymbol()).getExpression() // should be a AliasSymbol containing an expression
- );
- }
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestLimit.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,889 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import java.util.Arrays;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.optimizer.TestOptimizer.DependentProjectNode;
-import com.metamatrix.query.optimizer.TestOptimizer.DependentSelectNode;
-import com.metamatrix.query.optimizer.TestOptimizer.DupRemoveNode;
-import com.metamatrix.query.optimizer.TestOptimizer.DupRemoveSortNode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.FakeDataManager;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.TestProcessor;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.DependentAccessNode;
-import com.metamatrix.query.processor.relational.GroupingNode;
-import com.metamatrix.query.processor.relational.LimitNode;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy;
-import com.metamatrix.query.processor.relational.NestedLoopJoinStrategy;
-import com.metamatrix.query.processor.relational.NullNode;
-import com.metamatrix.query.processor.relational.PlanExecutionNode;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.SelectNode;
-import com.metamatrix.query.processor.relational.SortNode;
-import com.metamatrix.query.processor.relational.UnionAllNode;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-
-
-/**
- * @since 4.3
- */
-public class TestLimit extends TestCase {
-
- private static final int[] FULL_PUSHDOWN = new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- };
-
- public static final Class<?>[] NODE_TYPES = new Class[] {
- AccessNode.class,
- DependentAccessNode.class,
- DependentSelectNode.class,
- DependentProjectNode.class,
- DupRemoveNode.class,
- GroupingNode.class,
- LimitNode.class,
- NestedLoopJoinStrategy.class,
- MergeJoinStrategy.class,
- NullNode.class,
- PlanExecutionNode.class,
- ProjectNode.class,
- SelectNode.class,
- SortNode.class,
- UnionAllNode.class
- };
-
- public TestLimit(String name) {
- super(name);
- }
-
- private static FakeMetadataFacade exampleMetadata() {
- // Create models
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject vm1 = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g2 = FakeMetadataFactory.createPhysicalGroup("pm1.g2", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g3 = FakeMetadataFactory.createPhysicalGroup("pm1.g3", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g4 = FakeMetadataFactory.createPhysicalGroup("pm1.g4", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g5 = FakeMetadataFactory.createPhysicalGroup("pm1.g5", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g6 = FakeMetadataFactory.createPhysicalGroup("pm1.g6", pm1); //$NON-NLS-1$
-
- // Create physical elements
- List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm1g2e = FakeMetadataFactory.createElements(pm1g2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm1g3e = FakeMetadataFactory.createElements(pm1g3,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm1g4e = FakeMetadataFactory.createElements(pm1g4,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- ((FakeMetadataObject)pm1g4e.get(1)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
- ((FakeMetadataObject)pm1g4e.get(3)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
- List pm1g5e = FakeMetadataFactory.createElements(pm1g5,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- ((FakeMetadataObject)pm1g5e.get(0)).putProperty(FakeMetadataObject.Props.SELECT, Boolean.FALSE);
- List pm1g6e = FakeMetadataFactory.createElements(pm1g6,
- new String[] { "in", "in3" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
-
- // Create virtual groups
- QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM pm1.g1 LIMIT 100"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g1 = FakeMetadataFactory.createVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
-
- // Create virtual elements
- List vm1g1e = FakeMetadataFactory.createElements(vm1g1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
-
- QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT * FROM vm1.g1 ORDER BY e1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g2 = FakeMetadataFactory.createVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
-
- // Create virtual elements
- List vm1g2e = FakeMetadataFactory.createElements(vm1g2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(pm1g1);
- store.addObjects(pm1g1e);
- store.addObject(pm1g2);
- store.addObjects(pm1g2e);
- store.addObject(pm1g3);
- store.addObjects(pm1g3e);
- store.addObject(pm1g4);
- store.addObjects(pm1g4e);
- store.addObject(pm1g5);
- store.addObjects(pm1g5e);
- store.addObject(pm1g6);
- store.addObjects(pm1g6e);
-
- store.addObject(vm1);
- store.addObject(vm1g1);
- store.addObjects(vm1g1e);
- store.addObject(vm1g2);
- store.addObjects(vm1g2e);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
- public void testLimit() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 limit 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
-
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitPushdown() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 limit 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 100" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- public void testLimitWithOffset() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testPushedLimitWithOffset() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitWithOffsetFullyPushed() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 limit 50, 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 50, 100" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- public void testSort() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 order by e1 limit 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testSortPushed() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- // pm3 model supports order by
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm3.g1 order by e1 limit 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testSortPushedWithLimit() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- // pm3 model supports order by
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm3.g1 order by e1 limit 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1 LIMIT 100" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- public void testSortUnderLimitNotRemoved() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- // pm3 model supports order by
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM (SELECT * FROM pm3.g1 order by e1 limit 100) AS V1 ORDER BY v1.e2";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 2, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- //TODO: there is a redundent project node here
- public void testSortAboveLimitNotPushed() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM vm1.g2 order by e1";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 100" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, exampleMetadata(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitNotPushedWithUnion() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- // pm1 model supports order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 UNION SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM PM1.g2" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitPushedWithUnion() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- // pm1 model supports order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM PM1.g2 LIMIT 100", "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 LIMIT 100" //$NON-NLS-1$ //$NON-NLS-2$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitWithOffsetPushedWithUnion() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
- // pm1 model supports order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 LIMIT 50, 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT PM1.g2.e1 AS c_0, PM1.g2.e2 AS c_1, PM1.g2.e3 AS c_2, PM1.g2.e4 AS c_3 FROM PM1.g2 LIMIT (100 + 50)", "SELECT pm1.g1.e1 AS c_0, pm1.g1.e2 AS c_1, pm1.g1.e3 AS c_2, pm1.g1.e4 AS c_3 FROM pm1.g1 LIMIT (100 + 50)" //$NON-NLS-1$ //$NON-NLS-2$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitNotPushedWithUnionOrderBy() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- // pm1 model supports order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM pm1.g1 UNION SELECT * FROM PM1.g2 ORDER BY e1 LIMIT 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM PM1.g2", "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" //$NON-NLS-1$ //$NON-NLS-2$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- }, NODE_TYPES);
- TestOptimizer.checkNodeTypes(plan, new int[] {1}, new Class[]{DupRemoveSortNode.class});
- }
-
- public void testCombinedLimits() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- // pm1 model supports order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT CASE WHEN (75 + (20 + 10)) < (100 + 10) THEN (75 + (20 + 10)) ELSE (100 + 10) END" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testCombinedLimitsWithOffset() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.ROW_OFFSET, true);
- // pm1 model supports order by
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT * from (SELECT pm1.g1.e1 FROM pm1.g1 LIMIT 10, 100) x LIMIT 20, 75";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 LIMIT (20 + 10), CASE WHEN 75 < 100 THEN 75 ELSE 100 END" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- public void testInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- //caps.setCapabilitySupport(SourceCapabilities.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- // pm3 model supports order by
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM (SELECT * FROM pm3.g1) as v1 limit 100";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 LIMIT 100" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- /**
- * This turns out to be an important test for LIMIT: there are several nodes
- * (e.g. grouping, inline views, aggregates, sorting, joins, etc) that should not be pushed
- * down (because they change row order or row count) if there is already a limit node in that plan branch,
- * which can only be placed above LIMIT with an inline view. This test acts as a gatekeeper for avoiding
- * several of those pushdowns.
- *
- * @since 4.3
- */
- public void testInlineViewAboveLimitNotMerged() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- // pm3 model supports order by
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM (SELECT * FROM pm3.g1 limit 100) as v1 order by e1";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT v_0.c_0, v_0.c_1, v_0.c_2, v_0.c_3 FROM (SELECT pm3.g1.e1 AS c_0, pm3.g1.e2 AS c_1, pm3.g1.e3 AS c_2, pm3.g1.e4 AS c_3 FROM pm3.g1 LIMIT 100) AS v_0 ORDER BY c_0" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * since there is no order by with the nested limit, the criteria can be pushed through
- *
- */
- public void testCriteriaPushedUnderLimit() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- // pm3 model supports order by
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- String sql = "SELECT * FROM (SELECT * FROM pm3.g1 limit 100) as v1 where v1.e1 = 1";//$NON-NLS-1$
- String[] expectedSql = new String[] {
- "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 WHERE pm3.g1.e1 = '1' LIMIT 100" //$NON-NLS-1$
- };
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- public void testInlineViewJoin() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "SELECT x FROM ((SELECT e1 as x FROM pm1.g1 LIMIT 700) c INNER JOIN (SELECT e1 FROM pm1.g2) d ON d.e1 = c.x) order by x LIMIT 5";//$NON-NLS-1$
- String[] expectedSql = new String[] {"SELECT e1 FROM pm1.g1 LIMIT 700", "SELECT e1 FROM pm1.g2"};//$NON-NLS-1$ //$NON-NLS-2$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
-
- //test to ensure that the unnecessary inline view removal is done properly
- FakeDataManager fdm = new FakeDataManager();
- TestProcessor.sampleData1(fdm);
- TestProcessor.helpProcess(plan, fdm, new List[] {
- Arrays.asList("a"), //$NON-NLS-1$
- Arrays.asList("a"), //$NON-NLS-1$
- Arrays.asList("a"), //$NON-NLS-1$
- Arrays.asList("a"), //$NON-NLS-1$
- Arrays.asList("a"), //$NON-NLS-1$
- });
- }
-
- public void testDontPushSelectWithOrderedLimit() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select * from (SELECT e1 as x FROM pm1.g1 order by x LIMIT 700) y where x = 1";//$NON-NLS-1$
- String[] expectedSql = new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"};//$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testDontPushSelectWithOrderedLimit1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select * from (SELECT e1 as x FROM pm1.g1 order by x LIMIT 10, 700) y where x = 1";//$NON-NLS-1$
- String[] expectedSql = new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"};//$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- public void testLimitWithNoAccessNode() {
- String sql = "select 1 limit 1";//$NON-NLS-1$
- String[] expectedSql = new String[] {};
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), expectedSql);
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
- /**
- * Note here that the criteria made it to the having clause
- */
- public void testAggregateCriteriaOverUnSortedLimit() {
- String sql = "select a from (SELECT MAX(e2) as a FROM pm1.g1 GROUP BY e2 LIMIT 1) x where a = 0"; //$NON-NLS-1$
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- caps.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_HAVING, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String[] expectedSql = new String[] {"SELECT MAX(e2) FROM pm1.g1 GROUP BY e2 HAVING MAX(e2) = 0 LIMIT 1"};//$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder, expectedSql, true);
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN, NODE_TYPES);
- }
-
- public void testSortWithLimitInlineView() {
- String sql = "select e1 from (select pm1.g1.e1, pm1.g1.e2 from pm1.g1 order by pm1.g1.e1, pm1.g1.e2 limit 1) x"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0, g_0.e2"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Limit
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- }, NODE_TYPES);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptimizer.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,6781 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static org.junit.Assert.*;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.junit.Test;
-import org.teiid.resource.cci.SourceSystemFunctions;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.api.exception.query.QueryPlannerException;
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.common.types.DataTypeManager;
-import com.metamatrix.core.MetaMatrixRuntimeException;
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.function.FunctionLibrary;
-import com.metamatrix.query.function.FunctionTree;
-import com.metamatrix.query.function.SystemFunctionManager;
-import com.metamatrix.query.function.UDFSource;
-import com.metamatrix.query.mapping.relational.QueryNode;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.CapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.optimizer.relational.AliasGenerator;
-import com.metamatrix.query.optimizer.relational.rules.CapabilitiesUtil;
-import com.metamatrix.query.optimizer.relational.rules.RuleChooseDependent;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.AccessNode;
-import com.metamatrix.query.processor.relational.DependentAccessNode;
-import com.metamatrix.query.processor.relational.GroupingNode;
-import com.metamatrix.query.processor.relational.JoinNode;
-import com.metamatrix.query.processor.relational.JoinStrategy;
-import com.metamatrix.query.processor.relational.MergeJoinStrategy;
-import com.metamatrix.query.processor.relational.NestedLoopJoinStrategy;
-import com.metamatrix.query.processor.relational.NullNode;
-import com.metamatrix.query.processor.relational.PartitionedSortJoin;
-import com.metamatrix.query.processor.relational.PlanExecutionNode;
-import com.metamatrix.query.processor.relational.ProjectIntoNode;
-import com.metamatrix.query.processor.relational.ProjectNode;
-import com.metamatrix.query.processor.relational.RelationalNode;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.processor.relational.SelectNode;
-import com.metamatrix.query.processor.relational.SortNode;
-import com.metamatrix.query.processor.relational.UnionAllNode;
-import com.metamatrix.query.processor.relational.SortUtility.Mode;
-import com.metamatrix.query.resolver.QueryResolver;
-import com.metamatrix.query.resolver.util.BindVariableVisitor;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.visitor.GroupCollectorVisitor;
-import com.metamatrix.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-import com.metamatrix.query.unittest.FakeMetadataStore;
-import com.metamatrix.query.util.CommandContext;
-import com.metamatrix.query.validator.Validator;
-import com.metamatrix.query.validator.ValidatorReport;
-
-public class TestOptimizer {
-
- public interface DependentJoin {}
- public interface DependentSelectNode {}
- public interface DependentProjectNode {}
- public interface DupRemoveNode {}
- public interface DupRemoveSortNode {}
-
- public static final int[] FULL_PUSHDOWN = new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- };
-
- public enum ComparisonMode { EXACT_COMMAND_STRING, CORRECTED_COMMAND_STRING, FAILED_PLANNING }
-
- public static final boolean SHOULD_SUCCEED = true;
- public static final boolean SHOULD_FAIL = false;
-
- // ################################## TEST HELPERS ################################
-
- public static BasicSourceCapabilities getTypicalCapabilities() {
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.CRITERIA_BETWEEN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
- caps.setCapabilitySupport(Capability.CRITERIA_LIKE_ESCAPE, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_ISNULL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_OR, true);
- caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY_UNRELATED, true);
-
- // set typical max set size
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- return caps;
- }
-
- public static CapabilitiesFinder getGenericFinder(boolean supportsJoins) {
- final BasicSourceCapabilities caps = getTypicalCapabilities();
- if (!supportsJoins) {
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, false);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- }
- return new DefaultCapabilitiesFinder(caps);
- }
-
- public static CapabilitiesFinder getGenericFinder() {
- return getGenericFinder(true);
- }
-
- public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, String[] expectedAtomic) {
- return helpPlan(sql, md, null, getGenericFinder(), expectedAtomic, SHOULD_SUCCEED);
- }
-
- public static ProcessorPlan helpPlan(String sql,
- QueryMetadataInterface md, String[] expected,
- CapabilitiesFinder capFinder,
- ComparisonMode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- return helpPlan(sql, md, null, capFinder, expected, mode);
- }
-
- public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, String[] expectedAtomic, ComparisonMode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- return helpPlan(sql, md, null, getGenericFinder(), expectedAtomic, mode);
- }
-
- public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, boolean shouldSucceed) {
- Command command;
- try {
- command = helpGetCommand(sql, md, bindings);
- } catch (MetaMatrixException err) {
- throw new MetaMatrixRuntimeException(err);
- }
-
- return helpPlanCommand(command, md, capFinder, null, expectedAtomic, shouldSucceed ? ComparisonMode.CORRECTED_COMMAND_STRING : ComparisonMode.FAILED_PLANNING);
- }
-
- public static ProcessorPlan helpPlan(String sql, QueryMetadataInterface md, List bindings, CapabilitiesFinder capFinder, String[] expectedAtomic, ComparisonMode mode) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- Command command = helpGetCommand(sql, md, bindings);
-
- return helpPlanCommand(command, md, capFinder, null, expectedAtomic, mode);
- }
-
-
- public static Command helpGetCommand(String sql, QueryMetadataInterface md, List bindings) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- if(DEBUG) System.out.println("\n####################################\n" + sql); //$NON-NLS-1$
- Command command = QueryParser.getQueryParser().parseCommand(sql);
-
- // resolve
- QueryResolver.resolveCommand(command, md);
-
- ValidatorReport repo = Validator.validate(command, md);
-
- Collection failures = new ArrayList();
- repo.collectInvalidObjects(failures);
- if (failures.size() > 0){
- fail("Exception during validation (" + repo); //$NON-NLS-1$
- }
-
- // bind variables
- if(bindings != null) {
- BindVariableVisitor.bindReferences(command, bindings, md);
- }
-
- // rewrite
- command = QueryRewriter.rewrite(command, md, new CommandContext());
-
- return command;
- }
-
- public static ProcessorPlan helpPlanCommand(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, String[] expectedAtomic, ComparisonMode mode) {
- if (capFinder == null){
- capFinder = getGenericFinder();
- }
-
- // Collect atomic queries
- ProcessorPlan plan = getPlan(command, md, capFinder, analysisRecord, mode != ComparisonMode.FAILED_PLANNING);
-
- if (mode == ComparisonMode.CORRECTED_COMMAND_STRING) {
- checkAtomicQueries(expectedAtomic, plan, md, capFinder);
- } else if (mode == ComparisonMode.EXACT_COMMAND_STRING) {
- checkAtomicQueries(expectedAtomic, plan);
- }
-
- return plan;
- }
-
- public static void checkAtomicQueries(String[] expectedAtomic,
- ProcessorPlan plan) {
- Set<String> actualQueries = getAtomicQueries(plan);
-
- if (actualQueries.size() != 1 || expectedAtomic.length != 1) {
- // Compare atomic queries
- HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(expectedAtomic));
- assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
- } else {
- assertEquals("Did not get expected atomic query: ", expectedAtomic[0], actualQueries.iterator().next()); //$NON-NLS-1$
- }
- }
-
- public static void checkAtomicQueries(String[] expectedAtomic,
- ProcessorPlan plan, QueryMetadataInterface md, CapabilitiesFinder capFinder) {
- Set actualQueries = getAtomicQueries(plan);
-
- HashSet<String> expectedQueries = new HashSet<String>();
-
- // Compare atomic queries
- for (int i = 0; i < expectedAtomic.length; i++) {
- final String sql = expectedAtomic[i];
- Command command;
- try {
- command = helpGetCommand(sql, md, null);
- Collection groups = GroupCollectorVisitor.getGroupsIgnoreInlineViews(command, false);
- final GroupSymbol symbol = (GroupSymbol)groups.iterator().next();
- Object modelId = md.getModelID(symbol.getMetadataID());
- boolean supportsGroupAliases = CapabilitiesUtil.supportsGroupAliases(modelId, md, capFinder);
- command.acceptVisitor(new AliasGenerator(supportsGroupAliases));
- expectedQueries.add(command.toString());
- } catch (Exception err) {
- throw new RuntimeException(err);
- }
- }
-
- assertEquals("Did not get expected atomic queries: ", expectedQueries, actualQueries); //$NON-NLS-1$
- }
-
- static ProcessorPlan getPlan(Command command, QueryMetadataInterface md, CapabilitiesFinder capFinder, AnalysisRecord analysisRecord, boolean shouldSucceed) {
- // plan
- ProcessorPlan plan = null;
- if (analysisRecord == null) {
- analysisRecord = new AnalysisRecord(false, DEBUG);
- }
- if (shouldSucceed) {
- try {
- //do planning
- plan = QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, new CommandContext());
-
- } catch (Throwable e) {
- throw new MetaMatrixRuntimeException(e);
- } finally {
- if(DEBUG) {
- System.out.println(analysisRecord.getDebugLog());
- }
- }
- } else {
- Exception exception = null;
- try {
- //do planning
- QueryOptimizer.optimizePlan(command, md, null, capFinder, analysisRecord, null);
-
- } catch (QueryPlannerException e) {
- exception = e;
- } catch (MetaMatrixComponentException e) {
- exception = e;
- } catch (Throwable e) {
- throw new MetaMatrixRuntimeException(e);
- } finally {
- if(DEBUG) {
- System.out.println(analysisRecord.getDebugLog());
- }
- }
- assertNotNull("Expected exception but did not get one.", exception); //$NON-NLS-1$
- return null;
- }
-
- assertNotNull("Output elements are null", plan.getOutputElements()); //$NON-NLS-1$
-
- if(DEBUG) System.out.println("\n" + plan); //$NON-NLS-1$
-
- return plan;
- }
-
- public static Set<String> getAtomicQueries(ProcessorPlan plan) {
- Set<Command> atomicQueries = new HashSet<Command>();
- if(plan instanceof RelationalPlan) {
- getAtomicCommands( ((RelationalPlan)plan).getRootNode(), atomicQueries );
- }
-
- Set<String> stringQueries = new HashSet<String>();
-
- for (Command command : atomicQueries) {
- stringQueries.add(command.toString());
- }
-
- return stringQueries;
- }
-
- private static void getAtomicCommands(RelationalNode node, Set<Command> atomicQueries) {
- if(node instanceof AccessNode) {
- AccessNode accessNode = (AccessNode) node;
- atomicQueries.add( accessNode.getCommand());
- }
-
- // Recurse through children
- RelationalNode[] children = node.getChildren();
- for(int i=0; i<children.length; i++) {
- if(children[i] != null) {
- getAtomicCommands(children[i], atomicQueries);
- } else {
- break;
- }
- }
- }
-
- // Counts are (mostly) alphabetical:
- // Access, DependentAccess, DependentSelect, DependentProject, DupRemove, Grouping, NestedLoopJoinStrategy, Null, PlanExecution, Project, Select, Sort, UnionAll
- private static final Class[] COUNT_TYPES = new Class[] {
- AccessNode.class,
- DependentAccessNode.class,
- DependentSelectNode.class,
- DependentProjectNode.class,
- DupRemoveNode.class,
- GroupingNode.class,
- NestedLoopJoinStrategy.class,
- MergeJoinStrategy.class,
- NullNode.class,
- PlanExecutionNode.class,
- ProjectNode.class,
- SelectNode.class,
- SortNode.class,
- UnionAllNode.class
- };
-
- public static void checkNodeTypes(ProcessorPlan root, int[] expectedCounts) {
- checkNodeTypes(root, expectedCounts, COUNT_TYPES);
- }
-
- public static void checkNodeTypes(ProcessorPlan root, int[] expectedCounts, Class[] types) {
- if(! (root instanceof RelationalPlan)) {
- return;
- }
-
- int[] actualCounts = new int[types.length];
- collectCounts(((RelationalPlan)root).getRootNode(), actualCounts, types);
-
- for(int i=0; i<expectedCounts.length; i++) {
- assertEquals("Did not find the correct number of nodes for type " + types[i], //$NON-NLS-1$
- expectedCounts[i], actualCounts[i]);
- }
- }
-
- /**
- * Method collectCounts.
- * @param relationalNode
- * @return int[]
- */
- static void collectCounts(RelationalNode relationalNode, int[] counts, Class<?>[] types) {
- Class<?> nodeType = relationalNode.getClass();
- if(nodeType.equals(JoinNode.class)) {
- JoinStrategy strategy = ((JoinNode)relationalNode).getJoinStrategy();
- if (strategy instanceof NestedLoopJoinStrategy) {
- updateCounts(NestedLoopJoinStrategy.class, counts, types);
- } else if (strategy instanceof MergeJoinStrategy) {
- updateCounts(MergeJoinStrategy.class, counts, types);
- if (strategy instanceof PartitionedSortJoin) {
- updateCounts(PartitionedSortJoin.class, counts, types);
- }
- }
- if (((JoinNode)relationalNode).isDependent()) {
- updateCounts(DependentJoin.class, counts, types);
- }
- }else if (nodeType.equals(ProjectNode.class)){
- if (ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((ProjectNode)relationalNode).getSelectSymbols()).isEmpty()) {
- updateCounts(ProjectNode.class, counts, types);
- } else {
- updateCounts(DependentProjectNode.class, counts, types);
- }
- }else if (nodeType.equals(SelectNode.class)){
- if (ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((SelectNode)relationalNode).getCriteria()).isEmpty()) {
- updateCounts(SelectNode.class, counts, types);
- } else {
- updateCounts(DependentSelectNode.class, counts, types);
- }
- } else if (nodeType.equals(SortNode.class)) {
- Mode mode = ((SortNode)relationalNode).getMode();
- switch(mode) {
- case DUP_REMOVE:
- updateCounts(DupRemoveNode.class, counts, types);
- break;
- case DUP_REMOVE_SORT:
- updateCounts(DupRemoveSortNode.class, counts, types);
- break;
- case SORT:
- updateCounts(SortNode.class, counts, types);
- break;
- }
- } else {
- updateCounts(nodeType, counts, types);
- }
-
- RelationalNode[] children = relationalNode.getChildren();
- for(int i=0; i<children.length; i++) {
- if(children[i] != null) {
- collectCounts(children[i], counts, types);
- } else {
- break;
- }
- }
- }
-
- private static void updateCounts(Class nodeClass, int[] counts, Class[] types) {
- for(int i=0; i<types.length; i++) {
- if(types[i].equals(nodeClass)) {
- counts[i] = counts[i] + 1;
- return;
- }
- }
- }
-
- public static void checkDependentJoinCount(ProcessorPlan plan, int expectedCount) {
- checkNodeTypes(plan, new int[] {expectedCount}, new Class[] {DependentJoin.class});
- }
-
- public static FakeMetadataFacade example1() {
- // Create models
- FakeMetadataObject pm1 = FakeMetadataFactory.createPhysicalModel("pm1"); //$NON-NLS-1$
- FakeMetadataObject pm2 = FakeMetadataFactory.createPhysicalModel("pm2"); //$NON-NLS-1$
- FakeMetadataObject vm1 = FakeMetadataFactory.createVirtualModel("vm1"); //$NON-NLS-1$
-
- // Create physical groups
- FakeMetadataObject pm1g1 = FakeMetadataFactory.createPhysicalGroup("pm1.g1", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g2 = FakeMetadataFactory.createPhysicalGroup("pm1.g2", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g3 = FakeMetadataFactory.createPhysicalGroup("pm1.g3", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g4 = FakeMetadataFactory.createPhysicalGroup("pm1.g4", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g5 = FakeMetadataFactory.createPhysicalGroup("pm1.g5", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g6 = FakeMetadataFactory.createPhysicalGroup("pm1.g6", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g7 = FakeMetadataFactory.createPhysicalGroup("pm1.g7", pm1); //$NON-NLS-1$
- FakeMetadataObject pm1g8 = FakeMetadataFactory.createPhysicalGroup("pm1.g8", pm1); //$NON-NLS-1$
- FakeMetadataObject pm2g1 = FakeMetadataFactory.createPhysicalGroup("pm2.g1", pm2); //$NON-NLS-1$
- FakeMetadataObject pm2g2 = FakeMetadataFactory.createPhysicalGroup("pm2.g2", pm2); //$NON-NLS-1$
- FakeMetadataObject pm2g3 = FakeMetadataFactory.createPhysicalGroup("pm2.g3", pm2); //$NON-NLS-1$
-
- // Create physical elements
- List pm1g1e = FakeMetadataFactory.createElements(pm1g1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm1g2e = FakeMetadataFactory.createElements(pm1g2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm1g3e = FakeMetadataFactory.createElements(pm1g3,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm1g4e = FakeMetadataFactory.createElements(pm1g4,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List pm1g5e = FakeMetadataFactory.createElements(pm1g5,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List pm1g6e = FakeMetadataFactory.createElements(pm1g6,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List pm1g7e = FakeMetadataFactory.createElements(pm1g7,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List pm1g8e = FakeMetadataFactory.createElements(pm1g8,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List pm2g1e = FakeMetadataFactory.createElements(pm2g1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm2g2e = FakeMetadataFactory.createElements(pm2g2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List pm2g3e = FakeMetadataFactory.createElements(pm2g3,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
-
- // Create virtual groups
- QueryNode vm1g1n1 = new QueryNode("vm1.g1", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g1", vm1, vm1g1n1); //$NON-NLS-1$
-
- QueryNode vm1g2n1 = new QueryNode("vm1.g2", "SELECT * FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g2", vm1, vm1g2n1); //$NON-NLS-1$
-
- //defect 8096
- QueryNode vm1sub1n1 = new QueryNode("vm1.sub1", "SELECT * FROM vm1.g1 WHERE e1 IN (SELECT e1 FROM vm1.g3)"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1sub1 = FakeMetadataFactory.createVirtualGroup("vm1.sub1", vm1, vm1sub1n1); //$NON-NLS-1$
-
- QueryNode vm1g3n1 = new QueryNode("vm1.g3", "SELECT * FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g3", vm1, vm1g3n1); //$NON-NLS-1$
-
- QueryNode vm1g4n1 = new QueryNode("vm1.g4", "SELECT pm1.g1.e1, pm1.g2.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1=pm1.g2.e1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g4", vm1, vm1g4n1); //$NON-NLS-1$
-
- QueryNode vm1g5n1 = new QueryNode("vm1.g5", "SELECT DISTINCT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g5", vm1, vm1g5n1); //$NON-NLS-1$
-
- QueryNode vm1g6n1 = new QueryNode("vm1.g6", "SELECT e1, convert(e2, string), 3 as e3, ((e2+e4)/3) as e4 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g6 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.g6", vm1, vm1g6n1); //$NON-NLS-1$
-
- QueryNode vm1u1n1 = new QueryNode("vm1.u1", "SELECT * FROM pm1.g1 UNION SELECT * FROM pm1.g2 UNION ALL SELECT * FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u1", vm1, vm1u1n1); //$NON-NLS-1$
-
- QueryNode vm1u2n1 = new QueryNode("vm1.u2", "SELECT * FROM pm1.g1 UNION SELECT * FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u2", vm1, vm1u2n1); //$NON-NLS-1$
-
- QueryNode vm1u3n1 = new QueryNode("vm1.u3", "SELECT e1 FROM pm1.g1 UNION SELECT convert(e2, string) as x FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u3", vm1, vm1u3n1); //$NON-NLS-1$
-
- QueryNode vm1u4n1 = new QueryNode("vm1.u4", "SELECT concat(e1, 'x') as v1 FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u4", vm1, vm1u4n1); //$NON-NLS-1$
-
- QueryNode vm1u5n1 = new QueryNode("vm1.u5", "SELECT concat(e1, 'x') as v1 FROM pm1.g1 UNION ALL SELECT concat('a', e1) FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u5", vm1, vm1u5n1); //$NON-NLS-1$
-
- QueryNode vm1u6n1 = new QueryNode("vm1.u6", "SELECT x1.e1 AS elem, 'xyz' AS const FROM pm1.g1 AS x1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u6 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u6", vm1, vm1u6n1); //$NON-NLS-1$
-
- QueryNode vm1u7n1 = new QueryNode("vm1.u7", "SELECT 's1' AS const, e1 FROM pm1.g1 UNION ALL SELECT 's2', e1 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u7 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u7", vm1, vm1u7n1); //$NON-NLS-1$
-
- QueryNode vm1u8n1 = new QueryNode("vm1.u8", "SELECT const, e1 FROM vm1.u7 UNION ALL SELECT 's3', e1 FROM pm1.g3"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u8 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u8", vm1, vm1u8n1); //$NON-NLS-1$
-
- QueryNode vm1u9n1 = new QueryNode("vm1.u9", "SELECT e1 as a, e1 as b FROM pm1.g1 UNION ALL SELECT e1, e1 FROM pm1.g2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1u9 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.u9", vm1, vm1u9n1); //$NON-NLS-1$
-
- QueryNode vm1a1n1 = new QueryNode("vm1.a1", "SELECT e1, SUM(e2) AS sum_e2 FROM pm1.g1 GROUP BY e1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1a1 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a1", vm1, vm1a1n1); //$NON-NLS-1$
-
- QueryNode vm1a2n1 = new QueryNode("vm1.a2", "SELECT e1, SUM(e2) AS sum_e2 FROM pm1.g1 GROUP BY e1 HAVING SUM(e2) > 5"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1a2 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a2", vm1, vm1a2n1); //$NON-NLS-1$
-
- QueryNode vm1a3n1 = new QueryNode("vm1.a3", "SELECT SUM(e2) AS sum_e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1a3 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a3", vm1, vm1a3n1); //$NON-NLS-1$
-
- QueryNode vm1a4n1 = new QueryNode("vm1.a4", "SELECT COUNT(*) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1a4 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a4", vm1, vm1a4n1); //$NON-NLS-1$
-
- QueryNode vm1a5n1 = new QueryNode("vm1.a5", "SELECT vm1.a4.count FROM vm1.a4 UNION ALL SELECT COUNT(*) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1a5 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a5", vm1, vm1a5n1); //$NON-NLS-1$
-
- QueryNode vm1a6n1 = new QueryNode("vm1.a6", "SELECT COUNT(*) FROM vm1.u2"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1a6 = FakeMetadataFactory.createUpdatableVirtualGroup("vm1.a6", vm1, vm1a6n1); //$NON-NLS-1$
-
- QueryNode vm1g7n1 = new QueryNode("vm1.g7", "select DECODESTRING(e1, 'S,Pay,P,Rec') as e1, e2 FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
- FakeMetadataObject vm1g7 = FakeMetadataFactory.createVirtualGroup("vm1.g7", vm1, vm1g7n1); //$NON-NLS-1$
-
- // Create virtual elements
- List vm1g1e = FakeMetadataFactory.createElements(vm1g1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1g2e = FakeMetadataFactory.createElements(vm1g2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1g3e = FakeMetadataFactory.createElements(vm1g3,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- //for defect 8096
- List vm1sub1e = FakeMetadataFactory.createElements(vm1sub1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1g4e = FakeMetadataFactory.createElements(vm1g4,
- new String[] { "e1", "e2" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
- List vm1g5e = FakeMetadataFactory.createElements(vm1g5,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING});
- List vm1g6e = FakeMetadataFactory.createElements(vm1g6,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1g7e = FakeMetadataFactory.createElements(vm1g7,
- new String[] { "e1", "e2"}, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER});
- List vm1u1e = FakeMetadataFactory.createElements(vm1u1,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1u2e = FakeMetadataFactory.createElements(vm1u2,
- new String[] { "e1", "e2", "e3", "e4" }, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.BOOLEAN, DataTypeManager.DefaultDataTypes.DOUBLE });
- List vm1u3e = FakeMetadataFactory.createElements(vm1u3,
- new String[] { "e1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List vm1u4e = FakeMetadataFactory.createElements(vm1u4,
- new String[] { "v1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List vm1u5e = FakeMetadataFactory.createElements(vm1u5,
- new String[] { "v1" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.STRING });
- List vm1u6e = FakeMetadataFactory.createElements(vm1u6,
- new String[] { "elem", "const" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
- List vm1u7e = FakeMetadataFactory.createElements(vm1u7,
- new String[] { "const", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
- List vm1u8e = FakeMetadataFactory.createElements(vm1u8,
- new String[] { "const", "e1" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
- List vm1u9e = FakeMetadataFactory.createElements(vm1u9,
- new String[] { "a", "b" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.STRING });
- List vm1a1e = FakeMetadataFactory.createElements(vm1a1,
- new String[] { "e1", "sum_e2" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
- List vm1a2e = FakeMetadataFactory.createElements(vm1a2,
- new String[] { "e1", "sum_e2" }, //$NON-NLS-1$ //$NON-NLS-2$
- new String[] { DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER });
- List vm1a3e = FakeMetadataFactory.createElements(vm1a3,
- new String[] { "sum_e2" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
- List vm1a4e = FakeMetadataFactory.createElements(vm1a4,
- new String[] { "count" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
- List vm1a5e = FakeMetadataFactory.createElements(vm1a5,
- new String[] { "count" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
- List vm1a6e = FakeMetadataFactory.createElements(vm1a6,
- new String[] { "count" }, //$NON-NLS-1$
- new String[] { DataTypeManager.DefaultDataTypes.INTEGER });
-
- // Add all objects to the store
- FakeMetadataStore store = new FakeMetadataStore();
- store.addObject(pm1);
- store.addObject(pm1g1);
- store.addObjects(pm1g1e);
- store.addObject(pm1g2);
- store.addObjects(pm1g2e);
- store.addObject(pm1g3);
- store.addObjects(pm1g3e);
- store.addObject(pm1g4);
- store.addObjects(pm1g4e);
- store.addObject(pm1g5);
- store.addObjects(pm1g5e);
- store.addObject(pm1g6);
- store.addObjects(pm1g6e);
- store.addObject(vm1g7);
- store.addObjects(vm1g7e);
- store.addObject(pm1g7);
- store.addObjects(pm1g7e);
- store.addObject(pm1g8);
- store.addObjects(pm1g8e);
-
- store.addObject(pm2);
- store.addObject(pm2g1);
- store.addObjects(pm2g1e);
- store.addObject(pm2g2);
- store.addObjects(pm2g2e);
- store.addObject(pm2g3);
- store.addObjects(pm2g3e);
-
- store.addObject(vm1);
- store.addObject(vm1g1);
- store.addObjects(vm1g1e);
- store.addObject(vm1g2);
- store.addObjects(vm1g2e);
- store.addObject(vm1g3);
- store.addObjects(vm1g3e);
-
- //for defect 8096
- store.addObject(vm1sub1);
- store.addObjects(vm1sub1e);
-
- store.addObject(vm1g4);
- store.addObjects(vm1g4e);
- store.addObject(vm1g5);
- store.addObjects(vm1g5e);
- store.addObject(vm1g6);
- store.addObjects(vm1g6e);
- store.addObject(vm1u1);
- store.addObjects(vm1u1e);
- store.addObject(vm1u2);
- store.addObjects(vm1u2e);
- store.addObject(vm1u3);
- store.addObjects(vm1u3e);
- store.addObject(vm1u4);
- store.addObjects(vm1u4e);
- store.addObject(vm1u5);
- store.addObjects(vm1u5e);
- store.addObject(vm1u6);
- store.addObjects(vm1u6e);
- store.addObject(vm1u7);
- store.addObjects(vm1u7e);
- store.addObject(vm1u8);
- store.addObjects(vm1u8e);
- store.addObject(vm1u9);
- store.addObjects(vm1u9e);
- store.addObject(vm1a1);
- store.addObjects(vm1a1e);
- store.addObject(vm1a2);
- store.addObjects(vm1a2e);
- store.addObject(vm1a3);
- store.addObjects(vm1a3e);
- store.addObject(vm1a4);
- store.addObjects(vm1a4e);
- store.addObject(vm1a5);
- store.addObjects(vm1a5e);
- store.addObject(vm1a6);
- store.addObjects(vm1a6e);
-
- // Create the facade from the store
- return new FakeMetadataFacade(store);
- }
-
- // ################################## ACTUAL TESTS ################################
-
- /**
- * Test defect 8096 - query a virtual group with subquery of another virtual group
- */
- @Test public void testVirtualSubqueryINClause_8096() {
- helpPlan("SELECT * FROM vm1.sub1", example1(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
- }
-
- @Test public void testQueryPhysical() {
- ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1, e2, pm1.g1.e3 as a, e4 as b FROM pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1, e2, pm1.g1.e3, e4 FROM pm1.g1"} ); //$NON-NLS-1$
- assertTrue(!plan.requiresTransaction(true));
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testSelectStarPhysical() {
- ProcessorPlan plan = helpPlan("SELECT * FROM pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testQuerySingleSourceVirtual() {
- ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testQueryMultiSourceVirtual() {
- ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, g_0.e2, g_1.e3, g_1.e4 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPhysicalVirtualJoinWithCriteria() throws Exception {
- ProcessorPlan plan = helpPlan("SELECT vm1.g2.e1 from vm1.g2, pm1.g3 where vm1.g2.e1=pm1.g3.e1 and vm1.g2.e2 > 0", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = g_2.e1) AND (g_0.e2 > 0)" }, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testQueryWithExpression() {
- helpPlan("SELECT e4 FROM pm3.g1 WHERE e4 < convert('2001-11-01 10:30:40.42', timestamp)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e4 FROM pm3.g1 WHERE e4 < {ts'2001-11-01 10:30:40.42'}"} ); //$NON-NLS-1$
- }
-
- @Test public void testInsert() {
- helpPlan("Insert into pm1.g1 (pm1.g1.e1, pm1.g1.e2) values ('MyString', 1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "INSERT INTO pm1.g1 (pm1.g1.e1, pm1.g1.e2) VALUES ('MyString', 1)"} ); //$NON-NLS-1$
- }
-
- @Test public void testUpdate1() {
- helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e3= 'true'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e3 = TRUE"} ); //$NON-NLS-1$
- }
-
- @Test public void testUpdate2() {
- helpPlan("Update pm1.g1 Set pm1.g1.e1= LTRIM('MyString'), pm1.g1.e2= 1 where pm1.g1.e2= convert(pm1.g1.e4, integer)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "UPDATE pm1.g1 SET pm1.g1.e1 = 'MyString', pm1.g1.e2 = 1 WHERE pm1.g1.e2 = convert(pm1.g1.e4, integer)"} ); //$NON-NLS-1$
- }
-
- @Test public void testDelete() {
- helpPlan("Delete from pm1.g1 where pm1.g1.e1 = cast(pm1.g1.e2 AS string)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "DELETE FROM pm1.g1 WHERE pm1.g1.e1 = cast(pm1.g1.e2 AS string)"} ); //$NON-NLS-1$
- }
-
- // ############################# TESTS ON EXAMPLE 1 ############################
-
- @Test public void testCopyInAcrossJoin() throws Exception {
- ProcessorPlan plan = helpPlan("select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN ('a', 'b') ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCopyMatchAcrossJoin() throws Exception {
- helpPlan("select pm1.g1.e1, pm2.g2.e1 from pm1.g1, pm2.g2 where pm1.g1.e1=pm2.g2.e1 and pm1.g1.e1 LIKE '%1'", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 LIKE '%1' ORDER BY c_0", //$NON-NLS-1$
- "SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 WHERE g_0.e1 LIKE '%1' ORDER BY c_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCopyOrAcrossJoin() throws Exception {
- helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and (pm1.g1.e1 = 'abc' OR pm1.g1.e1 = 'def')", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e1 = 'def')", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e1 = 'def')" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCopyMultiElementCritAcrossJoin() throws Exception {
- helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and pm1.g1.e2=pm1.g2.e2 and (pm1.g1.e1 = 'abc' OR pm1.g1.e2 = 5)", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g2.e1, pm1.g2.e2 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e2 = 5)", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testCantCopyAcrossJoin1() throws Exception {
- helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and concat(pm1.g1.e1, pm1.g1.e2) = 'abc'", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testCantCopyAcrossJoin2() throws Exception {
- helpPlan("select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 where pm1.g1.e1=pm1.g2.e1 and (pm1.g1.e1 = 'abc' OR pm1.g1.e2 = 5)", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughFrame1() {
- helpPlan("select * from vm1.g1, vm1.g2 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g2.e1", example1(), //$NON-NLS-1$
- new String[] { "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughFrame2() throws Exception {
- helpPlan("select * from vm1.g1, vm1.g3 where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g3.e1", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" }, getGenericFinder(false), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughFrame3() {
- helpPlan("select * from vm1.g1, vm1.g2, vm1.g1 as a where vm1.g1.e1='abc' and vm1.g1.e1=vm1.g2.e1 and vm1.g1.e1=a.e1", example1(), //$NON-NLS-1$
- new String[] { "SELECT g1__1.e1, g1__1.e2, g1__1.e3, g1__1.e4 FROM pm1.g1 AS g1__1 WHERE g1__1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT g1__2.e1, g1__2.e2, g1__2.e3, g1__2.e4 FROM pm1.g1 AS g1__2 WHERE g1__2.e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughUnion1() {
- helpPlan("select e1 from vm1.u1 where e1='abc'", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE pm1.g3.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughUnion2() {
- helpPlan("select e1 from vm1.u2 where e1='abc'", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughUnion3() {
- helpPlan("select e1 from vm1.u1 where e1='abc' and e2=5", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE (pm1.g3.e1 = 'abc') AND (pm1.g3.e2 = 5)", //$NON-NLS-1$
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') AND (pm1.g2.e2 = 5)", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') AND (pm1.g1.e2 = 5)" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushingCriteriaThroughUnion4() {
- helpPlan("select e1 from vm1.u1 where e1='abc' or e2=5", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE (pm1.g3.e1 = 'abc') OR (pm1.g3.e2 = 5)", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (pm1.g1.e1 = 'abc') OR (pm1.g1.e2 = 5)", //$NON-NLS-1$
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE (pm1.g2.e1 = 'abc') OR (pm1.g2.e2 = 5)" } ); //$NON-NLS-1$
- }
-
- // expression in a subquery of the union
- @Test public void testPushingCriteriaThroughUnion5() {
- helpPlan("select e1 from vm1.u3 where e1='abc'", example1(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT e1 FROM pm1.g1 WHERE e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- /** defect #4956 */
- @Test public void testPushCriteriaThroughUnion6() {
- helpPlan("select v1 from vm1.u4 where vm1.u4.v1='x'", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g2 WHERE e1 = 'x'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushCriteriaThroughUnion7() {
- helpPlan("select v1 from vm1.u5 where vm1.u5.v1='x'", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushCriteriaThroughUnion8() {
- helpPlan("select v1 from vm1.u5 where length(v1) > 0", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushCriteriaThroughUnion11() {
- helpPlan("select * from vm1.u8 where const = 's3' or e1 is null", example1(), //$NON-NLS-1$
- new String[] { "SELECT 's3', e1 FROM pm1.g3", //$NON-NLS-1$
- "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
- "SELECT 's1', e1 FROM pm1.g1 WHERE e1 IS NULL" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushCriteriaThroughUnion12() {
- helpPlan("select * from vm1.u8 where const = 's1' or e1 is null", example1(), //$NON-NLS-1$
- new String[] { "SELECT 's3', e1 FROM pm1.g3 WHERE e1 IS NULL", //$NON-NLS-1$
- "SELECT 's2', e1 FROM pm1.g2 WHERE e1 IS NULL", //$NON-NLS-1$
- "SELECT 's1', e1 FROM pm1.g1" } ); //$NON-NLS-1$
- }
-
- /** defect #4997 */
- @Test public void testCountStarNoRows() {
- ProcessorPlan plan = helpPlan("select count(*) from vm1.u4", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g2", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g1" } ); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testPushingCriteriaWithCopy() {
- ProcessorPlan plan = helpPlan("select vm1.u1.e1 from vm1.u1, pm1.g1 where vm1.u1.e1='abc' and vm1.u1.e1=pm1.g1.e1", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g3.e1, pm1.g3.e2, pm1.g3.e3, pm1.g3.e4 FROM pm1.g3 WHERE pm1.g3.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2 WHERE pm1.g2.e1 = 'abc'", //$NON-NLS-1$
- "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE pm1.g1.e1 = 'abc'" } ); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 4, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 2 // UnionAll
- });
- }
-
- @Test public void testVirtualGroupWithAliasedElement() {
- helpPlan("select elem FROM vm1.u6 where elem='abc' and const='xyz'", example1(), //$NON-NLS-1$
- new String[] { "SELECT x1.e1 FROM pm1.g1 AS x1 WHERE x1.e1 = 'abc'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushThroughGroup1() {
- helpPlan("select * FROM vm1.a1 WHERE e1 = 'x'", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = 'x'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushThroughGroup2() {
- helpPlan("select * FROM vm1.a2 WHERE e1 = 'x'", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = 'x'" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushThroughGroup3() {
- helpPlan("select * FROM vm1.a3 WHERE sum_e2 > 0", example1(), //$NON-NLS-1$
- new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushMultiGroupCriteria() {
- ProcessorPlan plan = helpPlan("select pm2.g1.e1 from pm2.g1, pm2.g2 where pm2.g1.e1 = pm2.g2.e1 and (pm2.g1.e2 = 1 OR pm2.g2.e2 = 2)", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2 WHERE (pm2.g1.e1 = pm2.g2.e1) AND ((pm2.g1.e2 = 1) OR (pm2.g2.e2 = 2))" } ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleCrossJoin1() throws Exception {
- helpPlan("select pm1.g1.e1 FROM pm1.g1, pm1.g2", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
- }
-
- @Test public void testSimpleCrossJoin2() {
- helpPlan("select pm2.g1.e1 FROM pm2.g1, pm2.g2", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2"} ); //$NON-NLS-1$
-
- }
-
- @Test public void testSimpleCrossJoin3() {
- helpPlan("select pm2.g1.e1 FROM pm2.g1 CROSS JOIN pm2.g2", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2"} ); //$NON-NLS-1$
-
- }
-
- @Test public void testMultiSourceCrossJoin() throws Exception {
- helpPlan("select pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
- "SELECT pm1.g3.e1 FROM pm1.g3" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
- }
-
- @Test public void testSingleSourceCrossJoin() {
- helpPlan("select pm2.g1.e1 FROM pm2.g1, pm2.g2, pm2.g3", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1 FROM pm2.g1, pm2.g2, pm2.g3"} ); //$NON-NLS-1$
- }
-
- @Test public void testSelfJoins() {
- helpPlan("select pm2.g1.e1 FROM pm2.g1 JOIN pm2.g1 AS x ON pm2.g1.e1=x.e1", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1 FROM pm2.g1 order by e1", //$NON-NLS-1$
- "SELECT x.e1 FROM pm2.g1 AS x order by e1" } ); //$NON-NLS-1$
- }
-
- @Test public void testDefect5282_1() {
- helpPlan("select * FROM vm1.a4 WHERE vm1.a4.count > 0", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } ); //$NON-NLS-1$
- }
-
- @Test public void testDefect5282_2() {
- helpPlan("select count(*) FROM vm1.a4", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } ); //$NON-NLS-1$
- }
-
- @Test public void testDefect5282_3() {
- helpPlan("select * FROM vm1.a5 WHERE vm1.a5.count > 0", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" } ); //$NON-NLS-1$
- }
-
- @Test public void testDepJoinHintBaseline() throws Exception {
- ProcessorPlan plan = helpPlan("select * FROM vm1.g4", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testDefect6425_1() {
- helpPlan("select * from vm1.u9", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT e1, e1 FROM pm1.g2" } ); //$NON-NLS-1$
- }
-
- @Test public void testDefect6425_2() {
- helpPlan("select count(*) from vm1.u9", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g2" } ); //$NON-NLS-1$
- }
-
- @Test public void testPushMatchCritWithReference() {
- List bindings = new ArrayList();
- bindings.add("pm1.g2.e1"); //$NON-NLS-1$
- helpPlan("select e1 FROM pm1.g1 WHERE e1 LIKE ?", example1(), bindings, null, //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 LIKE ?" }, true ); //$NON-NLS-1$
- }
-
- @Test public void testDefect6517() {
- helpPlan("select count(*) from vm1.g5", example1(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT pm1.g1.e1 FROM pm1.g1" }); //$NON-NLS-1$
- }
-
- @Test public void testDefect5283() {
- helpPlan("select * from vm1.a6", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2" } ); //$NON-NLS-1$
- }
-
- @Test public void testManyJoinsOverThreshold() throws Exception {
- long begin = System.currentTimeMillis();
- helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3, pm1.g4, pm1.g5, pm1.g6, pm1.g7, pm1.g8, pm1.g1 AS x, pm1.g2 AS y WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1 AND pm1.g3.e1 = pm1.g4.e1 AND pm1.g4.e1 = pm1.g5.e1 AND pm1.g5.e1=pm1.g6.e1 AND pm1.g6.e1=pm1.g7.e1 AND pm1.g7.e1=pm1.g8.e1", //$NON-NLS-1$
- example1(),
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
- "SELECT pm1.g3.e1 FROM pm1.g3", //$NON-NLS-1$
- "SELECT pm1.g4.e1 FROM pm1.g4", //$NON-NLS-1$
- "SELECT pm1.g5.e1 FROM pm1.g5", //$NON-NLS-1$
- "SELECT pm1.g6.e1 FROM pm1.g6", //$NON-NLS-1$
- "SELECT pm1.g7.e1 FROM pm1.g7", //$NON-NLS-1$
- "SELECT pm1.g8.e1 FROM pm1.g8", //$NON-NLS-1$
- "SELECT x.e1 FROM pm1.g1 AS x", //$NON-NLS-1$
- "SELECT y.e1 FROM pm1.g2 AS y" }, new DefaultCapabilitiesFinder(), ComparisonMode.CORRECTED_COMMAND_STRING ); //$NON-NLS-1$
-
- long elapsed = System.currentTimeMillis() - begin;
- assertTrue("Did not plan many join query in reasonable time frame: " + elapsed + " ms", elapsed < 4000); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- @Test public void testAggregateWithoutGroupBy() {
- ProcessorPlan plan = helpPlan("select count(e2) from pm1.g1", example1(), //$NON-NLS-1$
- new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testHavingWithoutGroupBy() {
- ProcessorPlan plan = helpPlan("select count(e2) from pm1.g1 HAVING count(e2) > 0", example1(), //$NON-NLS-1$
- new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testHavingAndGroupBy() {
- ProcessorPlan plan = helpPlan("select e1, count(e2) from pm1.g1 group by e1 having count(e2) > 0 and sum(e2) > 0", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1" } ); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testAllJoinsInSingleClause() throws Exception {
- ProcessorPlan plan = helpPlan("select pm1.g1.e1 FROM pm1.g1 join (pm1.g2 right outer join pm1.g3 on pm1.g2.e1=pm1.g3.e1) on pm1.g1.e1=pm1.g3.e1", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", //$NON-NLS-1$
- "SELECT pm1.g2.e1 FROM pm1.g2", //$NON-NLS-1$
- "SELECT pm1.g3.e1 FROM pm1.g3" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testSelectCountStarFalseCriteria() {
- ProcessorPlan plan = helpPlan("Select count(*) from pm1.g1 where 1=0", example1(), //$NON-NLS-1$
- new String[] { });
- checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 1, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testSubquery1() {
- ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1) AS x", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testSubquery2() {
- ProcessorPlan plan = helpPlan("Select e1, a from (select e1 FROM pm1.g1) AS x, (select e1 as a FROM pm1.g2) AS y WHERE x.e1=y.a", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, g_1.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testSubquery3() {
- ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1) AS x WHERE x.e1 = 'a'", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = 'a'" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testSubquery4() {
- ProcessorPlan plan = helpPlan("Select e1 from (select e1 FROM pm1.g1 WHERE e1 = 'a') AS x", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = 'a'" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testSubqueryInClause1() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCompareSubquery1() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 < any (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCompareSubquery2() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 <= some (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCompareSubquery3() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 >= all (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCompareSubquery4() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 > (select e1 FROM pm2.g1 where e2 = 13)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testExistsSubquery1() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where exists (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testScalarSubquery1() {
- ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') from pm1.g1", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 1, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testScalarSubquery2() {
- ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 where e1 = 'x') as X from pm1.g1", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 1, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testTempGroup() {
- ProcessorPlan plan = helpPlan("select e1 from tm1.g1 where e1 = 'x'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM tm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testNotPushDistinct() throws Exception {
- ProcessorPlan plan = helpPlan("select distinct e1 from pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1" }, new DefaultCapabilitiesFinder(), ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushDistinct() {
- ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT e1 FROM pm3.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctSort() {
- ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1 order by e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT e1 FROM pm3.g1 ORDER BY e1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctWithCriteria() {
- ProcessorPlan plan = helpPlan("select distinct e1 from pm3.g1 where e1 = 'x'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT e1 FROM pm3.g1 WHERE e1 = 'x'" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual1() {
- ProcessorPlan plan = helpPlan("select * from vm1.g12", FakeMetadataFactory.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$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual2() {
- ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g12", FakeMetadataFactory.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$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual3() {
- ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g12 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual4() {
- ProcessorPlan plan = helpPlan("select * from vm1.g13", FakeMetadataFactory.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$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual5() {
- ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g13", FakeMetadataFactory.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$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual6() {
- ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g13 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual7() {
- ProcessorPlan plan = helpPlan("select * from vm1.g14", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual8() {
- ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g14", FakeMetadataFactory.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$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushDistinctVirtual9() {
- ProcessorPlan plan = helpPlan("select DISTINCT * from vm1.g14 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT pm3.g1.e1, pm3.g1.e2, pm3.g1.e3, pm3.g1.e4 FROM pm3.g1 ORDER BY pm3.g1.e1" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Defect #7819
- */
- @Test public void testPushDistinctWithExpressions() {
- ProcessorPlan plan = helpPlan("SELECT DISTINCT * FROM vm1.g15", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm3.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testNestedSubquery() {
- ProcessorPlan plan = helpPlan("SELECT IntKey, LongNum FROM (SELECT IntKey, LongNum FROM (SELECT IntKey, LongNum, DoubleNum FROM BQT2.SmallA ) AS x ) AS y ORDER BY IntKey", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] { "SELECT IntKey, LongNum FROM BQT2.SmallA order by intkey" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** Tests a user's order by is pushed to the source */
- @Test public void testPushOrderBy() {
- ProcessorPlan plan = helpPlan("SELECT pm3.g1.e1 FROM pm3.g1 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm3.g1.e1 FROM pm3.g1 ORDER BY pm3.g1.e1"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** Tests an order by is not pushed to source due to join */
- @Test public void testDontPushOrderByWithJoin() {
- ProcessorPlan plan = helpPlan("SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 INNER JOIN pm2.g2 ON pm3.g1.e1 = pm2.g2.e1 ORDER BY pm3.g1.e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e1", //$NON-NLS-1$
- "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Tests that user's order by gets pushed to the source, but query
- * transformation order by is discarded
- */
- @Test public void testPushOrderByThroughFrame() {
- ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g14 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1 ORDER BY pm3.g1.e2"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Tests that query transformation order by is discarded by
- */
- @Test public void testPushOrderByThroughFrame2() {
- ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g1 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1 order by e2"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Tests that query transformation order by is discarded by
- * user order by, and that user order by is discarded because
- * of the function in the query transformation
- */
- @Test public void testPushOrderByThroughFrame3() {
- ProcessorPlan plan = helpPlan("SELECT e, e2 FROM vm1.g16 ORDER BY e2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm3.g1"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Tests that a user's order by does not get pushed to the source
- * if there is a UNION in the query transformation
- */
- @Test public void testPushOrderByThroughFrame4_Union() {
- ProcessorPlan plan = helpPlan("SELECT e1, e2 FROM vm1.g17 ORDER BY e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1", //$NON-NLS-1$
- "SELECT pm3.g2.e1, pm3.g2.e2 FROM pm3.g2"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 1, // Sort
- 1 // UnionAll
- });
- }
-
- /** Tests outer join defect #7945 - see also defect #10050*/
- @Test public void testOuterJoinDefect7945() {
- ProcessorPlan plan = helpPlan(
- "SELECT BQT1.SmallA.IntKey AS SmallA_IntKey, BQT2.MediumB.IntKey AS MediumB_IntKey, BQT3.MediumB.IntKey AS MediumC_IntKey " + //$NON-NLS-1$
- "FROM (BQT1.SmallA RIGHT OUTER JOIN BQT2.MediumB ON BQT1.SmallA.IntKey = BQT2.MediumB.IntKey) " + //$NON-NLS-1$
- "RIGHT OUTER JOIN BQT3.MediumB ON BQT2.MediumB.IntKey = BQT3.MediumB.IntKey " + //$NON-NLS-1$
- "WHERE BQT3.MediumB.IntKey < 1500", //$NON-NLS-1$
- FakeMetadataFactory.exampleBQTCached(),
- new String[] {
- "SELECT BQT3.MediumB.IntKey FROM BQT3.MediumB WHERE BQT3.MediumB.IntKey < 1500 order by intkey", //$NON-NLS-1$
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE BQT1.SmallA.IntKey < 1500 order by intkey", //$NON-NLS-1$
- "SELECT BQT2.MediumB.IntKey FROM BQT2.MediumB WHERE BQT2.MediumB.IntKey < 1500 order by intkey" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Tests outer join defect #7945 */
- @Test public void testFunctionSimplification1() {
- ProcessorPlan plan = helpPlan(
- "SELECT x FROM vm1.g18 WHERE x = 92.0", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- new String[] {
- "SELECT e4 FROM pm1.g1 WHERE e4 = 0.92" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCantPushJoin1() {
- ProcessorPlan plan = helpPlan(
- "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g2 b WHERE a.e1 = b.e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, TestOptimizer.getGenericFinder(false),
- new String[] {"SELECT a.e1 FROM pm1.g1 AS a", "SELECT b.e1, b.e2 FROM pm1.g2 AS b"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCantPushJoin2() {
- ProcessorPlan plan = helpPlan(
- "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g2 b, pm2.g1 c WHERE a.e1 = b.e1 AND b.e1 = c.e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, TestOptimizer.getGenericFinder(false),
- new String[] {"SELECT a.e1 FROM pm1.g1 AS a", //$NON-NLS-1$
- "SELECT b.e1, b.e2 FROM pm1.g2 AS b", //$NON-NLS-1$
- "SELECT c.e1 FROM pm2.g1 AS c"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushSelfJoin1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT a.e1, b.e2 FROM pm1.g1 a, pm1.g1 b WHERE a.e1 = b.e1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT a.e1, b.e2 FROM pm1.g1 AS a, pm1.g1 AS b WHERE a.e1 = b.e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushSelfJoin2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT a.e1 AS x, concat(a.e2, b.e2) AS y FROM pm1.g1 a, pm1.g1 b WHERE a.e1 = b.e1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT a.e1, a.e2, b.e2 FROM pm1.g1 AS a, pm1.g1 AS b WHERE a.e1 = b.e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushOuterJoin1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT pm1.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm1.g2 ON pm1.g1.e1 = pm1.g2.e1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g2 LEFT OUTER JOIN pm1.g1 ON pm1.g1.e1 = pm1.g2.e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushOuterJoin2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT pm1.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm1.g2 ON pm1.g1.e1 = pm1.g2.e1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- // With join expression that can't be pushed
- @Test public void testPushOuterJoin3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT pm1.g1.e1 FROM pm1.g1 RIGHT OUTER JOIN pm1.g2 ON pm1.g1.e1 = pm1.g2.e1 || 'x'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- @Test public void testPushGroupBy1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1, e2 as x FROM pm1.g1 GROUP BY e1, e2", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1 GROUP BY e1, e2"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- }
-
- @Test public void testPushGroupBy2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1, MAX(e2) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- }
-
- @Test public void testPushGroupBy3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1, e2 as x FROM pm1.g1 GROUP BY e1, e2", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- @Test public void testPushGroupBy4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT x+2 AS y FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT MAX(e2) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- @Test public void testPushHaving1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushHaving2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushHaving3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1 FROM pm1.g1 GROUP BY e1 HAVING MAX(e1) = 'zzz'", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushAggregate1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT MAX(e1) FROM pm1.g1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT MAX(e1) FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushAggregate2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT MAX(e1) FROM pm1.g1 GROUP BY e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT MAX(e1) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushAggregate3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushAggregate4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Can't push aggs due to not being able to push COUNT in the HAVING clause.
- */
- @Test public void testPushAggregate5() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT e2, MAX(e1) FROM pm1.g1 GROUP BY e2 HAVING COUNT(e1) > 0", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e2, e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Can't push aggs due to not being able to push function inside the aggregate
- */
- @Test public void testPushAggregate6() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT COUNT(length(e1)) FROM pm1.g1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Can't push aggs due to not being able to push function inside having
- */
- @Test public void testPushAggregate7() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT COUNT(*) FROM pm1.g1 GROUP BY e1 HAVING length(e1) > 0", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * BQT query that is failing
- */
- @Test public void testPushAggregate8() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sqlIn =
- "SELECT intkey FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND " + //$NON-NLS-1$
- "(sa.stringkey IN (46)) AND (sa.datevalue = (" + //$NON-NLS-1$
- "SELECT MAX(sa.datevalue) FROM bqt1.smalla AS sb " + //$NON-NLS-1$
- "WHERE (sb.intkey = sa.intkey) AND (sa.stringkey = sb.stringkey) ))"; //$NON-NLS-1$
-
- String sqlOut = "SELECT intkey FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND (sa.stringkey = '46') AND (sa.datevalue = (SELECT sa.datevalue FROM bqt1.smalla AS sb WHERE (sb.intkey = sa.intkey) AND (sb.stringkey = sa.stringkey)))"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sqlIn,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {sqlOut},
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testQueryManyJoin() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
- ProcessorPlan plan = helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 JOIN ((pm1.g2 JOIN pm1.g3 ON pm1.g2.e1=pm1.g3.e1) JOIN pm1.g4 ON pm1.g3.e1=pm1.g4.e1) ON pm1.g1.e1=pm1.g4.e1", //$NON-NLS-1$
- metadata,
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g3 AS g_2, pm1.g4 AS g_3 WHERE (g_1.e1 = g_2.e1) AND (g_2.e1 = g_3.e1) AND (g_0.e1 = g_3.e1)"}, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushSelectDistinct() {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
- ProcessorPlan plan = helpPlan("SELECT DISTINCT e1 FROM pm3.g1", //$NON-NLS-1$
- metadata,
- new String[] { "SELECT DISTINCT e1 FROM pm3.g1"} ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInCriteria1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1 FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInSelect1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT lower(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInSelect2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT lower(e1), upper(e1), e2 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInSelect3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT lower(e1), upper(e1) FROM pm1.g1 WHERE upper(e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushFunctionInSelect4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT x FROM (SELECT lower(e1) AS x, upper(e1) AS y FROM pm1.g1 WHERE upper(e1) = 'X') AS z", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInSelect5() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT y, e, x FROM (SELECT lower(e1) AS x, upper(e1) AS y, 5 as z, e1 AS e FROM pm1.g1 WHERE upper(e1) = 'X') AS w", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT ucase(e1), e1, lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X'"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInSelect6_defect_10081() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setFunctionSupport("upper", true); //$NON-NLS-1$
- caps.setFunctionSupport("lower", false); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT upper(lower(e1)) FROM pm1.g1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushFunctionInSelectWithOrderBy1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1, lower(e1) FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY e1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1, lcase(e1) FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY e1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** defect 13336 */
- @Test public void testPushFunctionInSelectWithOrderBy1a() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X' ORDER BY x", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1, lcase(e1) AS x FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY x"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** defect 13336 */
- @Test public void testPushFunctionInSelectWithOrderBy2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport(SourceSystemFunctions.LCASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1, x FROM (SELECT e1, lower(e1) AS x FROM pm1.g1 WHERE upper(e1) = 'X') AS z ORDER BY x", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1, lcase(e1) AS EXPR FROM pm1.g1 WHERE ucase(e1) = 'X' ORDER BY EXPR"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInJoin1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushFunctionInJoin2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(pm1.g3.e1, 'a') AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
- "SELECT pm1.g3.e1 FROM pm1.g3"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushFunctionInJoin3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setFunctionSupport(SourceSystemFunctions.UCASE, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2, (SELECT e1 AS x FROM pm1.g3) AS g WHERE pm1.g1.e1 = convert(pm1.g2.e2, string) AND pm1.g1.e1 = concat(g.x, 'a') AND upper(pm1.g1.e1) = 'X'", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g2.e3 FROM pm1.g1, pm1.g2 WHERE (pm1.g1.e1 = convert(pm1.g2.e2, string)) AND (ucase(pm1.g1.e1) = 'X') AND (ucase(convert(pm1.g2.e2, string)) = 'X')", //$NON-NLS-1$
- "SELECT e1 FROM pm1.g3"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testUnionOverFunctions() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT StringCol AS E " + //$NON-NLS-1$
- "FROM (SELECT CONVERT(BQT1.SmallA.IntNum, string) AS StringCol, BQT1.SmallA.IntNum AS IntCol FROM BQT1.SmallA " + //$NON-NLS-1$
- "UNION ALL SELECT BQT1.SmallB.StringNum, CONVERT(BQT1.SmallB.StringNum, integer) FROM BQT1.SmallB) AS x", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT CONVERT(BQT1.SmallA.IntNum, string) FROM BQT1.SmallA", //$NON-NLS-1$
- "SELECT BQT1.SmallB.StringNum FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testDefect9827() {
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan("SELECT intkey, c FROM (SELECT DISTINCT b.intkey, b.intnum, a.stringkey AS c FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY) AS x ORDER BY x.intkey", metadata, //$NON-NLS-1$
- new String[] {"SELECT DISTINCT b.intkey, b.intnum, a.stringkey FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.INTKEY = b.INTKEY"} ); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * This tests that a criteria with no elements is not pushed down,
- * but instead is cleaned up properly later
- * See defect 9865
- */
- @Test public void testCrossJoinNoElementCriteriaOptimization2() {
- ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} = {b'true'}", example1(), //$NON-NLS-1$
- new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * <p>This tests that a SELECT node with no groups is not pushed down without the capability to have a subquery in the where clause.
- */
- @Test public void testCrossJoinNoElementCriteriaOptimization3() {
- ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} in (select e3 FROM vm1.g1)", example1(), //$NON-NLS-1$
- new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * <p>This tests that a SELECT node with no groups is pushed down.
- */
- @Test public void testCrossJoinNoElementCriteriaOptimization4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} in (select e3 FROM vm1.g1)", example1(), null, capFinder, //$NON-NLS-1$
- new String[]{"SELECT g1__1.e1 FROM pm1.g1 AS g1__1 WHERE TRUE IN (SELECT pm1.g1.e3 FROM pm1.g1)", "SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}, true); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Criteria should be copied across this join
- */
- @Test public void testCopyCriteriaWithOuterJoin_defect10050(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 where pm2.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1 LEFT OUTER JOIN pm2.g2 ON pm2.g1.e1 = pm2.g2.e1 AND pm2.g2.e1 IN ('a', 'b') WHERE pm2.g1.e1 IN ('a', 'b')" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Criteria should be copied across this join
- */
- @Test public void testCopyCriteriaWithOuterJoin2_defect10050(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2=pm2.g2.e2 where pm2.g1.e1 = 'a' and pm2.g1.e2 = 1", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0 LEFT OUTER JOIN pm2.g2 AS g_1 ON g_0.e1 = g_1.e1 AND g_0.e2 = g_1.e2 AND g_1.e2 = 1 AND g_1.e1 = 'a' WHERE (g_0.e1 = 'a') AND (g_0.e2 = 1)" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * See also case 2912.
- */
- @Test public void testCopyCriteriaWithOuterJoin5_defect10050(){
-
- ProcessorPlan plan = helpPlan(
- "select pm2.g1.e1, pm2.g2.e1, pm2.g3.e1 from ( (pm2.g1 right outer join pm2.g2 on pm2.g1.e1=pm2.g2.e1) right outer join pm2.g3 on pm2.g2.e1=pm2.g3.e1) where pm2.g3.e1 = 'a'", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_2.e1, g_1.e1, g_0.e1 FROM pm2.g3 AS g_0 LEFT OUTER JOIN (pm2.g2 AS g_1 LEFT OUTER JOIN pm2.g1 AS g_2 ON g_2.e1 = g_1.e1 AND g_2.e1 = 'a') ON g_1.e1 = g_0.e1 AND g_1.e1 = 'a' WHERE g_0.e1 = 'a'" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- *
- */
- @Test public void testCopyCriteriaWithOuterJoin6_defect10050(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 left outer join pm2.g2 on pm2.g2.e1=pm2.g1.e1 where pm2.g1.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1 LEFT OUTER JOIN pm2.g2 ON pm2.g2.e1 = pm2.g1.e1 AND pm2.g2.e1 IN ('a', 'b') WHERE pm2.g1.e1 IN ('a', 'b')" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Same as previous test, only right outer join
- */
- @Test public void testCopyCriteriaWithOuterJoin7_defect10050(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 right outer join pm2.g2 on pm2.g2.e1=pm2.g1.e1 where pm2.g2.e1 IN ('a', 'b')", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g2 LEFT OUTER JOIN pm2.g1 ON pm2.g2.e1 = pm2.g1.e1 AND pm2.g1.e1 IN ('a', 'b') WHERE pm2.g2.e1 IN ('a', 'b')" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCleanCriteria(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2 where pm2.g1.e1=pm2.g2.e1 and pm2.g1.e2 IN (1, 2)", example1(), //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1, pm2.g2.e1 FROM pm2.g1, pm2.g2 WHERE (pm2.g1.e1 = pm2.g2.e1) AND (pm2.g1.e2 IN (1, 2))" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCleanCriteria2(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1, pm2.g2 where pm2.g1.e1=pm2.g2.e1 and pm2.g1.e1 = 'a'", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'a') AND (g_1.e1 = 'a')" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCleanCriteria3(){
-
- ProcessorPlan plan = helpPlan("select pm2.g1.e1, pm2.g2.e1 from pm2.g1 inner join pm2.g2 on pm2.g1.e1=pm2.g2.e1 where pm2.g1.e1 = 'a'", example1(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1, g_1.e1 FROM pm2.g1 AS g_0, pm2.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'a') AND (g_1.e1 = 'a')" }); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
-
- @Test public void testPushSubqueryInWhereClause1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm1.g2)", example1(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT e1 FROM pm1.g2)"}, SHOULD_SUCCEED ); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushSubqueryInWhereClause2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select max(e1) FROM pm1.g2)", example1(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT MAX(e1) FROM pm1.g2)" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Check that subquery is pushed if the subquery selects a function that is pushed
- */
- @Test public void testPushSubqueryInWhereClause3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setFunctionSupport("ltrim", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT ltrim(e1) FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT ltrim(e1) FROM pm1.g2)" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Check that subquery is pushed if the subquery selects an aliased function that is pushed
- */
- @Test public void testPushSubqueryInWhereClause4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setFunctionSupport("ltrim", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT ltrim(e1) as m FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 IN (SELECT ltrim(e1) FROM pm1.g2)" }, SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** Case 1456, defect 10492*/
- @Test public void testAliasingDefect1(){
- // Create query
- String sql = "SELECT e1 FROM vm1.g1 X WHERE e2 = (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1)";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder,
- new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1 WHERE g1__1.e2 = (SELECT MAX(pm1.g1.e2) FROM pm1.g1 WHERE pm1.g1.e1 = g1__1.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** Case 1456, defect 10492*/
- @Test public void testAliasingDefect2(){
- // Create query
- String sql = "SELECT X.e1 FROM vm1.g1 X, vm1.g1 Z WHERE X.e2 = (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1 AND Y.e2 = Z.e2) AND X.e1 = Z.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1, pm1.g1 AS g1__2 WHERE (g1__1.e2 = (SELECT MAX(pm1.g1.e2) FROM pm1.g1 WHERE (pm1.g1.e1 = g1__1.e1) AND (pm1.g1.e2 = g1__2.e2))) AND (g1__1.e1 = g1__2.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** Case 1456, defect 10492*/
- @Test public void testAliasingDefect3(){
- // Create query
- String sql = "SELECT X.e1 FROM pm1.g2, vm1.g1 X WHERE X.e2 = ANY (SELECT MAX(e2) FROM vm1.g1 Y WHERE X.e1 = Y.e1) AND X.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_1.e1 FROM pm1.g2 AS g_0, pm1.g1 AS g_1 WHERE (g_1.e1 = g_0.e1) AND (g_1.e2 = SOME (SELECT MAX(g_2.e2) FROM pm1.g1 AS g_2 WHERE g_2.e1 = g_1.e1))" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /** Should use merge join since neither access node is "strong" - order by's pushed to source */
- @Test public void testUseMergeJoin3(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Model supports order by, should be pushed to the source */
- @Test public void testUseMergeJoin4(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Should use merge join, since costs are not known, neither access node is "strong" */
- @Test public void testUseMergeJoin5_CostsNotKnown(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** one side of join supports order by, the other doesn't*/
- @Test public void testUseMergeJoin7(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE pm1.g1.e1 = pm2.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm2.g2.e1 FROM pm2.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** reverse of testUseMergeJoin7 */
- @Test public void testUseMergeJoin7a(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE pm1.g1.e1 = pm2.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** function on one side of join should prevent order by from being pushed down*/
- @Test public void testUseMergeJoin8(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm2.g2 WHERE concat(pm1.g1.e1, 'x') = pm2.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm2.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm2.g2.e1 FROM pm2.g2 ORDER BY pm2.g2.e1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Model supports order by, functions in join criteria */
- @Test public void testUseMergeJoin9(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE concat(pm1.g1.e1, 'x') = concat(pm1.g2.e1, 'x')";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 500));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 3, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** should be one dependent join */
- @Test public void testMultiMergeJoin1(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2, pm1.g3 WHERE pm1.g1.e1 = pm1.g2.e1 AND pm1.g2.e1 = pm1.g3.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE / 4));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE));
- FakeMetadataObject g3 = metadata.getStore().findObject("pm1.g3", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g3.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm1.g2.e1 FROM pm1.g2", "SELECT pm1.g3.e1 FROM pm1.g3" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 2, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testLargeSetCriteria() {
- // Create query
- String sql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA INNER JOIN BQT2.SmallB ON BQT1.SmallA.IntKey = BQT2.SmallB.IntKey WHERE BQT1.SmallA.IntKey IN (1,2,3,4,5)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1));
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA ORDER BY BQT1.SmallA.IntKey", //$NON-NLS-1$
- "SELECT BQT2.SmallB.IntKey FROM BQT2.SmallB ORDER BY BQT2.SmallB.IntKey" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 2, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testMergeJoin_defect11236(){
- // Create query
- String sql = "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE BQT1.SmallA.IntKey = (BQT1.SmallB.IntKey + 1)"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT BQT1.SmallB.IntKey FROM BQT1.SmallB", //$NON-NLS-1$
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA ORDER BY BQT1.SmallA.IntKey" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testNoFrom() {
- ProcessorPlan plan = helpPlan("SELECT 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {} );
-
- checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testINCriteria_defect10718(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1));
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, new Integer(RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000));
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2 ORDER BY pm1.g2.e1"}, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testDefect10711(){
- ProcessorPlan plan = helpPlan("SELECT * from vm1.g1a as X", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1"} ); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- }
-
- // SELECT 5, SUM(IntKey) FROM BQT1.SmallA
- @Test public void testAggregateNoGroupByWithExpression() {
- ProcessorPlan plan = helpPlan("SELECT 5, SUM(IntKey) FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] { "SELECT IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** defect 11630 - note that the lookup function is not pushed down, it will actually be evaluated before being sent to the connector */
- @Test public void testLookupFunction() {
-
- ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', 1) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1', 'e1', 'e2', 1) IS NULL" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- }
-
- /** case 5213 - note here that the lookup cannot be pushed down since it is dependent upon an element symbol*/
- @Test public void testLookupFunction2() throws Exception {
-
- ProcessorPlan plan = helpPlan("SELECT e1 FROM pm1.g2 WHERE LOOKUP('pm1.g1','e1', 'e2', e2) IS NULL", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e2, g_0.e1 FROM pm1.g2 AS g_0" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- /** defect 21965 */
- @Test public void testLookupFunctionInSelect() {
- ProcessorPlan plan = helpPlan("SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1, LOOKUP('pm1.g1','e1', 'e2', 1) FROM pm1.g2" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- // SELECT * FROM (SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT DISTINCT IntNum FROM BQT1.SmallA) AS x WHERE IntKey = 0
- @Test public void testCase1649() {
- ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA) AS x WHERE IntKey = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT IntKey FROM BQT1.SmallA WHERE IntKey = 0", "SELECT IntNum FROM BQT1.SmallA WHERE IntNum = 0" }); //$NON-NLS-1$ //$NON-NLS-2$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
- @Test public void testCase1727_1() {
- ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] {
- "SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
- "SELECT IntKey, IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- // SELECT * FROM (SELECT IntKey a, IntNum b FROM BQT1.SmallA UNION ALL SELECT Intkey, Intkey FROM BQT1.SmallA) as x WHERE b = 0
- @Test public void testCase1727_2() {
- ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT IntKey a, IntKey b FROM BQT1.SmallA UNION ALL SELECT IntKey, IntNum FROM BQT1.SmallA) as x WHERE b = 0", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] {
- "SELECT IntKey, IntNum FROM BQT1.SmallA WHERE IntNum = 0", //$NON-NLS-1$
- "SELECT IntKey, IntKey FROM BQT1.SmallA WHERE IntKey = 0" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testCountStarOverSelectDistinct() {
- ProcessorPlan plan = helpPlan("SELECT COUNT(*) FROM (SELECT DISTINCT IntNum, Intkey FROM bqt1.smalla) AS x", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] {
- "SELECT DISTINCT IntNum, Intkey FROM bqt1.smalla" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- //virtual group with two elements. One selectable, one not
- @Test public void testVirtualGroup1() {
- ProcessorPlan plan = helpPlan("select e2 from vm1.g35", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e2 FROM pm1.g1" } ); //$NON-NLS-1$
-
- checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testBQT9500_126() {
- String sql = "SELECT IntKey, LongNum, expr FROM (SELECT IntKey, LongNum, concat(LongNum, 'abc') FROM BQT2.SmallA ) AS x ORDER BY IntKey"; //$NON-NLS-1$
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {
- "SELECT IntKey, LongNum FROM BQT2.SmallA" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- });
-
- }
-
- public void helpTestUnionPushdown(boolean queryHasOrderBy, boolean hasUnionCapability, boolean hasUnionOrderByCapability) {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, hasUnionCapability);
- caps.setCapabilitySupport((Capability.QUERY_ORDERBY), hasUnionOrderByCapability);
- caps.setCapabilitySupport((Capability.QUERY_SET_ORDER_BY), hasUnionOrderByCapability);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sqlUnion = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB";//$NON-NLS-1$
- String sqlOrderBy = sqlUnion + " ORDER BY IntKey"; //$NON-NLS-1$
- String sql = null;
- if(queryHasOrderBy) {
- sql = sqlOrderBy;
- } else {
- sql = sqlUnion;
- }
-
- String[] expectedSql = null;
- if(hasUnionCapability) {
- if(queryHasOrderBy && hasUnionOrderByCapability) {
- expectedSql = new String[] {sqlOrderBy };
- } else {
- expectedSql = new String[] {sqlUnion };
- }
- } else {
- expectedSql = new String[] { "SELECT IntKey FROM BQT1.SmallA", "SELECT IntKey FROM BQT1.SmallB" }; //$NON-NLS-1$//$NON-NLS-2$
- }
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder, expectedSql, SHOULD_SUCCEED);
-
- int accessCount = hasUnionCapability ? 1 : 2;
- int projectCount = 0;
- int sortCount = 0;
- if(queryHasOrderBy && ! (hasUnionCapability && hasUnionOrderByCapability)) {
- sortCount = 1;
- }
- int unionCount = hasUnionCapability ? 0 : 1;
-
-
-
- checkNodeTypes(plan, new int[] {
- accessCount, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- projectCount, // Project
- 0, // Select
- sortCount, // Sort
- unionCount // UnionAll
- });
- }
-
- /**
- * Query has union but no order by and no capabilities.
- */
- @Test public void testUnionPushdown1() {
- helpTestUnionPushdown(false, false, false);
- }
-
- /**
- * Query has union but no order by and only union capability.
- */
- @Test public void testUnionPushdown2() {
- helpTestUnionPushdown(false, true, false);
- }
-
- /**
- * Query has union with order by and no capabilities.
- */
- @Test public void testUnionPushdown3() {
- helpTestUnionPushdown(true, false, false);
- }
-
- /**
- * Query has union with order by and just union capability.
- */
- @Test public void testUnionPushdown4() {
- helpTestUnionPushdown(true, true, false);
- }
-
- /**
- * Query has union with order by and both capabilities.
- */
- @Test public void testUnionPushdown5() {
- helpTestUnionPushdown(true, true, true);
- }
-
- @Test public void testUnionPushdownWithSelectNoFrom() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT 1 UNION ALL SELECT 2", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder, new String[] {}, SHOULD_SUCCEED);
-
- checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testUnionPushdownWithSelectNoFromFirstBranch() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT 1 UNION ALL SELECT IntKey FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder, new String[] {"SELECT IntKey FROM BQT1.SmallA"}, SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testUnionPushdownWithSelectNoFromSecondBranch() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT 1", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder, new String[] {"SELECT IntKey FROM BQT1.SmallA"}, SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testUnionPushdownMultipleBranches() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB UNION ALL SELECT IntKey FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB UNION ALL SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionPushdownMultipleBranchesMixedModels1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB UNION ALL SELECT IntKey FROM BQT2.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB", "SELECT IntKey FROM BQT2.SmallA"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testUnionPushdownMultipleBranchesNoDupRemoval() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB UNION SELECT IntKey FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB UNION SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testAggregateOverUnionPushdown() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT COUNT(*) FROM (SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB) AS x", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA UNION SELECT IntKey FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testUnionPushdownWithFunctionsAndAliases() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT IntKey+2, StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT (IntKey + 2), StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionPushdownWithInternalOrderBy() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("(SELECT IntKey FROM BQT1.SmallA ORDER BY IntKey) UNION ALL SELECT IntKey FROM BQT1.SmallB", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionPushdownWithInternalDistinct() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan("SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB", metadata, //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT DISTINCT IntKey FROM BQT1.SmallA UNION ALL SELECT IntKey FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionNoAllPushdownInInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT x FROM (SELECT IntKey+2, StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB) AS g", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT (IntKey + 2), StringKey AS x FROM BQT1.SmallA UNION SELECT IntKey, StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testUnionAllPushdownInInlineView() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, false);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT x FROM (SELECT IntKey+2, StringKey AS x FROM BQT1.SmallA UNION ALL SELECT IntKey, StringKey FROM BQT1.SmallB) AS g", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT StringKey AS x FROM BQT1.SmallA UNION ALL SELECT StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionAllPushdownVirtualGroup() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT * FROM vm1.g4", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 UNION ALL SELECT convert(e2, string) FROM pm1.g2"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionAllPushdownVirtualGroup2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- capFinder.addCapabilities("pm3", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT e2 FROM vm1.g17", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] {"SELECT pm3.g1.e2 FROM pm3.g1 UNION ALL SELECT pm3.g2.e2 FROM pm3.g2"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUnionAllPushdownVirtualGroup3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT intnum, 10 FROM bqt1.smalla) AS x", //$NON-NLS-1$
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT intkey FROM BQT1.SmallA", "SELECT IntNum FROM bqt1.smalla"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- // Allow pushing literals
- @Test public void testUnionAllPushdownVirtualGroup4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT * FROM (SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT intnum, 10 FROM bqt1.smalla) AS x", //$NON-NLS-1$
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT intkey, 5 FROM BQT1.SmallA UNION ALL SELECT IntNum, 10 FROM bqt1.smalla"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushCaseInSelect() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testCantPushCaseInSelectWithFunction() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT CASE e1 WHEN 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushSearchedCaseInSelect() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT CASE WHEN e1 = 'a' THEN 10 ELSE 0 END FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testCantPushSearchedCaseInSelectWithFunction() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT CASE WHEN e1 = 'a' THEN 10 ELSE (e2+0) END FROM pm1.g1", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushdownFunctionNotEvaluated() {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
- caps.setFunctionSupport("xyz", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FunctionLibrary funcLibrary = new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
- FakeMetadataFacade metadata = new FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
-
-
- ProcessorPlan plan = helpPlan(
- "SELECT e1 FROM pm1.g1 WHERE xyz() > 0", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT e1 FROM pm1.g1 WHERE xyz() > 0"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testNoSourceQuery() {
- ProcessorPlan plan = helpPlan("SELECT * FROM (select parsetimestamp(x,'yyyy-MM-dd') as c1 from (select '2004-10-20' as x) as y) as z " +//$NON-NLS-1$
- "WHERE c1= '2004-10-20 00:00:00.0'", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- new String[] { });
-
- checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** defect 14510 */
- @Test public void testDefect14510LookupFunction() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataFactory.setCardinality("bqt1.smallb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
- FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.IntKey = lookup('BQT1.SmallB', 'IntKey', 'StringKey', BQT1.SmallB.StringKey)) AND (BQT1.SmallA.IntKey = 1)", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE BQT1.SmallA.IntKey = 1", "SELECT BQT1.SmallB.StringKey FROM BQT1.SmallB"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** defect 14510 */
- @Test public void testDefect14510LookupFunction2() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
- FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.SmallA LEFT OUTER JOIN BQT1.MediumB ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey', BQT1.MediumB.StringKey)", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA", "SELECT BQT1.MediumB.StringKey, BQT1.MediumB.IntKey FROM BQT1.MediumB"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** defect 14510 */
- @Test public void testDefect14510LookupFunction3() throws Exception {
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, new Integer(1000));
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQT();
- FakeMetadataFactory.setCardinality("bqt1.mediumb", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY + 1000, metadata); //$NON-NLS-1$
- FakeMetadataFactory.setCardinality("bqt1.smalla", RuleChooseDependent.DEFAULT_INDEPENDENT_CARDINALITY - 1, metadata); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "SELECT BQT1.SmallA.IntKey, BQT1.MediumB.IntKey FROM BQT1.MediumB RIGHT OUTER JOIN BQT1.SmallA ON BQT1.SmallA.IntKey = lookup('BQT1.MediumB', 'IntKey', 'StringKey',BQT1.MediumB.StringKey)", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA", "SELECT BQT1.MediumB.StringKey, BQT1.MediumB.IntKey FROM BQT1.MediumB"}, //$NON-NLS-1$ //$NON-NLS-2$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCase2125() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_NOT, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_AVG, false);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "SELECT OD.IntKEy, P.IntKEy, O.IntKey " + //$NON-NLS-1$
- "FROM (bqt1.smalla AS OD INNER JOIN bqt1.smallb AS P ON OD.StringKey = P.StringKey) " + //$NON-NLS-1$
- "INNER JOIN bqt1.mediuma AS O ON O.IntKey = OD.IntKey " + //$NON-NLS-1$
- "WHERE (OD.IntNum > (SELECT SUM(IntNum) FROM bqt1.smalla)) AND " + //$NON-NLS-1$
- "(P.longnum > (SELECT AVG(LongNum) FROM bqt1.smallb WHERE bqt1.smallb.datevalue = O.datevalue))"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT g_1.longnum, g_2.datevalue, g_0.IntKEy, g_1.IntKEy, g_2.IntKey FROM bqt1.smalla AS g_0, bqt1.smallb AS g_1, bqt1.mediuma AS g_2 WHERE (g_0.StringKey = g_1.StringKey) AND (g_2.IntKey = g_0.IntKey) AND (g_0.IntNum > (SELECT SUM(g_3.IntNum) FROM bqt1.smalla AS g_3))"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushdownLiteralInSelectUnderAggregate() {
- String sql = "SELECT COUNT(*) FROM (SELECT '' AS y, a.IntKey FROM BQT1.SmallA a union all select '', b.intkey from bqt1.smallb b) AS x"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT '' AS y FROM BQT1.SmallA AS a UNION ALL SELECT '' FROM bqt1.smallb AS b"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushdownLiteralInSelectUnderAggregate2() {
- String sql = "SELECT SUM(z) FROM (SELECT '' AS y, a.IntKey as z FROM BQT1.SmallA a union all select b.stringkey, 0 from bqt1.smallb b) AS x group by z"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT a.IntKey AS z FROM BQT1.SmallA AS a UNION ALL SELECT 0 FROM bqt1.smallb AS b"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushdownLiteralInSelectUnderAggregate3() {
- String sql = "SELECT code, SUM(ID) FROM (SELECT IntKey AS ID, '' AS Code FROM BQT1.SmallA union all select intkey, stringkey from bqt1.smallb b) AS x group by code"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT '' AS Code, IntKey AS ID FROM BQT1.SmallA UNION ALL SELECT stringkey, intkey FROM bqt1.smallb AS b"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushdownLiteralInSelectWithOrderBy() {
- String sql = "SELECT 1, concat('a', 'b' ) AS X FROM BQT1.SmallA where intkey = 0 " + //$NON-NLS-1$
- "UNION ALL " + //$NON-NLS-1$
- "select 2, 'Hello2' from BQT1.SmallA where intkey = 1 order by X desc"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT 1, 'ab' AS X FROM BQT1.SmallA WHERE intkey = 0 UNION ALL SELECT 2, 'Hello2' FROM BQT1.SmallA WHERE IntKey = 1 ORDER BY X DESC"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testUpdateWithElement() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "UPDATE BQT1.SmallA SET IntKey = IntKey + 1"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"UPDATE BQT1.SmallA SET IntKey = (IntKey + 1)"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testCase2187() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT t.intkey FROM (SELECT a.IntKey FROM bqt1.smalla a left outer join bqt1.smallb b on a.intkey=b.intkey, bqt1.smalla x) as t full outer JOIN bqt1.smallb c on t.intkey = c.intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT a.IntKey FROM ((bqt1.smalla AS a LEFT OUTER JOIN bqt1.smallb AS b ON a.intkey = b.intkey) CROSS JOIN bqt1.smalla AS x) FULL OUTER JOIN bqt1.smallb AS c ON a.IntKey = c.intkey"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testMultiUnionMergeVirtual() throws Exception {
- String sql = "SELECT * FROM " + //$NON-NLS-1$
- "(SELECT IntKey, 'a' AS s FROM (SELECT intkey, stringkey from BQT1.SmallA) as a union all " + //$NON-NLS-1$
- "select IntKey, 'b' FROM (SELECT intkey, stringkey from BQT1.SmallA) as b union all " + //$NON-NLS-1$
- "select IntKey, 'c' FROM (SELECT intkey, stringkey from BQT1.SmallA) as c " + //$NON-NLS-1$
- ") AS x"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"(SELECT g_2.intkey AS c_0, 'a' AS c_1 FROM BQT1.SmallA AS g_2 UNION ALL SELECT g_1.IntKey AS c_0, 'b' AS c_1 FROM BQT1.SmallA AS g_1) UNION ALL SELECT g_0.IntKey AS c_0, 'c' AS c_1 FROM BQT1.SmallA AS g_0"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testDefect16848_groupAliasNotSupported_1() {
- String sql = "SELECT sa.intkey, sa.objectvalue FROM bqt1.smalla AS sa WHERE (sa.intkey = 46) AND (sa.stringkey IN (46)) AND (sa.datevalue = (SELECT MAX(sb.datevalue) FROM bqt1.smalla AS sb WHERE (sb.intkey = sa.intkey) AND (sa.stringkey = sb.stringkey) ))"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- RelationalPlan plan = (RelationalPlan)helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT bqt1.smalla.datevalue, bqt1.smalla.intkey, bqt1.smalla.stringkey, bqt1.smalla.objectvalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = 46) AND (bqt1.smalla.stringkey = '46')"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- ProcessorPlan subplan = ValueIteratorProviderCollectorVisitor.getValueIteratorProviders(((SelectNode)plan.getRootNode().getChildren()[0]).getCriteria()).get(0).getCommand().getProcessorPlan();
-
- // Collect atomic queries
- Set<String> actualQueries = getAtomicQueries(subplan);
-
- // Compare atomic queries
- HashSet<String> expectedQueries = new HashSet<String>(Arrays.asList(new String[] { "SELECT bqt1.smalla.datevalue FROM bqt1.smalla WHERE (bqt1.smalla.intkey = bqt1.smalla.intkey) AND (bqt1.smalla.stringkey = bqt1.smalla.stringkey)"})); //$NON-NLS-1$
- assertEquals("Did not get expected atomic queries for subplan: ", expectedQueries, actualQueries); //$NON-NLS-1$
-
- checkNodeTypes(subplan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- @Test public void testFunctionOfAggregate1() {
- String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT (SUM(IntKey) + 1) FROM BQT1.SmallA GROUP BY IntKey"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testFunctionOfAggregateCantPush1() {
- String sql = "SELECT SUM(IntKey) + 1 AS x FROM BQT1.SmallA GROUP BY IntKey"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT IntKey FROM BQT1.SmallA"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testFunctionOfAggregateCantPush3() {
- String sql = "SELECT avg(intkey) * 2 FROM BQT1.SmallA "; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] {"SELECT intkey FROM BQT1.SmallA"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- private void helpTestCase2589NonPushdown(String sql, String[] expected) {
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- expected,
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- private void helpTestCase2589(String sql, String expected) throws Exception {
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SET_ORDER_BY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {expected},
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase2589() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
-
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589a() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589a ON MediumA.IntKey = SmallA_2589a.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589b() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589c() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB, BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey " + //$NON-NLS-1$
- "WHERE BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN (BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10') ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589d() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
- "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB INNER JOIN (BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10') ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589e() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
- "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN (BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10') ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589f() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA INNER JOIN VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey) " + //$NON-NLS-1$
- "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN (BQT1.MediumA INNER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey AND BQT1.SmallA.StringNum = '10'";//$NON-NLS-1$";
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589g() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA INNER JOIN VQT.SmallA_2589c ON MediumA.IntKey = SmallA_2589c.IntKey) " + //$NON-NLS-1$
- "ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA INNER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB " + //$NON-NLS-1$
- "ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey AND " + //$NON-NLS-1$
- "concat(BQT1.SmallA.StringNum, BQT1.SmallB.StringNum) = '1010') " + //$NON-NLS-1$
- "ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) ON BQT1.MediumB.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589h() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589c " + //$NON-NLS-1$
- "ON MediumA.IntKey = SmallA_2589c.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey AND concat(BQT1.SmallA.StringNum, BQT1.SmallB.StringNum) = '1010') ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- @Test public void testCase2589i() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN VQT.SmallA_2589d " + //$NON-NLS-1$
- "ON MediumA.IntKey = SmallA_2589d.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' AND BQT1.SmallA.IntNum = 10"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Test optimization doesn't happen if an outer join isn't involved
- */
- @Test public void testCase2589j() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA INNER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA, BQT1.SmallA WHERE (BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) AND (BQT1.SmallA.StringNum = '10')"; //$NON-NLS-1$
-
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Test optimization doesn't happen if an outer join isn't involved
- */
- @Test public void testCase2589k() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA INNER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA, BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) AND (BQT1.MediumA.IntKey = BQT1.SmallA.IntKey) AND (BQT1.SmallA.StringNum = '10')"; //$NON-NLS-1$
-
-
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Same as testCase2589 except right outer join
- */
- @Test public void testCase2589l() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM VQT.SmallA_2589 RIGHT OUTER JOIN " + //$NON-NLS-1$
- "BQT1.MediumA ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
-
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Same as testCase2589 except full outer join - criteria "below" full outer join cannot be
- * raised into the join criteria, so basically the virtual groups cannot be merged in this test.
- */
- @Test public void testCase2589m() {
- String sql = "SELECT BQT1.MediumA.IntKey FROM VQT.SmallA_2589 FULL OUTER JOIN " + //$NON-NLS-1$
- "BQT1.MediumA ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String[] expected = new String[] {
- "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" //$NON-NLS-1$
- };
-
- helpTestCase2589NonPushdown(sql, expected);
- }
-
- /**
- * Same as testCase2589b except full outer join
- */
- @Test public void testCase2589n() {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589b ON MediumA.IntKey = SmallA_2589b.IntKey"; //$NON-NLS-1$
-
- String[] expected = new String[] {
- "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB WHERE (BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) AND (BQT1.SmallA.StringNum = '10')" //$NON-NLS-1$
- };
- helpTestCase2589NonPushdown(sql, expected);
-
- }
-
- /**
- * Same as testCase2589 except with two virtual layers instead of one
- */
- @Test public void testCase2589o() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589f ON MediumA.IntKey = SmallA_2589f.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
-
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Same as testCase2589b except with two virtual layers instead of one
- */
- @Test public void testCase2589p() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589g ON MediumA.IntKey = SmallA_2589g.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Test 3 frames, where top frame has outer join, middle frame has inner join, and
- * bottom frame has criteria that must be made into join criteria.
- */
- @Test public void testCase2589q() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589h ON MediumA.IntKey = SmallA_2589h.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Similar to testCase2589b, except virtual transformation has criteria on an
- * element from each physical table
- */
- @Test public void testCase2589r() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589i ON MediumA.IntKey = SmallA_2589i.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.StringKey = BQT1.SmallB.StringKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' AND BQT1.SmallB.StringNum = '10'"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Test user criteria that should NOT be moved into join clause
- */
- @Test public void testCase2589s() throws Exception {
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey " + //$NON-NLS-1$
- "WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Test user criteria that should NOT be moved into join clause
- */
- @Test public void testCase2589t() throws Exception {
- String sql = "SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE BQT1.MediumA.IntNum = 10) as z " + //$NON-NLS-1$
- "LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589 ON z.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * The above test written with an inline view instead of a virtual group.
- * This test translates to - how can this query be rewritten without subqueries such
- * that the same results are produced? More specifically, where should the criteria
- * go - WHERE clause or FROM clause?
- */
- @Test public void testCase2589u() throws Exception {
- String sql = "SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
- "LEFT OUTER JOIN " + //$NON-NLS-1$
- "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
- "ON z.IntKey = y.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Same sql as testCase2589, but the model doesn't support outer joins, so
- * case 2589 optimization shouldn't happen.
- */
- @Test public void testCase2589v() {
-
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String expected[] = new String[] {
- "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" //$NON-NLS-1$
- };
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- expected,
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Same as previous testCase2589v, but with full outer join.
- */
- @Test public void testCase2589w() {
-
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA FULL OUTER JOIN " + //$NON-NLS-1$
- "VQT.SmallA_2589 ON MediumA.IntKey = SmallA_2589.IntKey"; //$NON-NLS-1$
-
- String expected[] = new String[] {
- "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA", //$NON-NLS-1$
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA WHERE StringNum = '10'" //$NON-NLS-1$
- };
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, false);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- expected,
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test a complicated join tree involving multiple models, but with a nested
- * outer join predicate spanning only one model, and see if the case 2589
- * fix happens. The important thing is the criteria "StringNum = '10'" needs
- * to be put in the join criteria, not the where clause, of the second atomic
- * query, because in the user query it is on the inner side of an outer join.
- */
- @Test public void testCase2589x() throws Exception {
-
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT2.SmallA INNER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
- "ON MediumA.IntKey = y.IntKey) " + //$NON-NLS-1$
- "ON BQT2.SmallA.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected[] = new String[] {
- "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA", //$NON-NLS-1$
- "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'" //$NON-NLS-1$
- };
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- expected,
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test two outer joins, one nested within the other, all pushable to one source,
- * with inline views having criteria that each need to be migrated to their
- * respective join predicate join criteria.
- *
- * The tree below illustrates the canonical plan (plus access nodes). 'y' and
- * 'z' are two inline views. Notice each has a SELECT node underneath - the
- * criteria represented by each of those SELECT nodes is on the inner side of
- * their respective left outer joins (LOJ). So, each criteria needs to be
- * migrated to the join criteria.
- *
- * <pre>
- * LOJ
- * / \
- * LOJ SRC z
- * / \ |
- * SRC SRC y SEL
- * MedB | |
- * SEL ACC
- * | |
- * ACC SRC SmA
- * |
- * SRC MedA
- * </pre>
- * Here's a diagram of what the join plan of the resulting atomic query should
- * look like.
- * <pre>
- * ACC
- * |
- * LOJ**
- * / \
- * LOJ** SRC **criteria migrated to here
- * / \ SmA
- * SRC SRC
- * MedB MedA
- * </pre>
- */
- @Test public void testCase2589y() throws Exception {
- String sql = "SELECT L.IntKey, y.IntKey, z.IntKey " + //$NON-NLS-1$
- "FROM (BQT1.MediumB as L LEFT OUTER JOIN " + //$NON-NLS-1$
- "(SELECT IntKey FROM BQT1.MediumA as M WHERE M.IntNum = 4) as y ON y.IntKey = L.IntKey) " + //$NON-NLS-1$
- "LEFT OUTER JOIN (SELECT IntKey FROM BQT1.SmallA as S WHERE S.StringNum = '10') as z " + //$NON-NLS-1$
- "ON z.IntKey = y.IntKey"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumB.IntKey, BQT1.MediumA.IntKey, BQT1.SmallA.IntKey " + //$NON-NLS-1$
- "FROM (BQT1.MediumB LEFT OUTER JOIN " + //$NON-NLS-1$
- "BQT1.MediumA ON BQT1.MediumA.IntKey = BQT1.MediumB.IntKey AND BQT1.MediumA.IntNum = 4) " + //$NON-NLS-1$
- "LEFT OUTER JOIN BQT1.SmallA " + //$NON-NLS-1$
- "ON BQT1.SmallA.IntKey = BQT1.MediumA.IntKey AND BQT1.SmallA.StringNum = '10'"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Test a complicated join tree involving multiple models, but with a nested
- * outer join predicate spanning only one model, and see if the case 2589
- * fix happens. The important thing is the criteria "StringNum = '10'" needs
- * to be put in the join criteria, not the where clause, of the second atomic
- * query, because in the user query it is on the inner side of an outer join.
- */
- @Test public void testCase2589z() {
-
- String sql = "SELECT BQT1.MediumA.IntKey FROM BQT2.SmallA INNER JOIN " + //$NON-NLS-1$
- "(BQT1.MediumA LEFT OUTER JOIN " + //$NON-NLS-1$
- "(SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA, BQT1.SmallB " + //$NON-NLS-1$
- "WHERE BQT1.SmallA.IntKey = BQT1.SmallB.IntKey AND BQT1.SmallA.StringNum = '10') as y " + //$NON-NLS-1$
- "ON MediumA.IntKey = y.IntKey) " + //$NON-NLS-1$
- "ON BQT2.SmallA.IntKey = BQT1.MediumA.IntKey"; //$NON-NLS-1$
-
- String expected[] = new String[] {
- "SELECT BQT2.SmallA.IntKey FROM BQT2.SmallA", //$NON-NLS-1$
- "SELECT BQT1.MediumA.IntKey FROM BQT1.MediumA LEFT OUTER JOIN (BQT1.SmallA INNER JOIN BQT1.SmallB ON BQT1.SmallA.IntKey = BQT1.SmallB.IntKey) ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10'" //$NON-NLS-1$
- };
-
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, false);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- expected,
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Union with multiple joins underneath
- */
- @Test public void testCase2589aa() throws Exception {
- String sql = "SELECT * FROM (SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
- "LEFT OUTER JOIN " + //$NON-NLS-1$
- "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
- "ON z.IntKey = y.IntKey " + //$NON-NLS-1$
- "UNION ALL SELECT z.IntKey FROM (SELECT IntKey FROM BQT1.MediumA WHERE IntNum = 10) as z " + //$NON-NLS-1$
- "LEFT OUTER JOIN " + //$NON-NLS-1$
- "(SELECT IntKey FROM BQT1.SmallA WHERE StringNum = '10') as y " + //$NON-NLS-1$
- "ON z.IntKey = y.IntKey) as x"; //$NON-NLS-1$
-
- String expected = "SELECT BQT1.MediumA.IntKey AS c_0 FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10 UNION ALL SELECT BQT1.MediumA.IntKey AS c_0 FROM BQT1.MediumA LEFT OUTER JOIN BQT1.SmallA ON BQT1.MediumA.IntKey = BQT1.SmallA.IntKey AND BQT1.SmallA.StringNum = '10' WHERE BQT1.MediumA.IntNum = 10"; //$NON-NLS-1$
- helpTestCase2589(sql, expected);
- }
-
- /**
- * Since can now guarantee unique select column names, it's ok to have repeated entries in the order by clause.
- */
- @Test public void testOrderByDuplicates() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT intkey, x FROM (select intkey, intkey x from bqt1.smalla) z ORDER BY x, intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT g_0.intkey AS c_0, g_0.intkey AS c_1 FROM bqt1.smalla AS g_0 ORDER BY c_1, c_0"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- //Test use of OrderBy with expression
- @Test public void testCase2507() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT vqt.smallb.a12345 FROM vqt.smallb ORDER BY vqt.smallb.a12345"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT Concat(stringKey, stringNum) AS EXPR FROM BQT1.SmallA ORDER BY EXPR"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase2507A() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as EXPR, bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR, EXPR_1"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR, bqt1.smalla.stringKey AS EXPR_1 FROM bqt1.smalla ORDER BY EXPR, EXPR_1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase2507B() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum), bqt1.smalla.stringKey as EXPR_1 FROM bqt1.smalla ORDER BY EXPR_1"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum), bqt1.smalla.stringKey AS EXPR_1 FROM bqt1.smalla ORDER BY EXPR_1"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * RulePlanJoins does not initially allow the cross join push.
- * The subsequent RuleRaiseAccess does since we believe it was the intent of the user
- */
- @Test public void testPushCrossJoins() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT b1.intkey from (bqt1.SmallA a1 cross join bqt1.smalla a2 cross join bqt1.mediuma b1) " + //$NON-NLS-1$
- " left outer join bqt1.mediumb b2 on b1.intkey = b2.intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT g_2.intkey FROM ((bqt1.SmallA AS g_0 CROSS JOIN bqt1.smalla AS g_1) CROSS JOIN bqt1.mediuma AS g_2) LEFT OUTER JOIN bqt1.mediumb AS g_3 ON g_2.intkey = g_3.intkey"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase3023() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT bqt1.SmallA.intkey from (bqt1.SmallA inner join (" //$NON-NLS-1$
- + "SELECT BAD.intkey from bqt1.SmallB as BAD left outer join bqt1.MediumB on BAD.intkey = bqt1.MediumB.intkey) as X on bqt1.SmallA.intkey = X.intkey) inner join bqt1.MediumA on X.intkey = bqt1.MediumA.intkey"; //$NON-NLS-1$
-
- helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT bqt1.SmallA.intkey FROM (bqt1.SmallA INNER JOIN (bqt1.SmallB AS BAD LEFT OUTER JOIN bqt1.MediumB ON BAD.intkey = bqt1.MediumB.intkey) ON bqt1.SmallA.intkey = BAD.intkey) INNER JOIN bqt1.MediumA ON BAD.intkey = bqt1.MediumA.intkey"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
- }
-
- @Test public void testCase3367() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = example1();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("select e1 from pm1.g1 where pm1.g1.e1 IN (SELECT pm1.g2.e1 FROM pm1.g2 WHERE (pm1.g1.e1 = 2))", metadata, //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1 WHERE pm1.g1.e1 IN (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g1.e1 = '2')" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /*
- * Set criteria was not getting pushed down correctly when there was a self-join
- * of a virtual table containing a join in it's transformation. All virtual
- * models use the same physical model pm1.
- */
- @Test public void testCase3778() throws Exception {
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(
- "select a.e1, b.e1 from vm2.g1 a, vm2.g1 b where a.e1 = b.e1 and a.e2 in (select e2 from vm1.g1)", //$NON-NLS-1$
- metadata, null, capFinder, new String[] {"SELECT g_0.e1, g_2.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1, pm1.g1 AS g_2, pm1.g2 AS g_3 WHERE (g_2.e2 = g_3.e2) AND (g_0.e2 = g_1.e2) AND (g_0.e1 = g_2.e1) AND (g_0.e2 IN (SELECT g_4.e2 FROM pm1.g1 AS g_4))"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Ensures that order by expressions are not repeated when multiple criteria span a merge join
- */
- @Test public void testCase3832() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "select bqt1.smalla.intkey from bqt1.smalla, bqt2.smalla, bqt2.smallb where bqt1.smalla.intkey = bqt2.smalla.intkey and bqt1.smalla.intkey = bqt2.smallb.intkey and bqt2.smalla.stringkey = bqt2.smallb.stringkey"; //$NON-NLS-1$
-
- helpPlan(sql,
- metadata,
- null,
- capFinder,
- new String[] {
- "SELECT bqt2.smallb.intkey AS c_0, bqt2.smalla.intkey AS c_1 FROM bqt2.smalla, bqt2.smallb WHERE bqt2.smalla.stringkey = bqt2.smallb.stringkey ORDER BY c_0, c_1", //$NON-NLS-1$
- "SELECT bqt1.smalla.intkey AS c_0 FROM bqt1.smalla ORDER BY c_0"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING);
-
- }
-
- /*
- * Functions containing exec statements should not be evaluated
- */
- @Test public void testDefect21972() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select e1 from pm1.g1 where e1 = convert((exec pm1.sq11(1, 2)), integer)"; //$NON-NLS-1$
-
- helpPlan(sql,
- FakeMetadataFactory.example1Cached(),
- null,
- capFinder,
- new String[] {
- "SELECT e1 FROM pm1.g1"}, //$NON-NLS-1$
- SHOULD_SUCCEED);
-
- }
-
- @Test public void testExpressionSymbolPreservation() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT * from (select '1' as test, intkey from bqt2.smalla) foo, (select '2' as test, intkey from bqt2.smalla) foo2 where foo.intkey = foo2.intkey"; //$NON-NLS-1$
-
- helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {"SELECT '1', g_0.intkey, '2', g_1.IntKey FROM bqt2.smalla AS g_0, bqt2.smalla AS g_1 WHERE g_0.intkey = g_1.IntKey"}, //$NON-NLS-1$
- ComparisonMode.EXACT_COMMAND_STRING );
-
- }
-
- //since this does not support convert, it should not be collapsed
- @Test public void testBadCollapseUnion() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select convert(e2+1,string) from pm1.g1 union all select e1 from pm1.g2";//$NON-NLS-1$
- String[] expectedSql = new String[] {"SELECT e2 FROM pm1.g1", "SELECT e1 FROM pm1.g2"};//$NON-NLS-1$ //$NON-NLS-2$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(),
- null, capFinder, expectedSql, SHOULD_SUCCEED);
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
-
- }
-
- @Test public void testCase3966() {
- ProcessorPlan plan = helpPlan("insert into vm1.g37 (e1, e2, e3, e4) values('test', 1, convert('true', boolean) , convert('12', double) )", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {} );
-
- checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 1, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /*
- * Select literals created by runtime evaluation should not be pushed down.
- */
- @Test public void testCase4017() throws Exception {
-
- String sql = "SELECT env('soap_host') AS HOST, intkey from bqt2.smalla"; //$NON-NLS-1$
-
- helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, new DefaultCapabilitiesFinder(),
- new String[] {"SELECT bqt2.smalla.intkey FROM bqt2.smalla"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- /**
- * Test of RuleCopyCriteria. Criteria should NOT be copied across a join if the join has any other operator
- * other than an equality operator, but if the single group criteria is equality, then we can copy into a join criteria
- */
- @Test public void testCase4265() throws Exception {
- String sql = "SELECT X.intkey, Y.intkey FROM BQT1.SmallA X, BQT1.SmallA Y WHERE X.IntKey <> Y.IntKey and Y.IntKey = 1"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {
- "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey <> 1", //$NON-NLS-1$
- "SELECT g_0.IntKey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- /**
- * Test of RuleCopyCriteria. Criteria should be copied across a join only for an equality operator in
- * the join criteria.
- */
- @Test public void testCase4265ControlTest() throws Exception {
- String sql = "SELECT X.intkey, Y.intkey FROM BQT1.SmallA X, BQT1.SmallA Y WHERE X.IntKey = Y.IntKey and Y.IntKey = 1"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {
- "SELECT g_0.intkey FROM BQT1.SmallA AS g_0 WHERE g_0.IntKey = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- /**
- * The bug was in FrameUtil.convertCriteria() method, where ExistsCriteria was not being checked for.
- */
- @Test public void testExistsCriteriaInSelect() {
- String sql = "select intkey, case when exists (select stringkey from bqt1.smallb) then 'nuge' end as a from vqt.smalla"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 1, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- /**
- * Try substituting "is not null" for "exists" criteria
- */
- @Test public void testScalarSubQueryInSelect() {
- String sql = "select intkey, case when (select stringkey from bqt1.smallb) is not null then 'nuge' end as a from vqt.smalla"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {
- "SELECT BQT1.SmallA.IntKey FROM BQT1.SmallA" }); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 1, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
-
- }
-
- @Test public void testCase4263() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = example1();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("select vm1.g1.e1 from vm1.g1 left outer join (select * from vm1.g2 as v where v.e1 = (select max(vm1.g2.e1) from vm1.g2 where v.e1 = vm1.g2.e1)) f2 on (f2.e1 = vm1.g1.e1)", metadata, //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT g1__1.e1 FROM pm1.g1 AS g1__1 LEFT OUTER JOIN pm1.g1 AS g1__2 ON g1__2.e1 = g1__1.e1 AND g1__2.e1 = (SELECT MAX(pm1.g1.e1) FROM pm1.g1 WHERE pm1.g1.e1 = g1__2.e1)" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase4263b() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = example1();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("select vm1.g1.e1 from vm1.g1 left outer join (select * from vm1.g2 as v where v.e1 = (select max(pm2.g1.e1) from pm2.g1 where v.e1 = pm2.g1.e1)) f2 on (f2.e1 = vm1.g1.e1)", metadata, //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1", "SELECT g1__1.e1 FROM pm1.g1 AS g1__1" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCase4279() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = example1();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
-
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("select * from (select v1.e1, v2.e1 as e1_1, v1.e2, v2.e2 as e2_2 from (select * from vm1.g7 where vm1.g7.e2 = 1) v1 left outer join (select * from vm1.g7 where vm1.g7.e2 = 1) v2 on v1.e2 = v2.e2) as v3 where v3.e2 = 1", metadata, //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT CASE WHEN g_0.e1 = 'S' THEN 'Pay' WHEN g_0.e1 = 'P' THEN 'Rec' ELSE g_0.e1 END, CASE WHEN g_1.e1 = 'S' THEN 'Pay' WHEN g_1.e1 = 'P' THEN 'Rec' ELSE g_1.e1 END, g_0.e2, g_1.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g1 AS g_1 ON g_0.e2 = g_1.e2 AND g_1.e2 = 1 WHERE g_0.e2 = 1" }, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase4312() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- helpPlan("select ? + 1, pm1.g1.e1 AS EXPR_1 FROM pm1.g1", example1(), null, capFinder, //$NON-NLS-1$
- new String[] {
- "SELECT (? + 1) AS expr, pm1.g1.e1 FROM pm1.g1"}, true); //$NON-NLS-1$
-
- }
-
- @Test public void testCase2507_2(){
-
- String sql = "SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " + //$NON-NLS-1$
- "FROM BQT1.SmallA, BQT1.SmallB WHERE SmallA.IntKey = SmallB.IntKey) as X ORDER BY X.a"; //$NON-NLS-1$
-
- String expected = "SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) AS EXPR " + //$NON-NLS-1$
- "FROM BQT1.SmallA, BQT1.SmallB WHERE BQT1.SmallA.IntKey = BQT1.SmallB.IntKey ORDER BY EXPR"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {expected},
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- private void helpTestCase2430and2507(String sql, String expected) {
-
- // TEST PLANNING
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_ORDERED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER_FULL, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {expected},
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- //Test use of OrderBy with Alias
- @Test public void testCase2430D() {
- String sql = "SELECT bqt1.smalla.longnum + bqt1.smalla.longnum as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
- "bqt1.smalla.doublenum as EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
-
- String expected = "SELECT (bqt1.smalla.longnum + bqt1.smalla.longnum) AS c1234567890123456789012345678901234567890, bqt1.smalla.doublenum AS EXPR " + //$NON-NLS-1$
- "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR"; //$NON-NLS-1$
- helpTestCase2430and2507(sql, expected);
- }
-
- /*
- * If expressionsymbol comparison would ignore expression names then this should just select a single column,
- * but for now it will select 2.
- */
- @Test public void testCase2430E() {
- String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
- "CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890, EXPR "; //$NON-NLS-1$
-
- String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c1234567890123456789012345678901234567890, CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) " + //$NON-NLS-1$
- "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
- helpTestCase2430and2507(sql, expected);
- }
-
- @Test public void testCase2430G() {
- String sql = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) as c1234567890123456789012345678901234567890, " + //$NON-NLS-1$
- "CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS EXPR FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
-
- String expected = "SELECT CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) AS c1234567890123456789012345678901234567890, CONCAT(bqt1.smalla.stringKey, bqt1.smalla.stringNum) " + //$NON-NLS-1$
- "FROM bqt1.smalla ORDER BY c1234567890123456789012345678901234567890"; //$NON-NLS-1$
- helpTestCase2430and2507(sql, expected);
- }
-
- @Test public void testCase2507_1(){
-
- String sql = "SELECT a FROM (SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) as a " + //$NON-NLS-1$
- "FROM BQT1.SmallA) as X ORDER BY X.a"; //$NON-NLS-1$
-
- String expected = "SELECT concat(BQT1.SmallA.StringKey, BQT1.SmallA.StringNum) AS EXPR FROM BQT1.SmallA ORDER BY EXPR"; //$NON-NLS-1$
-
- // Plan query
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("concat", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql,
- metadata,
- null, capFinder,
- new String[] {expected},
- TestOptimizer.SHOULD_SUCCEED );
-
- TestOptimizer.checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * This is taken from testPushCorrelatedSubquery1. However this subquery is not expected to be pushed down since the correlated
- * reference expression cannot be evaluated by the source.
- */
- @Test public void testDefect23614() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = concat(n.stringkey, 'a') )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT intkey, n.stringkey FROM bqt1.smalla AS n" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Normally the following queries would plan as if they were federated, but setting the connector_id source property
- * allows them to be planned as if they were the same source.
- */
- @Test public void testSameConnector() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_OUTER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setSourceProperty(Capability.CONNECTOR_ID, "1"); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA A LEFT OUTER JOIN BQT2.MediumB B ON A.IntKey = B.IntKey", //$NON-NLS-1$
- metadata, null, capFinder,
- new String[] {
- "SELECT A.IntKey, B.IntKey FROM BQT1.SmallA AS A LEFT OUTER JOIN BQT2.MediumB AS B ON A.IntKey = B.IntKey"}, //$NON-NLS-1$
- true);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- plan = helpPlan(
- "SELECT A.IntKey FROM BQT1.SmallA A UNION select B.intkey from BQT2.MediumB B", //$NON-NLS-1$
- metadata, null, capFinder,
- new String[] {
- "SELECT A.IntKey FROM BQT1.SmallA AS A UNION SELECT B.intkey FROM BQT2.MediumB AS B"}, //$NON-NLS-1$
- true);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Test changes to RuleCollapseSource for removing aliases
- */
- @Test public void testCase4898() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT 'a' as A FROM BQT1.SmallA A UNION select 'b' as B from BQT1.MediumB B", //$NON-NLS-1$
- metadata, null, capFinder,
- new String[] {
- "SELECT 'a' AS A FROM BQT1.SmallA AS A UNION SELECT 'b' FROM BQT1.MediumB AS B"}, //$NON-NLS-1$
- true);
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testDefect13971() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_DISTINCT, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "select b from (select distinct booleanvalue b, intkey from bqt1.smalla) as x"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] {"SELECT DISTINCT booleanvalue, intkey FROM bqt1.smalla"}, SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Ensures that aliases are not stripped from projected symbols if they might conflict with an order by element
- */
- @Test public void testCase5067() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- String sql = "SELECT a.intkey as stringkey, b.stringkey as key2 from bqt1.smalla a, bqt1.smallb b where a.intkey = b.intkey order by stringkey"; //$NON-NLS-1$
-
- // Plan query
- ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] {"SELECT a.intkey AS stringkey, b.stringkey AS key2 FROM bqt1.smalla AS a, bqt1.smallb AS b WHERE a.intkey = b.intkey ORDER BY stringkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testDontPushConvertObject() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT intkey from bqt1.smalla WHERE stringkey = convert(objectvalue, string)", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT stringkey, objectvalue, intkey FROM bqt1.smalla"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testDontPushConvertClobToString() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("LOB", caps); //$NON-NLS-1$
-
- // Add join capability to pm1
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- ProcessorPlan plan = helpPlan(
- "SELECT ClobValue from LOB.LobTbl WHERE convert(ClobValue, string) = ?", //$NON-NLS-1$
- metadata,
- null, capFinder,
- new String[] {"SELECT ClobValue FROM LOB.LobTbl"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testSelectIntoWithDistinct() throws Exception {
- String sql = "select distinct e1 into #temp from pm1.g1"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(sql, metadata, new String[] {"SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
-
- checkNodeTypes(plan, new int[] {1}, new Class[] {ProjectIntoNode.class});
- }
-
- /**
- * previously the subqueries were being pushed too far and then not having the appropriate correlated references
- */
- @Test public void testCorrelatedSubqueryOverJoin() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- String sql = "select pm1.g1.e1 from pm1.g1, (select * from pm1.g2) y where (pm1.g1.e1 = y.e1) and exists (select e2 from pm1.g2 where e1 = y.e1) and exists (select e3 from pm1.g2 where e1 = y.e1)"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder, new String[] {"SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 AS g2__1 WHERE (pm1.g1.e1 = g2__1.e1) AND (EXISTS (SELECT e2 FROM pm1.g2 WHERE e1 = g2__1.e1)) AND (EXISTS (SELECT e3 FROM pm1.g2 WHERE e1 = g2__1.e1))"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * see testSimpleCrossJoin3
- */
- @Test public void testMaxFromGroups() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setSourceProperty(Capability.MAX_QUERY_FROM_GROUPS, new Integer(1));
- capFinder.addCapabilities("pm2", caps); //$NON-NLS-1$
-
- helpPlan("select pm2.g1.e1 FROM pm2.g1 CROSS JOIN pm2.g2", example1(), null, capFinder, //$NON-NLS-1$
- new String[] { "SELECT pm2.g1.e1 FROM pm2.g1", "SELECT pm2.g2.e1 FROM pm2.g2"}, true ); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- @Test public void testCase6249() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", TestOptimizer.getTypicalCapabilities()); //$NON-NLS-1$
-
- String sql = "select count(*) from (select intkey from bqt1.smalla union all select intkey from bqt1.smallb) as a"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT COUNT(*) FROM (SELECT intkey FROM bqt1.smalla UNION ALL SELECT intkey FROM bqt1.smallb) AS a"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase6181() throws Exception {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select a.e1 from (select 1 e1) a, (select e1, 1 as a, x from (select e1, CASE WHEN e1 = 'a' THEN e2 ELSE e3 END as x from pm1.g2) y group by e1, x) b where a.e1 = b.x"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, metadata, null, capFinder,
- new String[] {"SELECT v_1.c_0 FROM (SELECT v_0.c_1 AS c_0 FROM (SELECT g_0.e1 AS c_0, CASE WHEN g_0.e1 = 'a' THEN g_0.e2 ELSE g_0.e3 END AS c_1 FROM pm1.g2 AS g_0 WHERE CASE WHEN g_0.e1 = 'a' THEN g_0.e2 ELSE g_0.e3 END IN (<dependent values>)) AS v_0 GROUP BY v_0.c_0, v_0.c_1) AS v_1 ORDER BY c_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 0, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCase6325() {
- String sql = "select e1 into #temp from pm4.g1 where e1='1'"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = helpPlan(sql, metadata, new String[] {"SELECT e1 FROM pm4.g1 WHERE e1 = '1'"}); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase6364() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_FUNCTIONS_IN_GROUP_BY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "select * from (SELECT 1+ SUM(intnum) AS s FROM bqt1.smalla) a WHERE a.s>10"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT (1 + SUM(intnum)) FROM bqt1.smalla HAVING SUM(intnum) > 9"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testExceptPushdown() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_EXCEPT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- String sql = "select e1 from pm1.g1 except select e1 from pm1.g2"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT g_1.e1 AS c_0 FROM pm1.g1 AS g_1 EXCEPT SELECT g_0.e1 AS c_0 FROM pm1.g2 AS g_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testCase6597() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
- caps.setCapabilitySupport(Capability.CRITERIA_NOT, false);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- // Create query
- String sql = "select IntKey from bqt1.smalla where stringkey not like '2%'"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[] {"SELECT stringkey, IntKey FROM bqt1.smalla"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCopyCriteriaWithIsNull() {
- String sql = "select * from (select a.intnum, a.intkey y, b.intkey from bqt1.smalla a, bqt2.smalla b where a.intkey = b.intkey) x where intkey is null"; //$NON-NLS-1$
-
- helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), new String[] {});
- }
-
- /**
- * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
- * query containing a <code>BETWEEN</code> comparison in the queries
- * <code>WHERE</code> statement.
- * <p>
- * For example:
- * <p>
- * SELECT * FROM pm1.g1 WHERE e2 BETWEEN 1 AND 2
- */
- @Test public void testBetween() {
- helpPlan("select * from pm1.g1 where e2 between 1 and 2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1 WHERE (e2 >= 1) AND (e2 <= 2)"} ); //$NON-NLS-1$
- }
-
- /**
- * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
- * query containing a <code>CASE</code> expression in which a
- * <code>BETWEEN</code> comparison is used in the queries
- * <code>SELECT</code> statement.
- * <p>
- * For example:
- * <p>
- * SELECT CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END FROM pm1.g1
- */
- @Test public void testBetweenInCase() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- helpPlan("select case when e2 between 3 and 5 then e2 else -1 end from pm1.g1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END FROM pm1.g1"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED);
- }
-
- /**
- * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
- * query containing an aggregate SUM with a <code>CASE</code> expression
- * in which a <code>BETWEEN</code> comparison is used in the queries
- * <code>SELECT</code> statement.
- * <p>
- * For example:
- * <p>
- * SELECT SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END) FROM pm1.g1
- */
- @Test public void testBetweenInCaseInSum() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- helpPlan("select sum(case when e2 between 3 and 5 then e2 else -1 end) from pm1.g1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT SUM(CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END) FROM pm1.g1"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED);
- }
-
- /**
- * Test <code>QueryOptimizer</code>'s ability to plan a fully-pushed-down
- * query containing an aggregate SUM with a <code>CASE</code> expression
- * in which a <code>BETWEEN</code> comparison is used in the queries
- * <code>SELECT</code> statement and a GROUP BY is specified.
- * <p>
- * For example:
- * <p>
- * SELECT e1, SUM(CASE WHEN e2 BETWEEN 3 AND 5 THEN e2 ELSE -1 END)
- * FROM pm1.g1 GROUP BY e1
- */
- @Test public void testBetweenInCaseInSumWithGroupBy() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SEARCHED_CASE, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_SUM, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- helpPlan("select sum(case when e2 between 3 and 5 then e2 else -1 end) from pm1.g1 group by e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] { "SELECT SUM(CASE WHEN (e2 >= 3) AND (e2 <= 5) THEN e2 ELSE -1 END) FROM pm1.g1 GROUP BY e1"}, //$NON-NLS-1$
- TestOptimizer.SHOULD_SUCCEED);
- }
-
- /**
- * Test the query optimizer's ability to properly plan and optimize a query
- * that uses ambiguous alias names in the top level query and its sub-query.
- * <p>
- * No source table is being used. For example, <code>SELECT A.e2 FROM
- * (SELECT e2 FROM (SELECT 1 AS e2) AS A) AS A</code>
- * <p>
- * The test is to ensure that A.e2 from the top level is not confused with
- * e2 in the second level.
- * <p>
- * Related Defects: JBEDSP-1137
- */
- @Test public void testAmbiguousAliasInSubQueryNoSource() {
- // Create query
- String sql = "SELECT A.e2 AS e2 FROM (" + //$NON-NLS-1$
- " SELECT e2 AS e2 FROM (" + //$NON-NLS-1$
- " SELECT 5 AS e2" + //$NON-NLS-1$
- " ) AS A" + //$NON-NLS-1$
- ") AS A"; //$NON-NLS-1$
-
- helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
- }
-
- /**
- * Test the query optimizer's ability to properly plan and optimize a query
- * that uses ambiguous alias names in the top level query and its sub-query
- * and uses columns belonging to the alias as a parameter to a function.
- * <p>
- * No source table is being used. For example, <code>SELECT CONVERT(A.e2,
- * biginteger) AS e2 FROM (SELECT CONVERT(e2, long) AS e2 FROM (SELECT 1 AS
- * e2) AS A) AS A</code>
- * <p>
- * The test is to ensure that A.e2 from the top level is not confused with
- * e2 in the second level.
- * <p>
- * Related Defects: JBEDSP-1137
- */
- @Test public void testAmbiguousAliasFunctionInSubQueryNoSource() {
- // Create query
- String sql = "SELECT CONVERT(A.e2, biginteger) AS e2 FROM (" + //$NON-NLS-1$
- " SELECT CONVERT(e2, long) AS e2 FROM (" + //$NON-NLS-1$
- " SELECT 5 AS e2" + //$NON-NLS-1$
- " ) AS A" + //$NON-NLS-1$
- ") AS A"; //$NON-NLS-1$
-
- helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {});
- }
-
- /**
- * Test the query optimizer's ability to properly plan and optimize a query
- * that uses ambiguous alias names in the top level query and its sub-query.
- * <p>
- * For example, <code>SELECT A.e2 FROM (SELECT e12FROM pm1.g1 AS A) AS A</code>
- * <p>
- * The test is to ensure that A.e2 from the top level is not confused with
- * e2 in the second level.
- * <p>
- * Related Defects: JBEDSP-1137
- */
- @Test public void testAmbiguousAliasInSubQuerySource() {
- // Create query
- String sql = "SELECT A.e2 AS e2 FROM (" + //$NON-NLS-1$
- " SELECT e2 AS e2 FROM pm1.g1 AS A" + //$NON-NLS-1$
- ") AS A"; //$NON-NLS-1$
-
- helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[] {"SELECT e2 FROM pm1.g1 AS A"}); //$NON-NLS-1$
- }
-
- /**
- * Test the query optimizer's ability to properly plan and optimize a query
- * that uses ambiguous alias names in the top level query and its sub-query
- * and uses columns belonging to the alias as a parameter to a function.
- * <p>
- * For example, <code>SELECT CONVERT(A.e2, biginteger) AS e2 FROM (SELECT
- * CONVERT(e2, long) AS e2 FROM pm1.g1 AS A) AS A</code>
- * <p>
- * The test is to ensure that A.e2 from the top level is not confused with
- * e2 in the second level.
- * <p>
- * Related Defects: JBEDSP-1137
- */
- @Test public void testAmbiguousAliasFunctionInSubQuerySource() {
- // Create query
- String sql = "SELECT CONVERT(A.e2, biginteger) AS e2 FROM (" + //$NON-NLS-1$
- " SELECT CONVERT(e2, long) AS e2 FROM pm1.g1 AS A" + //$NON-NLS-1$
- ") AS A"; //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- helpPlan(sql, metadata, new String[] {"SELECT e2 FROM pm1.g1 AS A"}); //$NON-NLS-1$
-
- // Add convert capability to pm1 and try it again
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- helpPlan(sql, metadata, null, capFinder,
- new String[] {"SELECT CONVERT(CONVERT(e2, long), biginteger) FROM pm1.g1 AS A"}, //$NON-NLS-1$
- SHOULD_SUCCEED );
- }
-
- public static final boolean DEBUG = false;
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestOptionalJoins.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,503 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import org.junit.Test;
-
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestOptionalJoins {
-
- @Test public void testOptionalJoinNode1() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode1_1() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1,pm2.g2.e1 FROM pm1.g1, /* optional */ pm2.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1", "SELECT pm2.g2.e1 FROM pm2.g2"} ); //$NON-NLS-1$//$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinNode2() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1, /* optional */ pm1.g2, pm1.g3", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g3 AS g_1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode3() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode3_1() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1, pm2.g2.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm2.g2 on pm1.g1.e1 = pm2.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e1 AS c_0 FROM pm2.g2 AS g_0 ORDER BY c_0", "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"} ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinNode4() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode5() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN /* optional */ pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g2 AS g_1 ON g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode6() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM (pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g3 AS g_1 ON g_0.e1 = g_1.e1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode7() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN pm1.g2 on pm1.g1.e1 = pm1.g2.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g3.e1 FROM pm1.g3"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode8() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ (select * from pm1.g2) as X on pm1.g1.e1 = x.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode9() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g2.e1 FROM pm1.g2, /* optional */ vm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g2.e1 FROM pm1.g2"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode10() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM /* optional */ vm1.g1, pm1.g1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode11() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g1.e1 FROM pm1.g1 LEFT OUTER JOIN /* optional */ vm1.g2 on pm1.g1.e1 = vm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode12() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM /* optional */ (pm1.g1 LEFT OUTER JOIN vm1.g1 on pm1.g1.e1 = vm1.g1.e1) LEFT OUTER JOIN pm1.g3 on pm1.g1.e1 = pm1.g3.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g3.e1 FROM pm1.g3"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode13() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT count(pm1.g1.e1) FROM pm1.g1 LEFT OUTER JOIN /* optional */ pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * The distinct prevents the removal of the optional join
- */
- @Test public void testOptionalJoinNode14() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT ve1 FROM vm1.g4", FakeMetadataFactory.example4(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 WHERE g_0.e1 IN (<dependent values>) ORDER BY c_0", "SELECT DISTINCT g_0.e1 AS c_0 FROM pm1.g2 AS g_0 ORDER BY c_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 1, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinNode15() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x.e1 FROM (select vm1.g1.e1, vm1.g2.e2 from vm1.g1 LEFT OUTER JOIN /* optional */vm1.g2 on vm1.g1.e2 = vm1.g2.e2) AS x", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g1.e1 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinNode16() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1, (select distinct e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY y, z) AS x", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT e2, e3 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinNode17() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT e3 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinWithIntersection() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM pm1.g3 inner join (select pm1.g1.e2 as y from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1) AS x on pm1.g3.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e1 FROM pm1.g3 AS g_0, pm1.g1 AS g_1, pm1.g2 AS g_2 WHERE (g_1.e1 = g_2.e1) AND (g_0.e2 = g_1.e2)"}, ComparisonMode.EXACT_COMMAND_STRING ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinWithNestedOrderBy() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM pm1.g3 inner join (select pm1.g2.e1, pm1.g1.e2 as y from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1 order by pm1.g2.e1 limit 10000) AS x on pm1.g3.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm1.g3 AS g_0 ORDER BY c_0", "SELECT g_0.e2 AS c_0 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1 ORDER BY g_1.e1"} ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Grouping will prevent the removal from happening
- */
- @Test public void testOptionalJoinWithGroupingOverAllColumns() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT pm1.g3.e1 FROM pm1.g3, (select max(pm1.g1.e4) y from /* optional */ pm1.g1, pm1.g2 where pm1.g1.e1 = pm1.g2.e1) AS x where pm1.g3.e2=x.y", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT g_0.e2, g_0.e1 FROM pm1.g3 AS g_0", "SELECT g_0.e4 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 = g_1.e1"} ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 3, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Union should prevent the removal from happening
- */
- @Test public void testOptionalJoinWithUnion() {
- ProcessorPlan plan = TestOptimizer.helpPlan("select pm1.g2.e4 from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1 union all select convert(pm1.g2.e2, double) from /* optional */ pm1.g1 inner join pm1.g2 on pm1.g1.e1 = pm1.g2.e1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT pm1.g2.e4 FROM pm1.g2", "SELECT pm1.g2.e2 FROM pm1.g2"} ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinWithCompoundCriteria() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT length(z) FROM /* optional */ pm1.g1 inner join (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x on pm1.g1.e2=x.y and concat(x.y, x.z) = '1'", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT e3 FROM pm1.g1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinWithDupRemoval() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT a.e1 from (SELECT distinct pm1.g1.e1, x.y FROM pm1.g1, /* optional */ (select e2 as y, e3 || 'x' as z from pm1.g1 ORDER BY z) AS x where pm1.g1.e2=x.y) as a", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] {"SELECT DISTINCT g_0.e2 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0", "SELECT DISTINCT g_0.e2 AS c_0, g_0.e1 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"} ); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // Join
- 1, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Cross Joins do not allow for join removal
- * This could be optimized though as an exists predicate
- */
- @Test public void testOptionalJoinWithoutHint_crossJoin() {
- ProcessorPlan plan = TestOptimizer
- .helpPlan(
- "SELECT distinct pm1.g1.e1 from pm1.g1, pm1.g2", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinWithoutHint_outerJoin() {
- ProcessorPlan plan = TestOptimizer
- .helpPlan(
- "SELECT distinct pm1.g1.e2 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT DISTINCT g_0.e2 FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testOptionalJoinWithoutHint_aggregate() {
- ProcessorPlan plan = TestOptimizer
- .helpPlan(
- "SELECT pm1.g1.e3, max(pm1.g1.e2) from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) group by pm1.g1.e3", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * The average agg will prevent the join removal
- */
- @Test public void testOptionalJoinWithoutHint_aggregate1() {
- ProcessorPlan plan = TestOptimizer
- .helpPlan(
- "SELECT pm1.g1.e3, avg(pm1.g1.e2) from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) group by pm1.g1.e3", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e3, g_0.e2 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g2 AS g_1 ON g_0.e1 = g_1.e1" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinWithoutHint_union() {
- ProcessorPlan plan = TestOptimizer
- .helpPlan(
- "SELECT pm1.g1.e3 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) union select 1", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e3 FROM pm1.g1 AS g_0" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Test public void testOptionalJoinWithOrderedLimit() {
- ProcessorPlan plan = TestOptimizer
- .helpPlan(
- "select distinct * from (SELECT pm1.g1.e3 from pm1.g1 left outer join pm1.g2 on (pm1.g1.e1 = pm1.g2.e1) order by e3 limit 10) x", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT g_0.e3 AS c_0 FROM pm1.g1 AS g_0 LEFT OUTER JOIN pm1.g2 AS g_1 ON g_0.e1 = g_1.e1 ORDER BY c_0" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // Join
- 0, // MergeJoin
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestPartitionedJoinPlanning.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestPartitionedJoinPlanning.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestPartitionedJoinPlanning.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,83 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright (C) 2009 Red Hat, Inc.
- * Licensed to Red Hat, Inc. under one or more contributor
- * license agreements. See the copyright.txt file in the
- * distribution for a full listing of individual contributors.
- *
- * 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 com.metamatrix.query.optimizer;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-
-import org.junit.Test;
-
-import com.metamatrix.common.buffer.BufferManager;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.PartitionedSortJoin;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-import com.metamatrix.query.unittest.FakeMetadataObject;
-
-public class TestPartitionedJoinPlanning {
-
- @Test public void testUsePartitionedMergeJoin(){
- // Create query
- String sql = "SELECT pm1.g1.e1 FROM pm1.g1, pm1.g2 WHERE pm1.g1.e1 = pm1.g2.e1";//$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, 100);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1();
- FakeMetadataObject g1 = metadata.getStore().findObject("pm1.g1", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g1.putProperty(FakeMetadataObject.Props.CARDINALITY, BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE);
- FakeMetadataObject g2 = metadata.getStore().findObject("pm1.g2", FakeMetadataObject.GROUP); //$NON-NLS-1$
- g2.putProperty(FakeMetadataObject.Props.CARDINALITY, BufferManager.DEFAULT_PROCESSOR_BATCH_SIZE * 16);
-
- ProcessorPlan plan = helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT pm1.g1.e1 FROM pm1.g1 ORDER BY pm1.g1.e1", "SELECT pm1.g2.e1 FROM pm1.g2" }, SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkNodeTypes(plan, new int[] {1}, new Class[] {PartitionedSortJoin.class});
- }
-
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleMergeVirtual.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,321 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static junit.framework.Assert.*;
-
-import org.junit.Test;
-
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.DefaultCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.processor.relational.SortNode;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestRuleMergeVirtual {
-
- @Test public void testSimpleMergeGroupBy() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT MAX(e2) AS x FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeGroupBy1() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT v_0.c_1 FROM (SELECT DISTINCT g_0.e1 AS c_0, MAX(g_0.e2) AS c_1 FROM pm1.g1 AS g_0 GROUP BY g_0.e1) AS v_0"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Same as above but all required symbols are selected
- */
- @Test public void testSimpleMergeGroupBy2() {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x, e1 FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- metadata, null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeGroupBy3() {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x, e1 FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- metadata, null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeGroupBy4() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x, x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT v_0.c_0, v_0.c_0 FROM (SELECT MAX(g_0.e2) AS c_0 FROM pm1.g1 AS g_0 GROUP BY g_0.e1) AS v_0"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeGroupBy5() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z where z.x = 1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT MAX(e2) AS x FROM pm1.g1 GROUP BY e1 HAVING MAX(e2) = 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeGroupBy6() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z where z.x = 1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT MAX(e2) AS x FROM pm1.g1 GROUP BY e1 HAVING MAX(e2) = 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeGroupBy7() {
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x, e1 FROM (SELECT distinct e1, max(e2) as x FROM pm1.g1 GROUP BY e1) AS z", //$NON-NLS-1$
- metadata, null, TestAggregatePushdown.getAggregatesFinder(),
- new String[] {
- "SELECT DISTINCT MAX(e2) AS x, e1 FROM pm1.g1 GROUP BY e1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeUnion() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {
- "SELECT '1' AS x FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeUnion1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {
- "SELECT '1' AS x FROM pm1.g1 UNION SELECT e1 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Same as above, but the expression will prevent the source removal
- */
- @Test public void testSimpleMergeUnion2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT distinct x || 'b' FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {
- "SELECT '1' AS x FROM pm1.g1 UNION ALL SELECT e1 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testSimpleMergeUnion3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT distinct x FROM (select '1' as x, e2 from pm1.g1 union all select e1, 1 from pm1.g2) x) y, pm1.g2", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {
- "SELECT '1' AS x FROM pm1.g1 UNION SELECT e1 FROM pm1.g2", "SELECT pm1.g2.e1, pm1.g2.e2, pm1.g2.e3, pm1.g2.e4 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testSimpleMergeWithLimit() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select * from (select e1 from pm1.g1 limit 1) x", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {
- "SELECT e1 FROM pm1.g1 LIMIT 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSimpleMergeWithLimit1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.ROW_LIMIT, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("select * from (select e1 from pm1.g1 limit 1) x order by e1", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {
- "SELECT e1 FROM pm1.g1 LIMIT 1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // Limit
- 0, // NestedLoopJoinStrategy
-
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 1, // Sort
- 0 // UnionAll
- }, TestLimit.NODE_TYPES);
- }
-
- /**
- * Note that the merge is not performed since it would create an expression in the group by clause
- */
- @Test public void testViewPreservationWithGroupByExpression() throws Exception {
- String sql = "SELECT gbl_date " + //$NON-NLS-1$
- "FROM " + //$NON-NLS-1$
- "(SELECT a.intkey as x, convert(a.TimestampValue, date) AS gbl_date, b.intkey as y " + //$NON-NLS-1$
- "FROM bqt1.smalla a INNER JOIN bqt1.smallb b on a.stringkey=b.stringkey) as z " + //$NON-NLS-1$
- "GROUP BY gbl_date"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT v_0.c_0 FROM (SELECT convert(g_0.TimestampValue, date) AS c_0 FROM bqt1.smalla AS g_0, bqt1.smallb AS g_1 WHERE g_0.stringkey = g_1.stringkey) AS v_0 GROUP BY v_0.c_0" }, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testSortAliasWithSameName() throws Exception {
- String sql = "select e1 from (select distinct pm1.g1.e1 as e1 from pm1.g1) x order by e1"; //$NON-NLS-1$
-
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] {"SELECT g_0.e1 FROM pm1.g1 AS g_0"}, capFinder, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- SortNode node = (SortNode)plan.getRootNode();
- assertTrue("Alias was not accounted for in sort node", node.getElements().containsAll(node.getSortElements())); //$NON-NLS-1$
- }
-
- @Test public void testMergeImplicitGroupBy() throws Exception {
- BasicSourceCapabilities caps = TestAggregatePushdown.getAggregateCapabilities();
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT x FROM (SELECT min(y), max(x) as x FROM (select e1 x, e2 + 1 y from pm1.g1) a) AS b", //$NON-NLS-1$
- FakeMetadataFactory.example1Cached(), null, new DefaultCapabilitiesFinder(caps),
- new String[] {
- "SELECT MAX(g_0.e1) FROM pm1.g1 AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRaiseNull.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,358 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import java.util.Arrays;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.processor.relational.RelationalPlan;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-
-public class TestRuleRaiseNull extends TestCase {
-
- public static final int[] FULLY_NULL = new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 1, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- };
-
- /**
- * Test that criteria will cause a branch of a union to be excised if the criteria renders it
- * impossible that the branch of the union would return results. In the following test,
- * each branch of the union projects a "null" in a different column. So, an equality criteria on
- * one of those columns should render one of the branches of the union unnecessary (since null
- * never equals anything). Expected behavior is that a NullNode is inserted in place of the
- * unnecessary access node.
- */
- public void testUnionCriteriaOptimization() {
-
- String sql = "select * from ( select intkey as cola, null as colb, intnum as colc from bqt1.smalla union all select null, intkey, intnum from bqt2.smalla) as X where X.cola = 1"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[] {"SELECT intkey, null, intnum FROM bqt1.smalla WHERE intkey = 1"} ); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- }
-
- public void testRaiseNullWithInnerJoin() {
- String sql = "select b.intkey from (select intkey from bqt1.smalla where 1 = 0) a inner join (select intkey from bqt1.smallb) b on (a.intkey = b.intkey)"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{});
- TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
- }
-
- public void testRaiseNullWithFullOuterJoin() {
- String sql = "select b.intkey from (select intkey from bqt1.smalla) a full outer join (select intkey from bqt1.smallb where 1 = 0) b on (a.intkey = b.intkey)"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT null FROM bqt1.smalla"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithOuterJoin() {
- String sql = "select b.intkey from (select intkey from bqt1.smalla) a left outer join (select intkey from bqt1.smallb where 1 = 0) b on (a.intkey = b.intkey)"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT null FROM bqt1.smalla"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithOuterJoin1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "select smallb.intkey, smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (1 = 2)"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[]{"SELECT null, bqt1.smalla.intkey FROM bqt1.smalla"}, true); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithUnion() {
- String sql = "select b.x from (select intkey as x from bqt1.smalla where 1 = 0 union all select intnum as y from bqt1.smalla) b"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT IntNum FROM bqt1.smalla"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
-
- assertEquals(Arrays.asList(new Object[] {new ElementSymbol("b.x")}), plan.getOutputElements()); //$NON-NLS-1$
- }
-
- public void testRaiseNullWithUnion1() {
- String sql = "select b.intkey from (select intkey from bqt1.smalla union all select intnum from bqt1.smalla where 1 = 0) b"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT intkey FROM bqt1.smalla"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithUnion2() {
- String sql = "select b.intkey, b.x from (select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select intnum as a, null from bqt1.smalla union all select 1 as z, intkey as b from bqt1.smallb) b"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT 1, intkey FROM bqt1.smallb", "SELECT IntNum, null FROM bqt1.smalla"}); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- public void testRaiseNullWithUnion3() {
- String sql = "select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select intnum, intkey as z from bqt1.smalla where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{});
- TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
- }
-
- public void testRaiseNullWithUnion4() throws Exception {
- String sql = "select b.intkey, b.x from (select intkey, intnum as x from bqt1.smalla where 1 = 0 union all select 1 as z, intkey as b from bqt1.smallb) b inner join bqt1.smalla on b.intkey = bqt1.smalla.intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT 1, g_0.intkey FROM bqt1.smallb AS g_0, bqt1.smalla AS g_1 WHERE g_1.IntKey = 1"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithUnion5() {
- String sql = "select intkey from bqt1.smalla union all select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT intkey FROM bqt1.smalla"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithUnion6() {
- String sql = "select intkey from bqt1.smalla union all select intkey from bqt2.smalla union all select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT intkey FROM bqt1.smalla", "SELECT intkey FROM bqt2.smalla"}); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- public void testPushCriteriaThroughUnion9() {
- TestOptimizer.helpPlan("select * from vm1.u8 where const = 's1'", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT 's1', e1 FROM pm1.g1" } ); //$NON-NLS-1$
- }
-
- public void testPushCriteriaThroughUnion10() {
- TestOptimizer.helpPlan("select * from vm1.u8 where const = 's3'", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { "SELECT 's3', e1 FROM pm1.g3" } ); //$NON-NLS-1$
- }
-
- public void testRaiseNullWithOuterJoinAndHaving() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "select smallb.intkey, smalla.intkey from bqt1.smalla left outer join bqt1.smallb on (1 = 2) group by smalla.intkey, smallb.intkey having max(smallb.intkey) = 1"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[]{"SELECT bqt1.smalla.intkey FROM bqt1.smalla"}, true); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Ensures proper handling of the removal of the first branch and
- * duplicate symbol names in the next branch
- */
- public void testRaiseNullWithUnion7() throws Exception {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_INLINE_VIEWS, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
-
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- String sql = "select max(intkey), intnum from (select intkey, intnum from bqt2.smalla where 1 = 0 union all select intnum, intnum from bqt2.smalla union all select intkey, stringkey from bqt2.smalla) x group by intnum"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(), null, capFinder,
- new String[]{"SELECT MAX(v_0.c_1), v_0.c_0 FROM (SELECT g_1.IntNum AS c_0, g_1.IntNum AS c_1 FROM bqt2.smalla AS g_1 UNION ALL SELECT g_0.StringKey AS c_0, g_0.IntKey AS c_1 FROM bqt2.smalla AS g_0) AS v_0 GROUP BY v_0.c_0"}, TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithUnionOrderBy() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_ORDERBY, true);
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleBQTCached();
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sql = "select intkey from bqt1.smalla where 1 = 0 union all select intnum from bqt2.smalla order by intkey"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata, null, capFinder,
- new String[]{"SELECT intnum AS intkey FROM bqt2.smalla ORDER BY intkey"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithGroupBy() {
- String sql = "select max(e2), e1 from pm1.g1 where 1 = 0 group by e1"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{});
-
- TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
- }
-
- public void testRaiseNullWithGroupBy1() {
- String sql = "select max(e2) from pm1.g1 where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{});
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 0, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 1, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- public void testRaiseNullWithExcept() {
- String sql = "select e1 from pm1.g1 except select e2 from pm1.g2 where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{"SELECT DISTINCT g_0.e1 FROM pm1.g1 AS g_0"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithIntersect() {
- String sql = "select max(e2) from pm1.g1 intersect select e2 from pm1.g2 where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(), new String[]{});
-
- TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
- }
-
- /**
- * This tests that a criteria with no elements is not pushed down,
- * but instead is cleaned up properly later
- * See defect 9865
- */
- public void testCrossJoinNoElementCriteriaOptimization() {
- ProcessorPlan plan = TestOptimizer.helpPlan("select Y.e1, Y.e2 FROM vm1.g1 X, vm1.g1 Y where {b'true'} = {b'false'}", TestOptimizer.example1(), //$NON-NLS-1$
- new String[0]);
- TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
- }
-
- public void testSelectLiteralFalseCriteria() {
- ProcessorPlan plan = TestOptimizer.helpPlan("Select 'x' from pm1.g1 where 1=0", TestOptimizer.example1(), //$NON-NLS-1$
- new String[] { });
- TestOptimizer.checkNodeTypes(plan, FULLY_NULL);
- }
-
- public void testRaiseNullWithUnionNotAll() {
- String sql = "select intkey from bqt2.smalla union select intkey from bqt2.smalla where 1 = 0"; //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, FakeMetadataFactory.exampleBQTCached(),
- new String[]{"SELECT DISTINCT intkey FROM bqt2.smalla"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- public void testRaiseNullWithUnionAndAliases() {
- String sql = "select pm1.g1.e1 from pm1.g1, (select e1 from pm1.g1 where (1 = 0) union all select e1 as x from pm1.g2) x where pm1.g1.e1 <> x.e1"; //$NON-NLS-1$
-
- RelationalPlan plan = (RelationalPlan)TestOptimizer.helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[]{"SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE g_0.e1 <> g_1.e1"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRemoveSorts.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRemoveSorts.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestRuleRemoveSorts.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.query.optimizer.TestOptimizer.ComparisonMode;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestRuleRemoveSorts extends TestCase {
-
- /** Tests an order by in a query transformation */
- public void testRemovedOrderByFromQueryTransform() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1, e2 FROM vm1.g14", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT pm3.g1.e1, pm3.g1.e2 FROM pm3.g1"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Tests an order by in a query transformation, where the
- * physical model does not support pushing order bys
- */
- public void testRemovedOrderByFromQueryTransform2() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e, e2 FROM vm1.g8", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Tests an order by in a query transformation, where the
- * query transformation contains a function
- */
- public void testRemovedOrderByFromQueryTransform3() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e, e2 FROM vm1.g16", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm3.g1"}); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Tests an order by in a query transformation */
- public void testRemovedOrderByFromQueryTransform4() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT e1, e2 FROM vm1.g13", FakeMetadataFactory.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$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /** Order by is not removed */
- public void testOrderByWithLimit() throws Exception {
- ProcessorPlan plan = TestOptimizer.helpPlan("select * from (SELECT e1, e2 FROM pm1.g1 order by e1 limit 10) x", FakeMetadataFactory.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$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSortOptimization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSortOptimization.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSortOptimization.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,171 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-
-import org.junit.Test;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestSortOptimization {
-
- @Test public void testSortDupCombination() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Create query
- String sql = "select distinct e1, e2 from pm1.g1 order by e2"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, FULL_PUSHDOWN);
- checkNodeTypes(plan, new int[] {1}, new Class[] {DupRemoveSortNode.class});
- }
-
- @Test public void testSortDupCombination1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Create query
- String sql = "select e1, e2 from pm1.g1 union select e1, e2 from pm1.g2 order by e2"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1", "SELECT e1, e2 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- checkNodeTypes(plan, new int[] {1}, new Class[] {DupRemoveSortNode.class});
- }
-
- @Test public void testSortDupCombination2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Create query
- String sql = "select x.*, y.* from (select distinct e1, e2 from pm1.g1) x, (select distinct e1, e2 from pm1.g2) y where x.e1 = y.e1"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT e1, e2 FROM pm1.g1", "SELECT e1, e2 FROM pm1.g2"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
-
- checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 1, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkNodeTypes(plan, new int[] {0}, new Class[] {DupRemoveSortNode.class});
- }
-
- @Test public void testGroupDupCombination() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Create query
- String sql = "select max(e1), e2 from (select distinct e1, e2 from pm1.g1) x group by e2"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT pm1.g1.e1, pm1.g1.e2 FROM pm1.g1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkNodeTypes(plan, new int[] {0}, new Class[] {DupRemoveSortNode.class});
- }
-
- @Test public void testSortGroupCombination() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- // Create query
- String sql = "select max(e1), e2 from pm1.g1 x group by e2 order by e2"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(), null, capFinder,
- new String[] {"SELECT pm1.g1.e2, pm1.g1.e1 FROM pm1.g1"}, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$
-
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- checkNodeTypes(plan, new int[] {0}, new Class[] {DupRemoveSortNode.class});
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestStoredProcedurePlanning.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,415 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import org.junit.Ignore;
-import org.junit.Test;
-
-import com.metamatrix.query.metadata.TempMetadataAdapter;
-import com.metamatrix.query.metadata.TempMetadataStore;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestStoredProcedurePlanning {
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 1a
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery1() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery2() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 1b
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery3() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq2('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery4() {
- ProcessorPlan plan = TestOptimizer.helpPlan("select x.e1 from (EXEC pm1.sq1()) as x", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testStoredQuery5() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testStoredQuery6() {
- ProcessorPlan plan = TestOptimizer.helpPlan("select x.e1 from (EXEC pm1.sp1()) as x", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery7() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sqsp1()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp1()" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 1c
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery8() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq3('1', 1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'", "SELECT e1, e2 FROM pm1.g1 WHERE e2 = 1" }); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 5a
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery9() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq4()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] {"SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 5b
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery10() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq5('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'"}); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 5c
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery11() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq6()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] {"SELECT e1, e2 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 6a
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery12() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq7()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 6c
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery13() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq8('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 6b
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery14() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq9('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1 WHERE e1 = '1'" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 6d
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery15() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq10('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- /**
- * Test planning stored queries.
- */
- @Test public void testStoredQuery16() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp2(1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp2(1)" }); //$NON-NLS-1$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Test planning stored queries. GeminiStoredQueryTestPlan - 6d
- */
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery17() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq11(1, 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp2(?)" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 1, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- //GeminiStoredQueryTestPlan - 2a, 2b
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery18() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq12('1', 1)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 1)" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- //GeminiStoredQueryTestPlan - 2c
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery19() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq13('1')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 2)" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- //GeminiStoredQueryTestPlan - 3c
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery20() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq14('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "UPDATE pm1.g1 SET e1 = '1' WHERE e2 = 2" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- //GeminiStoredQueryTestPlan - 4b
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery21() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq15('1', 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery22() {
- ProcessorPlan plan = TestOptimizer.helpPlan("select e1 from (EXEC pm1.sq1()) as x where e1='a' union (select e1 from vm1.g2 where e1='b')", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE g_0.e1 = 'a'", "SELECT g_0.e1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 WHERE (g_0.e1 = g_1.e1) AND (g_0.e1 = 'b') AND (g_1.e1 = 'b')" }); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery23() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq16()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "INSERT INTO pm1.g1 (e1, e2) VALUES ('1', 2)" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testStoredQuery24() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sp3()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp3()" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- // test implicit type conversion of argument
- @Ignore("stored procedure wrapper removal logic has been removed")
- @Test public void testStoredQuery25() {
- ProcessorPlan plan = TestOptimizer.helpPlan("EXEC pm1.sq15(1, 2)", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "DELETE FROM pm1.g1 WHERE (e1 = '1') AND (e2 = 2)" }); //$NON-NLS-1$
-
- TestOptimizer.checkNodeTypes(plan, TestOptimizer.FULL_PUSHDOWN);
- }
-
- @Test public void testStoredQueryXML1() {
- TestOptimizer.helpPlan("EXEC pm1.sq18()", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), new String[] { }); //$NON-NLS-1$
- }
-
- /**
- * union of two stored procs - case #1466
- */
- @Test public void testStoredProc1() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT * FROM (EXEC pm1.sp2(1)) AS x UNION ALL SELECT * FROM (EXEC pm1.sp2(2)) AS y", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp2(1)", "EXEC pm1.sp2(2)" }); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 4, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- /**
- * union of stored proc and query - case #1466
- */
- @Test public void testStoredProc2() {
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT * FROM (EXEC pm1.sp2(1)) AS x UNION ALL SELECT e1, e2 FROM pm1.g1", new TempMetadataAdapter(FakeMetadataFactory.example1Cached(), new TempMetadataStore()), //$NON-NLS-1$
- new String[] { "EXEC pm1.sp2(1)", "SELECT e1, e2 FROM pm1.g1" }); //$NON-NLS-1$ //$NON-NLS-2$
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestSubqueryPushdown.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,715 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-
-import org.junit.Test;
-import org.teiid.resource.cci.SourceSystemFunctions;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFacade;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestSubqueryPushdown {
-
- @Test public void testPushSubqueryBelowVirtual() throws Exception {
- String sql = "select g3.e1 from (select e1, max(e2) y from pm1.g1 group by e1) x, pm1.g3 where exists (select e1 from pm1.g2 where x.e1 = e1)"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g1 AS g_0 WHERE EXISTS (SELECT g_1.e1 FROM pm1.g2 AS g_1 WHERE g_1.e1 = g_0.e1)", //$NON-NLS-1$
- "SELECT g_0.e1 FROM pm1.g3 AS g_0" }, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Same as above, but using a correlated variable based on an aggregate
- * @throws Exception
- */
- @Test public void testDontPushSubqueryBelowVirtual() throws Exception {
- String sql = "select g3.e1 from (select e1, max(e2) y from pm1.g1 group by e1) x, pm1.g3 where exists (select e1 from pm1.g2 where x.y = e1)"; //$NON-NLS-1$
-
- // Create capabilities
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.CRITERIA_EXISTS, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- FakeMetadataFacade metadata = FakeMetadataFactory.example1Cached();
-
- // Plan query
- ProcessorPlan plan = TestOptimizer.helpPlan(sql, metadata,
- null, capFinder,
- new String[] { "SELECT g_0.e1 FROM pm1.g3 AS g_0", //$NON-NLS-1$
- "SELECT g_0.e1, g_0.e2 FROM pm1.g1 AS g_0" }, //$NON-NLS-1$
- TestOptimizer.ComparisonMode.EXACT_COMMAND_STRING);
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 1, // Grouping
- 1, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 2, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushCorrelatedSubquery1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey)" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushCorrelatedSubquery2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sqlIn =
- "SELECT c37n.intkey " + //$NON-NLS-1$
- "FROM bqt1.mediuma AS c37n, bqt1.smallb AS m37n " + //$NON-NLS-1$
- "WHERE (m37n.stringkey LIKE '%0') AND " + //$NON-NLS-1$
- "(c37n.stringkey = ('1' || (m37n.intkey || '0'))) AND " + //$NON-NLS-1$
- "(c37n.datevalue = (" + //$NON-NLS-1$
- "SELECT MAX(c37s.datevalue) " + //$NON-NLS-1$
- "FROM bqt1.mediuma AS c37s, bqt1.smallb AS m37s " + //$NON-NLS-1$
- "WHERE (m37s.stringkey LIKE '%0') AND " + //$NON-NLS-1$
- "(c37s.stringkey = ('1' || (m37s.intkey || '0'))) AND " + //$NON-NLS-1$
- "(m37s.stringkey = m37n.stringkey) ))"; //$NON-NLS-1$
-
- String sqlOut = "SELECT g_0.intkey FROM bqt1.mediuma AS g_0, bqt1.smallb AS g_1 WHERE (g_0.stringkey = concat('1', concat(g_1.intkey, '0'))) AND (g_0.datevalue = (SELECT MAX(g_2.datevalue) FROM bqt1.mediuma AS g_2, bqt1.smallb AS g_3 WHERE (g_2.stringkey = concat('1', concat(g_3.intkey, '0'))) AND (g_3.stringkey LIKE '%0') AND (g_3.stringkey = g_1.stringkey))) AND (g_1.stringkey LIKE '%0')"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sqlIn, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { sqlOut }, SHOULD_SUCCEED);
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- @Test public void testPushCorrelatedSubquery3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_LIKE, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_INNER, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_JOIN_SELFJOIN, true);
- caps.setFunctionSupport("||", true); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- String sqlIn =
- "SELECT intkey " + //$NON-NLS-1$
- "FROM vqt.smalla AS e " + //$NON-NLS-1$
- "WHERE (stringkey = 'VOD.L') AND " + //$NON-NLS-1$
- "(datevalue = (" + //$NON-NLS-1$
- "SELECT MAX(datevalue) " + //$NON-NLS-1$
- "FROM vqt.smalla " + //$NON-NLS-1$
- "WHERE (stringkey = e.stringkey) ))"; //$NON-NLS-1$
-
- String sqlOut =
- "SELECT SmallA__1.IntKey FROM BQT1.SmallA AS SmallA__1 WHERE (SmallA__1.StringKey = 'VOD.L') AND (SmallA__1.DateValue = (SELECT MAX(BQT1.SmallA.DateValue) FROM BQT1.SmallA WHERE BQT1.SmallA.StringKey = SmallA__1.StringKey))"; //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan(sqlIn, FakeMetadataFactory.exampleBQTCached(),
- null, capFinder,
- new String[] { sqlOut }, SHOULD_SUCCEED);
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /**
- * Check that scalar subquery in select is pushed
- */
- public void DEFER_testPushSubqueryInSelectClause1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT stringkey, (SELECT intkey FROM BQT1.SmallA AS b WHERE Intnum = 22) FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT stringkey, (SELECT intkey FROM BQT1.SmallA AS b WHERE Intnum = 22) FROM BQT1.SmallA" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCorrelatedSubquery1() {
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1 WHERE pm1.g1.e2 = pm2.g1.e2)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, pm1.g1.e2 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCorrelatedSubquery2() {
- ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 WHERE pm1.g1.e2 = pm2.g1.e2) from pm1.g1", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, pm1.g1.e2 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 1, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer1() {
- ProcessorPlan plan = helpPlan("Select e1 from vm1.g6 where e1 in (select e1 FROM pm2.g1 WHERE vm1.g6.e3 = pm2.g1.e2)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer2() {
- ProcessorPlan plan = helpPlan("Select e1 from vm1.g6 where e1 in (select e1 FROM pm2.g1 WHERE vm1.g6.e4 = pm2.g1.e4)", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2, e4 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCorrelatedSubqueryVirtualLayer3() {
- ProcessorPlan plan = helpPlan("Select e1, (select e1 FROM pm2.g1 WHERE vm1.g6.e4 = pm2.g1.e4) from vm1.g6", example1(), //$NON-NLS-1$
- new String[] { "SELECT e1, e2, e4 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 1, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testCorrelatedSubqueryInTransformation2() {
- String sql = "Select * from vm1.g20"; //$NON-NLS-1$
- ProcessorPlan plan = helpPlan(sql, FakeMetadataFactory.example1Cached(),
- new String[] { "SELECT pm1.g1.e1, pm1.g1.e2, pm1.g1.e3, pm1.g1.e4 FROM pm1.g1" }); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery cannot all be pushed to the source.
- */
- @Test public void testNoPushSubqueryInWhereClause1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select max(e1) FROM pm1.g2)", example1(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery is from a different model
- * than the outer query.
- */
- @Test public void testNoPushSubqueryInWhereClause2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", getTypicalCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select e1 FROM pm2.g1)", example1(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Do not support XML query as subquery
- * Check that subquery is not pushed if the subquery is not relational.
- */
- public void defer_testNoPushSubqueryInWhereClause3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (select * from xmltest.doc1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery has a function that can't be pushed
- * in the SELECT clause
- */
- @Test public void testNoPushSubqueryInWhereClause4() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT ltrim(e1) FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery selects a constant value
- */
- @Test public void testNoPushSubqueryInWhereClause5() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT 'xyz' FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery does ORDER BY
- */
- @Test public void testNoPushSubqueryInWhereClause6() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT e1 FROM pm1.g2 ORDER BY e1 limit 2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery has a function that can't be pushed
- * in the SELECT clause
- */
- @Test public void testNoPushSubqueryInWhereClause7() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setFunctionSupport("ltrim", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT rtrim(ltrim(e1)) FROM pm1.g2)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery holds non-query access node.
- */
- @Test public void testNoPushSubqueryInWhereClause8() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("pm2", new BasicSourceCapabilities()); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (EXEC pm1.sqsp1())", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- /**
- * Check that subquery is not pushed if the subquery is correlated and correlated not supported
- */
- @Test public void testNoPushSubqueryInWhereClause9() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, false);
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("Select e1 from pm1.g1 where e1 in (SELECT pm1.g2.e1 FROM pm1.g2 WHERE pm1.g2.e1 = pm1.g1.e1)", FakeMetadataFactory.example1Cached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT e1 FROM pm1.g1" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, new int[] {
- 1, // Access
- 0, // DependentAccess
- 1, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 1, // Project
- 0, // Select
- 0, // Sort
- 0 // UnionAll
- });
- }
-
- @Test public void testPushMultipleCorrelatedSubquery1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = new BasicSourceCapabilities();
- caps.setCapabilitySupport(Capability.CRITERIA_OR, true);
- caps.setCapabilitySupport(Capability.CRITERIA_COMPARE_EQ, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_ALL, true);
- caps.setCapabilitySupport(Capability.CRITERIA_QUANTIFIED_SOME, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN, true);
- caps.setCapabilitySupport(Capability.CRITERIA_IN_SUBQUERY, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MIN, true);
- caps.setCapabilitySupport(Capability.QUERY_FROM_GROUP_ALIAS, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("SELECT intkey FROM bqt1.smalla AS n WHERE intkey = (SELECT MAX(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey ) or intkey = (SELECT MIN(intkey) FROM bqt1.smallb AS s WHERE s.stringkey = n.stringkey )", FakeMetadataFactory.exampleBQTCached(), //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT g_0.intkey FROM bqt1.smalla AS g_0 WHERE (g_0.intkey = (SELECT MAX(g_1.intkey) FROM bqt1.smallb AS g_1 WHERE g_1.stringkey = g_0.stringkey)) OR (g_0.intkey = (SELECT MIN(g_2.IntKey) FROM bqt1.smallb AS g_2 WHERE g_2.StringKey = g_0.stringkey))" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
- /*
- * Expressions containing subqueries can be pushed down
- */
- @Test public void testProjectSubqueryPushdown() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- FakeMetadataFacade metadata = example1();
-
- BasicSourceCapabilities caps = getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_CORRELATED, true);
- caps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_SCALAR, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES, true);
- caps.setCapabilitySupport(Capability.QUERY_AGGREGATES_MAX, true);
- caps.setFunctionSupport("+", true); //$NON-NLS-1$
- caps.setFunctionSupport("convert", true); //$NON-NLS-1$
- capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = helpPlan("select pm1.g1.e1, convert((select max(vm1.g1.e1) from vm1.g1), integer) + 1 from pm1.g1", metadata, //$NON-NLS-1$
- null, capFinder,
- new String[] { "SELECT g_0.e1, (convert((SELECT MAX(g_1.e1) FROM pm1.g1 AS g_1), integer) + 1) FROM pm1.g1 AS g_0" }, SHOULD_SUCCEED); //$NON-NLS-1$
- checkNodeTypes(plan, FULL_PUSHDOWN);
- }
-
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestUnionPlanning.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestUnionPlanning.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/TestUnionPlanning.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer;
-
-import com.metamatrix.query.optimizer.capabilities.BasicSourceCapabilities;
-import com.metamatrix.query.optimizer.capabilities.FakeCapabilitiesFinder;
-import com.metamatrix.query.optimizer.capabilities.SourceCapabilities.Capability;
-import com.metamatrix.query.processor.ProcessorPlan;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-import junit.framework.TestCase;
-
-public class TestUnionPlanning extends TestCase {
-
- public void testUnionPushDown() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
- new String[] { "SELECT IntNum FROM BQT2.SmallA", "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 2, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 1 // UnionAll
- });
- }
-
- /**
- * Here the change in the all causes us not to pushdown
- */
- public void testUnionPushDown1() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
- new String[] { "SELECT IntNum FROM BQT2.SmallA", "SELECT IntKey FROM BQT1.SmallA", "SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 1, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 2 // UnionAll
- });
- }
-
- public void testUnionPushDown2() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
- capFinder.addCapabilities("BQT3", caps1); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT3.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
- new String[] { "SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA", "SELECT IntNum FROM BQT3.SmallA", "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 2 // UnionAll
- });
- }
-
- public void testUnionPushDown3() {
- FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
- BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
- caps.setCapabilitySupport(Capability.QUERY_UNION, true);
- caps.setCapabilitySupport(Capability.QUERY_SELECT_EXPRESSION, true);
- capFinder.addCapabilities("BQT1", caps); //$NON-NLS-1$
- capFinder.addCapabilities("BQT2", caps); //$NON-NLS-1$
- BasicSourceCapabilities caps1 = TestOptimizer.getTypicalCapabilities();
- capFinder.addCapabilities("BQT3", caps1); //$NON-NLS-1$
-
- ProcessorPlan plan = TestOptimizer.helpPlan("SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT3.SmallA UNION ALL (SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA)", FakeMetadataFactory.exampleBQTCached(), null, capFinder,//$NON-NLS-1$
- new String[] { "SELECT IntNum FROM BQT3.SmallA", "SELECT IntNum FROM BQT2.SmallA UNION ALL (SELECT IntNum FROM BQT2.SmallA UNION ALL SELECT IntNum FROM BQT2.SmallA)", "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA" }, TestOptimizer.SHOULD_SUCCEED); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- TestOptimizer.checkNodeTypes(plan, new int[] {
- 3, // Access
- 0, // DependentAccess
- 0, // DependentSelect
- 0, // DependentProject
- 0, // DupRemove
- 0, // Grouping
- 0, // NestedLoopJoinStrategy
- 0, // MergeJoinStrategy
- 0, // Null
- 0, // PlanExecution
- 0, // Project
- 0, // Select
- 0, // Sort
- 2 // UnionAll
- });
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestAliasGenerator.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,152 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer.relational;
-
-import static org.junit.Assert.*;
-
-import org.junit.Test;
-
-import com.metamatrix.api.exception.MetaMatrixComponentException;
-import com.metamatrix.api.exception.MetaMatrixProcessingException;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.parser.QueryParser;
-import com.metamatrix.query.resolver.TestResolver;
-import com.metamatrix.query.rewriter.QueryRewriter;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.sql.lang.Query;
-import com.metamatrix.query.sql.symbol.ElementSymbol;
-import com.metamatrix.query.sql.symbol.GroupSymbol;
-import com.metamatrix.query.sql.symbol.SingleElementSymbol;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestAliasGenerator {
-
- private Command helpTest(String sql,
- String expected,
- boolean aliasGroups,
- QueryMetadataInterface metadata) throws MetaMatrixComponentException, MetaMatrixProcessingException {
- Command command = TestResolver.helpResolve(sql, metadata, null);
- command = QueryRewriter.rewrite(command, metadata, null);
- command.acceptVisitor(new AliasGenerator(aliasGroups));
- assertEquals(expected, command.toString());
- return command;
- }
-
- /**
- * Ensures that views are named with v_ even without metadata
- */
- @Test public void testViewAliasing() throws Exception {
- String sql = "select y.e1 from (select pm1.g1.e1 from pm1.g1) y"; //$NON-NLS-1$
- Query command = (Query)QueryParser.getQueryParser().parseCommand(sql);
- ((ElementSymbol)command.getSelect().getSymbol(0)).setGroupSymbol(new GroupSymbol("y")); //$NON-NLS-1$
- command.acceptVisitor(new AliasGenerator(true));
- assertEquals("SELECT v_0.c_0 FROM (SELECT pm1.g1.e1 AS c_0 FROM pm1.g1 AS g_0) AS v_0", command.toString()); //$NON-NLS-1$
- }
-
- @Test public void testLongOrderByAlias() throws Exception {
- String sql = "select pm1.g1.e1 || pm1.g1.e2 as asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa, pm1.g1.e2 from pm1.g1 order by asfasdfadfasdfasdfadfasdfadsfasdfasdfasdfasdfasdfadfa"; //$NON-NLS-1$
- String expected = "SELECT concat(g_0.e1, g_0.e2) AS c_0, g_0.e2 AS c_1 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
- }
-
- @Test public void testOrderBySymbolName() throws Exception {
- String sql = "select e1 from pm1.g1 order by e1"; //$NON-NLS-1$
- String expected = "SELECT g_0.e1 AS c_0 FROM pm1.g1 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- Query command = (Query)helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
- assertEquals(command.getOrderBy().getSortKeys().get(0).getName(), "e1"); //$NON-NLS-1$
- assertEquals(((SingleElementSymbol)command.getProjectedSymbols().get(0)).getShortName(), "e1"); //$NON-NLS-1$
- }
-
- @Test public void testInlineViewWithSubQuery() throws Exception {
- String sql = "select intnum from (select intnum from bqt1.smallb where intnum in (select intnum a from bqt1.smalla)) b"; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT g_1.intnum FROM bqt1.smalla AS g_1)) AS v_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testInlineViewOrderBy() throws Exception {
- String sql = "select intnum from (select intnum from bqt1.smallb) b order by b.intnum"; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testNestedInlineViewOrderBy() throws Exception {
- String sql = "select x from (select intnum x from (select intnum from bqt1.smallb) b order by x) y order by x"; //$NON-NLS-1$
- String expected = "SELECT v_1.c_0 FROM (SELECT v_0.c_0 FROM (SELECT g_0.intnum AS c_0 FROM bqt1.smallb AS g_0) AS v_0) AS v_1 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testInlineViewWithOnClause() throws Exception {
- String sql = "select abcd.efg from (select intkey as efg from bqt1.smalla) abcd inner join (select intnum from bqt1.smallb) b on (b.intnum = abcd.efg)"; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0 FROM (SELECT g_0.intkey AS c_0 FROM bqt1.smalla AS g_0) AS v_0 INNER JOIN (SELECT g_1.intnum AS c_0 FROM bqt1.smallb AS g_1) AS v_1 ON v_1.c_0 = v_0.c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testUnionOrderBy() throws Exception {
- String sql = "select e1, e2 as c_0 from pm1.g1 union all select 1, e1 from pm1.g2 order by e1"; //$NON-NLS-1$
- String expected = "SELECT g_1.e1 AS c_0, g_1.e2 AS c_1 FROM pm1.g1 AS g_1 UNION ALL SELECT '1' AS c_0, g_0.e1 AS c_1 FROM pm1.g2 AS g_0 ORDER BY c_0"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
- }
-
- @Test public void testDuplicateShortElementName() throws Exception {
- String sql = "select pm1.g1.e1, pm1.g2.e1 from pm1.g1, pm1.g2 order by pm1.g1.e1, pm1.g2.e1"; //$NON-NLS-1$
- String expected = "SELECT g_0.e1 AS c_0, g_1.e1 AS c_1 FROM pm1.g1 AS g_0, pm1.g2 AS g_1 ORDER BY c_0, c_1"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.example1Cached());
- }
-
- @Test public void testCorrelatedRefernce() throws Exception {
- String sql = "select intnum, stringnum from (select intnum, stringnum from bqt1.smallb) b where intnum in (select b.stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
- String expected = "SELECT v_0.c_0, v_0.c_1 FROM (SELECT g_0.intnum AS c_0, g_0.stringnum AS c_1 FROM bqt1.smallb AS g_0) AS v_0 WHERE v_0.c_0 IN (SELECT concat(v_0.c_1, v_1.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_1)"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testCorrelatedRefernce1() throws Exception {
- String sql = "select intnum, stringnum from bqt1.smallb where intnum in (select stringnum || b.intnum from (select intnum from bqt1.smalla) b) "; //$NON-NLS-1$
- String expected = "SELECT g_0.intnum, g_0.stringnum FROM bqt1.smallb AS g_0 WHERE g_0.intnum IN (SELECT concat(g_0.stringnum, v_0.c_0) FROM (SELECT g_1.intnum AS c_0 FROM bqt1.smalla AS g_1) AS v_0)"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testGroupAliasNotSupported() throws Exception {
- String sql = "select b.intkey from bqt1.smalla b"; //$NON-NLS-1$
- String expected = "SELECT bqt1.smalla.intkey FROM bqt1.smalla"; //$NON-NLS-1$
- helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testUnionAliasing() throws Exception {
- String sql = "SELECT IntKey FROM BQT1.SmallA UNION ALL SELECT IntNum FROM BQT1.SmallA"; //$NON-NLS-1$
- String expected = "SELECT BQT1.SmallA.IntKey AS c_0 FROM BQT1.SmallA UNION ALL SELECT BQT1.SmallA.IntNum AS c_0 FROM BQT1.SmallA"; //$NON-NLS-1$
- helpTest(sql, expected, false, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testUnrelatedOrderBy() throws Exception {
- String sql = "SELECT b.IntKey FROM BQT1.SmallA a, BQT1.SmallA b ORDER BY a.StringKey"; //$NON-NLS-1$
- String expected = "SELECT g_1.IntKey AS c_0 FROM BQT1.SmallA AS g_0, BQT1.SmallA AS g_1 ORDER BY g_0.StringKey"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
- @Test public void testUnrelatedOrderBy1() throws Exception {
- String sql = "SELECT b.IntKey FROM (select intkey, stringkey from BQT1.SmallA) a, (select intkey, stringkey from BQT1.SmallA) b ORDER BY a.StringKey"; //$NON-NLS-1$
- String expected = "SELECT v_1.c_0 FROM (SELECT g_0.intkey AS c_0, g_0.stringkey AS c_1 FROM BQT1.SmallA AS g_0) AS v_0, (SELECT g_1.intkey AS c_0, g_1.stringkey AS c_1 FROM BQT1.SmallA AS g_1) AS v_1 ORDER BY v_0.c_1"; //$NON-NLS-1$
- helpTest(sql, expected, true, FakeMetadataFactory.exampleBQTCached());
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestMaterialization.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,141 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer.relational;
-
-import static com.metamatrix.query.optimizer.TestOptimizer.*;
-import static org.junit.Assert.*;
-
-import java.util.Collection;
-
-import org.junit.Ignore;
-import org.junit.Test;
-import org.teiid.client.plan.Annotation;
-
-import com.metamatrix.query.analysis.AnalysisRecord;
-import com.metamatrix.query.metadata.QueryMetadataInterface;
-import com.metamatrix.query.optimizer.TestOptimizer;
-import com.metamatrix.query.sql.lang.Command;
-import com.metamatrix.query.unittest.FakeMetadataFactory;
-
-public class TestMaterialization {
-
- @Test public void testMaterializedTransformation() throws Exception {
- String userSql = "SELECT MATVIEW.E1 FROM MATVIEW"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection<Annotation> annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- @Ignore("we no longer auto detect this case, if we need this logic it will have to be added to the rewriter since it changes select into to an insert")
- @Test public void testMaterializedTransformationLoading() throws Exception {
- String userSql = "SELECT MATVIEW.E1 INTO MatTable.MatStage FROM MATVIEW"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection<Annotation> annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- @Test public void testMaterializedTransformationNoCache() throws Exception {
- String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE MatView.MatView"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection<Annotation> annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- //related to defect 14423
- @Test public void testMaterializedTransformationNoCache2() throws Exception {
- String userSql = "SELECT MATVIEW.E1 FROM MATVIEW OPTION NOCACHE"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
-
- Collection<Annotation> annotations = analysis.getAnnotations();
- assertNotNull("Expected annotations but got none", annotations); //$NON-NLS-1$
- assertTrue("Expected one annotation", annotations.size() == 1); //$NON-NLS-1$
- assertEquals("Expected catagory mat view", annotations.iterator().next().getCategory(), Annotation.MATERIALIZED_VIEW); //$NON-NLS-1$
- }
-
- @Test public void testNoCacheInTransformation() throws Exception {
- String userSql = "SELECT VGROUP.E1 FROM VGROUP"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testTableNoCacheDoesntCascade() throws Exception {
- String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache matview.matview1"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.e1 FROM MatTable.MatTable AS g_0 WHERE g_0.e1 = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
- @Test public void testNoCacheCascade() throws Exception {
- String userSql = "SELECT MATVIEW1.E1 FROM MATVIEW1 option nocache"; //$NON-NLS-1$
-
- QueryMetadataInterface metadata = FakeMetadataFactory.exampleMaterializedView();
- AnalysisRecord analysis = new AnalysisRecord(true, DEBUG);
-
- Command command = helpGetCommand(userSql, metadata, null);
-
- TestOptimizer.helpPlanCommand(command, metadata, getGenericFinder(), analysis, new String[] {"SELECT g_0.x FROM MatSrc.MatSrc AS g_0 WHERE g_0.x = '1'"}, ComparisonMode.EXACT_COMMAND_STRING); //$NON-NLS-1$
- }
-
-}
Deleted: trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestRuleStack.java
===================================================================
--- trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestRuleStack.java 2010-05-11 21:47:57 UTC (rev 2116)
+++ trunk/engine/src/test/java/com/metamatrix/query/optimizer/relational/TestRuleStack.java 2010-05-11 22:01:58 UTC (rev 2117)
@@ -1,99 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package com.metamatrix.query.optimizer.relational;
-
-import junit.framework.TestCase;
-
-import com.metamatrix.query.optimizer.relational.rules.RuleConstants;
-import com.metamatrix.query.optimizer.relational.rules.RulePushSelectCriteria;
-
-/**
- */
-public class TestRuleStack extends TestCase {
-
- /**
- * Constructor for TestRuleStack.
- * @param arg0
- */
- public TestRuleStack(String arg0) {
- super(arg0);
- }
-
-
- public void testInitialization() {
- RuleStack stack = new RuleStack();
- assertEquals("Initial stack is not empty", true, stack.isEmpty()); //$NON-NLS-1$
- assertEquals("Initial size is not 0", 0, stack.size()); //$NON-NLS-1$
- assertNull("Top is not null", stack.pop()); //$NON-NLS-1$
- }
-
- public void helpTestPop(RuleStack stack, OptimizerRule expectedPop, int expectedSize) {
- OptimizerRule out = stack.pop();
- int outSize = stack.size();
-
- assertSame("Did not get same object", expectedPop, out); //$NON-NLS-1$
- assertEquals("Stack changed size", expectedSize, outSize); //$NON-NLS-1$
- }
-
- public void testPopOneRule() {
- RuleStack stack = new RuleStack();
- int expectedSize = stack.size();
-
- OptimizerRule rule = new RulePushSelectCriteria();
- stack.push(rule);
-
- helpTestPop(stack, rule, expectedSize);
- }
-
- public void testPopNothing() {
- RuleStack stack = new RuleStack();
- helpTestPop(stack, null, 0);
- }
-
- public void testRemove() {
- // Set up
- RuleStack stack = new RuleStack();
- stack.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
- stack.push(RuleConstants.COLLAPSE_SOURCE);
- stack.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
-
- // Remove all instances of ASSIGN_OUTPUT_ELEMENTS
- stack.remove(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
-
- // Verify size and pop'ed values
- assertEquals(1, stack.size());
- assertEquals(RuleConstants.COLLAPSE_SOURCE, stack.pop());
- assertEquals(null, stack.pop());
- }
-
- public void testContains() {
- // Set up
- RuleStack stack = new RuleStack();
- stack.push(RuleConstants.ASSIGN_OUTPUT_ELEMENTS);
- stack.push(RuleConstants.COLLAPSE_SOURCE);
-
- assertEquals(true, stack.contains(RuleConstants.ASSIGN_OUTPUT_ELEMENTS));
- assertEquals(false, stack.contains(RuleConstants.PLACE_ACCESS));
- }
-
-}
15 years, 11 months