teiid SVN: r3894 - branches/7.7.x/api/src/main/java/org/teiid/logging.
by teiid-commits@lists.jboss.org
Author: van.halbert
Date: 2012-02-23 16:04:48 -0500 (Thu, 23 Feb 2012)
New Revision: 3894
Modified:
branches/7.7.x/api/src/main/java/org/teiid/logging/CommandLogMessage.java
Log:
TEIID-1951 changed reference to connectorBindingName to translatorName, and added new getTranslatorName method and deprecated the getConnectorBindingName. The admin guide in confluence has been updated to an example of command logging using translatorName, instead of connectorBindingName, in the log
Modified: branches/7.7.x/api/src/main/java/org/teiid/logging/CommandLogMessage.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/logging/CommandLogMessage.java 2012-02-22 02:54:36 UTC (rev 3893)
+++ branches/7.7.x/api/src/main/java/org/teiid/logging/CommandLogMessage.java 2012-02-23 21:04:48 UTC (rev 3894)
@@ -58,7 +58,7 @@
private String sql;
private Integer rowCount;
private String modelName;
- private String connectorBindingName;
+ private String translatorName;
private ExecutionContext executionContext;
public CommandLogMessage(long timestamp,
@@ -100,13 +100,13 @@
long sourceCommandID,
String transactionID,
String modelName,
- String connectorBindingName,
+ String translatorName,
String sessionID,
String principal,
String sql,
ExecutionContext context) {
// dataSourceCommandStart
- this(timestamp, requestID, sourceCommandID, transactionID, modelName, connectorBindingName, sessionID, principal, null, Event.NEW, context);
+ this(timestamp, requestID, sourceCommandID, transactionID, modelName, translatorName, sessionID, principal, null, Event.NEW, context);
this.sql = sql;
}
public CommandLogMessage(long timestamp,
@@ -114,7 +114,7 @@
long sourceCommandID,
String transactionID,
String modelName,
- String connectorBindingName,
+ String translatorName,
String sessionID,
String principal,
Integer finalRowCount,
@@ -128,7 +128,7 @@
this.sourceCommandID = sourceCommandID;
this.transactionID = transactionID;
this.modelName = modelName;
- this.connectorBindingName = connectorBindingName;
+ this.translatorName = translatorName;
this.sessionID = sessionID;
this.principal = principal;
this.rowCount = finalRowCount;
@@ -143,9 +143,9 @@
return "\t"+ event +" USER COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\ttxID=" + transactionID + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tvdbName=" + vdbName + "\tvdbVersion=" + vdbVersion + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
if (event == Event.NEW) {
- return "\tSTART DATA SRC COMMAND:\tstartTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
+ return "\tSTART DATA SRC COMMAND:\tstartTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\ttranslatorName=" + translatorName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tsql=" + sql; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$
}
- return "\t"+ event +" SRC COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\tconnectorBindingName=" + connectorBindingName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
+ return "\t"+ event +" SRC COMMAND:\tendTime=" + new Timestamp(timestamp) + "\trequestID=" + requestID + "\tsourceCommandID="+ sourceCommandID + "\ttxID=" + transactionID + "\tmodelName="+ modelName + "\ttranslatorName=" + translatorName + "\tsessionID=" + sessionID + "\tprincipal=" + principal + "\tfinalRowCount=" + rowCount; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$//$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$ //$NON-NLS-9$ //$NON-NLS-10$
}
public long getTimestamp() {
@@ -192,9 +192,18 @@
public String getModelName() {
return modelName;
}
+
+ /**
+ * @deprecated in 7.7 see {@link #getTranslatorName()}
+ */
public String getConnectorBindingName() {
- return connectorBindingName;
+ return translatorName;
}
+
+ public String getTranslatorName() {
+ return translatorName;
+ }
+
public Event getStatus() {
return event;
}
12 years, 10 months
teiid SVN: r3893 - in branches/7.7.x/engine/src: main/java/org/teiid/query/sql/lang and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-21 21:54:36 -0500 (Tue, 21 Feb 2012)
New Revision: 3893
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
Log:
TEIID-1949 fix for assertionerror with sorting
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-02-20 02:38:50 UTC (rev 3892)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleCollapseSource.java 2012-02-22 02:54:36 UTC (rev 3893)
@@ -55,26 +55,7 @@
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.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.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.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.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.*;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.navigator.DeepPostOrderNavigator;
import org.teiid.query.sql.symbol.AggregateSymbol;
@@ -263,6 +244,13 @@
}
PlanNode groupNode = NodeEditor.findNodePreOrder(node, NodeConstants.Types.GROUP, NodeConstants.Types.SOURCE);
if (groupNode != null) {
+ if (query.getOrderBy() != null) {
+ query.setOrderBy(query.getOrderBy().clone());
+ }
+ if (query.getHaving() != null) {
+ query.setHaving((Criteria) query.getHaving().clone());
+ }
+ query.setSelect(query.getSelect().clone());
SymbolMap symbolMap = (SymbolMap) groupNode.getProperty(NodeConstants.Info.SYMBOL_MAP);
//map back to expression form
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java 2012-02-20 02:38:50 UTC (rev 3892)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/sql/lang/Select.java 2012-02-22 02:54:36 UTC (rev 3893)
@@ -197,7 +197,7 @@
* Return a deep copy of this Select.
* @return Deep clone
*/
- public Object clone() {
+ public Select clone() {
Select copy = new Select(LanguageObject.Util.deepClone(this.symbols, SelectSymbol.class));
copy.setDistinct( isDistinct() );
return copy;
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2012-02-20 02:38:50 UTC (rev 3892)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestProcessor.java 2012-02-22 02:54:36 UTC (rev 3893)
@@ -4106,7 +4106,32 @@
// Run query
helpProcess(plan, dataManager, expected);
}
+
+ @Test public void testPushedGroupingWithOrderBy() {
+ // Create query
+ final String sql = "SELECT e1, e2, count(*) as Count FROM pm1.g1 as DB GROUP BY e1, e2 ORDER BY e1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", 1, 2 }),
+ Arrays.asList(new Object[] { "b", 1, 2 }) //$NON-NLS-1$
+ };
+
+ // Construct data manager with data
+ HardcodedDataManager dataManager = new HardcodedDataManager();
+ dataManager.addData("SELECT pm1.g1.e1, pm1.g1.e2, COUNT(*) FROM pm1.g1 GROUP BY pm1.g1.e1, pm1.g1.e2", new List<?>[] {Arrays.asList("b", 1, 2), Arrays.asList("a", 1, 2)});
+ FakeCapabilitiesFinder capFinder = new FakeCapabilitiesFinder();
+ BasicSourceCapabilities bsc = new BasicSourceCapabilities();
+ bsc.setCapabilitySupport(Capability.QUERY_GROUP_BY, true);
+ bsc.setCapabilitySupport(Capability.QUERY_AGGREGATES_COUNT_STAR, true);
+ capFinder.addCapabilities("pm1", bsc);
+ // Plan query
+ ProcessorPlan plan = helpGetPlan(sql, RealMetadataFactory.example1Cached(), capFinder);
+ // Run query
+ helpProcess(plan, dataManager, expected);
+ }
+
/**
* Test <code>QueryProcessor</code>'s ability to process a query containing
* an aggregate COUNT with a <code>CASE</code> expression in which a
12 years, 10 months
teiid SVN: r3892 - in trunk: engine/src/main/java/org/teiid/query/function/metadata and 7 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-19 21:38:50 -0500 (Sun, 19 Feb 2012)
New Revision: 3892
Removed:
trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
Modified:
trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
Log:
TEIID-1560 consolidating FunctionMethod constructors
Modified: trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -117,7 +117,7 @@
}
public FunctionMethod(String name, String description, String category, FunctionParameter[] inputParams, FunctionParameter outputParam) {
- this(name, description, category, PushDown.MUST_PUSHDOWN, null, null, inputParams, outputParam, true, Determinism.DETERMINISTIC);
+ this(name, description, category, PushDown.MUST_PUSHDOWN, null, null, inputParams!=null?Arrays.asList(inputParams):null, outputParam, true, Determinism.DETERMINISTIC);
}
public FunctionMethod(String name,
@@ -126,7 +126,7 @@
PushDown pushdown,
String invocationClass,
String invocationMethod,
- FunctionParameter[] inputParams,
+ List<FunctionParameter> inputParams,
FunctionParameter outputParam,
boolean nullOnNull,
Determinism deterministic) {
@@ -137,14 +137,18 @@
setPushdown(pushdown);
setInvocationClass(invocationClass);
setInvocationMethod(invocationMethod);
- if (inputParams != null) {
- setInputParameters(Arrays.asList(inputParams));
- }
+ setInputParameters(inputParams);
setOutputParameter(outputParam);
setNullOnNull(nullOnNull);
setDeterminism(deterministic);
}
+ public FunctionMethod(String name, String description, String category,
+ String invocationClass, String invocationMethod,
+ FunctionParameter[] inputParams, FunctionParameter outputParam) {
+ this(name, description, category, PushDown.CAN_PUSHDOWN, invocationClass, invocationMethod, inputParams!=null?Arrays.asList(inputParams):null, outputParam, true, Determinism.DETERMINISTIC);
+ }
+
/**
* Return name of method
* @return Name
@@ -298,7 +302,9 @@
*/
public void setInputParameters(List<FunctionParameter> params) {
this.inParameters.clear();
- this.inParameters.addAll(params);
+ if (params != null) {
+ this.inParameters.addAll(params);
+ }
}
/**
Deleted: trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/engine/src/main/java/org/teiid/query/function/metadata/FunctionMethod.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -1,79 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.query.function.metadata;
-
-import org.teiid.metadata.FunctionParameter;
-
-
-/**
- * @see FunctionMetadataValidator
- * @see FunctionCategoryConstants
- */
-public class FunctionMethod extends org.teiid.metadata.FunctionMethod {
- private static final long serialVersionUID = -2380536393719646754L;
-
- /**
- * Construct a function method with default pushdown and null dependent attributes.
- * @param name Function name
- * @param description Function description
- * @param category Function category
- * @param invocationClass Invocation class
- * @param invocationMethod Invocation method
- * @param inputParams Input parameters
- * @param outputParam Output parameter (return parameter)
- */
- public FunctionMethod(String name, String description, String category,
- String invocationClass, String invocationMethod,
- FunctionParameter[] inputParams, FunctionParameter outputParam) {
- super(name, description, category, PushDown.CAN_PUSHDOWN, invocationClass, invocationMethod, inputParams, outputParam, true, Determinism.DETERMINISTIC);
- }
-
- /**
- * Construct a function method with all parameters assuming null dependent and non-deterministic.
- * @param name Function name
- * @param description Function description
- * @param category Function category
- * @param invocationClass Invocation class
- * @param invocationMethod Invocation method
- * @param inputParams Input parameters
- * @param outputParam Output parameter (return parameter)
- */
- public FunctionMethod(String name, String description, String category,
- PushDown pushdown, String invocationClass, String invocationMethod,
- FunctionParameter[] inputParams, FunctionParameter outputParam) {
- super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, false,Determinism.NONDETERMINISTIC);
- }
-
- public FunctionMethod(String name,
- String description,
- String category,
- PushDown pushdown,
- String invocationClass,
- String invocationMethod,
- FunctionParameter[] inputParams,
- FunctionParameter outputParam,
- boolean nullDependent,
- Determinism deterministic) {
- super(name, description, category, pushdown, invocationClass, invocationMethod, inputParams, outputParam, !nullDependent, deterministic);
- }
-}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -28,6 +28,7 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.metadata.FunctionMethod.PushDown;
@@ -36,7 +37,6 @@
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.translator.SourceSystemFunctions;
@@ -211,37 +211,37 @@
private void addArrayLength() {
functions.add(new FunctionMethod(SourceSystemFunctions.ARRAY_LENGTH, QueryPlugin.Util.getString("SystemSource.array_length_desc"), MISCELLANEOUS, PushDown.CAN_PUSHDOWN, FUNCTION_CLASS, SourceSystemFunctions.ARRAY_LENGTH, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("array", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.array_param1"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.array_length_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(
+ new FunctionParameter("array", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.array_param1"))), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.array_length_result")), true, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addArrayGet() {
functions.add(new FunctionMethod(SourceSystemFunctions.ARRAY_GET, QueryPlugin.Util.getString("SystemSource.array_get_desc"), MISCELLANEOUS, PushDown.CAN_PUSHDOWN, FUNCTION_CLASS, SourceSystemFunctions.ARRAY_GET, //$NON-NLS-1$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("array", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.array_param1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.array_get_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.array_get_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("index", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.array_get_param2"))), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.array_get_result")), true, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addUnescape() {
functions.add(new FunctionMethod(SourceSystemFunctions.UNESCAPE, QueryPlugin.Util.getString("SystemSource.unescape_desc"), STRING, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, SourceSystemFunctions.UNESCAPE, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_param1"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(
+ new FunctionParameter("string", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_param1"))), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.unescape_result")), true, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addSecurityFunctions() {
functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, PushDown.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("roleType", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, Determinism.USER_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), true, Determinism.USER_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(new FunctionMethod("hasRole", QueryPlugin.Util.getString("SystemSource.hasRole_description"), SECURITY, PushDown.CANNOT_PUSHDOWN, SECURITY_FUNCTION_CLASS, "hasRole", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
- new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), false, Determinism.USER_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ Arrays.asList(
+ new FunctionParameter("roleName", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.hasRole_param2"))), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.BOOLEAN, QueryPlugin.Util.getString("SystemSource.hasRole_result")), true, Determinism.USER_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addFormatNumberFunctions() {
@@ -458,18 +458,16 @@
private void addTimestampAddFunction() {
functions.add(
- new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_desc"), DATETIME, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Timestampadd_d_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_desc"), DATETIME, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("interval", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("timestamp", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_arg3"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Timestampadd_t_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
new FunctionMethod(SourceSystemFunctions.TIMESTAMPADD, QueryPlugin.Util.getString("SystemSource.Timestampadd_ts_desc"), DATETIME, FUNCTION_CLASS, "timestampAdd", //$NON-NLS-1$ //$NON-NLS-2$
@@ -523,9 +521,9 @@
private void addClobFunction(String name, String description, String methodName, String returnType) {
functions.add(
new FunctionMethod(name, description, STRING, PushDown.MUST_PUSHDOWN, FUNCTION_CLASS, methodName,
- new FunctionParameter[] {
- new FunctionParameter("clob", DataTypeManager.DefaultDataTypes.CLOB, QueryPlugin.Util.getString("SystemSource.Clobfunc_arg1")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", returnType, description), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$
+ Arrays.asList(
+ new FunctionParameter("clob", DataTypeManager.DefaultDataTypes.CLOB, QueryPlugin.Util.getString("SystemSource.Clobfunc_arg1")) ), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", returnType, description), true, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$
}
private void addConcatFunction() {
@@ -543,10 +541,10 @@
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concatop_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
FunctionMethod concat2 = new FunctionMethod("concat2", QueryPlugin.Util.getString("SystemSource.Concat_desc"), STRING, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("string1", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")), true, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("string2", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_arg2")) ), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Concat_result_desc")), false, Determinism.DETERMINISTIC ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(concat2);
}
@@ -620,9 +618,8 @@
private void addSpaceFunction() {
functions.add(
- new FunctionMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Space_arg1"))}, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(FunctionLibrary.SPACE, QueryPlugin.Util.getString("SystemSource.Space_desc"), STRING, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("count", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.Space_arg1"))}, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Space_result")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -792,18 +789,16 @@
private void addDecodeFunction(String functionName, String resultType) {
functions.add(
- new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode1_desc"), MISCELLANEOUS, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode1_desc"), MISCELLANEOUS, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode1_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", resultType, QueryPlugin.Util.getString("SystemSource.Decode1_result") ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode2_desc"), MISCELLANEOUS, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("delimiter", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(functionName, QueryPlugin.Util.getString("SystemSource.Decode2_desc"), MISCELLANEOUS, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("input", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("decodeString", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("delimiter", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Decode2_arg3")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", resultType, QueryPlugin.Util.getString("SystemSource.Decode2_result") ) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -812,54 +807,54 @@
for (String keyValueType : DataTypeManager.getAllDataTypeNames()) {
functions.add(
new FunctionMethod("lookup", QueryPlugin.Util.getString("SystemSource.Lookup_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "lookup", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("codetable", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lookup_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("returnelement", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lookup_arg2")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("keyelement", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Lookup_arg3")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("keyvalue", keyValueType, QueryPlugin.Util.getString("SystemSource.Lookup_arg4")), //$NON-NLS-1$ //$NON-NLS-2$
- },
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.Lookup_result")), true, Determinism.VDB_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("keyvalue", keyValueType, QueryPlugin.Util.getString("SystemSource.Lookup_arg4")) //$NON-NLS-1$ //$NON-NLS-2$
+ ),
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.OBJECT, QueryPlugin.Util.getString("SystemSource.Lookup_result")), false, Determinism.VDB_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
}
private void addUserFunction() {
functions.add(
new FunctionMethod("user", QueryPlugin.Util.getString("SystemSource.User_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "user", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), false, Determinism.USER_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.User_result")), true, Determinism.USER_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addCurrentDatabaseFunction() {
functions.add(
new FunctionMethod("current_database", QueryPlugin.Util.getString("SystemSource.current_database_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "current_database", null, //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("current_database_result")), false, Determinism.VDB_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("current_database_result")), true, Determinism.VDB_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addEnvFunction() {
functions.add(
new FunctionMethod("env", QueryPlugin.Util.getString("SystemSource.Env_desc"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "env", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("variablename", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_varname")) //$NON-NLS-1$ //$NON-NLS-2$
- },
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ ),
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Env_result")), true, Determinism.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, PushDown.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, Determinism.SESSION_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.session_id_result")), true, Determinism.SESSION_DETERMINISTIC) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addCommandPayloadFunctions() {
functions.add(
new FunctionMethod("commandpayload", QueryPlugin.Util.getString("SystemSource.CommandPayload_desc0"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {},
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, Determinism.COMMAND_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ null,
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), true, Determinism.COMMAND_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
new FunctionMethod("commandpayload", QueryPlugin.Util.getString("SystemSource.CommandPayload_desc1"), MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, FUNCTION_CLASS, "commandPayload", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("property", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_property")) //$NON-NLS-1$ //$NON-NLS-2$
- },
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), false, Determinism.COMMAND_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ ),
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.CommandPayload_result")), true, Determinism.COMMAND_DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addIfNullFunctions() {
@@ -899,16 +894,14 @@
new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattimestamp_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattimestamp_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(FunctionLibrary.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Formatdate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formatdate_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(FunctionLibrary.FORMATDATE, QueryPlugin.Util.getString("SystemSource.Formatdate_desc"),CONVERSION, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("date", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Formatdate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formatdate_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formatdate_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(FunctionLibrary.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("time", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Formattime_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattime_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(FunctionLibrary.FORMATTIME, QueryPlugin.Util.getString("SystemSource.Formattime_desc"),CONVERSION, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("time", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Formattime_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattime_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Formattime_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -920,16 +913,14 @@
new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.Parsetimestamp_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(FunctionLibrary.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("time", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetime_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetime_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(FunctionLibrary.PARSETIME, QueryPlugin.Util.getString("SystemSource.Parsetime_desc"),CONVERSION, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("time", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetime_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsetime_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIME, QueryPlugin.Util.getString("SystemSource.Parsetime_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
functions.add(
- new FunctionMethod(FunctionLibrary.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"),CONVERSION, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
- new FunctionParameter("date", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsedate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsedate_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
+ createSyntheticMethod(FunctionLibrary.PARSEDATE, QueryPlugin.Util.getString("SystemSource.Parsedate_desc"),CONVERSION, null, null, new FunctionParameter[] { //$NON-NLS-1$
+ new FunctionParameter("date", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsedate_arg1")), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("format", DataTypeManager.DefaultDataTypes.STRING, QueryPlugin.Util.getString("SystemSource.Parsedate_arg2")) }, //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("result", DataTypeManager.DefaultDataTypes.DATE, QueryPlugin.Util.getString("SystemSource.Parsedate_result_desc")) ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
@@ -1038,10 +1029,10 @@
private void addXmlConcat() {
functions.add(new FunctionMethod(SourceSystemFunctions.XMLCONCAT, QueryPlugin.Util.getString("SystemSource.xmlconcat_description"), XML, PushDown.CAN_PUSHDOWN, XML_FUNCTION_CLASS, "xmlConcat", //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("param1", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_param1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("param2", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_param2"), true)}, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_result")), true, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("param2", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_param2"), true)), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.XML, QueryPlugin.Util.getString("SystemSource.xmlconcat_result")), false, Determinism.DETERMINISTIC ) ); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addTimeZoneFunctions() {
@@ -1062,29 +1053,29 @@
private void addUnixTimeFunctions() {
functions.add(new FunctionMethod(FunctionLibrary.FROM_UNIXTIME, QueryPlugin.Util.getString("SystemSource.from_unixtime_description"), DATETIME, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("unix_timestamp", DataTypeManager.DefaultDataTypes.INTEGER, QueryPlugin.Util.getString("SystemSource.from_unixtime_param1")) //$NON-NLS-1$ //$NON-NLS-2$
- },
- new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.from_unixtime_result")), false, Determinism.DETERMINISTIC )); //$NON-NLS-1$ //$NON-NLS-2$
+ ),
+ new FunctionParameter("result", DataTypeManager.DefaultDataTypes.TIMESTAMP, QueryPlugin.Util.getString("SystemSource.from_unixtime_result")), true, Determinism.DETERMINISTIC )); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addTypedNullIfFunction(String type) {
functions.add(
new FunctionMethod(FunctionLibrary.NULLIF, QueryPlugin.Util.getString("SystemSource.nullif_description"), MISCELLANEOUS, PushDown.SYNTHETIC, null, null, //$NON-NLS-1$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("op1", type, QueryPlugin.Util.getString("SystemSource.nullif_param1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("op2", type, QueryPlugin.Util.getString("SystemSource.nullif_param1")) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.nullif_result")), true, Determinism.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("op2", type, QueryPlugin.Util.getString("SystemSource.nullif_param1")) ), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.nullif_result")), false, Determinism.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
}
private void addTypedCoalesceFunction(String type) {
functions.add(
new FunctionMethod(FunctionLibrary.COALESCE, QueryPlugin.Util.getString("SystemSource.coalesce_description"), MISCELLANEOUS, PushDown.CAN_PUSHDOWN, FUNCTION_CLASS, "coalesce", //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter[] {
+ Arrays.asList(
new FunctionParameter("op1", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1")), //$NON-NLS-1$ //$NON-NLS-2$
new FunctionParameter("op2", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1")), //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("op3", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1"), true) }, //$NON-NLS-1$ //$NON-NLS-2$
- new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.coalesce_result")), true, Determinism.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("op3", type, QueryPlugin.Util.getString("SystemSource.coalesce_param1"), true) ), //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter("result", type, QueryPlugin.Util.getString("SystemSource.coalesce_result")), false, Determinism.DETERMINISTIC)); //$NON-NLS-1$ //$NON-NLS-2$
}
/**
@@ -1104,4 +1095,10 @@
public Class<?> getInvocationClass(String className, ClassLoader classloader) throws ClassNotFoundException {
return Class.forName(className, true, classloader);
}
+
+ public static FunctionMethod createSyntheticMethod(String name, String description, String category,
+ String invocationClass, String invocationMethod, FunctionParameter[] inputParams,
+ FunctionParameter outputParam) {
+ return new FunctionMethod(name, description, category, PushDown.SYNTHETIC, invocationClass, invocationMethod, inputParams!=null?Arrays.asList(inputParams):null, outputParam, false,Determinism.NONDETERMINISTIC);
+ }
}
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/engine/src/test/java/org/teiid/query/function/TestFunctionTree.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -24,6 +24,7 @@
import static org.junit.Assert.*;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
@@ -77,7 +78,7 @@
@Test public void testLoadErrors() {
FunctionMethod method = new FunctionMethod(
"dummy", null, null, PushDown.CAN_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[0],
+ new ArrayList<FunctionParameter>(0),
new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), false, Determinism.DETERMINISTIC); //$NON-NLS-1$
//allowed, since we're not validating the class
@@ -140,7 +141,7 @@
@Test public void testNullCategory() {
FunctionMethod method = new FunctionMethod(
"dummy", null, null, PushDown.MUST_PUSHDOWN, "nonexistentClass", "noMethod", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[0],
+ new ArrayList<FunctionParameter>(0),
new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$
false, Determinism.DETERMINISTIC);
@@ -154,9 +155,9 @@
@Test public void testVarbinary() throws Exception {
FunctionMethod method = new FunctionMethod(
"dummy", null, null, PushDown.CANNOT_PUSHDOWN, TestFunctionTree.class.getName(), "toString", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- new FunctionParameter[] {new FunctionParameter("in", DataTypeManager.DefaultDataTypes.VARBINARY)}, //$NON-NLS-1$
+ Arrays.asList(new FunctionParameter("in", DataTypeManager.DefaultDataTypes.VARBINARY)), //$NON-NLS-1$
new FunctionParameter("output", DataTypeManager.DefaultDataTypes.STRING), //$NON-NLS-1$
- false, Determinism.DETERMINISTIC);
+ true, Determinism.DETERMINISTIC);
FunctionTree sys = RealMetadataFactory.SFM.getSystemFunctions();
FunctionLibrary fl = new FunctionLibrary(sys, new FunctionTree("foo", new UDFSource(Arrays.asList(method)), true));
FunctionDescriptor fd = fl.findFunction("dummy", new Class<?>[] {DataTypeManager.DefaultDataClasses.VARBINARY});
Modified: trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -22,19 +22,15 @@
package org.teiid.query.function.metadata;
-import junit.framework.TestCase;
-
+import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
+import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
-public class TestFunctionMethod extends TestCase {
+public class TestFunctionMethod {
- public TestFunctionMethod(String name) {
- super(name);
- }
-
- public void testEquivalence1() {
+ @Test public void testEquivalence1() {
FunctionParameter p1 = new FunctionParameter("in", "string"); //$NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout = new FunctionParameter("out", "string"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -45,7 +41,7 @@
UnitTestUtil.helpTestEquivalence(0, m1, m1);
}
- public void testEquivalence11() {
+ @Test public void testEquivalence11() {
FunctionParameter pout = new FunctionParameter("out", "string"); //$NON-NLS-1$ //$NON-NLS-2$
FunctionMethod m1 = new FunctionMethod("length", "", FunctionCategoryConstants.STRING, //$NON-NLS-1$ //$NON-NLS-2$
@@ -55,7 +51,7 @@
UnitTestUtil.helpTestEquivalence(0, m1, m1);
}
- public void testEquivalence2() {
+ @Test public void testEquivalence2() {
FunctionParameter p1 = new FunctionParameter("in", "string"); //$NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout = new FunctionParameter("out", "string"); //$NON-NLS-1$ //$NON-NLS-2$
@@ -73,7 +69,7 @@
UnitTestUtil.helpTestEquivalence(1, m1, m2);
}
- public void testEquivalence3() {
+ @Test public void testEquivalence3() {
FunctionParameter p1 = new FunctionParameter("in", "string"); //$NON-NLS-1$ //$NON-NLS-2$
FunctionParameter pout = new FunctionParameter("out", "string"); //$NON-NLS-1$ //$NON-NLS-2$
Modified: trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/engine/src/test/java/org/teiid/query/optimizer/FakeFunctionMetadataSource.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -27,20 +27,21 @@
import java.util.List;
import org.teiid.core.types.DataTypeManager;
+import org.teiid.metadata.FunctionMethod;
import org.teiid.metadata.FunctionParameter;
+import org.teiid.metadata.FunctionMethod.Determinism;
import org.teiid.metadata.FunctionMethod.PushDown;
import org.teiid.query.function.FunctionMetadataSource;
-import org.teiid.query.function.metadata.FunctionMethod;
-
+@SuppressWarnings("nls")
public class FakeFunctionMetadataSource implements FunctionMetadataSource {
public Collection<org.teiid.metadata.FunctionMethod> getFunctionMethods() {
List<org.teiid.metadata.FunctionMethod> methods = new ArrayList<org.teiid.metadata.FunctionMethod>();
methods.add(new FunctionMethod("xyz", "", "misc", PushDown.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$
+ null,
+ new FunctionParameter("out", "integer"), true, Determinism.DETERMINISTIC)); //$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$
@@ -60,7 +61,7 @@
return methods;
}
- public Class getInvocationClass(String className, ClassLoader cl) throws ClassNotFoundException {
+ public Class<?> getInvocationClass(String className, ClassLoader cl) throws ClassNotFoundException {
return Class.forName(className, true, cl);
}
Modified: trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -533,7 +533,7 @@
}
if (valid && outputParam != null) {
model.addFunction(new FunctionMethod(procedureRecord.getName(), procedureRecord.getAnnotation(), model.getName(), PushDown.MUST_PUSHDOWN,
- null, null, args.toArray(new FunctionParameter[args.size()]), outputParam, false, deterministic?Determinism.DETERMINISTIC:Determinism.NONDETERMINISTIC));
+ null, null, args, outputParam, false, deterministic?Determinism.DETERMINISTIC:Determinism.NONDETERMINISTIC));
continue;
}
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/test-integration/common/src/test/java/org/teiid/jdbc/TestLocalConnections.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -160,7 +160,7 @@
};
}
});
- FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", new FunctionParameter[0], new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), true, FunctionMethod.Determinism.NONDETERMINISTIC);
+ FunctionMethod function = new FunctionMethod("foo", null, FunctionCategoryConstants.MISCELLANEOUS, PushDown.CANNOT_PUSHDOWN, TestLocalConnections.class.getName(), "blocking", null, new FunctionParameter("result", DataTypeManager.DefaultDataTypes.INTEGER), false, FunctionMethod.Determinism.NONDETERMINISTIC);
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
udfs.put("test", Arrays.asList(function));
server.deployVDB("PartsSupplier", UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb", udfs);
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestMatViews.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -68,7 +68,7 @@
@Before public void setUp() throws Exception {
server = new FakeServer();
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
- udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), false, Determinism.NONDETERMINISTIC)));
+ udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), true, Determinism.NONDETERMINISTIC)));
server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", udfs);
conn = server.createConnection("jdbc:teiid:matviews");
}
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java 2012-02-18 03:14:47 UTC (rev 3891)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestReplication.java 2012-02-20 02:38:50 UTC (rev 3892)
@@ -138,7 +138,7 @@
server.setReplicator(jor);
server.start(new DQPConfiguration(), true);
HashMap<String, Collection<FunctionMethod>> udfs = new HashMap<String, Collection<FunctionMethod>>();
- udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), false, Determinism.NONDETERMINISTIC)));
+ udfs.put("funcs", Arrays.asList(new FunctionMethod("pause", null, null, PushDown.CANNOT_PUSHDOWN, TestMatViews.class.getName(), "pause", null, new FunctionParameter("return", DataTypeManager.DefaultDataTypes.INTEGER), true, Determinism.NONDETERMINISTIC)));
server.deployVDB(MATVIEWS, UnitTestUtil.getTestDataPath() + "/matviews.vdb", udfs);
return server;
}
12 years, 10 months
teiid SVN: r3891 - branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-17 22:14:47 -0500 (Fri, 17 Feb 2012)
New Revision: 3891
Modified:
branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
Log:
TEIIDDES-152 adding extension properties for null-on-null and varargs
Modified: branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2012-02-17 16:12:11 UTC (rev 3890)
+++ branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2012-02-18 03:14:47 UTC (rev 3891)
@@ -497,6 +497,8 @@
}
} else if (procedureRecord.isFunction()) {
boolean deterministic = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "deterministic", true)); //$NON-NLS-1$
+ boolean nullOnNull = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "null-on-null", false)); //$NON-NLS-1$
+ boolean varargs = Boolean.valueOf(procedureRecord.getProperty(AbstractMetadataRecord.RELATIONAL_URI + "varargs", false)); //$NON-NLS-1$
FunctionParameter outputParam = null;
List<FunctionParameter> args = new ArrayList<FunctionParameter>(procedureRecord.getParameters().size() - 1);
boolean valid = true;
@@ -520,8 +522,13 @@
}
}
if (valid && outputParam != null) {
- model.addFunction(new FunctionMethod(procedureRecord.getName(), procedureRecord.getAnnotation(), model.getName(), PushDown.MUST_PUSHDOWN,
- null, null, args.toArray(new FunctionParameter[args.size()]), outputParam, false, deterministic?Determinism.DETERMINISTIC:Determinism.NONDETERMINISTIC));
+ FunctionMethod function = new FunctionMethod(procedureRecord.getName(), procedureRecord.getAnnotation(), model.getName(), PushDown.MUST_PUSHDOWN,
+ null, null, args.toArray(new FunctionParameter[args.size()]), outputParam, false, deterministic?Determinism.DETERMINISTIC:Determinism.NONDETERMINISTIC);
+ function.setNullOnNull(nullOnNull);
+ if (varargs && !function.getInputParameters().isEmpty()) {
+ function.getInputParameters().get(args.size() - 1).setVarArg(varargs);
+ }
+ model.addFunction(function);
continue;
}
}
12 years, 10 months
teiid SVN: r3890 - in trunk/test-integration: perf and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-17 11:12:11 -0500 (Fri, 17 Feb 2012)
New Revision: 3890
Modified:
trunk/test-integration/perf/pom.xml
trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java
trunk/test-integration/pom.xml
Log:
forward merge from 7.7
Modified: trunk/test-integration/perf/pom.xml
===================================================================
--- trunk/test-integration/perf/pom.xml 2012-02-16 16:09:23 UTC (rev 3889)
+++ trunk/test-integration/perf/pom.xml 2012-02-17 16:12:11 UTC (rev 3890)
@@ -3,26 +3,11 @@
<parent>
<artifactId>teiid-test-integration</artifactId>
<groupId>org.jboss.teiid</groupId>
- <version>7.7.0.CR1</version>
+ <version>8.0.0.beta1-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>test-integration-perf</artifactId>
- <name>Common Integration Tests</name>
+ <name>Performance Integration Tests</name>
<description>Performance tests that do not require external dependencies</description>
- <dependencies>
- <dependency>
- <artifactId>teiid-cache-jbosscache</artifactId>
- <groupId>org.jboss.teiid</groupId>
- </dependency>
- <dependency>
- <groupId>jgroups</groupId>
- <artifactId>jgroups</artifactId>
- </dependency>
- <dependency>
- <groupId>commons-logging</groupId>
- <artifactId>commons-logging</artifactId>
- </dependency>
- </dependencies>
-
</project>
\ No newline at end of file
Modified: trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java
===================================================================
--- trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java 2012-02-16 16:09:23 UTC (rev 3889)
+++ trunk/test-integration/perf/src/test/java/org/teiid/query/eval/TestEnginePerformance.java 2012-02-17 16:12:11 UTC (rev 3890)
@@ -83,7 +83,6 @@
import org.teiid.query.sql.lang.OrderBy;
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.unittest.RealMetadataFactory;
import org.teiid.query.util.CommandContext;
@@ -203,7 +202,7 @@
return data;
}
- public void helpTestSort(Mode mode, int expectedRowCount, List<? extends SingleElementSymbol> sortElements, List<?>[] data, List<? extends SingleElementSymbol> elems, BufferManager bufferManager) throws TeiidComponentException, TeiidProcessingException {
+ public void helpTestSort(Mode mode, int expectedRowCount, List<? extends Expression> sortElements, List<?>[] data, List<? extends Expression> elems, BufferManager bufferManager) throws TeiidComponentException, TeiidProcessingException {
CommandContext context = new CommandContext ("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
BlockingFakeRelationalNode dataNode = new BlockingFakeRelationalNode(0, data);
@@ -221,7 +220,7 @@
process(sortNode, expectedRowCount);
}
- public void helpTestEquiJoin(int expectedRowCount, List<?>[] leftData, List<?>[] rightData, List<? extends SingleElementSymbol> elems, BufferManager bufferManager, JoinStrategy joinStrategy, JoinType joinType) throws TeiidComponentException, TeiidProcessingException {
+ public void helpTestEquiJoin(int expectedRowCount, List<?>[] leftData, List<?>[] rightData, List<? extends Expression> elems, BufferManager bufferManager, JoinStrategy joinStrategy, JoinType joinType) throws TeiidComponentException, TeiidProcessingException {
CommandContext context = new CommandContext ("pid", "test", null, null, 1); //$NON-NLS-1$ //$NON-NLS-2$
FakeRelationalNode dataNode1 = new FakeRelationalNode(1, leftData);
Modified: trunk/test-integration/pom.xml
===================================================================
--- trunk/test-integration/pom.xml 2012-02-16 16:09:23 UTC (rev 3889)
+++ trunk/test-integration/pom.xml 2012-02-17 16:12:11 UTC (rev 3890)
@@ -18,6 +18,18 @@
<apache.ant.version>1.7.0</apache.ant.version>
</properties>
+
+ <profiles>
+ <profile>
+ <!--
+ This profile is activated manually, as in "mvn ... -P release ..."
+ -->
+ <id>perf</id>
+ <modules>
+ <module>perf</module>
+ </modules>
+ </profile>
+ </profiles>
<dependencies>
<dependency>
12 years, 10 months
teiid SVN: r3889 - branches/7.7.x/api/src/main/java/org/teiid/metadata.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-16 11:09:23 -0500 (Thu, 16 Feb 2012)
New Revision: 3889
Modified:
branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java
Log:
TEIID-1936 refining the set method for the metadatastore
Modified: branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2012-02-15 22:48:46 UTC (rev 3888)
+++ branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2012-02-16 16:09:23 UTC (rev 3889)
@@ -350,5 +350,10 @@
public void setMetadataStore(MetadataStore metadataStore) {
this.store = metadataStore;
+ if (this.store.getSchemas().isEmpty()) {
+ this.store.addSchema(schema);
+ } else {
+ this.schema = this.store.getSchemas().values().iterator().next();
+ }
}
}
12 years, 10 months
teiid SVN: r3887 - in branches/7.7.x/engine/src: main/java/org/teiid/query/processor/relational and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-15 15:12:04 -0500 (Wed, 15 Feb 2012)
New Revision: 3887
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
Log:
TEIID-1939 fix for error with multisource metadata
Modified: branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2012-02-15 20:01:52 UTC (rev 3886)
+++ branches/7.7.x/engine/src/main/java/org/teiid/dqp/internal/process/multisource/MultiSourcePlanToProcessConverter.java 2012-02-15 20:12:04 UTC (rev 3887)
@@ -113,7 +113,10 @@
throw new QueryPlannerException(e, e.getMessage());
}
} else if (node instanceof ProjectIntoNode) {
- throw new AssertionError("Multisource insert with query expression not allowed not allowed, should have been caught in validation."); //$NON-NLS-1$
+ ProjectIntoNode pin = (ProjectIntoNode)node;
+ if(this.multiSourceModels.contains(pin.getModelName())) {
+ throw new AssertionError("Multisource insert with query expression not allowed, should have been caught in validation."); //$NON-NLS-1$
+ }
}
return node;
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2012-02-15 20:01:52 UTC (rev 3886)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/ProjectIntoNode.java 2012-02-15 20:12:04 UTC (rev 3887)
@@ -296,4 +296,9 @@
public void closeDirect() {
closeRequest();
}
+
+ public String getModelName() {
+ return modelName;
+ }
+
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2012-02-15 20:01:52 UTC (rev 3886)
+++ branches/7.7.x/engine/src/test/java/org/teiid/dqp/internal/process/multisource/TestMultiSourcePlanToProcessConverter.java 2012-02-15 20:12:04 UTC (rev 3887)
@@ -38,6 +38,9 @@
import org.teiid.dqp.internal.process.DQPWorkContext;
import org.teiid.query.analysis.AnalysisRecord;
import org.teiid.query.metadata.QueryMetadataInterface;
+import org.teiid.query.metadata.TempCapabilitiesFinder;
+import org.teiid.query.metadata.TempMetadataAdapter;
+import org.teiid.query.metadata.TempMetadataStore;
import org.teiid.query.optimizer.QueryOptimizer;
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
@@ -92,8 +95,6 @@
}
public void helpTestMultiSourcePlan(QueryMetadataInterface metadata, String userSql, String multiModel, int sourceCount, ProcessorDataManager dataMgr, List<?>[] expectedResults, VDBMetaData vdb, List<?> params) throws Exception {
-
- DQPWorkContext dqpContext = RealMetadataFactory.buildWorkContext(metadata, vdb);
Set<String> multiSourceModels = vdb.getMultiSourceModelNames();
for (String model:multiSourceModels) {
@@ -106,7 +107,10 @@
}
}
- MultiSourceMetadataWrapper wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
+ QueryMetadataInterface wrapper = new MultiSourceMetadataWrapper(metadata, multiSourceModels);
+ wrapper = new TempMetadataAdapter(wrapper, new TempMetadataStore());
+ DQPWorkContext dqpContext = RealMetadataFactory.buildWorkContext(wrapper, vdb);
+
AnalysisRecord analysis = new AnalysisRecord(false, DEBUG);
Command command = TestResolver.helpResolve(userSql, wrapper);
@@ -117,14 +121,14 @@
BasicSourceCapabilities bsc = TestOptimizer.getTypicalCapabilities();
bsc.setFunctionSupport(SourceSystemFunctions.CONCAT, true);
fakeFinder.addCapabilities(multiModel, bsc);
-
+
CapabilitiesFinder finder = new MultiSourceCapabilitiesFinder(fakeFinder, multiSourceModels);
-
+ finder = new TempCapabilitiesFinder(finder);
IDGenerator idGenerator = new IDGenerator();
Properties props = new Properties();
CommandContext context = new CommandContext("0", "test", "user", null, vdb.getName(), vdb.getVersion(), props, false); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(metadata, idGenerator, analysis, finder, multiSourceModels, dqpContext, context));
+ context.setPlanToProcessConverter(new MultiSourcePlanToProcessConverter(wrapper, idGenerator, analysis, finder, multiSourceModels, dqpContext, context));
ProcessorPlan plan = QueryOptimizer.optimizePlan(command, wrapper, idGenerator, finder, analysis, context);
@@ -346,5 +350,17 @@
dataMgr.addData("EXEC MultiModel.proc('b')", new List<?>[] {Arrays.asList(1)}); //$NON-NLS-1$
helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
}
+
+ @Test public void testTempInsert() throws Exception {
+ final QueryMetadataInterface metadata = RealMetadataFactory.exampleMultiBinding();
+ final String userSql = "INSERT INTO #x select * from MultiModel.Phys"; //$NON-NLS-1$
+ final String multiModel = "MultiModel"; //$NON-NLS-1$
+ final int sources = 3;
+ final List<?>[] expected = new List<?>[] { Arrays.asList(3)};
+ final MultiSourceDataManager dataMgr = new MultiSourceDataManager();
+ dataMgr.setMustRegisterCommands(true);
+ dataMgr.addData("SELECT g_0.a, g_0.b FROM MultiModel.Phys AS g_0", new List<?>[] {Arrays.asList("a", "b")}); //$NON-NLS-1$
+ helpTestMultiSourcePlan(metadata, userSql, multiModel, sources, dataMgr, expected, RealMetadataFactory.exampleMultiBindingVDB());
+ }
}
12 years, 10 months
teiid SVN: r3886 - in branches/7.7.x/connectors/sandbox/translator-coherence/src: test/java/org/teiid/translator/coherence and 1 other directories.
by teiid-commits@lists.jboss.org
Author: van.halbert
Date: 2012-02-15 15:01:52 -0500 (Wed, 15 Feb 2012)
New Revision: 3886
Modified:
branches/7.7.x/connectors/sandbox/translator-coherence/src/main/java/org/teiid/translator/coherence/CoherenceExecutionFactory.java
branches/7.7.x/connectors/sandbox/translator-coherence/src/test/java/org/teiid/translator/coherence/TestCoherenceTranslator.java
branches/7.7.x/connectors/sandbox/translator-coherence/src/test/resources/Coherence_Designer_Project/Trade.vdb
branches/7.7.x/connectors/sandbox/translator-coherence/src/test/resources/Coherence_Designer_Project/Trade_Object.xmi
Log:
fix issue when submitting delete of root object
Modified: branches/7.7.x/connectors/sandbox/translator-coherence/src/main/java/org/teiid/translator/coherence/CoherenceExecutionFactory.java
===================================================================
--- branches/7.7.x/connectors/sandbox/translator-coherence/src/main/java/org/teiid/translator/coherence/CoherenceExecutionFactory.java 2012-02-15 18:39:23 UTC (rev 3885)
+++ branches/7.7.x/connectors/sandbox/translator-coherence/src/main/java/org/teiid/translator/coherence/CoherenceExecutionFactory.java 2012-02-15 20:01:52 UTC (rev 3886)
@@ -89,6 +89,10 @@
public List getSupportedFunctions() {
return Collections.EMPTY_LIST;
}
+
+ public boolean supportsCompareCriteriaEquals() {
+ return true;
+ }
@Override
Modified: branches/7.7.x/connectors/sandbox/translator-coherence/src/test/java/org/teiid/translator/coherence/TestCoherenceTranslator.java
===================================================================
--- branches/7.7.x/connectors/sandbox/translator-coherence/src/test/java/org/teiid/translator/coherence/TestCoherenceTranslator.java 2012-02-15 18:39:23 UTC (rev 3885)
+++ branches/7.7.x/connectors/sandbox/translator-coherence/src/test/java/org/teiid/translator/coherence/TestCoherenceTranslator.java 2012-02-15 20:01:52 UTC (rev 3886)
@@ -275,8 +275,11 @@
}
-
- public TranslationUtility getTradeTranslationUtility() {
+ /**
+ * this is used as an alternative to loading the vdb
+ * @return
+ */
+ private TranslationUtility getTradeTranslationUtility() {
MetadataStore metadataStore = new MetadataStore();
// Create TRADE
Schema trading = RealMetadataFactory.createPhysicalModel("Trade_Object", metadataStore); //$NON-NLS-1$
Modified: branches/7.7.x/connectors/sandbox/translator-coherence/src/test/resources/Coherence_Designer_Project/Trade.vdb
===================================================================
(Binary files differ)
Modified: branches/7.7.x/connectors/sandbox/translator-coherence/src/test/resources/Coherence_Designer_Project/Trade_Object.xmi
===================================================================
--- branches/7.7.x/connectors/sandbox/translator-coherence/src/test/resources/Coherence_Designer_Project/Trade_Object.xmi 2012-02-15 18:39:23 UTC (rev 3885)
+++ branches/7.7.x/connectors/sandbox/translator-coherence/src/test/resources/Coherence_Designer_Project/Trade_Object.xmi 2012-02-15 20:01:52 UTC (rev 3886)
@@ -11,7 +11,7 @@
</diagram>
</diagram:DiagramContainer>
<relational:BaseTable xmi:uuid="mmuuid:5b23705c-0091-412a-9e79-c61ed02bd618" name="Trade" nameInSource="org.teiid.translator.coherence.Trade" cardinality="1">
- <columns xmi:uuid="mmuuid:9ac8e953-1818-4ce6-a9d8-14d1a8539370" name="TradeID" nameInSource="TradeId" nativeType="Long" uniqueKeys="mmuuid/48e9ee81-01d2-4696-b63f-6a9f6f326aef">
+ <columns xmi:uuid="mmuuid:9ac8e953-1818-4ce6-a9d8-14d1a8539370" name="TradeID" nameInSource="TradeId" nativeType="Long" uniqueKeys="mmuuid/ac210048-f093-4ed3-9af4-90669fc99c3c">
<type href="http://www.w3.org/2001/XMLSchema#long"/>
</columns>
<columns xmi:uuid="mmuuid:139a5ee2-44dc-4b5f-b3d0-68a269ffd7a1" name="Name" nameInSource="Name" nativeType="String" caseSensitive="false">
@@ -20,7 +20,7 @@
<columns xmi:uuid="mmuuid:9e0828ec-d634-4211-8e44-6f94f3092a27" name="Legs" nativeType="Collection" selectable="false" updateable="false">
<type href="http://www.metamatrix.com/metamodels/SimpleDatatypes-instance#object"/>
</columns>
- <primaryKey xmi:uuid="mmuuid:48e9ee81-01d2-4696-b63f-6a9f6f326aef" name="TradeID_PK" nameInSource="" columns="mmuuid/9ac8e953-1818-4ce6-a9d8-14d1a8539370" foreignKeys="mmuuid/3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe"/>
+ <primaryKey xmi:uuid="mmuuid:ac210048-f093-4ed3-9af4-90669fc99c3c" name="TradeId_PK" columns="mmuuid/9ac8e953-1818-4ce6-a9d8-14d1a8539370" foreignKeys="mmuuid/3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe"/>
</relational:BaseTable>
<relational:BaseTable xmi:uuid="mmuuid:3c3beef7-0a75-4bbb-9aaa-7ea240da41f3" name="Leg" nameInSource="org.teiid.translator.coherence.Leg" cardinality="10">
<columns xmi:uuid="mmuuid:3ad9207c-b90f-4aca-bd66-8cd9b3a0e2a3" name="LegID" nameInSource="LegId" nativeType="Long" uniqueKeys="mmuuid/ea715b26-57e0-4245-b3a4-d326dcde47aa">
@@ -35,7 +35,7 @@
<columns xmi:uuid="mmuuid:937693a2-bd2b-40eb-971d-8eee24fca82a" name="TradeID" nameInSource="TradeId" nativeType="Long" selectable="false" updateable="false" foreignKeys="mmuuid/3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe">
<type href="http://www.w3.org/2001/XMLSchema#long"/>
</columns>
- <foreignKeys xmi:uuid="mmuuid:3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe" name="LegToTrade_FK" nameInSource="Legs" columns="mmuuid/937693a2-bd2b-40eb-971d-8eee24fca82a" uniqueKey="mmuuid/48e9ee81-01d2-4696-b63f-6a9f6f326aef"/>
+ <foreignKeys xmi:uuid="mmuuid:3a3196cd-3e6c-48bf-aa02-e6c99fb1fafe" name="LegToTrade_FK" nameInSource="Legs" columns="mmuuid/937693a2-bd2b-40eb-971d-8eee24fca82a" uniqueKey="mmuuid/ac210048-f093-4ed3-9af4-90669fc99c3c"/>
<primaryKey xmi:uuid="mmuuid:ea715b26-57e0-4245-b3a4-d326dcde47aa" name="LegID_PK" columns="mmuuid/3ad9207c-b90f-4aca-bd66-8cd9b3a0e2a3"/>
</relational:BaseTable>
<mmcore:AnnotationContainer xmi:uuid="mmuuid:146acc5c-ec00-4c47-b40f-bcde7a260d72"/>
12 years, 10 months
teiid SVN: r3885 - in branches/7.7.x: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc and 5 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-02-15 13:39:23 -0500 (Wed, 15 Feb 2012)
New Revision: 3885
Added:
branches/7.7.x/metadata/src/test/resources/keys.vdb
branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
branches/7.7.x/test-integration/common/src/test/resources/keys.vdb
Removed:
branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
Modified:
branches/7.7.x/api/src/main/java/org/teiid/metadata/ForeignKey.java
branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java
branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
branches/7.7.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
Log:
TEIID-1946 allowing foreign keys to reference unique constraints
Modified: branches/7.7.x/api/src/main/java/org/teiid/metadata/ForeignKey.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/metadata/ForeignKey.java 2012-02-15 15:58:55 UTC (rev 3884)
+++ branches/7.7.x/api/src/main/java/org/teiid/metadata/ForeignKey.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -47,10 +47,17 @@
uniqueKeyID = keyID;
}
+ /**
+ * @return the primary key or unique key referenced by this foreign key
+ */
public KeyRecord getPrimaryKey() {
return this.primaryKey;
}
+ /**
+ *
+ * @param primaryKey, the primary key or unique key referenced by this foreign key
+ */
public void setPrimaryKey(KeyRecord primaryKey) {
this.primaryKey = primaryKey;
}
Modified: branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java
===================================================================
--- branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2012-02-15 15:58:55 UTC (rev 3884)
+++ branches/7.7.x/api/src/main/java/org/teiid/metadata/MetadataFactory.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -185,7 +185,7 @@
}
/**
- * Adds a foreign key to the given table. The column names should be in key order.
+ * Adds a foreign key to the given table. The referenced primary key must already exist. The column names should be in key order.
* @param name
* @param columnNames
* @param pkTable
@@ -194,20 +194,65 @@
* @throws TranslatorException
*/
public ForeignKey addForiegnKey(String name, List<String> columnNames, Table pkTable, Table table) throws TranslatorException {
+ return addForiegnKey(name, columnNames, null, pkTable, table, false);
+ }
+
+ /**
+ * Adds a foreign key to the given table. The referenced key may be automatically created if addUniqueConstraint is true. The column names should be in key order.
+ * @param name
+ * @param columnNames
+ * @param referencedColumnNames, may be null to indicate that the primary key should be used.
+ * @param pkTable
+ * @param table
+ * @param addUniqueConstraint
+ * @return
+ * @throws TranslatorException
+ */
+ public ForeignKey addForiegnKey(String name, List<String> columnNames, List<String> referencedColumnNames, Table pkTable, Table table, boolean addUniqueConstraint) throws TranslatorException {
ForeignKey foreignKey = new ForeignKey();
foreignKey.setParent(table);
+ KeyRecord uniqueKey = null;
foreignKey.setColumns(new ArrayList<Column>(columnNames.size()));
+ assignColumns(columnNames, table, foreignKey);
+ if (referencedColumnNames == null) {
+ uniqueKey = pkTable.getPrimaryKey();
+ } else {
+ for (KeyRecord record : pkTable.getUniqueKeys()) {
+ if (keyMatches(referencedColumnNames, record)) {
+ uniqueKey = record;
+ break;
+ }
+ }
+ if (uniqueKey == null && pkTable.getPrimaryKey() != null && keyMatches(referencedColumnNames, pkTable.getPrimaryKey())) {
+ uniqueKey = pkTable.getPrimaryKey();
+ }
+ }
+ if (uniqueKey == null) {
+ if (!addUniqueConstraint) {
+ throw new TranslatorException("No unique key defined for table " + pkTable + " for columns " + referencedColumnNames); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ uniqueKey = addIndex(name + "_unique", false, referencedColumnNames, pkTable); //$NON-NLS-1$
+ }
foreignKey.setName(name);
setUUID(foreignKey);
- if (pkTable.getPrimaryKey() == null) {
- throw new TranslatorException("No primary key defined for table " + pkTable); //$NON-NLS-1$
- }
- foreignKey.setPrimaryKey(pkTable.getPrimaryKey());
- foreignKey.setUniqueKeyID(pkTable.getPrimaryKey().getUUID());
- assignColumns(columnNames, table, foreignKey);
+ foreignKey.setPrimaryKey(uniqueKey);
+ foreignKey.setUniqueKeyID(uniqueKey.getUUID());
table.getForeignKeys().add(foreignKey);
return foreignKey;
}
+
+ private boolean keyMatches(List<String> names,
+ KeyRecord record) {
+ if (names.size() != record.getColumns().size()) {
+ return false;
+ }
+ for (int i = 0; i < names.size(); i++) {
+ if (!names.get(i).equals(record.getColumns().get(i))) {
+ return false;
+ }
+ }
+ return true;
+ }
/**
* Add a procedure with the given name to the model.
Modified: branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java
===================================================================
--- branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2012-02-15 15:58:55 UTC (rev 3884)
+++ branches/7.7.x/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/JDBCMetdataProcessor.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -28,8 +28,10 @@
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;
@@ -86,6 +88,7 @@
private boolean quoteNameInSource = true;
private boolean useProcedureSpecificName;
private boolean useCatalogName = true;
+ private boolean autoCreateUniqueConstraints = true;
private Set<String> unsignedTypes = new HashSet<String>();
private String quoteString;
@@ -112,17 +115,15 @@
try {
Map<String, TableInfo> tableMap = getTables(metadataFactory, metadata);
-
+ HashSet<TableInfo> tables = new LinkedHashSet<TableInfo>(tableMap.values());
if (importKeys) {
- getPrimaryKeys(metadataFactory, metadata, tableMap);
-
- getForeignKeys(metadataFactory, metadata, tableMap);
+ getPrimaryKeys(metadataFactory, metadata, tables);
+ getIndexes(metadataFactory, metadata, tables, !importIndexes);
+ getForeignKeys(metadataFactory, metadata, tables, tableMap);
+ } else if (importIndexes) {
+ getIndexes(metadataFactory, metadata, tables, false);
}
- if (importIndexes) {
- getIndexes(metadataFactory, metadata, tableMap);
- }
-
if (importProcedures) {
getProcedures(metadataFactory, metadata);
}
@@ -214,8 +215,9 @@
table.setSupportsUpdate(true);
String remarks = tables.getString(5);
table.setAnnotation(remarks);
- tableMap.put(fullName, new TableInfo(tableCatalog, tableSchema, tableName, table));
- tableMap.put(tableName, new TableInfo(tableCatalog, tableSchema, tableName, table));
+ TableInfo ti = new TableInfo(tableCatalog, tableSchema, tableName, table);
+ tableMap.put(fullName, ti);
+ tableMap.put(tableName, ti);
}
tables.close();
@@ -301,10 +303,10 @@
}
private void getPrimaryKeys(MetadataFactory metadataFactory,
- DatabaseMetaData metadata, Map<String, TableInfo> tableMap)
+ DatabaseMetaData metadata, Collection<TableInfo> tables)
throws SQLException, TranslatorException {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing primary keys"); //$NON-NLS-1$
- for (TableInfo tableInfo : tableMap.values()) {
+ for (TableInfo tableInfo : tables) {
ResultSet pks = metadata.getPrimaryKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
TreeMap<Short, String> keyColumns = null;
String pkName = null;
@@ -330,26 +332,31 @@
}
private void getForeignKeys(MetadataFactory metadataFactory,
- DatabaseMetaData metadata, Map<String, TableInfo> tableMap) throws SQLException, TranslatorException {
+ DatabaseMetaData metadata, Collection<TableInfo> tables, Map<String, TableInfo> tableMap) throws SQLException, TranslatorException {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing foreign keys"); //$NON-NLS-1$
- for (TableInfo tableInfo : tableMap.values()) {
+ for (TableInfo tableInfo : tables) {
ResultSet fks = metadata.getImportedKeys(tableInfo.catalog, tableInfo.schema, tableInfo.name);
TreeMap<Short, String> keyColumns = null;
+ TreeMap<Short, String> referencedKeyColumns = null;
String fkName = null;
TableInfo pkTable = null;
short savedSeqNum = Short.MAX_VALUE;
while (fks.next()) {
String columnName = fks.getString(8);
short seqNum = fks.getShort(9);
+ String pkColumnName = fks.getString(4);
+
if (seqNum <= savedSeqNum) {
if (keyColumns != null) {
- metadataFactory.addForiegnKey(fkName, new ArrayList<String>(keyColumns.values()), pkTable.table, tableInfo.table);
+ metadataFactory.addForiegnKey(fkName, new ArrayList<String>(keyColumns.values()), new ArrayList<String>(referencedKeyColumns.values()), pkTable.table, tableInfo.table, autoCreateUniqueConstraints);
}
keyColumns = new TreeMap<Short, String>();
+ referencedKeyColumns = new TreeMap<Short, String>();
fkName = null;
}
savedSeqNum = seqNum;
keyColumns.put(seqNum, columnName);
+ referencedKeyColumns.put(seqNum, pkColumnName);
if (fkName == null) {
String tableCatalog = fks.getString(1);
String tableSchema = fks.getString(2);
@@ -367,16 +374,16 @@
}
}
if (keyColumns != null) {
- metadataFactory.addForiegnKey(fkName, new ArrayList<String>(keyColumns.values()), pkTable.table, tableInfo.table);
+ metadataFactory.addForiegnKey(fkName, new ArrayList<String>(keyColumns.values()), new ArrayList<String>(referencedKeyColumns.values()), pkTable.table, tableInfo.table, autoCreateUniqueConstraints);
}
fks.close();
}
}
private void getIndexes(MetadataFactory metadataFactory,
- DatabaseMetaData metadata, Map<String, TableInfo> tableMap) throws SQLException, TranslatorException {
+ DatabaseMetaData metadata, Collection<TableInfo> tables, boolean uniqueOnly) throws SQLException, TranslatorException {
LogManager.logDetail(LogConstants.CTX_CONNECTOR, "JDBCMetadataProcessor - Importing index info"); //$NON-NLS-1$
- for (TableInfo tableInfo : tableMap.values()) {
+ for (TableInfo tableInfo : tables) {
ResultSet indexInfo = metadata.getIndexInfo(tableInfo.catalog, tableInfo.schema, tableInfo.name, false, importApproximateIndexes);
TreeMap<Short, String> indexColumns = null;
String indexName = null;
@@ -390,7 +397,7 @@
}
short ordinalPosition = indexInfo.getShort(8);
if (ordinalPosition <= savedOrdinalPosition) {
- if (indexColumns != null) {
+ if (indexColumns != null && (!uniqueOnly || !nonUnique)) {
metadataFactory.addIndex(indexName, nonUnique, new ArrayList<String>(indexColumns.values()), tableInfo.table);
}
indexColumns = new TreeMap<Short, String>();
@@ -407,7 +414,7 @@
}
}
}
- if (indexColumns != null) {
+ if (indexColumns != null && (!uniqueOnly || !nonUnique)) {
metadataFactory.addIndex(indexName, nonUnique, new ArrayList<String>(indexColumns.values()), tableInfo.table);
}
indexInfo.close();
@@ -486,4 +493,9 @@
this.useCatalogName = useCatalog;
}
+ public void setAutoCreateUniqueConstraints(
+ boolean autoCreateUniqueConstraints) {
+ this.autoCreateUniqueConstraints = autoCreateUniqueConstraints;
+ }
+
}
Modified: branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java
===================================================================
--- branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2012-02-15 15:58:55 UTC (rev 3884)
+++ branches/7.7.x/metadata/src/main/java/org/teiid/metadata/index/IndexMetadataFactory.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -363,7 +363,11 @@
}
tableRecord.setForiegnKeys(getByParent(tableRecord.getUUID(), MetadataConstants.RECORD_TYPE.FOREIGN_KEY, ForeignKey.class, false));
for (ForeignKey foreignKeyRecord : tableRecord.getForeignKeys()) {
- foreignKeyRecord.setPrimaryKey(getPrimaryKey(foreignKeyRecord.getUniqueKeyID()));
+ KeyRecord pk = (KeyRecord) getRecordByType(foreignKeyRecord.getUniqueKeyID(), MetadataConstants.RECORD_TYPE.PRIMARY_KEY, false);
+ if (pk == null) {
+ pk = (KeyRecord) getRecordByType(foreignKeyRecord.getUniqueKeyID(), MetadataConstants.RECORD_TYPE.UNIQUE_KEY);
+ }
+ foreignKeyRecord.setPrimaryKey(pk);
loadColumnSetRecords(foreignKeyRecord, uuidColumnMap);
foreignKeyRecord.setParent(tableRecord);
}
@@ -378,7 +382,7 @@
columnSetRecordImpl.setParent(tableRecord);
}
if (tableRecord.getPrimaryKey() != null) {
- KeyRecord primaryKey = getPrimaryKey(tableRecord.getPrimaryKey().getUUID());
+ KeyRecord primaryKey = (KeyRecord) getRecordByType(tableRecord.getPrimaryKey().getUUID(), MetadataConstants.RECORD_TYPE.PRIMARY_KEY);
loadColumnSetRecords(primaryKey, uuidColumnMap);
primaryKey.setParent(tableRecord);
tableRecord.setPrimaryKey(primaryKey);
Modified: branches/7.7.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java
===================================================================
--- branches/7.7.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2012-02-15 15:58:55 UTC (rev 3884)
+++ branches/7.7.x/metadata/src/test/java/org/teiid/metadata/index/TestMultipleModelIndexes.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -51,6 +51,14 @@
assertNotNull(t.getColumns().get(0).getDatatype());
}
+ @Test public void testUniqueReferencedKey() throws Exception {
+ TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/keys.vdb");
+ Collection fks = tm.getForeignKeysInGroup(tm.getGroupID("x.a"));
+ assertEquals(1, fks.size());
+ Object pk = tm.getPrimaryKeyIDForForeignKeyID(fks.iterator().next());
+ assertNotNull(pk);
+ }
+
@Test public void testSchemaLoad() throws Exception {
TransformationMetadata tm = VDBMetadataFactory.getVDBMetadata(UnitTestUtil.getTestDataPath() + "/Test.vdb");
Added: branches/7.7.x/metadata/src/test/resources/keys.vdb
===================================================================
(Binary files differ)
Property changes on: branches/7.7.x/metadata/src/test/resources/keys.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
Deleted: branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java
===================================================================
--- branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java 2012-02-15 15:58:55 UTC (rev 3884)
+++ branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -1,129 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * See the COPYRIGHT.txt file distributed with this work for information
- * regarding copyright ownership. Some portions may be licensed
- * to Red Hat, Inc. under one or more contributor license agreements.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
- * 02110-1301 USA.
- */
-
-package org.teiid.jdbc;
-
-import static org.junit.Assert.*;
-
-import java.sql.Connection;
-import java.util.LinkedHashMap;
-import java.util.Properties;
-
-import org.junit.Test;
-import org.teiid.core.types.DataTypeManager;
-import org.teiid.core.util.UnitTestUtil;
-import org.teiid.deployers.VDBRepository;
-import org.teiid.metadata.MetadataFactory;
-import org.teiid.metadata.MetadataStore;
-import org.teiid.metadata.Procedure;
-import org.teiid.metadata.Table;
-import org.teiid.metadata.index.VDBMetadataFactory;
-import org.teiid.query.metadata.TransformationMetadata.Resource;
-import org.teiid.translator.TranslatorException;
-import org.teiid.translator.jdbc.teiid.TeiidExecutionFactory;
-
-
-/**
- */
-@SuppressWarnings("nls")
-public class TestDymamicImportedMetaData {
-
- private MetadataFactory getMetadata(Properties importProperties, Connection conn)
- throws TranslatorException {
- MetadataFactory mf = createMetadataFactory("test", importProperties);
-
- TeiidExecutionFactory tef = new TeiidExecutionFactory();
- tef.getMetadata(mf, conn);
- return mf;
- }
-
- private MetadataFactory createMetadataFactory(String schema, Properties importProperties) {
- VDBRepository vdbRepository = new VDBRepository();
- vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
- return new MetadataFactory(schema, vdbRepository.getBuiltinDatatypes(), importProperties);
- }
-
- @Test public void testProcImport() throws Exception {
- FakeServer server = new FakeServer();
- server.deployVDB("vdb", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
- Connection conn = server.createConnection("jdbc:teiid:vdb"); //$NON-NLS-1$
-
- Properties importProperties = new Properties();
- importProperties.setProperty("importer.importProcedures", Boolean.TRUE.toString());
- MetadataFactory mf = getMetadata(importProperties, conn);
- Procedure p = mf.getMetadataStore().getSchemas().get("TEST").getProcedures().get("VDB.SYS.GETXMLSCHEMAS");
- assertEquals(1, p.getResultSet().getColumns().size());
- }
-
- @Test public void testDuplicateException() throws Exception {
- FakeServer server = new FakeServer();
- MetadataFactory mf = createMetadataFactory("x", new Properties());
- MetadataFactory mf1 = createMetadataFactory("y", new Properties());
-
- Table dup = mf.addTable("dup");
- Table dup1 = mf1.addTable("dup");
-
- mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
- mf1.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup1);
-
- MetadataStore ms = mf.getMetadataStore();
- ms.addSchema(mf1.getMetadataStore().getSchemas().values().iterator().next());
-
- server.deployVDB("test", ms, new LinkedHashMap<String, Resource>());
- Connection conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
-
- Properties importProperties = new Properties();
-
- mf = getMetadata(importProperties, conn);
- Table t = mf.getMetadataStore().getSchemas().get("TEST").getTables().get("TEST.X.DUP");
- assertEquals("\"test\".\"x\".\"dup\"", t.getNameInSource());
-
- importProperties.setProperty("importer.useFullSchemaName", Boolean.FALSE.toString());
- try {
- getMetadata(importProperties, conn);
- fail();
- } catch (TranslatorException e) {
-
- }
- }
-
- @Test public void testUseCatalog() throws Exception {
- FakeServer server = new FakeServer();
- MetadataFactory mf = createMetadataFactory("x", new Properties());
-
- Table dup = mf.addTable("dup");
-
- mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
-
- MetadataStore ms = mf.getMetadataStore();
-
- server.deployVDB("test", ms, new LinkedHashMap<String, Resource>());
- Connection conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
-
- Properties importProperties = new Properties();
- importProperties.setProperty("importer.useCatalogName", Boolean.FALSE.toString());
- mf = getMetadata(importProperties, conn);
- Table t = mf.getMetadataStore().getSchemas().get("TEST").getTables().get("X.DUP");
- assertEquals("\"x\".\"dup\"", t.getNameInSource());
- }
-
-}
Copied: branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java (from rev 3868, branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDymamicImportedMetaData.java)
===================================================================
--- branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java (rev 0)
+++ branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java 2012-02-15 18:39:23 UTC (rev 3885)
@@ -0,0 +1,154 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.jdbc;
+
+import static org.junit.Assert.*;
+
+import java.sql.Connection;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Properties;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.teiid.core.types.DataTypeManager;
+import org.teiid.core.util.UnitTestUtil;
+import org.teiid.deployers.VDBRepository;
+import org.teiid.metadata.ForeignKey;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.MetadataStore;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.Table;
+import org.teiid.metadata.index.VDBMetadataFactory;
+import org.teiid.query.metadata.TransformationMetadata.Resource;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.jdbc.teiid.TeiidExecutionFactory;
+
+
+/**
+ */
+@SuppressWarnings("nls")
+public class TestDynamicImportedMetaData {
+
+ private FakeServer server;
+
+ @Before public void setup() {
+ this.server = new FakeServer();
+ }
+
+ @After public void tearDown() {
+ this.server.stop();
+ }
+
+ private MetadataFactory getMetadata(Properties importProperties, Connection conn)
+ throws TranslatorException {
+ MetadataFactory mf = createMetadataFactory("test", importProperties);
+
+ TeiidExecutionFactory tef = new TeiidExecutionFactory();
+ tef.getMetadata(mf, conn);
+ return mf;
+ }
+
+ private MetadataFactory createMetadataFactory(String schema, Properties importProperties) {
+ VDBRepository vdbRepository = new VDBRepository();
+ vdbRepository.setSystemStore(VDBMetadataFactory.getSystem());
+ return new MetadataFactory(schema, vdbRepository.getBuiltinDatatypes(), importProperties);
+ }
+
+ @Test public void testUniqueReferencedKey() throws Exception {
+ server.deployVDB("vdb", UnitTestUtil.getTestDataPath() + "/keys.vdb");
+ Connection conn = server.createConnection("jdbc:teiid:vdb"); //$NON-NLS-1$
+
+ Properties importProperties = new Properties();
+ importProperties.setProperty("importer.importKeys", "true");
+ importProperties.setProperty("importer.schemaPattern", "x");
+ MetadataFactory mf = getMetadata(importProperties, conn);
+ Table t = mf.getMetadataStore().getSchemas().get("TEST").getTables().get("VDB.X.A");
+ List<ForeignKey> fks = t.getForeignKeys();
+ assertEquals(1, fks.size());
+ assertNotNull(fks.get(0).getPrimaryKey());
+ }
+
+ @Test public void testProcImport() throws Exception {
+ server.deployVDB("vdb", UnitTestUtil.getTestDataPath() + "/TestCase3473/test.vdb");
+ Connection conn = server.createConnection("jdbc:teiid:vdb"); //$NON-NLS-1$
+
+ Properties importProperties = new Properties();
+ importProperties.setProperty("importer.importProcedures", Boolean.TRUE.toString());
+ MetadataFactory mf = getMetadata(importProperties, conn);
+ Procedure p = mf.getMetadataStore().getSchemas().get("TEST").getProcedures().get("VDB.SYS.GETXMLSCHEMAS");
+ assertEquals(1, p.getResultSet().getColumns().size());
+ }
+
+ @Test public void testDuplicateException() throws Exception {
+ MetadataFactory mf = createMetadataFactory("x", new Properties());
+ MetadataFactory mf1 = createMetadataFactory("y", new Properties());
+
+ Table dup = mf.addTable("dup");
+ Table dup1 = mf1.addTable("dup");
+
+ mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
+ mf1.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup1);
+
+ MetadataStore ms = mf.getMetadataStore();
+ ms.addSchema(mf1.getMetadataStore().getSchemas().values().iterator().next());
+
+ server.deployVDB("test", ms, new LinkedHashMap<String, Resource>());
+ Connection conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
+
+ Properties importProperties = new Properties();
+
+ mf = getMetadata(importProperties, conn);
+ Table t = mf.getMetadataStore().getSchemas().get("TEST").getTables().get("TEST.X.DUP");
+ assertEquals("\"test\".\"x\".\"dup\"", t.getNameInSource());
+
+ importProperties.setProperty("importer.useFullSchemaName", Boolean.FALSE.toString());
+ try {
+ getMetadata(importProperties, conn);
+ fail();
+ } catch (TranslatorException e) {
+
+ }
+ }
+
+ @Test public void testUseCatalog() throws Exception {
+ MetadataFactory mf = createMetadataFactory("x", new Properties());
+
+ Table dup = mf.addTable("dup");
+
+ mf.addColumn("x", DataTypeManager.DefaultDataTypes.STRING, dup);
+
+ MetadataStore ms = mf.getMetadataStore();
+
+ server.deployVDB("test", ms, new LinkedHashMap<String, Resource>());
+ Connection conn = server.createConnection("jdbc:teiid:test"); //$NON-NLS-1$
+
+ Properties importProperties = new Properties();
+ importProperties.setProperty("importer.useCatalogName", Boolean.FALSE.toString());
+ mf = getMetadata(importProperties, conn);
+ Table t = mf.getMetadataStore().getSchemas().get("TEST").getTables().get("X.DUP");
+ assertEquals("\"x\".\"dup\"", t.getNameInSource());
+ }
+
+}
Property changes on: branches/7.7.x/test-integration/common/src/test/java/org/teiid/jdbc/TestDynamicImportedMetaData.java
___________________________________________________________________
Added: svn:mime-type
+ text/plain
Added: branches/7.7.x/test-integration/common/src/test/resources/keys.vdb
===================================================================
(Binary files differ)
Property changes on: branches/7.7.x/test-integration/common/src/test/resources/keys.vdb
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
12 years, 10 months