[teiid-commits] teiid SVN: r2117 - in trunk/engine/src: main/java/com/metamatrix/vdb and 86 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Tue May 11 18:02:14 EDT 2010


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;
-
- at 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));
-    }
-
-}



More information about the teiid-commits mailing list