Author: rareddy
Date: 2010-10-12 12:39:25 -0400 (Tue, 12 Oct 2010)
New Revision: 2642
Modified:
branches/7.1.x/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
branches/7.1.x/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
branches/7.1.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
branches/7.1.x/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
branches/7.1.x/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java
branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
branches/7.1.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
branches/7.1.x/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
branches/7.1.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
Log:
TEIID-950: By default disabled the "ENV" system function. Added new
"SESSION_ID" system function to retrieve the session information of the
executing user. Removed the static nature of loading the system functions to enable the
configuration.
Modified:
branches/7.1.x/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
===================================================================
---
branches/7.1.x/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/build/kits/jboss-container/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml 2010-10-12
16:39:25 UTC (rev 2642)
@@ -4,7 +4,15 @@
<!-- Deployer specific Stuff -->
<bean name="VDBStructure"
class="org.teiid.deployers.VDBStructure" />
- <bean name="VDBRepository"
class="org.teiid.deployers.VDBRepository"/>
+
+ <bean name="SystemFunctionManager"
class="org.teiid.query.function.SystemFunctionManager">
+ <property name="allowEnvFunction">false</property>
+ </bean>
+
+ <bean name="VDBRepository"
class="org.teiid.deployers.VDBRepository">
+ <property name="systemFunctionManager"><inject
bean="SystemFunctionManager"/></property>
+ </bean>
+
<bean name="SecurityHelper"
class="org.teiid.jboss.JBossSecurityHelper"/>
<bean name="JBossLifeCycleListener"
class="org.teiid.jboss.JBossLifeCycleListener"/>
Modified: branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-10-11 16:42:47
UTC (rev 2641)
+++ branches/7.1.x/build/kits/jboss-container/teiid-releasenotes.html 2010-10-12 16:39:25
UTC (rev 2642)
@@ -51,6 +51,7 @@
<li>The jdbc:metamatrix JDBC URL prefix is no longer accepted. Use jdbc:teiid
instead.
<li>Model visibility no longer restricts access to tables and procedures.
Setting visible to false will only hide entries from system tables. Data roles should be
used to restrict data access.
<li>On Admin API "getWorkManagerStats" methods renamed to
"getWorkerPoolStats". Also, "setRuntimeProperty" and
"getProcesses" methods are not supported.
+ <li>A new system function "session_id" is added to the system function
library. By default "ENV" system function is now turned off. To enable it edit
Teiid configuration file.
</ul>
<h4>from 7.0</h4>
<ul>
Modified:
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java
===================================================================
---
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/oracle/TestOracleTranslator.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -722,7 +722,7 @@
RealMetadataFactory.createElements(dual, new String[] {"something"},
new String[] {DataTypeManager.DefaultDataTypes.STRING}); //$NON-NLS-1$
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
- return new TransformationMetadata(null, store, null, null);
+ return new TransformationMetadata(null, store, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
public void helpTestVisitor(String vdb, String input, String expectedOutput) throws
TranslatorException {
Modified:
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java
===================================================================
---
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/sqlserver/TestSqlServerConversionVisitor.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -36,6 +36,7 @@
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.jdbc.TranslationHelper;
@@ -158,7 +159,7 @@
obj.setNativeType("uniqueidentifier"); //$NON-NLS-1$
CompositeMetadataStore store = new CompositeMetadataStore(metadataStore);
- QueryMetadataInterface metadata = new TransformationMetadata(null, store, null,
null);
+ QueryMetadataInterface metadata = new TransformationMetadata(null, store, null,
null, FakeMetadataFactory.SFM.getSystemFunctions());
TranslationUtility tu = new TranslationUtility(metadata);
Command command = tu.parseCommand("select max(x) from bar");
//$NON-NLS-1$
Modified:
branches/7.1.x/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java
===================================================================
---
branches/7.1.x/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/connectors/translator-ldap/src/test/java/org/teiid/translator/ldap/TestIQueryToLdapSearchParser.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -47,6 +47,7 @@
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.TranslatorException;
import org.teiid.translator.ldap.IQueryToLdapSearchParser;
@@ -303,7 +304,7 @@
}
// Create the facade from the store
- return new TransformationMetadata(null, new
CompositeMetadataStore(metadataStore), null, null);
+ return new TransformationMetadata(null, new
CompositeMetadataStore(metadataStore), null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
}
Modified:
branches/7.1.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java
===================================================================
---
branches/7.1.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/connectors/translator-salesforce/src/test/java/org/teiid/translator/salesforce/execution/visitors/TestVisitors.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -38,6 +38,7 @@
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TransformationMetadata;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.RealMetadataFactory;
import org.teiid.translator.salesforce.execution.visitors.JoinQueryVisitor;
import org.teiid.translator.salesforce.execution.visitors.SelectVisitor;
@@ -95,7 +96,7 @@
Column obj = contactCols.get(i);
obj.setNameInSource(contactNameInSource[i]);
}
- return new TransformationMetadata(null, new CompositeMetadataStore(store), null,
null);
+ return new TransformationMetadata(null, new CompositeMetadataStore(store), null,
null, FakeMetadataFactory.SFM.getSystemFunctions());
}
private static TranslationUtility translationUtility = new
TranslationUtility(exampleSalesforce());
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -56,7 +56,8 @@
// 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$
+ public static final String ENV = "env"; //$NON-NLS-1$
+ public static final String SESSION_ID = "session_id"; //$NON-NLS-1$
// Special pseudo-functions only for XML queries
public static final String CONTEXT = "context"; //$NON-NLS-1$
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -56,6 +56,7 @@
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.QueryPlugin;
import org.teiid.query.util.CommandContext;
+import org.teiid.query.util.ContextProperties;
/**
* Static method hooks for most of the function library.
@@ -1240,6 +1241,14 @@
return value;
}
+ public static Object session_id(CommandContext context) {
+ Properties envProps = context.getEnvironmentProperties();
+ if(envProps != null &&
envProps.containsKey(ContextProperties.SESSION_ID)) {
+ return envProps.getProperty(ContextProperties.SESSION_ID);
+ }
+ return null;
+ }
+
// ================= Function - MODIFYTIMEZONE ========================
public static Object modifyTimeZone(Timestamp value, String originalTimezoneString,
String targetTimezoneString) {
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/function/SystemFunctionManager.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -32,30 +32,28 @@
public class SystemFunctionManager {
- private static FunctionTree systemFunctionTree;
+ private FunctionTree systemFunctionTree;
+ private boolean allowEnvFunction = true;
- 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("ERR.015.001.0005",
report)); //$NON-NLS-1$
- }
-
- systemFunctionTree = new FunctionTree(systemSource, true);
- }
+ public FunctionTree getSystemFunctions() {
+ if(systemFunctionTree == null) {
+ // Create the system source and add it to the source list
+ SystemSource systemSource = new SystemSource(this.allowEnvFunction);
-
- public static FunctionTree getSystemFunctions() {
+ // 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 SystemSourcTe doesn't change
+ System.err.println(QueryPlugin.Util.getString("ERR.015.001.0005",
report)); //$NON-NLS-1$
+ }
+ systemFunctionTree = new FunctionTree(systemSource, true);
+ }
return systemFunctionTree;
}
- public static FunctionLibrary getSystemFunctionLibrary() {
- return new FunctionLibrary(systemFunctionTree, new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
+ public FunctionLibrary getSystemFunctionLibrary() {
+ return new FunctionLibrary(getSystemFunctions(), new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
}
/**
@@ -64,8 +62,16 @@
* @param source Source of function metadata
* @param report Report to update with any problems
*/
- private static void validateSource(FunctionMetadataSource source, ActivityReport
report) {
+ private void validateSource(FunctionMetadataSource source, ActivityReport report) {
Collection functionMethods = source.getFunctionMethods();
FunctionMetadataValidator.validateFunctionMethods(functionMethods,report);
}
+
+ public boolean isAllowEnvFunction() {
+ return allowEnvFunction;
+ }
+
+ public void setAllowEnvFunction(boolean allowEnvFunction) {
+ this.allowEnvFunction = allowEnvFunction;
+ }
}
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -55,7 +55,7 @@
/**
* Construct a source of system metadata.
*/
- public SystemSource() {
+ public SystemSource(boolean allowEnvFunction) {
// +, -, *, /
addArithmeticFunction(SourceSystemFunctions.ADD_OP,
QueryPlugin.Util.getString("SystemSource.Add_desc"), "plus",
QueryPlugin.Util.getString("SystemSource.Add_result_desc")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
addArithmeticFunction(SourceSystemFunctions.SUBTRACT_OP,
QueryPlugin.Util.getString("SystemSource.Subtract_desc"), "minus",
QueryPlugin.Util.getString("SystemSource.Subtract_result_desc")); //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
@@ -158,7 +158,10 @@
addLookupFunctions();
addUserFunction();
addCurrentDatabaseFunction();
- addEnvFunction();
+ if (allowEnvFunction) {
+ addEnvFunction();
+ }
+ addSessionIdFunction();
addCommandPayloadFunctions();
addIfNullFunctions();
@@ -787,6 +790,12 @@
new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING,
QueryPlugin.Util.getString("SystemSource.Env_result")), false,
FunctionMethod.SESSION_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
+ private void addSessionIdFunction() {
+ functions.add(
+ new FunctionMethod(FunctionLibrary.SESSION_ID,
QueryPlugin.Util.getString("SystemSource.session_id_desc"), MISCELLANEOUS,
FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "session_id", null,
//$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING,
QueryPlugin.Util.getString("SystemSource.session_id_result")), false,
FunctionMethod.SESSION_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
private void addCommandPayloadFunctions() {
functions.add(
new FunctionMethod("commandpayload",
QueryPlugin.Util.getString("SystemSource.CommandPayload_desc0"), MISCELLANEOUS,
FunctionMethod.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$
//$NON-NLS-2$ //$NON-NLS-3$
Modified:
branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java
===================================================================
---
branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/main/java/org/teiid/query/metadata/TransformationMetadata.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -65,7 +65,6 @@
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;
@@ -145,7 +144,7 @@
* TransformationMetadata constructor
* @param context Object containing the info needed to lookup metadta.
*/
- public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore
store, Map<String, Resource> vdbEntries, Collection <FunctionMethod>
udfMethods) {
+ public TransformationMetadata(VDBMetaData vdbMetadata, final CompositeMetadataStore
store, Map<String, Resource> vdbEntries, Collection <FunctionMethod>
udfMethods, FunctionTree systemFunctions) {
ArgCheck.isNotNull(store);
this.vdbMetaData = vdbMetadata;
this.store = store;
@@ -157,7 +156,7 @@
if (udfMethods == null) {
udfMethods = Collections.emptyList();
}
- this.functionLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(udfMethods), true));
+ this.functionLibrary = new FunctionLibrary(systemFunctions, new FunctionTree(new
UDFSource(udfMethods), true));
}
//==================================================================================
Modified: branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-11
16:42:47 UTC (rev 2641)
+++ branches/7.1.x/engine/src/main/resources/org/teiid/query/i18n.properties 2010-10-12
16:39:25 UTC (rev 2642)
@@ -622,6 +622,8 @@
SystemSource.decode_arg1=Clob
SystemSource.decode_arg2=The encoding
SystemSource.decode_result=byte representation Blob
+SystemSource.session_id_desc=Returns the session id of the currently logged in user
+SystemSource.session_id_result=Returns the session id of the currently logged in user
TempMetadataAdapter.Element_____{0}_____not_found._1=Element ''{0}'' not
found.
TempMetadataAdapter.Group_____{0}_____not_found._1=Group ''{0}'' not
found.
ExpressionEvaluator.Must_push=Function {0} is marked in the function metadata as a
function that must be evaluated at the source.
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -57,6 +57,7 @@
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants.NonReserved;
import org.teiid.query.function.metadata.FunctionMethod;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.unittest.TimestampUtil;
import org.teiid.query.util.CommandContext;
import org.teiid.translator.SourceSystemFunctions;
@@ -78,7 +79,7 @@
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)));
+ private FunctionLibrary library = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(Collections.EMPTY_LIST)));
@Before public void setUp() {
TimestampWithTimezone.resetCalendar(TimeZone.getTimeZone("GMT-06:00"));
//$NON-NLS-1$
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,7 +22,9 @@
package org.teiid.query.function;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.Arrays;
import java.util.Collection;
@@ -35,6 +37,7 @@
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.function.metadata.FunctionParameter;
import org.teiid.query.function.source.SystemSource;
+import org.teiid.query.unittest.FakeMetadataFactory;
@SuppressWarnings("nls")
public class TestFunctionTree {
@@ -44,7 +47,7 @@
* each one up by signature
*/
@Test public void testWalkTree() {
- SystemSource source = new SystemSource();
+ SystemSource source = new SystemSource(false);
FunctionTree ft = new FunctionTree(source);
Collection<String> categories = ft.getCategories();
@@ -73,11 +76,11 @@
new FunctionParameter("output",
DataTypeManager.DefaultDataTypes.STRING)); //$NON-NLS-1$
//allowed, since we're not validating the class
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(Arrays.asList(method))));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method))));
//should fail, no class
try {
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
fail();
} catch (TeiidRuntimeException e) {
@@ -87,7 +90,7 @@
//should fail, no method
try {
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
fail();
} catch (TeiidRuntimeException e) {
@@ -97,7 +100,7 @@
//should fail, not void
try {
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
fail();
} catch (TeiidRuntimeException e) {
@@ -107,7 +110,7 @@
//should fail, not public
try {
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
fail();
} catch (TeiidRuntimeException e) {
@@ -117,7 +120,7 @@
//should fail, not static
try {
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
fail();
} catch (TeiidRuntimeException e) {
@@ -126,7 +129,7 @@
method.setInvocationMethod("y");
//valid!
- new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(Arrays.asList(method)), true));
+ new FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new
FunctionTree(new UDFSource(Arrays.asList(method)), true));
}
@Test public void testNullCategory() {
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/function/metadata/TestSystemSource.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -43,7 +43,7 @@
// ################################## ACTUAL TESTS ################################
public void testValidate() {
- SystemSource source = new SystemSource();
+ SystemSource source = new SystemSource(false);
ActivityReport report = new ActivityReport("Test Report");
//$NON-NLS-1$
FunctionMetadataValidator.validateFunctionMethods(source.getFunctionMethods(),
report);
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/metadata/TestTransformationMetadata.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -80,7 +80,7 @@
vdb.addModel(buildModel("x"));
vdb.addModel(buildModel("x1"));
- return new TransformationMetadata(vdb, cms, null, null);
+ return new TransformationMetadata(vdb, cms, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
ModelMetaData buildModel(String name) {
@@ -113,7 +113,7 @@
model2.setVisible(true);
vdb.addModel(model2);
- TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null);
+ TransformationMetadata tm = new TransformationMetadata(vdb, cms, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
Collection result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(2, result.size());
@@ -121,7 +121,7 @@
model.setVisible(false);
- tm = new TransformationMetadata(vdb, cms, null, null);
+ tm = new TransformationMetadata(vdb, cms, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
result = tm.getGroupsForPartialName("y"); //$NON-NLS-1$
assertEquals(1, result.size());
}
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/optimizer/TestOptimizer.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,7 +22,11 @@
package org.teiid.query.optimizer;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.ArrayList;
import java.util.Arrays;
@@ -35,18 +39,16 @@
import org.teiid.api.exception.query.QueryPlannerException;
import org.teiid.common.buffer.BufferManager;
import org.teiid.core.TeiidComponentException;
+import org.teiid.core.TeiidException;
import org.teiid.core.TeiidProcessingException;
-import org.teiid.core.TeiidException;
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionLibrary;
import org.teiid.query.function.FunctionTree;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.UDFSource;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
-import org.teiid.query.optimizer.QueryOptimizer;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.CapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
@@ -4253,7 +4255,7 @@
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())));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,8 +22,14 @@
package org.teiid.query.processor;
-import static org.junit.Assert.*;
-import static org.teiid.query.optimizer.TestOptimizer.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.teiid.query.optimizer.TestOptimizer.FULL_PUSHDOWN;
+import static org.teiid.query.optimizer.TestOptimizer.checkNodeTypes;
+import static org.teiid.query.optimizer.TestOptimizer.getTypicalCapabilities;
+import static org.teiid.query.optimizer.TestOptimizer.helpPlan;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -5272,7 +5278,7 @@
caps.setFunctionSupport("myrtrim", true); //$NON-NLS-1$
capFinder.addCapabilities("pm1", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
processPreparedStatement(sql, expected, dataManager, capFinder,
@@ -5320,7 +5326,7 @@
caps.setFunctionSupport("concat", true); //$NON-NLS-1$
capFinder.addCapabilities("pm4", caps); //$NON-NLS-1$
- FunctionLibrary funcLibrary = new
FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
+ FunctionLibrary funcLibrary = new
FunctionLibrary(FakeMetadataFactory.SFM.getSystemFunctions(), new FunctionTree(new
UDFSource(new FakeFunctionMetadataSource().getFunctionMethods())));
FakeMetadataFacade metadata = new
FakeMetadataFacade(FakeMetadataFactory.example1Cached().getStore(), funcLibrary);
processPreparedStatement(sql, expected, dataManager, capFinder,
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/eval/TestExpressionEvaluator.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,7 +22,8 @@
package org.teiid.query.processor.eval;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
import java.io.Serializable;
import java.math.BigDecimal;
@@ -59,6 +60,7 @@
import org.teiid.query.sql.symbol.TestCaseExpression;
import org.teiid.query.sql.symbol.TestSearchedCaseExpression;
import org.teiid.query.sql.util.ValueIterator;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@SuppressWarnings("nls")
@@ -192,7 +194,7 @@
e2.setType(String.class);
Function func = new Function("concat", new Expression[] { e1, e2 });
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -214,7 +216,7 @@
e2.setType(String.class);
Function func = new Function("concat", new Expression[] { e2, e1 });
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new
Class[] { String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -235,7 +237,7 @@
e1.setType(Integer.class);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
e1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
SingleElementSymbol[] elements = new SingleElementSymbol[] {
@@ -307,7 +309,7 @@
@Test public void testUser() throws Exception {
Function func = new Function("user", new Expression[] {});
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("user", new
Class[] {} ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("user", new
Class[] {} ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
@@ -324,7 +326,7 @@
*/
@Test public void testEnv() throws Exception {
Function func = new Function("env", new Expression[] {});
//$NON-NLS-1$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("env", new Class[]
{String.class} ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("env", new
Class[] {String.class} ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
@@ -350,7 +352,7 @@
} else {
parameterSignature = new Class[] { String.class };
}
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("commandpayload",
parameterSignature ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("commandpayload",
parameterSignature ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
FakeDataManager dataMgr = new FakeDataManager();
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestGroupingNode.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,7 +22,7 @@
package org.teiid.query.processor.relational;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
import java.math.BigDecimal;
import java.util.ArrayList;
@@ -36,13 +36,11 @@
import org.teiid.common.buffer.BufferManager;
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.TupleBatch;
-import org.teiid.common.buffer.TupleSource;
import org.teiid.common.buffer.impl.BufferManagerImpl;
import org.teiid.core.TeiidComponentException;
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.aggregate.AggregateFunction;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.FakeTupleSource;
@@ -52,6 +50,7 @@
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.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -272,7 +271,7 @@
// Set grouping elements to null
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
CommandContext context = new CommandContext("pid", "test",
null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -309,7 +308,7 @@
col2.setType(Integer.class);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
col2 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
@@ -320,7 +319,7 @@
node.setElements(outputElements);
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
CommandContext context = new CommandContext("pid", "test",
null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
@@ -434,7 +433,7 @@
node.setElements(outputElements);
List groupingElements = new ArrayList();
- groupingElements.add(col1); //$NON-NLS-1$
+ groupingElements.add(col1);
node.setGroupingElements(groupingElements);
return node;
}
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestJoinNode.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -39,14 +39,7 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.processor.FakeDataManager;
-import org.teiid.query.processor.relational.JoinNode;
-import org.teiid.query.processor.relational.JoinStrategy;
-import org.teiid.query.processor.relational.MergeJoinStrategy;
-import org.teiid.query.processor.relational.NestedLoopJoinStrategy;
-import org.teiid.query.processor.relational.PartitionedSortJoin;
-import org.teiid.query.processor.relational.RelationalNode;
import org.teiid.query.processor.relational.MergeJoinStrategy.SortOption;
import org.teiid.query.sql.lang.CompareCriteria;
import org.teiid.query.sql.lang.JoinType;
@@ -54,6 +47,7 @@
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.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -209,7 +203,7 @@
case FUNCTION_CRITERIA :
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class }); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria joinCriteria = new CompareCriteria(es2,
CompareCriteria.EQ, func);
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestProjectNode.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -28,6 +28,8 @@
import java.util.List;
import java.util.Map;
+import junit.framework.TestCase;
+
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.common.buffer.BlockedException;
import org.teiid.common.buffer.BufferManager;
@@ -37,20 +39,17 @@
import org.teiid.core.TeiidProcessingException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.ProcessorDataManager;
-import org.teiid.query.processor.relational.ProjectNode;
import org.teiid.query.sql.symbol.Constant;
import org.teiid.query.sql.symbol.ElementSymbol;
import org.teiid.query.sql.symbol.Expression;
import org.teiid.query.sql.symbol.ExpressionSymbol;
import org.teiid.query.sql.symbol.Function;
+import org.teiid.query.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
-import junit.framework.TestCase;
-
/**
*/
public class TestProjectNode extends TestCase {
@@ -213,7 +212,7 @@
elements.add(es1);
Function func = new Function("concat", new Expression[] { es1, new
Constant("abc")}); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionDescriptor fd =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("concat", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+ FunctionDescriptor fd =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("concat", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.STRING);
ExpressionSymbol expr = new ExpressionSymbol("expr", func);
//$NON-NLS-1$
@@ -237,7 +236,7 @@
elements.add(es1);
Function func = new Function("convert", new Expression[] { es1, new
Constant("integer")}); //$NON-NLS-1$ //$NON-NLS-2$
- FunctionDescriptor fd =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("convert", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
+ FunctionDescriptor fd =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("convert", new
Class[] { DataTypeManager.DefaultDataClasses.STRING,
DataTypeManager.DefaultDataClasses.STRING }); //$NON-NLS-1$
func.setFunctionDescriptor(fd);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
ExpressionSymbol expr = new ExpressionSymbol("expr", func);
//$NON-NLS-1$
@@ -260,7 +259,7 @@
elements.add(es1);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, String.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.STRING);
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/processor/relational/TestSelectNode.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,7 +22,8 @@
package org.teiid.query.processor.relational;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import java.util.ArrayList;
import java.util.Arrays;
@@ -40,7 +41,6 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.query.eval.Evaluator;
import org.teiid.query.function.FunctionDescriptor;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.processor.BatchIterator;
import org.teiid.query.processor.FakeDataManager;
import org.teiid.query.processor.ProcessorDataManager;
@@ -51,6 +51,7 @@
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.unittest.FakeMetadataFactory;
import org.teiid.query.util.CommandContext;
public class TestSelectNode {
@@ -236,7 +237,7 @@
elements.add(es1);
Function func = new Function("lookup", new Expression[] { new
Constant("pm1.g1"), new Constant("e2"), new Constant("e1"),
es1 }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- FunctionDescriptor desc =
SystemFunctionManager.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
+ FunctionDescriptor desc =
FakeMetadataFactory.SFM.getSystemFunctionLibrary().findFunction("lookup", new
Class[] { String.class, String.class, String.class, Integer.class } ); //$NON-NLS-1$
func.setFunctionDescriptor(desc);
func.setType(DataTypeManager.DefaultDataClasses.INTEGER);
CompareCriteria crit = new CompareCriteria(func, CompareCriteria.EQ, new
Constant(new Integer(1)));
Modified: branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/resolver/TestResolver.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -22,7 +22,13 @@
package org.teiid.query.resolver;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.math.BigDecimal;
import java.math.BigInteger;
@@ -50,13 +56,11 @@
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.function.FunctionDescriptor;
import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.metadata.QueryMetadataInterface;
import org.teiid.query.metadata.TempMetadataID;
import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.parser.QueryParser;
-import org.teiid.query.resolver.QueryResolver;
import org.teiid.query.resolver.util.BindVariableVisitor;
import org.teiid.query.sql.LanguageObject;
import org.teiid.query.sql.ProcedureReservedWords;
@@ -1400,7 +1404,7 @@
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
- FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
+ FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] {
srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new
Constant(tgtTypeName) });
@@ -1436,7 +1440,7 @@
String tgtTypeName = DataTypeManager.DefaultDataTypes.DATE;
Expression expression = new Constant("2003-02-27"); //$NON-NLS-1$
- FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
+ FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.CONVERT, new Class[] {
srcType, DataTypeManager.DefaultDataClasses.STRING });
Function conversion = new Function(fd.getName(), new Expression[] { expression, new
Constant(tgtTypeName) });
@@ -1886,7 +1890,7 @@
//String sql = "select intkey from SmallA where user() =
'bqt2'";
// Expected left expression
- FunctionLibrary library = SystemFunctionManager.getSystemFunctionLibrary();
+ FunctionLibrary library = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
FunctionDescriptor fd = library.findFunction(FunctionLibrary.USER, new Class[] {
});
Function user = new Function(fd.getName(), new Expression[] {});
user.setFunctionDescriptor(fd);
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFacade.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -36,7 +36,6 @@
import org.teiid.core.util.ArgCheck;
import org.teiid.core.util.Assertion;
import org.teiid.query.function.FunctionLibrary;
-import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.mapping.xml.MappingBaseNode;
import org.teiid.query.mapping.xml.MappingDocument;
@@ -58,7 +57,7 @@
public FakeMetadataFacade(FakeMetadataStore store) {
this.store = store;
- this.functionLibrary = SystemFunctionManager.getSystemFunctionLibrary();
+ this.functionLibrary = FakeMetadataFactory.SFM.getSystemFunctionLibrary();
}
public FakeMetadataFacade(FakeMetadataStore store, FunctionLibrary funcLibrary) {
@@ -204,7 +203,7 @@
FakeMetadataObject group = (FakeMetadataObject) groupID;
QueryNode queryNode = (QueryNode) group.getProperty(FakeMetadataObject.Props.PLAN);
if (queryNode.getQuery() == null) {
- throw new QueryMetadataException("no query");
+ throw new QueryMetadataException("no query");//$NON-NLS-1$
}
return queryNode;
}
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/FakeMetadataFactory.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -39,6 +39,7 @@
import org.teiid.core.types.DataTypeManager;
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.metadata.Table;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.mapping.relational.QueryNode;
import org.teiid.query.mapping.xml.MappingAttribute;
import org.teiid.query.mapping.xml.MappingDocument;
@@ -51,6 +52,7 @@
@SuppressWarnings("nls")
public class FakeMetadataFactory {
+ public static SystemFunctionManager SFM = new SystemFunctionManager();
private static FakeMetadataFacade CACHED_EXAMPLE1 = example1();
private static FakeMetadataFacade CACHED_AGGREGATES = exampleAggregates();
Modified:
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java
===================================================================
---
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/engine/src/test/java/org/teiid/query/unittest/RealMetadataFactory.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -269,7 +269,7 @@
for (Schema schema : metadataStore.getSchemas().values()) {
vdbMetaData.addModel(FakeMetadataFactory.createModel(schema.getName(),
schema.isPhysical()));
}
- return new TransformationMetadata(vdbMetaData, store, null, null);
+ return new TransformationMetadata(vdbMetaData, store, null, null,
FakeMetadataFactory.SFM.getSystemFunctions());
}
/**
Modified: branches/7.1.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java
===================================================================
---
branches/7.1.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/metadata/src/test/java/org/teiid/cdk/api/TranslationUtility.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -103,7 +103,8 @@
this.metadata = new BasicQueryMetadataWrapper(this.metadata) {
@Override
public FunctionLibrary getFunctionLibrary() {
- return new FunctionLibrary(SystemFunctionManager.getSystemFunctions(), new
FunctionTree(new UDFSource(methods)));
+ SystemFunctionManager sfm = new SystemFunctionManager();
+ return new FunctionLibrary(sfm.getSystemFunctions(), new FunctionTree(new
UDFSource(methods)));
}
};
}
Modified:
branches/7.1.x/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java
===================================================================
---
branches/7.1.x/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/metadata/src/test/java/org/teiid/metadata/index/VDBMetadataFactory.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -39,6 +39,7 @@
import org.teiid.core.util.LRUCache;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.function.metadata.FunctionMetadataReader;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.CompositeMetadataStore;
@@ -83,8 +84,8 @@
if (udfFile != null) {
methods = FunctionMetadataReader.loadFunctionMethods(udfFile.openStream());
}
-
- vdbmetadata = new TransformationMetadata(null, new
CompositeMetadataStore(Arrays.asList(getSystem(),
imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(),
methods);
+ SystemFunctionManager sfm = new SystemFunctionManager();
+ vdbmetadata = new TransformationMetadata(null, new
CompositeMetadataStore(Arrays.asList(getSystem(),
imf.getMetadataStore(getSystem().getDatatypes()))), imf.getEntriesPlusVisibilities(),
methods, sfm.getSystemFunctions());
VDB_CACHE.put(vdbURL, vdbmetadata);
return vdbmetadata;
} catch (URISyntaxException e) {
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-10-11
16:42:47 UTC (rev 2641)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/CompositeVDB.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -31,6 +31,7 @@
import org.teiid.adminapi.impl.VDBMetaData;
import org.teiid.dqp.internal.datamgr.ConnectorManagerRepository;
import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.FunctionTree;
import org.teiid.query.function.metadata.FunctionMethod;
import org.teiid.query.metadata.CompositeMetadataStore;
import org.teiid.query.metadata.QueryMetadataInterface;
@@ -49,19 +50,21 @@
private LinkedHashMap<VDBKey, CompositeVDB> children;
private MetadataStore[] additionalStores;
private ConnectorManagerRepository cmr;
+ private FunctionTree systemFunctions;
// used as cached item to avoid rebuilding
private VDBMetaData mergedVDB;
- public CompositeVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr,
MetadataStore... additionalStores) {
+ public CompositeVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, FunctionTree systemFunctions,
ConnectorManagerRepository cmr, MetadataStore... additionalStores) {
this.vdb = vdb;
this.stores = stores;
this.visibilityMap = visibilityMap;
this.udf = udf;
+ this.systemFunctions = systemFunctions;
this.cmr = cmr;
this.additionalStores = additionalStores;
this.vdb.addAttchment(ConnectorManagerRepository.class, cmr);
- update(this.vdb);
+ update(this.vdb, this.systemFunctions);
}
public void addChild(CompositeVDB child) {
@@ -80,15 +83,15 @@
this.mergedVDB = null;
}
- void update(VDBMetaData vdbMetadata) {
- TransformationMetadata metadata = buildTransformationMetaData(vdbMetadata,
getVisibilityMap(), getMetadataStores(), getUDF());
+ void update(VDBMetaData vdbMetadata, FunctionTree systemFunctions) {
+ TransformationMetadata metadata = buildTransformationMetaData(vdbMetadata,
getVisibilityMap(), getMetadataStores(), getUDF(), systemFunctions);
vdbMetadata.addAttchment(QueryMetadataInterface.class, metadata);
vdbMetadata.addAttchment(TransformationMetadata.class, metadata);
TempTableStore globalTables = new TempTableStore("SYSTEM"); //$NON-NLS-1$
vdbMetadata.addAttchment(TempTableStore.class, globalTables);
}
- private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores,
UDFMetaData udf) {
+ private TransformationMetadata buildTransformationMetaData(VDBMetaData vdb,
LinkedHashMap<String, Resource> visibilityMap, MetadataStoreGroup stores,
UDFMetaData udf, FunctionTree systemFunctions) {
Collection <FunctionMethod> methods = null;
if (udf != null) {
methods = udf.getFunctions();
@@ -99,7 +102,7 @@
compositeStore.addMetadataStore(s);
}
- TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore,
visibilityMap, methods);
+ TransformationMetadata metadata = new TransformationMetadata(vdb, compositeStore,
visibilityMap, methods, systemFunctions);
return metadata;
}
@@ -110,7 +113,7 @@
}
if (this.mergedVDB == null) {
this.mergedVDB = buildVDB();
- update(mergedVDB);
+ update(mergedVDB, this.systemFunctions);
}
return this.mergedVDB;
}
Modified: branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java
===================================================================
--- branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-10-11
16:42:47 UTC (rev 2641)
+++ branches/7.1.x/runtime/src/main/java/org/teiid/deployers/VDBRepository.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -43,6 +43,7 @@
import org.teiid.logging.LogManager;
import org.teiid.metadata.Datatype;
import org.teiid.metadata.MetadataStore;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.metadata.TransformationMetadata.Resource;
import org.teiid.runtime.RuntimePlugin;
import org.teiid.translator.TranslatorException;
@@ -60,6 +61,7 @@
private MetadataStore odbcStore;
private boolean odbcEnabled = false;
private List<VDBLifeCycleListener> listeners = new
ArrayList<VDBLifeCycleListener>();
+ private SystemFunctionManager systemFunctionManager;
public void addVDB(VDBMetaData vdb, MetadataStoreGroup stores, LinkedHashMap<String,
Resource> visibilityMap, UDFMetaData udf, ConnectorManagerRepository cmr) throws
DeploymentException {
if (getVDB(vdb.getName(), vdb.getVersion()) != null) {
@@ -76,10 +78,10 @@
}
if (this.odbcStore == null) {
- this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf, cmr,
this.systemStore));
+ this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore));
}
else {
- this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf, cmr,
this.systemStore, odbcStore));
+ this.vdbRepo.put(vdbId(vdb), new CompositeVDB(vdb, stores, visibilityMap, udf,
this.systemFunctionManager.getSystemFunctions(), cmr, this.systemStore, odbcStore));
}
notifyAdd(vdb.getName(), vdb.getVersion());
}
@@ -208,7 +210,7 @@
void updateVDB(String name, int version) {
CompositeVDB v = this.vdbRepo.get(new VDBKey(name, version));
if (v!= null) {
- v.update(v.getVDB());
+ v.update(v.getVDB(), systemFunctionManager.getSystemFunctions());
}
}
@@ -231,4 +233,8 @@
l.removed(name, version);
}
}
+
+ public void setSystemFunctionManager(SystemFunctionManager mgr) {
+ this.systemFunctionManager = mgr;
+ }
}
Modified:
branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java
===================================================================
---
branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-10-11
16:42:47 UTC (rev 2641)
+++
branches/7.1.x/test-integration/common/src/test/java/org/teiid/jdbc/FakeServer.java 2010-10-12
16:39:25 UTC (rev 2642)
@@ -47,6 +47,7 @@
import org.teiid.metadata.Schema;
import org.teiid.metadata.index.IndexMetadataFactory;
import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.function.SystemFunctionManager;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
import org.teiid.query.optimizer.capabilities.SourceCapabilities;
import org.teiid.services.SessionServiceImpl;
@@ -68,6 +69,7 @@
this.logon = new LogonImpl(sessionService, null);
this.repo.setSystemStore(VDBMetadataFactory.getSystem());
+ this.repo.setSystemFunctionManager(new SystemFunctionManager());
this.repo.odbcEnabled();
this.repo.start();