teiid SVN: r2881 - branches/7.1.x/runtime/src/test/java/org/teiid/transport.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-01-28 11:30:06 -0500 (Fri, 28 Jan 2011)
New Revision: 2881
Modified:
branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
Log:
TEIID-1451 ensuring that the logon result gets cleared when disconnected
Modified: branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
===================================================================
--- branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java 2011-01-28 16:28:02 UTC (rev 2880)
+++ branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java 2011-01-28 16:30:06 UTC (rev 2881)
@@ -28,6 +28,7 @@
import java.net.InetSocketAddress;
import java.util.Properties;
+import org.junit.After;
import org.junit.Test;
import org.teiid.client.security.ILogon;
import org.teiid.client.security.InvalidSessionException;
@@ -58,6 +59,15 @@
private SocketServerConnectionFactory sscf;
private InetSocketAddress addr = new InetSocketAddress(0);
private int logonAttempts;
+
+ @After public void tearDown() {
+ if (this.listener != null) {
+ this.listener.stop();
+ }
+ if (this.listener1 != null) {
+ this.listener1.stop();
+ }
+ }
private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException,
ConnectionException {
13 years, 3 months
teiid SVN: r2880 - in branches/7.1.x: runtime/src/test/java/org/teiid/transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-01-28 11:28:02 -0500 (Fri, 28 Jan 2011)
New Revision: 2880
Added:
branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
Modified:
branches/7.1.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
Log:
TEIID-1451 ensuring that the logon result gets cleared when disconnected
Modified: branches/7.1.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- branches/7.1.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-01-28 14:14:41 UTC (rev 2879)
+++ branches/7.1.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-01-28 16:28:02 UTC (rev 2880)
@@ -263,6 +263,7 @@
this.logonResults.remove(this.serverInstance.getHostInfo());
if (this.logonResult != null) {
this.connectionFactory.disconnected(this.serverInstance, this.logonResult.getSessionToken());
+ this.logonResult = null;
}
}
Added: branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
===================================================================
--- branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java (rev 0)
+++ branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java 2011-01-28 16:28:02 UTC (rev 2880)
@@ -0,0 +1,128 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.transport;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.net.InetSocketAddress;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
+import org.teiid.client.security.LogonException;
+import org.teiid.client.security.LogonResult;
+import org.teiid.client.security.SessionToken;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.dqp.service.SessionService;
+import org.teiid.net.CommunicationException;
+import org.teiid.net.ConnectionException;
+import org.teiid.net.HostInfo;
+import org.teiid.net.TeiidURL;
+import org.teiid.net.socket.SocketServerConnection;
+import org.teiid.net.socket.SocketServerConnectionFactory;
+import org.teiid.net.socket.UrlServerDiscovery;
+import org.teiid.transport.TestSocketRemoting.FakeService;
+
+
+@SuppressWarnings("nls")
+public class TestFailover {
+
+ SocketListener listener;
+ SocketListener listener1;
+
+ private SocketServerConnectionFactory sscf;
+ private InetSocketAddress addr = new InetSocketAddress(0);
+ private int logonAttempts;
+
+ private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException,
+ ConnectionException {
+ listener = createListener(addr, config);
+ listener1 = createListener(addr, config);
+ listener1.stop();
+ Properties p = new Properties();
+ TeiidURL teiidUrl = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure);
+ teiidUrl.getHostInfo().add(new HostInfo(addr.getHostName(), listener1.getPort()));
+ String url = teiidUrl.getAppServerURL();
+ p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url);
+ p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
+ p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, Boolean.TRUE.toString());
+ if (sscf == null) {
+ sscf = new SocketServerConnectionFactory();
+ sscf.initialize(socketConfig);
+ }
+ return sscf.getConnection(p);
+ }
+
+ private SocketListener createListener(InetSocketAddress address, SSLConfiguration config) {
+ ClientServiceRegistryImpl server = new ClientServiceRegistryImpl();
+ server.registerClientService(ILogon.class, new LogonImpl(mock(SessionService.class), "fakeCluster") { //$NON-NLS-1$
+ @Override
+ public LogonResult logon(Properties connProps)
+ throws LogonException, ComponentNotFoundException {
+ logonAttempts++;
+ return new LogonResult(new SessionToken("dummy"), "x", 1, "z");
+ }
+
+ @Override
+ public ResultsFuture<?> ping() throws InvalidSessionException,
+ TeiidComponentException {
+ return ResultsFuture.NULL_FUTURE;
+ }
+
+ @Override
+ public void assertIdentity(SessionToken checkSession)
+ throws InvalidSessionException, TeiidComponentException {
+ throw new InvalidSessionException();
+ }
+
+ }, null);
+ server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
+ return new SocketListener(address.getPort(), address.getAddress().getHostAddress(), 1024, 1024, 1, config, server, BufferManagerFactory.getStandaloneBufferManager());
+ }
+
+ @Test public void testFailover() throws Exception {
+ SSLConfiguration config = new SSLConfiguration();
+ Properties p = new Properties();
+ SocketServerConnection conn = helpEstablishConnection(false, config, p);
+ assertTrue(conn.isOpen(1000));
+ //restart the second instance now that we know the connection was made to the first
+ listener1 = createListener(new InetSocketAddress(addr.getAddress(), listener1.getPort()), config);
+ listener.stop();
+ conn.isOpen(1000); //there is a chance this call can fail
+ assertTrue(conn.isOpen(1000));
+ listener1.stop();
+ //both instances are down
+ assertFalse(conn.isOpen(1000));
+ //bring the first back up
+ listener = createListener(new InetSocketAddress(addr.getAddress(), listener.getPort()), config);
+ assertTrue(conn.isOpen(1000));
+ assertEquals(3, logonAttempts);
+ conn.close();
+ }
+
+}
Property changes on: branches/7.1.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
13 years, 3 months
teiid SVN: r2879 - in branches/7.3.x: runtime/src/test/java/org/teiid/transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-01-28 09:14:41 -0500 (Fri, 28 Jan 2011)
New Revision: 2879
Added:
branches/7.3.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
Modified:
branches/7.3.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
Log:
TEIID-1451 ensuring that the logon result gets cleared when disconnected
Modified: branches/7.3.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java
===================================================================
--- branches/7.3.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-01-27 03:26:46 UTC (rev 2878)
+++ branches/7.3.x/client/src/main/java/org/teiid/net/socket/SocketServerConnection.java 2011-01-28 14:14:41 UTC (rev 2879)
@@ -282,6 +282,7 @@
this.logonResults.remove(this.serverInstance.getHostInfo());
if (this.logonResult != null) {
this.connectionFactory.disconnected(this.serverInstance, this.logonResult.getSessionToken());
+ this.logonResult = null;
}
}
Added: branches/7.3.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
===================================================================
--- branches/7.3.x/runtime/src/test/java/org/teiid/transport/TestFailover.java (rev 0)
+++ branches/7.3.x/runtime/src/test/java/org/teiid/transport/TestFailover.java 2011-01-28 14:14:41 UTC (rev 2879)
@@ -0,0 +1,127 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright (C) 2008 Red Hat, Inc.
+ * Licensed to Red Hat, Inc. under one or more contributor
+ * license agreements. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.transport;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+
+import java.net.InetSocketAddress;
+import java.util.Properties;
+
+import org.junit.Test;
+import org.teiid.client.security.ILogon;
+import org.teiid.client.security.InvalidSessionException;
+import org.teiid.client.security.LogonException;
+import org.teiid.client.security.LogonResult;
+import org.teiid.client.security.SessionToken;
+import org.teiid.client.util.ResultsFuture;
+import org.teiid.common.buffer.BufferManagerFactory;
+import org.teiid.core.ComponentNotFoundException;
+import org.teiid.core.TeiidComponentException;
+import org.teiid.dqp.service.SessionService;
+import org.teiid.net.CommunicationException;
+import org.teiid.net.ConnectionException;
+import org.teiid.net.HostInfo;
+import org.teiid.net.TeiidURL;
+import org.teiid.net.socket.SocketServerConnection;
+import org.teiid.net.socket.SocketServerConnectionFactory;
+import org.teiid.net.socket.UrlServerDiscovery;
+import org.teiid.transport.TestSocketRemoting.FakeService;
+
+
+@SuppressWarnings("nls")
+public class TestFailover {
+
+ SocketListener listener;
+ SocketListener listener1;
+
+ private SocketServerConnectionFactory sscf;
+ private InetSocketAddress addr = new InetSocketAddress(0);
+ private int logonAttempts;
+
+ private SocketServerConnection helpEstablishConnection(boolean clientSecure, SSLConfiguration config, Properties socketConfig) throws CommunicationException,
+ ConnectionException {
+ listener = createListener(addr, config);
+ listener1 = createListener(addr, config);
+ listener1.stop();
+ Properties p = new Properties();
+ TeiidURL teiidUrl = new TeiidURL(addr.getHostName(), listener.getPort(), clientSecure);
+ teiidUrl.getHostInfo().add(new HostInfo(addr.getHostName(), listener1.getPort()));
+ String url = teiidUrl.getAppServerURL();
+ p.setProperty(TeiidURL.CONNECTION.SERVER_URL, url);
+ p.setProperty(TeiidURL.CONNECTION.DISCOVERY_STRATEGY, UrlServerDiscovery.class.getName());
+ p.setProperty(TeiidURL.CONNECTION.AUTO_FAILOVER, Boolean.TRUE.toString());
+ if (sscf == null) {
+ sscf = new SocketServerConnectionFactory();
+ sscf.initialize(socketConfig);
+ }
+ return sscf.getConnection(p);
+ }
+
+ private SocketListener createListener(InetSocketAddress address, SSLConfiguration config) {
+ ClientServiceRegistryImpl server = new ClientServiceRegistryImpl();
+ server.registerClientService(ILogon.class, new LogonImpl(mock(SessionService.class), "fakeCluster") { //$NON-NLS-1$
+ @Override
+ public LogonResult logon(Properties connProps)
+ throws LogonException, ComponentNotFoundException {
+ logonAttempts++;
+ return new LogonResult(new SessionToken("dummy"), "x", 1, "z");
+ }
+
+ @Override
+ public ResultsFuture<?> ping() throws InvalidSessionException,
+ TeiidComponentException {
+ return ResultsFuture.NULL_FUTURE;
+ }
+
+ @Override
+ public void assertIdentity(SessionToken checkSession)
+ throws InvalidSessionException, TeiidComponentException {
+ throw new InvalidSessionException();
+ }
+
+ }, null);
+ server.registerClientService(FakeService.class, new TestSocketRemoting.FakeServiceImpl(), null);
+ return new SocketListener(address.getPort(), address.getAddress().getHostAddress(), 1024, 1024, 1, config, server, BufferManagerFactory.getStandaloneBufferManager());
+ }
+
+ @Test public void testFailover() throws Exception {
+ SSLConfiguration config = new SSLConfiguration();
+ Properties p = new Properties();
+ SocketServerConnection conn = helpEstablishConnection(false, config, p);
+ assertTrue(conn.isOpen(1000));
+ //restart the second instance now that we know the connection was made to the first
+ listener1 = createListener(new InetSocketAddress(addr.getAddress(), listener1.getPort()), config);
+ listener.stop();
+ conn.isOpen(1000); //there is a chance this call can fail
+ assertTrue(conn.isOpen(1000));
+ listener1.stop();
+ //both instances are down
+ assertFalse(conn.isOpen(1000));
+ //bring the first back up
+ listener = createListener(new InetSocketAddress(addr.getAddress(), listener.getPort()), config);
+ assertTrue(conn.isOpen(1000));
+ conn.close();
+ }
+
+}
Property changes on: branches/7.3.x/runtime/src/test/java/org/teiid/transport/TestFailover.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
13 years, 3 months
teiid SVN: r2878 - in branches/7.3.x: engine/src/main/java/org/teiid/query/function and 3 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-01-26 22:26:46 -0500 (Wed, 26 Jan 2011)
New Revision: 2878
Modified:
branches/7.3.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionForm.java
branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java
branches/7.3.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
branches/7.3.x/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
branches/7.3.x/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
Log:
TEIID-1446: with array types in the class, jaxb is behaving as described in the jira. Replaced the array attribute with collection type to avoid the exception
Modified: branches/7.3.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java
===================================================================
--- branches/7.3.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/api/src/main/java/org/teiid/metadata/FunctionMethod.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -22,7 +22,9 @@
package org.teiid.metadata;
+import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
@@ -103,8 +105,9 @@
private boolean nullOnNull;
private Determinism determinism = Determinism.DETERMINISTIC;
-
- private FunctionParameter[] inputParameters;
+
+ @XmlElement(name="inputParameters")
+ protected List<FunctionParameter> inParameters = new ArrayList<FunctionParameter>();
private FunctionParameter outputParameter;
protected FunctionMethod() {
@@ -131,7 +134,9 @@
setPushdown(pushdown);
setInvocationClass(invocationClass);
setInvocationMethod(invocationMethod);
- setInputParameters(inputParams);
+ if (inputParams != null) {
+ setInputParameters(Arrays.asList(inputParams));
+ }
setOutputParameter(outputParam);
setNullOnNull(nullOnNull);
setDeterminism(deterministic);
@@ -269,27 +274,28 @@
* @return Number of input parameters
*/
public int getInputParameterCount() {
- if(this.inputParameters == null) {
+ if(this.inParameters == null) {
return 0;
}
- return this.inputParameters.length;
+ return this.inParameters.size();
}
/**
* Get input parameters
* @return Array of input parameters, may be null if 0 parameters
*/
- @XmlElement
- public FunctionParameter[] getInputParameters() {
- return this.inputParameters;
+
+ public List<FunctionParameter> getInputParameters() {
+ return this.inParameters;
}
/**
* Set input parameters.
* @param params Input parameters
*/
- public void setInputParameters(FunctionParameter[] params) {
- this.inputParameters = params;
+ public void setInputParameters(List<FunctionParameter> params) {
+ this.inParameters.clear();
+ this.inParameters.addAll(params);
}
/**
@@ -322,8 +328,8 @@
*/
public int hashCode() {
int hash = HashCodeUtil.hashCode(0, super.getName());
- if(inputParameters != null) {
- hash = HashCodeUtil.hashCode(hash, Arrays.hashCode(inputParameters));
+ if(inParameters != null) {
+ hash = HashCodeUtil.hashCode(hash, inParameters.hashCode());
}
return hash;
}
@@ -356,16 +362,16 @@
}
// Compare types of parameters
- FunctionParameter[] thisInputs = this.getInputParameters();
- if(thisInputs != null && thisInputs.length > 0) {
+ List<FunctionParameter> thisInputs = this.getInputParameters();
+ if(thisInputs != null && thisInputs.size() > 0) {
// If thisInputs is not null and >0 and other parameter
// count matched this parameter count, otherInputs MUST be
// non null to have more than one parameter - so we don't
// need to check it here.
- FunctionParameter[] otherInputs = other.getInputParameters();
+ List<FunctionParameter> otherInputs = other.getInputParameters();
- for(int i=0; i<thisInputs.length; i++) {
- boolean paramMatch = compareWithNull(thisInputs[i], otherInputs[i]);
+ for(int i=0; i<thisInputs.size(); i++) {
+ boolean paramMatch = compareWithNull(thisInputs.get(i), otherInputs.get(i));
if(! paramMatch) {
return false;
}
@@ -412,15 +418,15 @@
// Print parameters
str.append("("); //$NON-NLS-1$
- if(inputParameters != null) {
- for(int i=0; i<inputParameters.length; i++) {
- if(inputParameters[i] != null) {
- str.append(inputParameters[i].toString());
+ if(inParameters != null) {
+ for(int i=0; i<inParameters.size(); i++) {
+ if(inParameters.get(i) != null) {
+ str.append(inParameters.get(i).toString());
} else {
str.append("<unknown>"); //$NON-NLS-1$
}
- if(i < (inputParameters.length-1)) {
+ if(i < (inParameters.size()-1)) {
str.append(", "); //$NON-NLS-1$
}
}
@@ -462,8 +468,8 @@
}
public boolean isVarArgs() {
- if (this.inputParameters != null && this.inputParameters.length > 0) {
- return inputParameters[inputParameters.length - 1].isVarArg();
+ if (this.inParameters != null && this.inParameters.size() > 0) {
+ return inParameters.get(inParameters.size() - 1).isVarArg();
}
return false;
}
Modified: branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionForm.java
===================================================================
--- branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionForm.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionForm.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -66,17 +66,17 @@
this.category = method.getCategory().toUpperCase();
// Get input parameter stuff
- FunctionParameter[] inputParams = method.getInputParameters();
+ List<FunctionParameter> inputParams = method.getInputParameters();
if(inputParams == null) {
inputParamNames = new ArrayList(0);
inputParamDescs = new ArrayList(0);
} else {
- inputParamNames = new ArrayList(inputParams.length);
- inputParamDescs = new ArrayList(inputParams.length);
+ inputParamNames = new ArrayList(inputParams.size());
+ inputParamDescs = new ArrayList(inputParams.size());
- for(int i=0; i<inputParams.length; i++) {
- inputParamNames.add(inputParams[i].getName().toUpperCase());
- inputParamDescs.add(inputParams[i].getDescription());
+ for(int i=0; i<inputParams.size(); i++) {
+ inputParamNames.add(inputParams.get(i).getName().toUpperCase());
+ inputParamDescs.add(inputParams.get(i).getDescription());
}
}
Modified: branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java
===================================================================
--- branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionLibrary.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -228,7 +228,7 @@
for (FunctionMethod nextMethod : functionMethods) {
int currentScore = 0;
- final FunctionParameter[] methodTypes = nextMethod.getInputParameters();
+ final List<FunctionParameter> methodTypes = nextMethod.getInputParameters();
//Holder for current signature with converts where required
FunctionDescriptor[] currentSignature = new FunctionDescriptor[types.length];
@@ -237,7 +237,7 @@
int i = 0;
for(; i < types.length; i++) {
//treat all varags as the same type
- final String tmpTypeName = methodTypes[Math.min(i, methodTypes.length - 1)].getType();
+ final String tmpTypeName = methodTypes.get(Math.min(i, methodTypes.size() - 1)).getType();
Class<?> targetType = DataTypeManager.getDataTypeClass(tmpTypeName);
Class<?> sourceType = types[i];
Modified: branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java
===================================================================
--- branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/engine/src/main/java/org/teiid/query/function/FunctionTree.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -263,11 +263,11 @@
String methodName = method.getName();
// Get input types for path
- FunctionParameter[] inputParams = method.getInputParameters();
+ List<FunctionParameter> inputParams = method.getInputParameters();
List<Class> inputTypes = new LinkedList<Class>();
if(inputParams != null) {
- for(int i=0; i<inputParams.length; i++) {
- String typeName = inputParams[i].getType();
+ for(int i=0; i<inputParams.size(); i++) {
+ String typeName = inputParams.get(i).getType();
inputTypes.add(DataTypeManager.getDataTypeClass(typeName));
}
}
Modified: branches/7.3.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java
===================================================================
--- branches/7.3.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/engine/src/main/java/org/teiid/query/function/metadata/FunctionMetadataValidator.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -23,6 +23,7 @@
package org.teiid.query.function.metadata;
import java.util.Collection;
+import java.util.List;
import org.teiid.api.exception.query.FunctionMetadataException;
import org.teiid.core.types.DataTypeManager;
@@ -90,10 +91,10 @@
validateInvocationMethod(method.getInvocationClass(), method.getInvocationMethod(), method.getPushdown());
// Validate input parameters
- FunctionParameter[] params = method.getInputParameters();
- if(params != null) {
- for(int i=0; i<params.length; i++) {
- validateFunctionParameter(params[i]);
+ List<FunctionParameter> params = method.getInputParameters();
+ if(params != null && !params.isEmpty()) {
+ for(int i=0; i<params.size(); i++) {
+ validateFunctionParameter(params.get(i));
}
}
Modified: branches/7.3.x/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java
===================================================================
--- branches/7.3.x/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/engine/src/test/java/org/teiid/query/function/TestFunctionMetadataReader.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -54,7 +54,7 @@
assertNull(m.getDescription());
assertEquals(1, m.getInputParameterCount());
- FunctionParameter in = m.getInputParameters()[0];
+ FunctionParameter in = m.getInputParameters().get(0);
assertEquals("prop", in.getName());
assertEquals("string", in.getType());
assertNull(in.getDescription());
Modified: branches/7.3.x/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java
===================================================================
--- branches/7.3.x/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java 2011-01-26 21:40:40 UTC (rev 2877)
+++ branches/7.3.x/engine/src/test/java/org/teiid/query/function/metadata/TestFunctionMethod.java 2011-01-27 03:26:46 UTC (rev 2878)
@@ -45,6 +45,16 @@
UnitTestUtil.helpTestEquivalence(0, m1, m1);
}
+ 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$
+ "com.metamatrix.query.function.FunctionMethods", "length", //$NON-NLS-1$ //$NON-NLS-2$
+ null, pout );
+
+ UnitTestUtil.helpTestEquivalence(0, m1, m1);
+ }
+
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$
13 years, 3 months
teiid SVN: r2877 - trunk/connectors.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-01-26 16:40:40 -0500 (Wed, 26 Jan 2011)
New Revision: 2877
Modified:
trunk/connectors/pom.xml
Log:
TEIID-1011: adding olap translator project to the build
Modified: trunk/connectors/pom.xml
===================================================================
--- trunk/connectors/pom.xml 2011-01-25 21:13:35 UTC (rev 2876)
+++ trunk/connectors/pom.xml 2011-01-26 21:40:40 UTC (rev 2877)
@@ -86,5 +86,6 @@
<module>connector-ws</module>
<module>sandbox</module>
<module>translator-ws</module>
+ <module>translator-olap</module>
</modules>
</project>
13 years, 3 months
teiid SVN: r2876 - in trunk: build/kits/jboss-container/teiid-examples/jca and 2 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-01-25 16:13:35 -0500 (Tue, 25 Jan 2011)
New Revision: 2876
Added:
trunk/build/kits/jboss-container/teiid-examples/jca/olap-xmla-ds.xml
Modified:
trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
Log:
TEIID-1011: adding documentation for using the translator
Modified: trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml 2011-01-25 20:19:07 UTC (rev 2875)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml 2011-01-25 21:13:35 UTC (rev 2876)
@@ -1,9 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<datasources>
+
+ <!--
+ Provide these jars in JBoss AS profile's "lib" directory, to place the mondrian JDBC driver
+ on classpath.
+
+ commons-math-1.0.jar
+ commons-vfs-1.0.jar
+ eigenbase-properties.jar
+ eigenbase-resgen.jar
+ eigenbase-xom.jar
+ javacup.jar
+ mondrian.jar
+ olap4j.jar
+
+ Only use this datasource, if your mondrian server is also deployed to same JBoss AS
+ server, this will make embedded connection to mondrian. If you are working remote
+ then use olap-xmla-ds.xml file
+ -->
+
<local-tx-datasource>
<jndi-name>mondrianDS</jndi-name>
<!-- note here that you need to also create datasource for source, this is for mondrian as source for teiid -->
- <connection-url>jdbc:mondrian:Provider=Mondrian;DataSource=java:foodmart;Catalog=${jboss.server.home.dir}/deploy/mondrian.war/WEB-INF/queries/FoodMart.xml;</connection-url>
+ <connection-url>jdbc:mondrian:Provider=Mondrian;DataSource=java:foodmart;Catalog=FoodMart;Catalog=${jboss.server.home.dir}/deploy/mondrian.war/WEB-INF/queries/FoodMart.xml;</connection-url>
<driver-class>mondrian.olap4j.MondrianOlap4jDriver</driver-class>
<user-name>user</user-name>
<password>password</password>
Added: trunk/build/kits/jboss-container/teiid-examples/jca/olap-xmla-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/olap-xmla-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/olap-xmla-ds.xml 2011-01-25 21:13:35 UTC (rev 2876)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+
+ <!-- olap4j.jar is required for this. Download from http://www.olap4j.org/ and place in the JBoss AS profile's "lib" directory -->
+ <no-tx-datasource>
+ <jndi-name>xmlaDS</jndi-name>
+ <!-- note here that you need to also create datasource for source, this is for mondrian as source for teiid -->
+ <connection-url>jdbc:xmla:Server=http://127.0.0.1:8080/mondrian/xmla;Provider=Mondrian;DataSource=java:foodmart;Catalog=FoodMart;</connection-url>
+ <driver-class>org.olap4j.driver.xmla.XmlaOlap4jDriver</driver-class>
+ <transaction-isolation>-1</transaction-isolation>
+ <user-name>user</user-name>
+ <password>password</password>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ </no-tx-datasource>
+
+</datasources>
Property changes on: trunk/build/kits/jboss-container/teiid-examples/jca/olap-xmla-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-01-25 20:19:07 UTC (rev 2875)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-01-25 21:13:35 UTC (rev 2876)
@@ -27,6 +27,7 @@
<H2><A NAME="Highlights"></A>Highlights</H2>
<UL>
<LI><B>Virtual procedure out params</B> - virtual procedures can now have RETURN/OUT/INOUT parameters to return values.
+ <LI><B>OLAP</B> - OLAP translator is now part of Teiid kit using OLAP4J
</UL>
<h2><a name="Compatibility">Compatibility Issues</a></h2>
Modified: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-01-25 20:19:07 UTC (rev 2875)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-01-25 21:13:35 UTC (rev 2876)
@@ -48,7 +48,6 @@
import org.teiid.translator.ProcedureExecution;
import org.teiid.translator.TranslatorException;
-@SuppressWarnings("nls")
public class OlapQueryExecution implements ProcedureExecution {
protected Command command;
@@ -130,7 +129,7 @@
this.rows = rowAxis.iterator();
if (this.rows.hasNext()) {
this.nextRow = this.rows.next();
- this.buffer = "<resultset>".toCharArray();
+ this.buffer = "<resultset>".toCharArray(); //$NON-NLS-1$
}
}
@@ -141,7 +140,7 @@
StringBuilder sb = new StringBuilder();
CellSetAxis cols = cellSet.getAxes().get(Axis.COLUMNS.axisOrdinal());
- sb.append("<row>");
+ sb.append("<row>"); //$NON-NLS-1$
// add in rows axis
List<Member> members = nextRow.getMembers();
@@ -150,7 +149,7 @@
columnName = columnName.replace(' ', '_');
sb.append('<').append(columnName).append('>');
sb.append(member.getName());
- sb.append("</").append(columnName).append('>');
+ sb.append("</").append(columnName).append('>'); //$NON-NLS-1$
}
// add col axis
@@ -160,9 +159,9 @@
columnName = columnName.replace(' ', '_');
sb.append('<').append(columnName).append('>');
sb.append(cell.getValue());
- sb.append("</").append(columnName).append('>');
+ sb.append("</").append(columnName).append('>'); //$NON-NLS-1$
}
- sb.append("</row>");
+ sb.append("</row>");//$NON-NLS-1$
// advance the cursor to next row.
if (this.rows.hasNext()) {
@@ -185,7 +184,7 @@
String next = readNextRow();
if (next == null) {
if (!this.closed) {
- this.buffer = "</resultset>".toCharArray();
+ this.buffer = "</resultset>".toCharArray();//$NON-NLS-1$
this.closed = true;
}
else {
Modified: trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml
===================================================================
--- trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-01-25 20:19:07 UTC (rev 2875)
+++ trunk/documentation/reference/src/main/docbook/en-US/content/translators.xml 2011-01-25 21:13:35 UTC (rev 2876)
@@ -1014,7 +1014,69 @@
</section>
</section>
</section>
+
<section>
+ <title>OLAP Translator</title>
+ <para>
+ The OLAP Services translator, known by the type name <emphasis>olap</emphasis>,
+ exposes stored procedures for calling analysis sevices backed by a OLAP server using MDX query lanaguage. Given the MDX
+ query, this translator executes the query and returns the results in XML format.
+ It will commonly be used with the <link linkend="xmltable">XMLTABLE</link> table functions to use XML formated data.
+ </para>
+ <para>
+ Since the Cube metadata exposed by the OLAP servers and relational database metadata are so different, there is no single
+ way to map the metadata from one to other. It is best that OLAP system be queried using its own native MDX language
+ through Teiid abstraction layers than introducing a custom Teiid based MDX like extensions for querying. To build MDX
+ queries dynamically use Teiid's abstraction layer define your target schema in relational terms and use Teiid's procedural
+ langaugage to build a query.
+ </para>
+
+ <section>
+ <title>Usage</title>
+ <para>
+ The olap translator exposes one low level procedure for accessing olap services.
+ </para>
+
+ <section>
+ <title>InvokeMDX Procedure</title>
+ <para>
+ <methodname>invokeMdx</methodname> returns the XML contents of results in tabular form.
+ </para>
+ <programlisting>Procedure invokeMdx(mdx in STRING) returns SQLXML</programlisting>
+
+ <para>
+ mdx parameter indicates the query in its original form that is to be executed on the OLAP server.
+ </para>
+ <para>
+ The results of the query will be returned in SQLXML form that in the format as shown below.
+ <programlisting role="XML" language="XML"><![CDATA[
+ <?xml version="1.0" encoding="UTF-8"?>
+ <resultset>
+ <row>
+ <Promotion_Media>All Media</Promotion_Media>
+ <Product>All Products</Product>
+ <Unit_Sales>266773.0</Unit_Sales>
+ <Store_Cost>225627.2336</Store_Cost>
+ <Store_Sales>565238.13</Store_Sales>
+ </row>
+ </resultset>
+ ]]></programlisting>
+ From the above XML result, the first two columns in the row were the members from the row axis and the
+ last three columns are the measures from the cube from column axis. Currently the resultset only supports
+ 2 dimentional cube.
+ </para>
+
+ <para>
+ This translator requires a data source to be configured to the OLAP cube using OLAP4J JDBC driver. Two sample
+ -ds.xml files provided for accessing OLAP servers in teiid-examples section. One is Mondrian specific, when Mondrian server is deloyed
+ in the same JBoss AS as Teiid (mondrian-ds.xml). To access any other OLAP servers using XMLA interface,
+ the data source for them can be created using them example template olap-xmla-ds.xml
+ </para>
+ </section>
+ </section>
+ </section>
+
+ <section>
<title>Delegating Translators</title>
<para>
You may create a delegating translator by extending the <code>org.teiid.translator.BaseDelegatingExecutionFactory</code>.
13 years, 3 months
teiid SVN: r2875 - in trunk/connectors/translator-jdbc/src: test/java/org/teiid/translator/jdbc/db2 and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-01-25 15:19:07 -0500 (Tue, 25 Jan 2011)
New Revision: 2875
Modified:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
Log:
TEIID-1281 correcting the max length
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java 2011-01-24 22:33:44 UTC (rev 2874)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java 2011-01-25 20:19:07 UTC (rev 2875)
@@ -49,7 +49,7 @@
if (function.getParameters().size() != 3) {
return null;
}
- //case when length < 0 then null when length < LENGTH(string) - start + 1 then exp else LENGTH(string) - start + 1
+ //case when length > LENGTH(string) - start + 1 then LENGTH(string) - start + 1 case when length > 0 then length end
Expression length = function.getParameters().get(2);
List<SearchedWhenClause> clauses = new ArrayList<SearchedWhenClause>(2);
Boolean isNegative = null;
@@ -60,13 +60,6 @@
isNegative = value < 0;
}
}
- if (isNegative == null) {
- clauses.add(new SearchedWhenClause(new Comparison(length, new Literal(0, TypeFacility.RUNTIME_TYPES.INTEGER), Operator.LT), new Literal(null, TypeFacility.RUNTIME_TYPES.INTEGER)));
- } else if (isNegative) {
- //TODO: could be done in the rewriter
- function.getParameters().set(2, null);
- return null;
- }
Expression maxLength = new Function(
SourceSystemFunctions.SUBTRACT_OP,
Arrays.asList(new Function(
@@ -74,15 +67,25 @@
Arrays.asList(function.getParameters().get(0)),
TypeFacility.RUNTIME_TYPES.INTEGER),
new Function(
- SourceSystemFunctions.ADD_OP,
+ SourceSystemFunctions.SUBTRACT_OP,
Arrays.asList(
function.getParameters().get(1),
new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)),
TypeFacility.RUNTIME_TYPES.INTEGER)),
TypeFacility.RUNTIME_TYPES.INTEGER);
- clauses.add(new SearchedWhenClause(new Comparison(length, maxLength, Operator.LE), length));
+ clauses.add(new SearchedWhenClause(new Comparison(length, maxLength, Operator.GT), maxLength));
+ Expression defaultExpr = null;
+ if (isNegative == null) {
+ clauses.add(new SearchedWhenClause(new Comparison(length, new Literal(0, TypeFacility.RUNTIME_TYPES.INTEGER), Operator.GT), length));
+ } else if (isNegative) {
+ //TODO: could be done in the rewriter
+ function.getParameters().set(2, null);
+ return null;
+ } else {
+ defaultExpr = length;
+ }
SearchedCase sc = new SearchedCase(clauses,
- maxLength, TypeFacility.RUNTIME_TYPES.INTEGER);
+ defaultExpr, TypeFacility.RUNTIME_TYPES.INTEGER);
function.getParameters().set(2, sc);
return null;
}
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2011-01-24 22:33:44 UTC (rev 2874)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2011-01-25 20:19:07 UTC (rev 2875)
@@ -245,7 +245,7 @@
@Test public void testSubstring() throws Exception {
String input = "SELECT substring(STRINGNUM, 2, 10) FROM BQT1.SMALLA"; //$NON-NLS-1$
- String output = "SELECT substr(SmallA.StringNum, 2, CASE WHEN 10 <= (length(SmallA.StringNum) - (2 + 1)) THEN 10 ELSE (length(SmallA.StringNum) - (2 + 1)) END) FROM SmallA"; //$NON-NLS-1$
+ String output = "SELECT substr(SmallA.StringNum, 2, CASE WHEN 10 > (length(SmallA.StringNum) - (2 - 1)) THEN (length(SmallA.StringNum) - (2 - 1)) ELSE 10 END) FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
@@ -254,7 +254,7 @@
@Test public void testSubstring1() throws Exception {
String input = "SELECT substring(STRINGNUM, 2, intnum) FROM BQT1.SMALLA"; //$NON-NLS-1$
- String output = "SELECT substr(SmallA.StringNum, 2, CASE WHEN SmallA.IntNum < 0 THEN NULL WHEN SmallA.IntNum <= (length(SmallA.StringNum) - (2 + 1)) THEN SmallA.IntNum ELSE (length(SmallA.StringNum) - (2 + 1)) END) FROM SmallA"; //$NON-NLS-1$
+ String output = "SELECT substr(SmallA.StringNum, 2, CASE WHEN SmallA.IntNum > (length(SmallA.StringNum) - (2 - 1)) THEN (length(SmallA.StringNum) - (2 - 1)) WHEN SmallA.IntNum > 0 THEN SmallA.IntNum END) FROM SmallA"; //$NON-NLS-1$
TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
input, output,
13 years, 3 months
teiid SVN: r2874 - in trunk: build/kits/jboss-container/teiid-examples/jca and 11 other directories.
by teiid-commits@lists.jboss.org
Author: rareddy
Date: 2011-01-24 17:33:44 -0500 (Mon, 24 Jan 2011)
New Revision: 2874
Added:
trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml
trunk/connectors/translator-olap/
trunk/connectors/translator-olap/pom.xml
trunk/connectors/translator-olap/src/
trunk/connectors/translator-olap/src/main/
trunk/connectors/translator-olap/src/main/java/
trunk/connectors/translator-olap/src/main/java/org/
trunk/connectors/translator-olap/src/main/java/org/teiid/
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
trunk/connectors/translator-olap/src/main/resources/
trunk/connectors/translator-olap/src/main/resources/META-INF/
trunk/connectors/translator-olap/src/main/resources/META-INF/jboss-beans.xml
Modified:
trunk/build/assembly/jboss-container/dist.xml
Log:
TEIID-1011: initial check in for mondrian olap as the source to the Teiid.
Modified: trunk/build/assembly/jboss-container/dist.xml
===================================================================
--- trunk/build/assembly/jboss-container/dist.xml 2011-01-24 19:30:06 UTC (rev 2873)
+++ trunk/build/assembly/jboss-container/dist.xml 2011-01-24 22:33:44 UTC (rev 2874)
@@ -184,6 +184,7 @@
<include>org.jboss.teiid.connectors:translator-ldap</include>
<include>org.jboss.teiid.connectors:translator-salesforce</include>
<include>org.jboss.teiid.connectors:translator-ws</include>
+ <include>org.jboss.teiid.connectors:translator-olap</include>
</includes>
<binaries>
Added: trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml
===================================================================
--- trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml (rev 0)
+++ trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml 2011-01-24 22:33:44 UTC (rev 2874)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<datasources>
+ <local-tx-datasource>
+ <jndi-name>mondrianDS</jndi-name>
+ <!-- note here that you need to also create datasource for source, this is for mondrian as source for teiid -->
+ <connection-url>jdbc:mondrian:Provider=Mondrian;DataSource=java:foodmart;Catalog=${jboss.server.home.dir}/deploy/mondrian.war/WEB-INF/queries/FoodMart.xml;</connection-url>
+ <driver-class>mondrian.olap4j.MondrianOlap4jDriver</driver-class>
+ <user-name>user</user-name>
+ <password>password</password>
+ <min-pool-size>5</min-pool-size>
+ <max-pool-size>20</max-pool-size>
+ </local-tx-datasource>
+</datasources>
\ No newline at end of file
Property changes on: trunk/build/kits/jboss-container/teiid-examples/jca/mondrian-ds.xml
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Property changes on: trunk/connectors/translator-olap
___________________________________________________________________
Name: svn:ignore
+ .settings
target
.project
.classpath
Added: trunk/connectors/translator-olap/pom.xml
===================================================================
--- trunk/connectors/translator-olap/pom.xml (rev 0)
+++ trunk/connectors/translator-olap/pom.xml 2011-01-24 22:33:44 UTC (rev 2874)
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <parent>
+ <artifactId>connectors</artifactId>
+ <groupId>org.jboss.teiid</groupId>
+ <version>7.4.0.Alpha1-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <artifactId>translator-olap</artifactId>
+ <groupId>org.jboss.teiid.connectors</groupId>
+ <name>OLAP Translator</name>
+ <description>This translator provides access to Query Analysis Cubes</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.teiid</groupId>
+ <artifactId>teiid-common-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.resource</groupId>
+ <artifactId>connector-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.olap4j</groupId>
+ <artifactId>olap4j</artifactId>
+ <version>0.9.8.343</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <outputDirectory>target/classes</outputDirectory>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ <includes>
+ <include>**/*.xml</include>
+ <include>**/*.properties</include>
+ </includes>
+ </resource>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>false</filtering>
+ <excludes>
+ <exclude>**/*.xml</exclude>
+ <exclude>**/*.properties</exclude>
+ </excludes>
+ </resource>
+ </resources>
+ </build>
+
+</project>
Added: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java (rev 0)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapExecutionFactory.java 2011-01-24 22:33:44 UTC (rev 2874)
@@ -0,0 +1,100 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.olap;
+
+import java.sql.Connection;
+import java.sql.SQLException;
+
+import javax.sql.DataSource;
+
+import org.olap4j.OlapConnection;
+import org.olap4j.OlapWrapper;
+import org.teiid.language.Call;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.metadata.MetadataFactory;
+import org.teiid.metadata.Procedure;
+import org.teiid.metadata.ProcedureParameter;
+import org.teiid.metadata.RuntimeMetadata;
+import org.teiid.metadata.BaseColumn.NullType;
+import org.teiid.metadata.ProcedureParameter.Type;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ExecutionFactory;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.Translator;
+import org.teiid.translator.TranslatorException;
+import org.teiid.translator.TypeFacility;
+
+@Translator(name="olap", description="A translator for OLAP Cubes")
+public class OlapExecutionFactory extends ExecutionFactory<DataSource, Connection> {
+ private static final String INVOKE_MDX = "invokeMdx"; //$NON-NLS-1$
+
+ @Override
+ public void getMetadata(MetadataFactory metadataFactory, Connection conn) throws TranslatorException {
+ Procedure p = metadataFactory.addProcedure(INVOKE_MDX);
+ p.setAnnotation("Invokes a XMLA webservice with provided MDX query that returns an XML result"); //$NON-NLS-1$
+
+ // mdx query in xml form
+ ProcedureParameter param = metadataFactory.addProcedureParameter("request", TypeFacility.RUNTIME_NAMES.STRING, Type.In, p); //$NON-NLS-1$
+ param.setAnnotation("The MDX query to execute"); //$NON-NLS-1$
+ param.setNullType(NullType.Nullable);
+
+ metadataFactory.addProcedureParameter("result", TypeFacility.RUNTIME_NAMES.XML, Type.ReturnValue, p); //$NON-NLS-1$
+ }
+
+ @Override
+ public ProcedureExecution createProcedureExecution(Call command, ExecutionContext executionContext, RuntimeMetadata metadata, Connection connection) throws TranslatorException {
+ return new OlapQueryExecution(command, unwrap(connection), executionContext, this);
+ }
+
+ private OlapConnection unwrap(Connection conn) throws TranslatorException {
+ try {
+ OlapWrapper wrapper = conn.unwrap(OlapWrapper.class);
+ OlapConnection olapConn = wrapper.unwrap(OlapConnection.class);
+ return olapConn;
+ } catch(SQLException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public Connection getConnection(DataSource ds)
+ throws TranslatorException {
+ try {
+ return ds.getConnection();
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public void closeConnection(Connection connection, DataSource factory) {
+ if (connection == null) {
+ return;
+ }
+ try {
+ connection.close();
+ } catch (SQLException e) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Error closing"); //$NON-NLS-1$
+ }
+ }
+}
Added: trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java
===================================================================
--- trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java (rev 0)
+++ trunk/connectors/translator-olap/src/main/java/org/teiid/translator/olap/OlapQueryExecution.java 2011-01-24 22:33:44 UTC (rev 2874)
@@ -0,0 +1,207 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+package org.teiid.translator.olap;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.sql.SQLException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.ListIterator;
+
+import javax.xml.transform.Source;
+import javax.xml.transform.stream.StreamSource;
+
+import org.olap4j.Axis;
+import org.olap4j.Cell;
+import org.olap4j.CellSet;
+import org.olap4j.CellSetAxis;
+import org.olap4j.OlapConnection;
+import org.olap4j.OlapStatement;
+import org.olap4j.Position;
+import org.olap4j.metadata.Member;
+import org.teiid.language.Argument;
+import org.teiid.language.Call;
+import org.teiid.language.Command;
+import org.teiid.logging.LogConstants;
+import org.teiid.logging.LogManager;
+import org.teiid.translator.ExecutionContext;
+import org.teiid.translator.ProcedureExecution;
+import org.teiid.translator.TranslatorException;
+
+@SuppressWarnings("nls")
+public class OlapQueryExecution implements ProcedureExecution {
+
+ protected Command command;
+ protected OlapConnection connection;
+ protected ExecutionContext context;
+ protected OlapExecutionFactory executionFactory;
+ private OlapStatement stmt;
+ private Source returnValue;
+
+
+ public OlapQueryExecution(Command command, OlapConnection connection, ExecutionContext context, OlapExecutionFactory executionFactory) {
+ this.command = command;
+ this.connection = connection;
+ this.context = context;
+ this.executionFactory = executionFactory;
+ }
+
+ @Override
+ public void execute() throws TranslatorException {
+ try {
+ Call procedure = (Call) this.command;
+ List<Argument> arguments = procedure.getArguments();
+ String mdxQuery = (String) arguments.get(0).getArgumentValue().getValue();
+ OlapStatement stmt = this.connection.createStatement();
+
+ CellSet cellSet = stmt.executeOlapQuery(mdxQuery);
+ this.returnValue = new StreamSource(new MdxResultsReader(cellSet));
+
+
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public void cancel() throws TranslatorException {
+ try {
+ if (this.stmt != null) {
+ this.stmt.cancel();
+ }
+ } catch (SQLException e) {
+ throw new TranslatorException(e);
+ }
+ }
+
+ @Override
+ public synchronized void close() {
+ try {
+ if (this.stmt != null) {
+ this.stmt.close();
+ this.stmt = null;
+ }
+ } catch (SQLException e) {
+ LogManager.logDetail(LogConstants.CTX_CONNECTOR, e, "Exception closing"); //$NON-NLS-1$
+ }
+ }
+
+ @Override
+ public List<?> next() throws TranslatorException {
+ return null;
+ }
+
+ @Override
+ public List<?> getOutputParameterValues() throws TranslatorException {
+ return Arrays.asList(this.returnValue);
+ }
+
+ static class MdxResultsReader extends Reader {
+ private CellSet cellSet;
+ private ListIterator<Position> rows;
+ private Position nextRow;
+ private boolean closed = false;
+ private char[] buffer;
+ private int index = 0;
+
+ public MdxResultsReader(CellSet cellSet) {
+ this.cellSet = cellSet;
+ CellSetAxis rowAxis = cellSet.getAxes().get(Axis.ROWS.axisOrdinal());
+ this.rows = rowAxis.iterator();
+ if (this.rows.hasNext()) {
+ this.nextRow = this.rows.next();
+ this.buffer = "<resultset>".toCharArray();
+ }
+ }
+
+ private String readNextRow() {
+ if (this.nextRow == null) {
+ return null;
+ }
+
+ StringBuilder sb = new StringBuilder();
+ CellSetAxis cols = cellSet.getAxes().get(Axis.COLUMNS.axisOrdinal());
+ sb.append("<row>");
+
+ // add in rows axis
+ List<Member> members = nextRow.getMembers();
+ for (Member member:members) {
+ String columnName = member.getHierarchy().getName();
+ columnName = columnName.replace(' ', '_');
+ sb.append('<').append(columnName).append('>');
+ sb.append(member.getName());
+ sb.append("</").append(columnName).append('>');
+ }
+
+ // add col axis
+ for (Position colPos : cols) {
+ Cell cell = cellSet.getCell(colPos, nextRow);
+ String columnName = colPos.getMembers().get(0).getName();
+ columnName = columnName.replace(' ', '_');
+ sb.append('<').append(columnName).append('>');
+ sb.append(cell.getValue());
+ sb.append("</").append(columnName).append('>');
+ }
+ sb.append("</row>");
+
+ // advance the cursor to next row.
+ if (this.rows.hasNext()) {
+ this.nextRow = this.rows.next();
+ }
+ else {
+ this.nextRow = null;
+ }
+ return sb.toString();
+ }
+
+ @Override
+ public void close() throws IOException {
+ }
+
+ @Override
+ public int read(char[] cbuf, int off, int len) throws IOException {
+ int availble = this.buffer.length - this.index;
+ if (availble == 0) {
+ String next = readNextRow();
+ if (next == null) {
+ if (!this.closed) {
+ this.buffer = "</resultset>".toCharArray();
+ this.closed = true;
+ }
+ else {
+ return -1;
+ }
+ }
+ else {
+ this.buffer = next.toCharArray();
+ }
+ this.index = 0;
+ availble = this.buffer.length;
+ }
+ len = (availble > len) ? len : availble;
+ System.arraycopy(this.buffer, this.index, cbuf, off, len);
+ this.index = this.index + len;
+ return len;
+ }
+ }
+}
Added: trunk/connectors/translator-olap/src/main/resources/META-INF/jboss-beans.xml
===================================================================
--- trunk/connectors/translator-olap/src/main/resources/META-INF/jboss-beans.xml (rev 0)
+++ trunk/connectors/translator-olap/src/main/resources/META-INF/jboss-beans.xml 2011-01-24 22:33:44 UTC (rev 2874)
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<deployment xmlns="urn:jboss:bean-deployer:2.0">
+ <!-- OLAP -->
+ <bean name="translator-olap-template" class="org.teiid.templates.TranslatorDeploymentTemplate">
+ <property name="info"><inject bean="translator-olap" /> </property>
+ <property name="managedObjectFactory"> <inject bean="ManagedObjectFactory" /> </property>
+ </bean>
+
+ <bean name="translator-olap" class="org.teiid.templates.TranslatorTemplateInfo">
+ <constructor factoryMethod="createTemplateInfo">
+ <factory bean="TranslatorDeploymentTemplateInfoFactory" />
+ <parameter class="java.lang.Class">org.teiid.templates.TranslatorTemplateInfo</parameter>
+ <parameter class="java.lang.Class">org.teiid.translator.olap.OlapExecutionFactory</parameter>
+ <parameter class="java.lang.String">translator-olap</parameter>
+ <parameter class="java.lang.String">olap</parameter>
+ </constructor>
+ </bean>
+</deployment>
13 years, 3 months
teiid SVN: r2873 - in trunk: connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2 and 1 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-01-24 14:30:06 -0500 (Mon, 24 Jan 2011)
New Revision: 2873
Added:
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java
Modified:
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
Log:
TEIID-1281 adding handling to ensure that the substring length parameter does not cause an exception for db2/derby
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-01-22 08:16:41 UTC (rev 2872)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-01-24 19:30:06 UTC (rev 2873)
@@ -123,6 +123,7 @@
<h2><a name="Other">Other Issues</a></h2>
<ul>
+ <li>TEIID-1281 - Negative start indexing is not supported by DB2 and Derby databases. Usage of the Teiid SUBSTRING against these sources should not use negative start values.
<li>TEIID-1008 - Most versions of Oracle and MySQL do not support deeply nested correlated references. There is currently no workaround for this issue.
<li>For compatibility with the 7.0 release if a stored procedure parameter list begins with identifier=, then it will be parsed as a named parameter invocation even if the intent was to use a comparison predicate
as the first parameter value. The workaround is to use nesting parens, e.g. call proc((identifier=value), ...), which clarifies that this is positional value. This workaround will not be needed in later releases.
Modified: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2011-01-22 08:16:41 UTC (rev 2872)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/DB2ExecutionFactory.java 2011-01-24 19:30:06 UTC (rev 2873)
@@ -74,7 +74,7 @@
registerFunctionModifier(SourceSystemFunctions.DAYOFMONTH, new AliasModifier("day")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.IFNULL, new AliasModifier("coalesce")); //$NON-NLS-1$
registerFunctionModifier(SourceSystemFunctions.LOCATE, new LocateFunctionModifier(getLanguageFactory()));
- registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new AliasModifier("substr")); //$NON-NLS-1$
+ registerFunctionModifier(SourceSystemFunctions.SUBSTRING, new SubstringFunctionModifier());
registerFunctionModifier(SourceSystemFunctions.MOD, new ModFunctionModifier("MOD", getLanguageFactory())); //$NON-NLS-1$
Added: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java
===================================================================
--- trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java (rev 0)
+++ trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java 2011-01-24 19:30:06 UTC (rev 2873)
@@ -0,0 +1,90 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership. Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package org.teiid.translator.jdbc.db2;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.teiid.language.Comparison;
+import org.teiid.language.Expression;
+import org.teiid.language.Function;
+import org.teiid.language.Literal;
+import org.teiid.language.SearchedCase;
+import org.teiid.language.SearchedWhenClause;
+import org.teiid.language.Comparison.Operator;
+import org.teiid.translator.SourceSystemFunctions;
+import org.teiid.translator.TypeFacility;
+import org.teiid.translator.jdbc.AliasModifier;
+
+public class SubstringFunctionModifier extends AliasModifier {
+
+ public SubstringFunctionModifier() {
+ super("substr"); //$NON-NLS-1$
+ }
+
+ @Override
+ public List<?> translate(Function function) {
+ this.modify(function);
+ if (function.getParameters().size() != 3) {
+ return null;
+ }
+ //case when length < 0 then null when length < LENGTH(string) - start + 1 then exp else LENGTH(string) - start + 1
+ Expression length = function.getParameters().get(2);
+ List<SearchedWhenClause> clauses = new ArrayList<SearchedWhenClause>(2);
+ Boolean isNegative = null;
+ if (length instanceof Literal) {
+ Literal l = (Literal)length;
+ if (!l.isMultiValued()) {
+ int value = (Integer)l.getValue();
+ isNegative = value < 0;
+ }
+ }
+ if (isNegative == null) {
+ clauses.add(new SearchedWhenClause(new Comparison(length, new Literal(0, TypeFacility.RUNTIME_TYPES.INTEGER), Operator.LT), new Literal(null, TypeFacility.RUNTIME_TYPES.INTEGER)));
+ } else if (isNegative) {
+ //TODO: could be done in the rewriter
+ function.getParameters().set(2, null);
+ return null;
+ }
+ Expression maxLength = new Function(
+ SourceSystemFunctions.SUBTRACT_OP,
+ Arrays.asList(new Function(
+ SourceSystemFunctions.LENGTH,
+ Arrays.asList(function.getParameters().get(0)),
+ TypeFacility.RUNTIME_TYPES.INTEGER),
+ new Function(
+ SourceSystemFunctions.ADD_OP,
+ Arrays.asList(
+ function.getParameters().get(1),
+ new Literal(1, TypeFacility.RUNTIME_TYPES.INTEGER)),
+ TypeFacility.RUNTIME_TYPES.INTEGER)),
+ TypeFacility.RUNTIME_TYPES.INTEGER);
+ clauses.add(new SearchedWhenClause(new Comparison(length, maxLength, Operator.LE), length));
+ SearchedCase sc = new SearchedCase(clauses,
+ maxLength, TypeFacility.RUNTIME_TYPES.INTEGER);
+ function.getParameters().set(2, sc);
+ return null;
+ }
+
+}
Property changes on: trunk/connectors/translator-jdbc/src/main/java/org/teiid/translator/jdbc/db2/SubstringFunctionModifier.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java
===================================================================
--- trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2011-01-22 08:16:41 UTC (rev 2872)
+++ trunk/connectors/translator-jdbc/src/test/java/org/teiid/translator/jdbc/db2/TestDB2SqlTranslator.java 2011-01-24 19:30:06 UTC (rev 2873)
@@ -242,5 +242,23 @@
input,
output, TRANSLATOR);
}
+
+ @Test public void testSubstring() throws Exception {
+ String input = "SELECT substring(STRINGNUM, 2, 10) FROM BQT1.SMALLA"; //$NON-NLS-1$
+ String output = "SELECT substr(SmallA.StringNum, 2, CASE WHEN 10 <= (length(SmallA.StringNum) - (2 + 1)) THEN 10 ELSE (length(SmallA.StringNum) - (2 + 1)) END) FROM SmallA"; //$NON-NLS-1$
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input, output,
+ TRANSLATOR);
+ }
+
+ @Test public void testSubstring1() throws Exception {
+ String input = "SELECT substring(STRINGNUM, 2, intnum) FROM BQT1.SMALLA"; //$NON-NLS-1$
+ String output = "SELECT substr(SmallA.StringNum, 2, CASE WHEN SmallA.IntNum < 0 THEN NULL WHEN SmallA.IntNum <= (length(SmallA.StringNum) - (2 + 1)) THEN SmallA.IntNum ELSE (length(SmallA.StringNum) - (2 + 1)) END) FROM SmallA"; //$NON-NLS-1$
+
+ TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB,
+ input, output,
+ TRANSLATOR);
+ }
+
}
13 years, 3 months
teiid SVN: r2872 - trunk/engine/src/main/resources/org/teiid/query.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2011-01-22 03:16:41 -0500 (Sat, 22 Jan 2011)
New Revision: 2872
Modified:
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
Log:
third time's a charm
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-01-22 02:13:43 UTC (rev 2871)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-01-22 08:16:41 UTC (rev 2872)
@@ -776,7 +776,7 @@
CriteriaPlanner.invalid_element=Element {0} is not a valid data node
results_not_found=Results for the mapping class {0} are not found;
RulePlanProcedures.no_values=No valid criteria specified for procedure parameter {0}
-ProcedurePlan.nonNullableParam=The procedure parameter is not nullable, but is set to null: {0}
+ProcedurePlan.nonNullableParam=The procedure parameter {0} is not nullable, but is set to null.
FileStoreageManager.error_creating=Error creating {0}
FileStoreageManager.error_reading=Error reading {0}
13 years, 3 months