teiid SVN: r4411 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor and 1 other directories.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2012-09-07 16:30:12 -0400 (Fri, 07 Sep 2012)
New Revision: 4411
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
Log:
TEIID-2146: Dependent join independent dup removal issue
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-09-07 20:06:48 UTC (rev 4410)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/DependentCriteriaProcessor.java 2012-09-07 20:30:12 UTC (rev 4411)
@@ -103,10 +103,10 @@
if (setState.maxNdv <= 0 || setState.maxNdv >= distinctCount) {
continue;
}
- if (dvs.getTupleBuffer().getSchema().size() > 1) {
+ if (dvs.getTupleBuffer().getSchema().size() > 1 && dependentSetStates.size() > 1) {
distinctCount = 0;
ValueIterator vi = dvs.getValueIterator(setState.valueExpression);
- if (dvs.getTupleBuffer().getSchema().indexOf(setState.valueExpression) == 0) {
+ if (setState.valueExpression.equals(dependentSetStates.get(0).valueExpression)) {
Object last = null;
while (vi.hasNext()) {
Object next = vi.next();
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2012-09-07 20:06:48 UTC (rev 4410)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/relational/SortUtility.java 2012-09-07 20:30:12 UTC (rev 4411)
@@ -129,7 +129,7 @@
sortTypes.add(orderByItem.isAscending());
nullOrderings.add(orderByItem.getNullOrdering());
}
- if (items.size() < schema.size() && mode != Mode.SORT) {
+ if (items.size() < schema.size() && mode == Mode.DUP_REMOVE_SORT) {
List<Expression> toAdd = new ArrayList<Expression>(schema);
toAdd.removeAll(sortElements);
sortElements.addAll(toAdd);
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2012-09-07 20:06:48 UTC (rev 4410)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestDependentJoins.java 2012-09-07 20:30:12 UTC (rev 4411)
@@ -37,6 +37,7 @@
import org.teiid.query.optimizer.TestOptimizer;
import org.teiid.query.optimizer.TestOptimizer.ComparisonMode;
import org.teiid.query.optimizer.capabilities.BasicSourceCapabilities;
+import org.teiid.query.optimizer.capabilities.DefaultCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.FakeCapabilitiesFinder;
import org.teiid.query.optimizer.capabilities.SourceCapabilities.Capability;
import org.teiid.query.processor.relational.JoinNode;
@@ -994,5 +995,33 @@
// Run query
TestProcessor.helpProcess(plan, dataManager, expected);
}
+
+ @Test public void testIndependentDupRemoval() {
+ // Create query
+ String sql = "SELECT pm1.g1.e1, pm1.g1.e2, pm2.g1.e2 FROM pm1.g1, pm2.g1 WHERE pm2.g1.e1=pm1.g1.e1 AND pm1.g1.e2<pm2.g1.e2 order by pm1.g1.e1 option makedep pm1.g1"; //$NON-NLS-1$
+
+ // Create expected results
+ List[] expected = new List[] {
+ Arrays.asList(new Object[] { "a", 0, 3 }), //$NON-NLS-1$
+ Arrays.asList(new Object[] { "a", 0, 3 }), //$NON-NLS-1$
+ };
+
+ BasicSourceCapabilities caps = TestOptimizer.getTypicalCapabilities();
+ caps.setSourceProperty(Capability.MAX_IN_CRITERIA_SIZE, 1);
+ caps.setSourceProperty(Capability.MAX_DEPENDENT_PREDICATES, 1);
+ caps.setCapabilitySupport(Capability.QUERY_ORDERBY, false);
+
+ QueryMetadataInterface fakeMetadata = RealMetadataFactory.example1Cached();
+
+ Command command = TestProcessor.helpParse(sql);
+ ProcessorPlan plan = TestProcessor.helpGetPlan(command, fakeMetadata, new DefaultCapabilitiesFinder(caps));
+
+ // Construct data manager with data
+ FakeDataManager dataManager = new FakeDataManager();
+ TestProcessor.sampleData1(dataManager);
+
+ // Run query
+ TestProcessor.helpProcess(plan, dataManager, expected);
+ }
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2012-09-07 20:06:48 UTC (rev 4410)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/relational/TestSortNode.java 2012-09-07 20:30:12 UTC (rev 4411)
@@ -245,24 +245,16 @@
@Test public void testBasicSortRemoveDup() throws Exception {
List[] expected = new List[] {
Arrays.asList(new Object[] { new Integer(0), "0" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(0), "3" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(1), "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(1), "5" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(2), "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(2), "4" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(3), "3" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(3), "6" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(4), "3" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(5), "2" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(5), "5" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(6), "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(6), "4" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(7), "3" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(8), "2" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(9), "1" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(9), "5" }), //$NON-NLS-1$
Arrays.asList(new Object[] { new Integer(10), "4" }), //$NON-NLS-1$
- Arrays.asList(new Object[] { new Integer(10), "9" }) //$NON-NLS-1$
};
helpTestBasicSort(expected, Mode.DUP_REMOVE);
11 years, 7 months
teiid SVN: r4410 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2012-09-07 16:06:48 -0400 (Fri, 07 Sep 2012)
New Revision: 4410
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
Log:
TEIID-2120 fix for batchiterator early termination
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2012-09-07 19:47:31 UTC (rev 4409)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/processor/BatchIterator.java 2012-09-07 20:06:48 UTC (rev 4410)
@@ -69,7 +69,7 @@
}
batch = source.nextBatch();
done = batch.getTerminationFlag();
- if (buffer != null && !saveOnMark) {
+ if (buffer != null && (!saveOnMark || mark)) {
buffer.addTupleBatch(batch, true);
}
}
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2012-09-07 19:47:31 UTC (rev 4409)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestBatchIterator.java 2012-09-07 20:06:48 UTC (rev 4410)
@@ -32,7 +32,6 @@
import org.teiid.common.buffer.BufferManagerFactory;
import org.teiid.common.buffer.TupleBuffer;
import org.teiid.common.buffer.BufferManager.TupleSourceType;
-import org.teiid.query.processor.BatchIterator;
import org.teiid.query.processor.relational.FakeRelationalNode;
import org.teiid.query.sql.symbol.ElementSymbol;
@@ -91,4 +90,21 @@
assertEquals(1, bi.nextTuple().get(0));
}
+ @Test public void testBatchReadDuringMark() throws Exception {
+ BatchIterator bi = new BatchIterator(new FakeRelationalNode(1, new List[] {
+ Arrays.asList(1),
+ Arrays.asList(1),
+ }, 1));
+ BufferManager bm = BufferManagerFactory.getStandaloneBufferManager();
+ bi.setBuffer(bm.createTupleBuffer(Arrays.asList(new ElementSymbol("x")), "test", TupleSourceType.PROCESSOR), true); //$NON-NLS-1$
+ bi.mark();
+ assertNotNull(bi.nextTuple());
+ assertNotNull(bi.nextTuple());
+ assertNull(bi.nextTuple());
+ bi.reset();
+ assertNotNull(bi.nextTuple());
+ assertNotNull(bi.nextTuple());
+ assertNull(bi.nextTuple());
+ }
+
}
11 years, 7 months
teiid SVN: r4409 - trunk/runtime/src/main/java/org/teiid/deployers.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-07 15:47:31 -0400 (Fri, 07 Sep 2012)
New Revision: 4409
Modified:
trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
Log:
TEIID-2166 being selective about the key types
Modified: trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2012-09-06 19:19:46 UTC (rev 4408)
+++ trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2012-09-07 19:47:31 UTC (rev 4409)
@@ -166,7 +166,7 @@
"false as atthasdef " + //$NON-NLS-1$
"FROM (SYS.Keys as k INNER JOIN SYS.KeyColumns as kc ON k.uid = kc.uid INNER JOIN SYS.Columns as t1 ON kc.SchemaName = t1.SchemaName AND kc.TableName = t1.TableName AND kc.Name = t1.Name INNER JOIN " + //$NON-NLS-1$
"SYS.Tables as st ON st.Name = t1.TableName AND st.SchemaName = t1.SchemaName) LEFT OUTER JOIN " + //$NON-NLS-1$
- "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name"; //$NON-NLS-1$
+ "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name WHERE k.type in ('Primary', 'Unique', 'Index')"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
11 years, 7 months
teiid SVN: r4408 - in branches/7.7.x/runtime/src: test/java/org/teiid/transport and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2012-09-06 15:19:46 -0400 (Thu, 06 Sep 2012)
New Revision: 4408
Modified:
branches/7.7.x/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
Log:
TEIID-2108: backport fix for ssl mode setting
Modified: branches/7.7.x/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java
===================================================================
--- branches/7.7.x/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2012-09-06 19:15:48 UTC (rev 4407)
+++ branches/7.7.x/runtime/src/main/java/org/teiid/transport/SSLConfiguration.java 2012-09-06 19:19:46 UTC (rev 4408)
@@ -41,7 +41,7 @@
public static final String TWOWAY = "2-way"; //$NON-NLS-1$
public static final String ANONYMOUS = "anonymous"; //$NON-NLS-1$
- public static final String LOGIN = "logIn"; //$NON-NLS-1$
+ public static final String LOGIN = "login"; //$NON-NLS-1$
public static final String DISABLED = "disabled"; //$NON-NLS-1$
public static final String ENABLED = "enabled"; //$NON-NLS-1$
@@ -100,11 +100,11 @@
}
public boolean isClientEncryptionEnabled() {
- return LOGIN.equals(mode);
+ return LOGIN.equalsIgnoreCase(mode);
}
public boolean isSslEnabled() {
- return ENABLED.equals(mode);
+ return ENABLED.equalsIgnoreCase(mode);
}
public String getMode() {
Modified: branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java
===================================================================
--- branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-06 19:15:48 UTC (rev 4407)
+++ branches/7.7.x/runtime/src/test/java/org/teiid/transport/TestCommSockets.java 2012-09-06 19:19:46 UTC (rev 4408)
@@ -262,4 +262,13 @@
assertArrayEquals(new String[] {"x","y","z"}, config.getEnabledCipherSuitesAsArray());
}
+ @Test public void testAnonSSLMode() throws Exception {
+ SSLConfiguration config = new SSLConfiguration();
+ config.setMode("enabled");
+ assertFalse(config.isClientEncryptionEnabled());
+ assertTrue(config.isSslEnabled());
+ config.setMode("login");
+ assertTrue(config.isClientEncryptionEnabled());
+ }
+
}
11 years, 7 months
teiid SVN: r4407 - in trunk: common-core/src/main/java/org/teiid/core/util and 3 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-06 15:15:48 -0400 (Thu, 06 Sep 2012)
New Revision: 4407
Modified:
trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java
trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java
trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
Log:
TEIID-2171 misc minor changes
Modified: trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java 2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/api/src/main/java/org/teiid/metadata/KeyRecord.java 2012-09-06 19:15:48 UTC (rev 4407)
@@ -39,13 +39,13 @@
private Type type;
public KeyRecord(Type type) {
+ if (type == Type.NonUnique) {
+ type = Type.Index;
+ }
this.type = type;
}
public Type getType() {
- if (type == Type.NonUnique) {
- type = Type.Index;
- }
return type;
}
Modified: trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java
===================================================================
--- trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java 2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/api/src/main/java/org/teiid/metadata/MetadataStore.java 2012-09-06 19:15:48 UTC (rev 4407)
@@ -50,7 +50,7 @@
}
public void addSchema(Schema schema) {
- if (this.schemas.put(schema.getCanonicalName(), schema) != null) {
+ if (this.schemas.put(schema.getName(), schema) != null) {
throw new DuplicateRecordException(DataPlugin.Util.gs(DataPlugin.Event.TEIID60012, schema.getName()));
}
this.schemaList.add(schema);
Modified: trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java
===================================================================
--- trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java 2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/common-core/src/main/java/org/teiid/core/util/StringUtil.java 2012-09-06 19:15:48 UTC (rev 4407)
@@ -364,8 +364,8 @@
* @param delimiter Characters which are delimit tokens
* @return List of string tokens contained in the tokenized string
*/
- public static List getTokens(String str, String delimiter) {
- ArrayList l = new ArrayList();
+ public static List<String> getTokens(String str, String delimiter) {
+ ArrayList<String> l = new ArrayList<String>();
StringTokenizer tokens = new StringTokenizer(str, delimiter);
while(tokens.hasMoreTokens()) {
l.add(tokens.nextToken());
@@ -835,22 +835,6 @@
return (!(str == null || str.trim().length() == 0));
}
- public static String toUpperCase(String str) {
- String newStr = convertBasicLatinToUpper(str);
- if (newStr == null) {
- return str.toUpperCase();
- }
- return newStr;
- }
-
- public static String toLowerCase(String str) {
- String newStr = convertBasicLatinToLower(str);
- if (newStr == null) {
- return str.toLowerCase();
- }
- return newStr;
- }
-
/**
* Create a valid filename from the given String.
*
@@ -892,45 +876,12 @@
return str.substring(0, 1).toUpperCase() + str.substring(1);
}
- private static String convertBasicLatinToUpper(String str) {
- char[] chars = str.toCharArray();
- for (int i = 0; i < chars.length; i++) {
- if (isBasicLatinLowerCase(chars[i])) {
- chars[i] = (char)('A' + (chars[i] - 'a'));
- } else if (!isBasicLatinChar(chars[i])) {
- return null;
- }
- }
- return new String(chars);
- }
-
- private static String convertBasicLatinToLower(String str) {
- char[] chars = str.toCharArray();
- for (int i = 0; i < chars.length; i++) {
- if (isBasicLatinUpperCase(chars[i])) {
- chars[i] = (char)('a' + (chars[i] - 'A'));
- } else if (!isBasicLatinChar(chars[i])) {
- return null;
- }
- }
- return new String(chars);
- }
-
- private static boolean isBasicLatinUpperCase(char c) {
- return c >= 'A' && c <= 'Z';
- }
- private static boolean isBasicLatinLowerCase(char c) {
- return c >= 'a' && c <= 'z';
- }
private static boolean isBasicLatinLetter(char c) {
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
}
private static boolean isBasicLatinDigit(char c) {
return c >= '0' && c <= '9';
}
- private static boolean isBasicLatinChar(char c) {
- return c <= '\u007F';
- }
/**
* Convert the given value to specified type.
Modified: trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java
===================================================================
--- trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java 2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/common-core/src/test/java/org/teiid/core/util/TestStringUtil.java 2012-09-06 19:15:48 UTC (rev 4407)
@@ -22,27 +22,21 @@
package org.teiid.core.util;
+import static org.junit.Assert.*;
+
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
-import junit.framework.TestCase;
+import org.junit.Test;
/**
* @version 1.0
* @author
*/
-public class TestStringUtil extends TestCase {
+public class TestStringUtil {
- /**
- * Constructor for TestStringUtil.
- * @param name
- */
- public TestStringUtil(String name) {
- super(name);
- }
-
// ********* H E L P E R M E T H O D S *********
public void helpTestEncloseInSingleQuotes(String input, String expectedResult){
String result = StringUtil.enclosedInSingleQuotes(input);
@@ -80,133 +74,133 @@
}
// ********* T E S T S U I T E M E T H O D S *********
- public void testEncloseInSingleQuotes() {
+ @Test public void testEncloseInSingleQuotes() {
helpTestEncloseInSingleQuotes("testString", "\'testString\'"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm1() {
+ @Test public void testComputeDisplayableForm1() {
helpTestComputeDisplayableForm("testString", "Test String"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm2() {
+ @Test public void testComputeDisplayableForm2() {
helpTestComputeDisplayableForm("TEST STRING", "TEST STRING"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm3() {
+ @Test public void testComputeDisplayableForm3() {
helpTestComputeDisplayableForm("TestSTRING", "Test STRING"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm4() {
+ @Test public void testComputeDisplayableForm4() {
helpTestComputeDisplayableForm("MetaMatrix", "Meta Matrix"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm5() {
+ @Test public void testComputeDisplayableForm5() {
helpTestComputeDisplayableForm("metaMatrix", "Meta Matrix"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm6() {
+ @Test public void testComputeDisplayableForm6() {
helpTestComputeDisplayableForm("Metamatrix", "Metamatrix"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm7() {
+ @Test public void testComputeDisplayableForm7() {
helpTestComputeDisplayableForm("SomeMetaMatrixEmbedded", "Some Meta Matrix Embedded"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm8() {
+ @Test public void testComputeDisplayableForm8() {
helpTestComputeDisplayableForm("SomeMetaMetaMatrixMetaEmbedded", "Some Meta Meta Matrix Meta Embedded"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputeDisplayableForm9() {
+ @Test public void testComputeDisplayableForm9() {
helpTestComputeDisplayableForm("SomemetaMatrixMetaMatrixMetaEmbedded", "Somemeta Matrix Meta Matrix Meta Embedded"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm1() {
+ @Test public void testComputePluralForm1() {
helpTestComputePluralForm("Test", "Tests"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm2() {
+ @Test public void testComputePluralForm2() {
helpTestComputePluralForm("ss", "sses"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm3() {
+ @Test public void testComputePluralForm3() {
helpTestComputePluralForm("x", "xes"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm4() {
+ @Test public void testComputePluralForm4() {
helpTestComputePluralForm("ch", "ches"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm5() {
+ @Test public void testComputePluralForm5() {
helpTestComputePluralForm("zy", "zies"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm6() {
+ @Test public void testComputePluralForm6() {
helpTestComputePluralForm("ay", "ays"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm7() {
+ @Test public void testComputePluralForm7() {
helpTestComputePluralForm("ey", "eys"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm8() {
+ @Test public void testComputePluralForm8() {
helpTestComputePluralForm("iy", "iys"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm9() {
+ @Test public void testComputePluralForm9() {
helpTestComputePluralForm("oy", "oys"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm10() {
+ @Test public void testComputePluralForm10() {
helpTestComputePluralForm("uy", "uys"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm11() {
+ @Test public void testComputePluralForm11() {
helpTestComputePluralForm("any", "anys"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testComputePluralForm12() {
+ @Test public void testComputePluralForm12() {
helpTestComputePluralForm("classes", "classes"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testJoin1() {
- List input = new ArrayList();
+ @Test public void testJoin1() {
+ List<String> input = new ArrayList<String>();
input.add("One"); //$NON-NLS-1$
input.add("Two"); //$NON-NLS-1$
helpTestJoin(input, null, null);
}
- public void testJoin2() {
+ @Test public void testJoin2() {
helpTestJoin(null, "/", null); //$NON-NLS-1$
}
- public void testJoin3() {
- List input = new ArrayList();
+ @Test public void testJoin3() {
+ List<String> input = new ArrayList<String>();
input.add("One"); //$NON-NLS-1$
input.add("Two"); //$NON-NLS-1$
helpTestJoin(input, "/", "One/Two"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testReplace1() {
+ @Test public void testReplace1() {
helpTestReplace("12225", null, "234", "12225"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testReplace2() {
+ @Test public void testReplace2() {
helpTestReplace("12225", "222", null, "12225"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public void testReplace3() {
+ @Test public void testReplace3() {
helpTestReplace("12225", "222", "234", "12345"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testReplaceAll() {
+ @Test public void testReplaceAll() {
helpTestReplaceAll("1121121112", "2", "1", "1111111111"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
}
- public void testTruncString() {
+ @Test public void testTruncString() {
helpTestTruncString("123456", 5, "12345"); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testGetStackTrace() {
+ @Test public void testGetStackTrace() {
final String expectedStackTrace = "java.lang.RuntimeException: Test"; //$NON-NLS-1$
final Throwable t = new RuntimeException("Test"); //$NON-NLS-1$
final String trace = StringUtil.getStackTrace(t);
@@ -215,15 +209,15 @@
}
}
- public void testToString() {
+ @Test public void testToString() {
final String[] input = new String[]{"string1","string2","string3"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
final String output = StringUtil.toString(input);
assertEquals("[string1,string2,string3]", output); //$NON-NLS-1$
}
- public void testGetTokens() {
+ @Test public void testGetTokens() {
final String input = "string with; tokens ; delimited by ; ; semicolons; there;; are 7 tokens."; //$NON-NLS-1$
- final List tokens = StringUtil.getTokens(input,";"); //$NON-NLS-1$
+ final List<String> tokens = StringUtil.getTokens(input,";"); //$NON-NLS-1$
assertEquals(7, tokens.size());
assertEquals("string with", tokens.get(0)); //$NON-NLS-1$
assertEquals(" tokens ", tokens.get(1)); //$NON-NLS-1$
@@ -234,8 +228,8 @@
assertEquals(" are 7 tokens.", tokens.get(6)); //$NON-NLS-1$
}
- public void testSplitOnEntireString() {
- List result = StringUtil.splitOnEntireString("thisNEXTcanNEXTbe", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+ @Test public void testSplitOnEntireString() {
+ List<String> result = StringUtil.splitOnEntireString("thisNEXTcanNEXTbe", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(3, result.size());
assertEquals("this", result.get(0)); //$NON-NLS-1$
assertEquals("can", result.get(1)); //$NON-NLS-1$
@@ -243,33 +237,33 @@
}
- public void testSplitOnEntireStringEmptyString() {
- List result = StringUtil.splitOnEntireString("", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+ @Test public void testSplitOnEntireStringEmptyString() {
+ List<String> result = StringUtil.splitOnEntireString("", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(1, result.size());
assertEquals("", result.get(0)); //$NON-NLS-1$
}
- public void testSplitOnEntireStringEntireStringIsDelimiter() {
- List result = StringUtil.splitOnEntireString("NEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+ @Test public void testSplitOnEntireStringEntireStringIsDelimiter() {
+ List<String> result = StringUtil.splitOnEntireString("NEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(2, result.size());
assertEquals("", result.get(0)); //$NON-NLS-1$
assertEquals("", result.get(1)); //$NON-NLS-1$
}
- public void testSplitOnEntireStringEmptyDelimiter() {
- List result = StringUtil.splitOnEntireString("test", ""); //$NON-NLS-1$ //$NON-NLS-2$
+ @Test public void testSplitOnEntireStringEmptyDelimiter() {
+ List<String> result = StringUtil.splitOnEntireString("test", ""); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(1, result.size());
assertEquals("test", result.get(0)); //$NON-NLS-1$
}
- public void testSplitOnEntireStringEndsWithDelimiter() {
- List result = StringUtil.splitOnEntireString("testNEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
+ @Test public void testSplitOnEntireStringEndsWithDelimiter() {
+ List<String> result = StringUtil.splitOnEntireString("testNEXT", "NEXT"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(2, result.size());
assertEquals("test", result.get(0)); //$NON-NLS-1$
assertEquals("", result.get(1)); //$NON-NLS-1$
}
- public void testIndexOfIgnoreCase() {
+ @Test public void testIndexOfIgnoreCase() {
String text = "test"; //$NON-NLS-1$
assertEquals(-1,StringUtil.indexOfIgnoreCase(null,text));
assertEquals(-1,StringUtil.indexOfIgnoreCase("",text)); //$NON-NLS-1$
@@ -283,7 +277,7 @@
assertEquals(2,StringUtil.indexOfIgnoreCase(text,"ST")); //$NON-NLS-1$
}
- public void testStartsWithIgnoreCase() {
+ @Test public void testStartsWithIgnoreCase() {
String text = "test"; //$NON-NLS-1$
assertEquals(false,StringUtil.startsWithIgnoreCase(null,text));
assertEquals(false,StringUtil.startsWithIgnoreCase("",text)); //$NON-NLS-1$
@@ -298,7 +292,7 @@
assertEquals(true,StringUtil.startsWithIgnoreCase(text,"TE")); //$NON-NLS-1$
}
- public void testEndsWithIgnoreCase() {
+ @Test public void testEndsWithIgnoreCase() {
String text = "test"; //$NON-NLS-1$
assertEquals(false,StringUtil.endsWithIgnoreCase(null,text));
assertEquals(false,StringUtil.endsWithIgnoreCase("",text)); //$NON-NLS-1$
@@ -313,30 +307,30 @@
assertEquals(true,StringUtil.endsWithIgnoreCase(text,"ST")); //$NON-NLS-1$
}
- public void testIsDigits() {
+ @Test public void testIsDigits() {
assertTrue(StringUtil.isDigits("012872")); //$NON-NLS-1$
assertTrue(StringUtil.isDigits("634644")); //$NON-NLS-1$
assertFalse(StringUtil.isDigits("A634644")); //$NON-NLS-1$
assertFalse(StringUtil.isDigits("634A644")); //$NON-NLS-1$
}
- public void testToFixedLengthNull() {
+ @Test public void testToFixedLengthNull() {
assertEquals(" ", StringUtil.toFixedLength(null, 4)); //$NON-NLS-1$
}
- public void testToFixedLengthPad() {
+ @Test public void testToFixedLengthPad() {
assertEquals("a ", StringUtil.toFixedLength("a", 4)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testToFixedLengthNoChange() {
+ @Test public void testToFixedLengthNoChange() {
assertEquals("abcd", StringUtil.toFixedLength("abcd", 4)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testToFixedLengthChop() {
+ @Test public void testToFixedLengthChop() {
assertEquals("abcd", StringUtil.toFixedLength("abcdefgh", 4)); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testIsLetter() {
+ @Test public void testIsLetter() {
assertTrue(StringUtil.isLetter('a'));
assertTrue(StringUtil.isLetter('A'));
assertFalse(StringUtil.isLetter('5'));
@@ -346,7 +340,7 @@
assertTrue(StringUtil.isLetter('\u0905')); // Devanagiri letter
}
- public void testIsDigit() {
+ @Test public void testIsDigit() {
assertFalse(StringUtil.isDigit('a'));
assertFalse(StringUtil.isDigit('A'));
assertTrue(StringUtil.isDigit('5'));
@@ -356,7 +350,7 @@
assertFalse(StringUtil.isDigit('\u0905')); // Devanagiri letter
}
- public void testIsLetterOrDigit() {
+ @Test public void testIsLetterOrDigit() {
assertTrue(StringUtil.isLetterOrDigit('a'));
assertTrue(StringUtil.isLetterOrDigit('A'));
assertTrue(StringUtil.isLetterOrDigit('5'));
@@ -366,21 +360,12 @@
assertTrue(StringUtil.isLetterOrDigit('\u0905')); // Devanagiri letter
}
- public void testToUpperCase() {
- assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", StringUtil.toUpperCase("abcdefghijklmnopqrstuvwxyz1234567890")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("LATIN1_\u00c0", StringUtil.toUpperCase("Latin1_\u00e0")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- public void testToLowerCase() {
- assertEquals("abcdefghijklmnopqrstuvwxyz1234567890", StringUtil.toLowerCase("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals("latin1_\u00e0", StringUtil.toLowerCase("Latin1_\u00c0")); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void testCreateFileName() {
+ @Test public void testCreateFileName() {
assertEquals("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890", StringUtil.createFileName("ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890")); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals("http:__www.metamatrix.com_parm1=test;parm2=testy2", StringUtil.createFileName("http://www.metamatrix.com?parm1=test;parm2=testy2")); //$NON-NLS-1$ //$NON-NLS-2$
}
- public void testGetFirstToken(){
+ @Test public void testGetFirstToken(){
assertEquals("/foo/bar", StringUtil.getFirstToken("/foo/bar.vdb", "."));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertEquals("", StringUtil.getFirstToken("/foo/bar.vdb", "/"));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
assertEquals("/foo", StringUtil.getFirstToken("/foo./bar.vdb", "."));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
@@ -388,12 +373,12 @@
assertEquals("vdb", StringUtil.getLastToken("/foo/bar.vdb", "."));//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
- public enum Test {
+ public enum EnumTest {
HELLO,
WORLD
}
- public void testValueOf() throws Exception {
+ @Test public void testValueOf() throws Exception {
assertEquals(Integer.valueOf(21), StringUtil.valueOf("21", Integer.class)); //$NON-NLS-1$
assertEquals(Boolean.valueOf(true), StringUtil.valueOf("true", Boolean.class)); //$NON-NLS-1$
assertEquals("Foo", StringUtil.valueOf("Foo", String.class)); //$NON-NLS-1$ //$NON-NLS-2$
@@ -415,7 +400,7 @@
assertEquals(3, m.size());
assertEquals(m.get("foo"), "bar"); //$NON-NLS-1$ //$NON-NLS-2$
assertEquals(m.get("x"), ""); //$NON-NLS-1$ //$NON-NLS-2$
- assertEquals(Test.HELLO, StringUtil.valueOf("HELLO", Test.class)); //$NON-NLS-1$
+ assertEquals(EnumTest.HELLO, StringUtil.valueOf("HELLO", EnumTest.class)); //$NON-NLS-1$
assertEquals(new URL("http://teiid.org"), StringUtil.valueOf("http://teiid.org", URL.class)); //$NON-NLS-1$ //$NON-NLS-2$
}
Modified: trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/engine/src/main/java/org/teiid/dqp/internal/process/DataTierManagerImpl.java 2012-09-06 19:15:48 UTC (rev 4407)
@@ -391,7 +391,7 @@
break;
case KEYS:
for (KeyRecord key : table.getAllKeys()) {
- rows.add(Arrays.asList(vdbName, table.getParent().getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(),
+ rows.add(Arrays.asList(vdbName, schema.getName(), table.getName(), key.getName(), key.getAnnotation(), key.getNameInSource(), key.getType().toString(),
false, (key instanceof ForeignKey)?((ForeignKey)key).getUniqueKeyID():null, key.getUUID(), oid++));
}
break;
Modified: trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-06 19:02:53 UTC (rev 4406)
+++ trunk/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2012-09-06 19:15:48 UTC (rev 4407)
@@ -44,6 +44,7 @@
import org.teiid.core.types.Transform;
import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.core.util.Assertion;
+import org.teiid.core.util.StringUtil;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants;
import org.teiid.language.Like.MatchMode;
@@ -98,7 +99,8 @@
public static final CompareCriteria FALSE_CRITERIA = new CompareCriteria(new Constant(1, DataTypeManager.DefaultDataClasses.INTEGER), CompareCriteria.EQ, new Constant(0, DataTypeManager.DefaultDataClasses.INTEGER));
public static final CompareCriteria UNKNOWN_CRITERIA = new CompareCriteria(new Constant(null, DataTypeManager.DefaultDataClasses.STRING), CompareCriteria.NE, new Constant(null, DataTypeManager.DefaultDataClasses.STRING));
- private static final Map<String, String> ALIASED_FUNCTIONS = new HashMap<String, String>();
+ private static final Map<String, String> ALIASED_FUNCTIONS = new TreeMap<String, String>(String.CASE_INSENSITIVE_ORDER);
+ private static final Set<String> PARSE_FORMAT_TYPES = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
static {
ALIASED_FUNCTIONS.put("lower", SourceSystemFunctions.LCASE); //$NON-NLS-1$
@@ -107,12 +109,11 @@
ALIASED_FUNCTIONS.put("nvl", SourceSystemFunctions.IFNULL); //$NON-NLS-1$
ALIASED_FUNCTIONS.put("||", SourceSystemFunctions.CONCAT); //$NON-NLS-1$
ALIASED_FUNCTIONS.put("chr", SourceSystemFunctions.CHAR); //$NON-NLS-1$
- }
-
- private static final Set<String> PARSE_FORMAT_TYPES = new HashSet<String>(Arrays.asList(DataTypeManager.DefaultDataTypes.TIME,
+ PARSE_FORMAT_TYPES.addAll( Arrays.asList(DataTypeManager.DefaultDataTypes.TIME,
DataTypeManager.DefaultDataTypes.DATE, DataTypeManager.DefaultDataTypes.TIMESTAMP, DataTypeManager.DefaultDataTypes.BIG_DECIMAL,
DataTypeManager.DefaultDataTypes.BIG_INTEGER, DataTypeManager.DefaultDataTypes.INTEGER, DataTypeManager.DefaultDataTypes.LONG,
DataTypeManager.DefaultDataTypes.FLOAT, DataTypeManager.DefaultDataTypes.DOUBLE));
+ }
// Constants used in simplifying mathematical criteria
private final static Integer INTEGER_ZERO = new Integer(0);
@@ -1556,15 +1557,15 @@
}
boolean isFormat = false;
Function leftFunction = (Function) crit.getLeftExpression();
- String funcName = leftFunction.getName().toLowerCase();
+ String funcName = leftFunction.getName();
String inverseFunction = null;
- if(funcName.startsWith("parse")) { //$NON-NLS-1$
+ if(StringUtil.startsWithIgnoreCase(funcName, "parse")) { //$NON-NLS-1$
String type = funcName.substring(5);
if (!PARSE_FORMAT_TYPES.contains(type)) {
return crit;
}
inverseFunction = "format" + type; //$NON-NLS-1$
- } else if(funcName.startsWith("format")) { //$NON-NLS-1$
+ } else if(StringUtil.startsWithIgnoreCase(funcName, "format")) { //$NON-NLS-1$
String type = funcName.substring(6);
if (!PARSE_FORMAT_TYPES.contains(type)) {
return crit;
@@ -2040,29 +2041,26 @@
return expression;
}
- private static Map<String, Integer> FUNCTION_MAP = new HashMap<String, Integer>();
+ private static Map<String, Integer> FUNCTION_MAP = new TreeMap<String, Integer>(String.CASE_INSENSITIVE_ORDER);
static {
- FUNCTION_MAP.put(FunctionLibrary.SPACE.toLowerCase(), 0);
- FUNCTION_MAP.put(FunctionLibrary.FROM_UNIXTIME.toLowerCase(), 1);
- FUNCTION_MAP.put(FunctionLibrary.NULLIF.toLowerCase(), 2);
- FUNCTION_MAP.put(FunctionLibrary.COALESCE.toLowerCase(), 3);
- FUNCTION_MAP.put(FunctionLibrary.CONCAT2.toLowerCase(), 4);
- FUNCTION_MAP.put(FunctionLibrary.TIMESTAMPADD.toLowerCase(), 5);
- FUNCTION_MAP.put(FunctionLibrary.PARSEDATE.toLowerCase(), 6);
- FUNCTION_MAP.put(FunctionLibrary.PARSETIME.toLowerCase(), 7);
- FUNCTION_MAP.put(FunctionLibrary.FORMATDATE.toLowerCase(), 8);
- FUNCTION_MAP.put(FunctionLibrary.FORMATTIME.toLowerCase(), 9);
- FUNCTION_MAP.put(SourceSystemFunctions.TRIM.toLowerCase(), 10);
+ FUNCTION_MAP.put(FunctionLibrary.SPACE, 0);
+ FUNCTION_MAP.put(FunctionLibrary.FROM_UNIXTIME, 1);
+ FUNCTION_MAP.put(FunctionLibrary.NULLIF, 2);
+ FUNCTION_MAP.put(FunctionLibrary.COALESCE, 3);
+ FUNCTION_MAP.put(FunctionLibrary.CONCAT2, 4);
+ FUNCTION_MAP.put(FunctionLibrary.TIMESTAMPADD, 5);
+ FUNCTION_MAP.put(FunctionLibrary.PARSEDATE, 6);
+ FUNCTION_MAP.put(FunctionLibrary.PARSETIME, 7);
+ FUNCTION_MAP.put(FunctionLibrary.FORMATDATE, 8);
+ FUNCTION_MAP.put(FunctionLibrary.FORMATTIME, 9);
+ FUNCTION_MAP.put(SourceSystemFunctions.TRIM, 10);
}
private Expression rewriteFunction(Function function) throws TeiidComponentException, TeiidProcessingException{
- if (function.isAggregate()) {
- //AggregateSymbol as = new AggregateSymbol(function.getName(), aggregateFunction, isDistinct, expression)
- }
//rewrite alias functions
- String functionLowerName = function.getName().toLowerCase();
- String actualName =ALIASED_FUNCTIONS.get(functionLowerName);
+ String functionName = function.getName();
+ String actualName =ALIASED_FUNCTIONS.get(functionName);
FunctionLibrary funcLibrary = this.metadata.getFunctionLibrary();
if (actualName != null) {
@@ -2076,8 +2074,8 @@
function.setFunctionDescriptor(descriptor);
}
- if(functionLowerName.startsWith("parse")) { //$NON-NLS-1$
- String type = functionLowerName.substring(5);
+ if(StringUtil.startsWithIgnoreCase(functionName, "parse")) { //$NON-NLS-1$
+ String type = functionName.substring(5);
if (PARSE_FORMAT_TYPES.contains(type) && Number.class.isAssignableFrom(function.getType()) && !type.equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
Function result = new Function(SourceSystemFunctions.PARSEBIGDECIMAL, function.getArgs());
FunctionDescriptor descriptor =
@@ -2086,8 +2084,8 @@
result.setType(DataTypeManager.DefaultDataClasses.BIG_DECIMAL);
return rewriteFunction(ResolverUtil.getConversion(result, DataTypeManager.DefaultDataTypes.BIG_DECIMAL, DataTypeManager.getDataTypeName(function.getType()), false, metadata.getFunctionLibrary()));
}
- } else if(functionLowerName.startsWith("format")) { //$NON-NLS-1$
- String type = functionLowerName.substring(6);
+ } else if(StringUtil.startsWithIgnoreCase(functionName, "format")) { //$NON-NLS-1$
+ String type = functionName.substring(6);
if (PARSE_FORMAT_TYPES.contains(type) && Number.class.isAssignableFrom(function.getArg(0).getType()) && !type.equals(DataTypeManager.DefaultDataTypes.BIG_DECIMAL)) {
Function bigDecimalParam = ResolverUtil.getConversion(function.getArg(0), DataTypeManager.getDataTypeName(function.getArg(0).getType()), DataTypeManager.DefaultDataTypes.BIG_DECIMAL, false, metadata.getFunctionLibrary());
Function result = new Function(SourceSystemFunctions.FORMATBIGDECIMAL, new Expression[] {bigDecimalParam, function.getArg(1)});
@@ -2099,7 +2097,7 @@
}
}
- Integer code = FUNCTION_MAP.get(functionLowerName);
+ Integer code = FUNCTION_MAP.get(functionName);
if (code != null) {
switch (code) {
case 0: { //space(x) => repeat(' ', x)
11 years, 7 months
teiid SVN: r4406 - in trunk/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-06 15:02:53 -0400 (Thu, 06 Sep 2012)
New Revision: 4406
Modified:
trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-2190 ensuring index use retains all equi-join predicates
Modified: trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2012-09-06 15:58:12 UTC (rev 4405)
+++ trunk/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2012-09-06 19:02:53 UTC (rev 4406)
@@ -25,8 +25,10 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
+import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
+import java.util.Map;
import java.util.Set;
import org.teiid.api.exception.query.QueryMetadataException;
@@ -131,44 +133,51 @@
key = NewCalculateCostUtil.getKeyUsed(leftExpressions, null, metadata, null);
right = false;
}
- if (key != null) {
+ if (key != null && joinNode.getProperty(NodeConstants.Info.DEPENDENT_VALUE_SOURCE) == null) {
//redo the join predicates based upon the key alone
List<Object> keyCols = metadata.getElementIDsInKey(key);
int[] reorder = new int[keyCols.size()];
- List<Integer> toCriteria = new ArrayList<Integer>(rightExpressions.size() - keyCols.size());
+ LinkedHashSet<Integer> toCriteria = new LinkedHashSet<Integer>();
List<Expression> keyExpressions = right?rightExpressions:leftExpressions;
- for (int j = 0; j < keyExpressions.size(); j++) {
- Expression ses = keyExpressions.get(j);
- if (!(ses instanceof ElementSymbol)) {
+ Map<Object, Integer> indexMap = new LinkedHashMap<Object, Integer>();
+ for (int i = 0; i < keyExpressions.size(); i++) {
+ Expression ses = keyExpressions.get(i);
+ if (!(ses instanceof ElementSymbol)) {
continue;
}
- ElementSymbol es = (ElementSymbol)ses;
- boolean found = false;
- for (int i = 0; !found && i < keyCols.size(); i++) {
- if (es.getMetadataID().equals(keyCols.get(i))) {
- reorder[i] = j;
- found = true;
+ Integer existing = indexMap.put(((ElementSymbol)ses).getMetadataID(), i);
+ if (existing != null) {
+ toCriteria.add(existing);
+ }
+ }
+ boolean found = true;
+ for (int i = 0; i < keyCols.size(); i++) {
+ Object id = keyCols.get(i);
+ Integer index = indexMap.remove(id);
+ if (index == null) {
+ found = false;
+ break;
+ }
+ reorder[i] = index;
+ }
+ if (found) {
+ toCriteria.addAll(indexMap.values());
+ List<Criteria> joinCriteria = (List<Criteria>) joinNode.getProperty(Info.NON_EQUI_JOIN_CRITERIA);
+ for (int index : toCriteria) {
+ Expression lses = leftExpressions.get(index);
+ Expression rses = rightExpressions.get(index);
+ CompareCriteria cc = new CompareCriteria(lses, CompareCriteria.EQ, rses);
+ if (joinCriteria == null || joinCriteria.isEmpty()) {
+ joinCriteria = new ArrayList<Criteria>();
}
- }
- if (!found) {
- toCriteria.add(j);
- }
- }
- List<Criteria> joinCriteria = (List<Criteria>) joinNode.getProperty(Info.NON_EQUI_JOIN_CRITERIA);
- for (int index : toCriteria) {
- Expression lses = leftExpressions.get(index);
- Expression rses = rightExpressions.get(index);
- CompareCriteria cc = new CompareCriteria(lses, CompareCriteria.EQ, rses);
- if (joinCriteria == null || joinCriteria.isEmpty()) {
- joinCriteria = new ArrayList<Criteria>();
joinCriteria.add(cc);
}
- }
- joinNode.setProperty(Info.NON_EQUI_JOIN_CRITERIA, joinCriteria);
- leftExpressions = RelationalNode.projectTuple(reorder, leftExpressions);
- rightExpressions = RelationalNode.projectTuple(reorder, rightExpressions);
- joinNode.setProperty(NodeConstants.Info.LEFT_EXPRESSIONS, leftExpressions);
- joinNode.setProperty(NodeConstants.Info.RIGHT_EXPRESSIONS, rightExpressions);
+ joinNode.setProperty(Info.NON_EQUI_JOIN_CRITERIA, joinCriteria);
+ leftExpressions = RelationalNode.projectTuple(reorder, leftExpressions);
+ rightExpressions = RelationalNode.projectTuple(reorder, rightExpressions);
+ joinNode.setProperty(NodeConstants.Info.LEFT_EXPRESSIONS, leftExpressions);
+ joinNode.setProperty(NodeConstants.Info.RIGHT_EXPRESSIONS, rightExpressions);
+ }
}
boolean pushedLeft = insertSort(joinNode.getFirstChild(), leftExpressions, joinNode, metadata, capabilitiesFinder, pushLeft);
Modified: trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2012-09-06 15:58:12 UTC (rev 4405)
+++ trunk/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2012-09-06 19:02:53 UTC (rev 4406)
@@ -475,9 +475,25 @@
execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
execute("insert into x1 (e2, e1) values (3, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
execute("select x.e1 from x makenotdep, x1 makenotdep where x.e2 = x1.e2 and x.e1 = x1.e1", new List[0]); //$NON-NLS-1$
+ //ensure join is preserved
execute("select x.e1 from x left outer join x1 on x.e2 = x1.e2 and x.e1 = x1.e1", new List[] {Arrays.asList("b")}); //$NON-NLS-1$
}
+ @Test public void testUnneededMergePredicate1() throws Exception {
+ execute("create local temporary table x (e1 string, e2 integer, e3 integer, primary key (e1))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+ execute("create local temporary table x1 (e1 string, e2 integer, e3 integer)", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
+
+ execute("insert into x (e3, e2, e1) values (4, 2, '1')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x (e3, e2, e1) values (4, 2, '2')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x1 (e3, e2, e1) values (5, 2, '1')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ execute("insert into x1 (e3, e2, e1) values (5, 1, '2')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
+ //ensure predicates are preserved
+ execute("select x.e1 from /*+ makenotdep */ x inner join /*+ makenotdep */ x1 on x.e1 = x1.e1 and upper(x.e1) = x1.e2", new List[] {Arrays.asList("1"), Arrays.asList("2")}); //$NON-NLS-1$
+ execute("select x.e1 from /*+ makenotdep */ x inner join /*+ makenotdep */ x1 on x.e1 = x1.e1 and upper(x.e1) = x1.e2 and x1.e3 = x.e3", new List[0]); //$NON-NLS-1$
+ //ensure there's no bad interaction with makedep
+ execute("select x.e1 from /*+ makedep */ x inner join x1 on x.e1 = x1.e1 and x.e2 = x1.e2", new List[] {Arrays.asList("1")}); //$NON-NLS-1$
+ }
+
private void sampleTable() throws Exception {
execute("create local temporary table x (e1 string, e2 integer, primary key (e1, e2))", new List[] {Arrays.asList(0)}); //$NON-NLS-1$
execute("insert into x (e2, e1) values (3, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
11 years, 7 months
teiid SVN: r4405 - in branches/7.7.x/engine/src: test/java/org/teiid/query/processor and 1 other directory.
by teiid-commits@lists.jboss.org
Author: jolee
Date: 2012-09-06 11:58:12 -0400 (Thu, 06 Sep 2012)
New Revision: 4405
Modified:
branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
Log:
TEIID-2107 fix for left outer join with index issue
Modified: branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java
===================================================================
--- branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2012-09-06 14:20:33 UTC (rev 4404)
+++ branches/7.7.x/engine/src/main/java/org/teiid/query/optimizer/relational/rules/RuleImplementJoinStrategy.java 2012-09-06 15:58:12 UTC (rev 4405)
@@ -162,7 +162,6 @@
if (joinCriteria == null || joinCriteria.isEmpty()) {
joinCriteria = new ArrayList<Criteria>();
joinCriteria.add(cc);
- joinNode.setProperty(Info.JOIN_TYPE, JoinType.JOIN_INNER);
}
}
joinNode.setProperty(Info.NON_EQUI_JOIN_CRITERIA, joinCriteria);
Modified: branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java
===================================================================
--- branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2012-09-06 14:20:33 UTC (rev 4404)
+++ branches/7.7.x/engine/src/test/java/org/teiid/query/processor/TestTempTables.java 2012-09-06 15:58:12 UTC (rev 4405)
@@ -476,6 +476,7 @@
execute("insert into x (e2, e1) values (2, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
execute("insert into x1 (e2, e1) values (3, 'b')", new List[] {Arrays.asList(1)}); //$NON-NLS-1$
execute("select x.e1 from x makenotdep, x1 makenotdep where x.e2 = x1.e2 and x.e1 = x1.e1", new List[0]); //$NON-NLS-1$
+ execute("select x.e1 from x left outer join x1 on x.e2 = x1.e2 and x.e1 = x1.e1", new List[] {Arrays.asList("b")}); //$NON-NLS-1$
}
private void sampleTable() throws Exception {
11 years, 7 months
teiid SVN: r4404 - in trunk: engine/src/main/java/org/teiid/query/validator and 4 other directories.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-06 10:20:33 -0400 (Thu, 06 Sep 2012)
New Revision: 4404
Modified:
trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected
trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected
trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected
trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected
Log:
TEIID-2166 corrected for multi-column and added pg_class/attribute entries for indexes
Modified: trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/engine/src/main/java/org/teiid/query/sql/visitor/AggregateSymbolCollectorVisitor.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -49,6 +49,10 @@
this.groupingColsUsed = groupingColsUsed;
}
+ public AggregateStopNavigator(LanguageVisitor visitor) {
+ super(visitor, PreOrPostOrderNavigator.PRE_ORDER, true);
+ }
+
public void visit(AggregateSymbol obj) {
// Visit aggregate symbol but do not dive into it's expression
preVisitVisitor(obj);
Modified: trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/engine/src/main/java/org/teiid/query/validator/ValidationVisitor.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -67,7 +67,6 @@
import org.teiid.query.sql.lang.ObjectTable.ObjectColumn;
import org.teiid.query.sql.lang.SetQuery.Operation;
import org.teiid.query.sql.lang.XMLTable.XMLColumn;
-import org.teiid.query.sql.navigator.PreOrPostOrderNavigator;
import org.teiid.query.sql.navigator.PreOrderNavigator;
import org.teiid.query.sql.proc.Block;
import org.teiid.query.sql.proc.BranchingStatement;
@@ -85,6 +84,7 @@
import org.teiid.query.sql.visitor.GroupCollectorVisitor;
import org.teiid.query.sql.visitor.SQLStringVisitor;
import org.teiid.query.sql.visitor.ValueIteratorProviderCollectorVisitor;
+import org.teiid.query.sql.visitor.AggregateSymbolCollectorVisitor.AggregateStopNavigator;
import org.teiid.query.validator.UpdateValidator.UpdateInfo;
import org.teiid.query.xquery.saxon.SaxonXQueryExpression;
import org.teiid.translator.SourceSystemFunctions;
@@ -623,7 +623,8 @@
}
}
};
- PreOrPostOrderNavigator.doVisit(object, ecv, PreOrPostOrderNavigator.PRE_ORDER, true);
+ AggregateStopNavigator asn = new AggregateStopNavigator(ecv);
+ object.acceptVisitor(asn);
}
private void validateNoAggsInClause(LanguageObject clause) {
Modified: trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java
===================================================================
--- trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/runtime/src/main/java/org/teiid/deployers/PgCatalogMetadataStore.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -152,7 +152,21 @@
"false as atthasdef " + //$NON-NLS-1$
"FROM SYS.Columns as t1 LEFT OUTER JOIN " + //$NON-NLS-1$
"SYS.Tables st ON (st.Name = t1.TableName AND st.SchemaName = t1.SchemaName) LEFT OUTER JOIN " + //$NON-NLS-1$
- "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name";//$NON-NLS-1$
+ "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name " +//$NON-NLS-1$
+ "UNION ALL SELECT kc.OID + (SELECT MAX(oid) FROM SYS.Columns) as oid, " + //$NON-NLS-1$
+ "k.oid + (SELECT MAX(OID) FROM SYS.Tables) as attrelid, " + //$NON-NLS-1$
+ "t1.Name as attname, " + //$NON-NLS-1$
+ "pt.oid as atttypid," + //$NON-NLS-1$
+ "pt.typlen as attlen, " + //$NON-NLS-1$
+ "convert(kc.Position, short) as attnum, " + //$NON-NLS-1$
+ "(CASE WHEN (t1.DataType = 'bigdecimal' OR t1.DataType = 'biginteger' OR t1.DataType = 'float' OR t1.DataType='double') THEN (4+(65536*t1.Precision)+t1.Scale) " + //$NON-NLS-1$
+ "ELSE (4+t1.Length) END) as atttypmod, " + //$NON-NLS-1$
+ "CASE WHEN (t1.NullType = 'No Nulls') THEN true ELSE false END as attnotnull, " + //$NON-NLS-1$
+ "false as attisdropped, " + //$NON-NLS-1$
+ "false as atthasdef " + //$NON-NLS-1$
+ "FROM (SYS.Keys as k INNER JOIN SYS.KeyColumns as kc ON k.uid = kc.uid INNER JOIN SYS.Columns as t1 ON kc.SchemaName = t1.SchemaName AND kc.TableName = t1.TableName AND kc.Name = t1.Name INNER JOIN " + //$NON-NLS-1$
+ "SYS.Tables as st ON st.Name = t1.TableName AND st.SchemaName = t1.SchemaName) LEFT OUTER JOIN " + //$NON-NLS-1$
+ "pg_catalog.matpg_datatype pt ON t1.DataType = pt.Name"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
@@ -200,7 +214,15 @@
"0 as relpages, " + //$NON-NLS-1$
"false as relhasrules, " + //$NON-NLS-1$
"false as relhasoids " + //$NON-NLS-1$
- "FROM SYS.Tables t1"; //$NON-NLS-1$
+ "FROM SYS.Tables t1 UNION ALL SELECT t1.OID + (SELECT MAX(oid) as max from sys.tables) as oid, t1.name as relname, " + //$NON-NLS-1$
+ "(SELECT OID FROM SYS.Schemas WHERE Name = t1.SchemaName) as relnamespace, " + //$NON-NLS-1$
+ "convert('i', char) as relkind," + //$NON-NLS-1$
+ "0 as relam, " + //$NON-NLS-1$
+ "convert(0, float) as reltuples, " + //$NON-NLS-1$
+ "0 as relpages, " + //$NON-NLS-1$
+ "false as relhasrules, " + //$NON-NLS-1$
+ "false as relhasoids " + //$NON-NLS-1$
+ "FROM SYS.Keys t1 WHERE t1.type in ('Primary', 'Unique', 'Index')"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
@@ -235,16 +257,16 @@
addPrimaryKey("pk_pg_index", Arrays.asList("oid"), t); //$NON-NLS-1$ //$NON-NLS-2$
- String transformation = "SELECT min(t1.OID) as oid, " + //$NON-NLS-1$
- "min(t1.OID) as indexrelid, " + //$NON-NLS-1$
+ String transformation = "SELECT k.oid as oid, " + //$NON-NLS-1$
+ "k.oid + (SELECT MAX(oid) as max from sys.tables) as indexrelid, " + //$NON-NLS-1$
"(SELECT OID FROM SYS.Tables WHERE SchemaName = t1.SchemaName AND Name = t1.TableName) as indrelid, " + //$NON-NLS-1$
"cast(count(t1.OID) as short) as indnatts, " + //$NON-NLS-1$
"false indisclustered, " + //$NON-NLS-1$
- "(CASE t1.KeyType WHEN 'Unique' THEN true ELSE false END) as indisunique, " + //$NON-NLS-1$
+ "(CASE WHEN t1.KeyType in ('Unique', 'Primary') THEN true ELSE false END) as indisunique, " + //$NON-NLS-1$
"(CASE t1.KeyType WHEN 'Primary' THEN true ELSE false END) as indisprimary, " + //$NON-NLS-1$
"'' as indexprs, asPGVector(" + //$NON-NLS-1$
arrayAgg("(select at.attnum FROM pg_attribute as at WHERE at.attname = t1.Name AND at.attrelid = (SELECT OID FROM SYS.Tables WHERE SchemaName = t1.SchemaName AND Name = t1.TableName))", "t1.position") +") as indkey " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- "FROM SYS.KeyColumns as t1 GROUP BY t1.uid, t1.KeyType, t1.SchemaName, t1.TableName, t1.Name"; //$NON-NLS-1$
+ "FROM SYS.Keys as k, Sys.KeyColumns as t1 WHERE k.uid = t1.uid GROUP BY k.oid, t1.KeyType, t1.SchemaName, t1.TableName, t1.KeyName"; //$NON-NLS-1$
t.setSelectTransformation(transformation);
t.setMaterialized(true);
return t;
Modified: trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java
===================================================================
--- trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/java/org/teiid/systemmodel/TestODBCSchema.java 2012-09-06 14:20:33 UTC (rev 4404)
@@ -2,7 +2,10 @@
import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.teiid.core.util.UnitTestUtil;
import org.teiid.jdbc.AbstractMMQueryTestCase;
@@ -12,6 +15,7 @@
@SuppressWarnings("nls")
public class TestODBCSchema extends AbstractMMQueryTestCase {
private static final String VDB = "PartsSupplier"; //$NON-NLS-1$
+ private static FakeServer server;
public TestODBCSchema() {
// this is needed because the result files are generated
@@ -19,11 +23,24 @@
super.DELIMITER = "\t"; //$NON-NLS-1$
}
- @Before public void setUp() throws Exception {
- FakeServer server = new FakeServer(true);
+ @BeforeClass public static void oneTimeSetUp() throws Exception {
+ server = new FakeServer(true);
server.deployVDB(VDB, UnitTestUtil.getTestDataPath() + "/PartsSupplier.vdb");
- this.internalConnection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
}
+
+ @AfterClass public static void oneTimeTearDown() {
+ server.stop();
+ }
+
+ @Before public void setUp() throws Exception {
+ this.internalConnection = server.createConnection("jdbc:teiid:" + VDB); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+
+ @After public void tearDown() throws Exception {
+ if (this.internalConnection != null) {
+ this.internalConnection.close();
+ }
+ }
@Test public void test_PG_AM() throws Exception {
execute("select * FROM pg_am"); //$NON-NLS-1$
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/testOBIEEColumnQuery.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -1,20 +1,20 @@
string short string string string
attname attnum relname nspname relname
-PART_ID 1 PARTSSUPPLIER.PARTS PartsSupplier PARTSSUPPLIER.PARTS
-SHIPPER_ID 1 PARTSSUPPLIER.SHIP_VIA PartsSupplier PARTSSUPPLIER.SHIP_VIA
-STATUS_ID 1 PARTSSUPPLIER.STATUS PartsSupplier PARTSSUPPLIER.STATUS
-SUPPLIER_ID 1 PARTSSUPPLIER.SUPPLIER PartsSupplier PARTSSUPPLIER.SUPPLIER
-SUPPLIER_ID 1 Columns PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
-PART_ID 1 DataTypes PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
-oid 1 ProcedureParams pg_catalog matpg_datatype
-name 1 Procedures pg_catalog matpg_datatype
-attname 1 Schemas pg_catalog matpg_relatt
-relname 1 Tables pg_catalog matpg_relatt
-nspname 1 VirtualDatabases pg_catalog matpg_relatt
-oid 1 matpg_datatype pg_catalog pg_attribute
-oid 1 matpg_relatt pg_catalog pg_class
-oid 1 pg_am pg_catalog pg_index
-oid 1 pg_attrdef pg_catalog pg_proc
+PART_ID 1 PK_PARTS PartsSupplier PARTSSUPPLIER.PARTS
+SHIPPER_ID 1 PK_SHIP_VIA PartsSupplier PARTSSUPPLIER.SHIP_VIA
+STATUS_ID 1 PK_STATUS PartsSupplier PARTSSUPPLIER.STATUS
+SUPPLIER_ID 1 PK_SUPPLIER PartsSupplier PARTSSUPPLIER.SUPPLIER
+SUPPLIER_ID 1 PK_SUPPLIER_PARTS PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
+oid 1 matpg_datatype_names pg_catalog matpg_datatype
+attname 1 pk_matpg_relatt_names pg_catalog matpg_relatt
+oid 1 pk_pg_attr pg_catalog pg_attribute
+oid 1 pk_pg_class pg_catalog pg_class
+oid 1 pk_pg_index pg_catalog pg_index
+oid 1 pk_pg_proc pg_catalog pg_proc
+PART_ID 2 PK_SUPPLIER_PARTS PartsSupplier PARTSSUPPLIER.SUPPLIER_PARTS
+name 2 matpg_datatype_names pg_catalog matpg_datatype
+relname 2 pk_matpg_relatt_names pg_catalog matpg_relatt
+nspname 3 pk_matpg_relatt_names pg_catalog matpg_relatt
Row Count : 15
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
attname 12 PartsSupplier java.lang.String attname string pg_catalog pg_attribute 4000 4000 0 false true false false 1 true true false false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_ATTRIBUTE.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -255,7 +255,29 @@
253 31 usename 1043 -1 2 4004 false false false
254 31 usecreatedb 16 1 3 5 false false false
255 31 usesuper 16 1 4 5 false false false
-Row Count : 255
+256 32 PART_ID 1043 -1 1 8 true false false
+257 33 SHIPPER_ID 21 2 1 4 true false false
+258 34 STATUS_ID 21 2 1 4 true false false
+259 35 SUPPLIER_ID 1043 -1 1 14 true false false
+260 36 SUPPLIER_STATUS 21 2 1 4 false false false
+261 37 SUPPLIER_ID 1043 -1 1 14 true false false
+262 37 PART_ID 1043 -1 2 8 true false false
+263 38 PART_ID 1043 -1 1 8 true false false
+264 39 SUPPLIER_ID 1043 -1 1 14 true false false
+265 40 oid 23 4 1 8 false false false
+266 40 name 1043 -1 2 4004 false false false
+267 41 typname 1043 -1 1 4004 false false false
+268 41 oid 23 4 2 8 false false false
+269 42 attname 1043 -1 1 4004 false false false
+270 42 relname 1043 -1 2 4004 false false false
+271 42 nspname 1043 -1 3 4004 false false false
+272 43 attrelid 23 4 1 8 false false false
+273 43 attnum 21 2 2 6 false false false
+274 44 oid 23 4 1 8 false false false
+275 45 oid 23 4 1 8 false false false
+276 46 oid 23 4 1 8 false false false
+277 47 oid 23 4 1 8 false false false
+Row Count : 277
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_attribute 11 10 0 false false false false 1 true true true false
attrelid 4 PartsSupplier java.lang.Integer attrelid integer pg_catalog pg_attribute 11 10 0 false false false false 1 true true true false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_CLASS.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -31,7 +31,20 @@
29 pg_trigger 4 v 0 0.0 0 false false
30 pg_type 4 v 0 0.0 0 false false
31 pg_user 4 v 0 0.0 0 false false
-Row Count : 31
+32 PK_PARTS 1 i 0 0.0 0 false false
+33 PK_SHIP_VIA 1 i 0 0.0 0 false false
+34 PK_STATUS 1 i 0 0.0 0 false false
+35 PK_SUPPLIER 1 i 0 0.0 0 false false
+37 PK_SUPPLIER_PARTS 1 i 0 0.0 0 false false
+40 matpg_datatype_names 4 i 0 0.0 0 false false
+41 matpg_datatype_ids 4 i 0 0.0 0 false false
+42 pk_matpg_relatt_names 4 i 0 0.0 0 false false
+43 idx_matpg_relatt_ids 4 i 0 0.0 0 false false
+44 pk_pg_attr 4 i 0 0.0 0 false false
+45 pk_pg_class 4 i 0 0.0 0 false false
+46 pk_pg_index 4 i 0 0.0 0 false false
+47 pk_pg_proc 4 i 0 0.0 0 false false
+Row Count : 44
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_class 11 10 0 false false false false 1 true true true false
relname 12 PartsSupplier java.lang.String relname string pg_catalog pg_class 4000 4000 0 false true false false 1 true true false false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSchema/test_PG_INDEX.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -1,28 +1,22 @@
integer integer integer short boolean boolean boolean string short[]
oid indexrelid indrelid indnatts indisclustered indisunique indisprimary indexprs indkey
-1 1 1 1 false false true [1]
-2 2 2 1 false false true [1]
-3 3 3 1 false false true [1]
-4 4 4 1 false false true [1]
-5 5 4 1 false false false [3]
-6 6 5 1 false false true [1]
-7 7 5 1 false false true [2]
-8 8 5 1 false false false [2]
-9 9 5 1 false false false [1]
-10 10 19 1 false false true [1]
-11 11 19 1 false false true [3]
-12 12 19 1 false false false [2]
-13 13 19 1 false false false [1]
-14 14 20 1 false false true [3]
-15 15 20 1 false false true [4]
-16 16 20 1 false false true [5]
-17 17 20 1 false false false [1]
-18 18 20 1 false false false [2]
-19 19 23 1 false false true [1]
-20 20 24 1 false false true [1]
-21 21 26 1 false false true [1]
-22 22 28 1 false false true [1]
-Row Count : 22
+1 32 1 1 false true true [1]
+2 33 2 1 false true true [1]
+3 34 3 1 false true true [1]
+4 35 4 1 false true true [1]
+5 36 4 1 false false false [3]
+6 37 5 2 false true true [1, 2]
+7 38 5 1 false false false [2]
+8 39 5 1 false false false [1]
+9 40 19 2 false true true [1, 3]
+10 41 19 2 false false false [2, 1]
+11 42 20 3 false true true [3, 4, 5]
+12 43 20 2 false false false [1, 2]
+13 44 23 1 false true true [1]
+14 45 24 1 false true true [1]
+15 46 26 1 false true true [1]
+16 47 28 1 false true true [1]
+Row Count : 16
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
oid 4 PartsSupplier java.lang.Integer oid integer pg_catalog pg_index 11 10 0 false false false false 1 true true true false
indexrelid 4 PartsSupplier java.lang.Integer indexrelid integer pg_catalog pg_index 11 10 0 false false false false 1 true true true false
Modified: trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected
===================================================================
--- trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected 2012-09-06 11:18:06 UTC (rev 4403)
+++ trunk/test-integration/common/src/test/resources/TestODBCSocketTransport/testInt2Vector.expected 2012-09-06 14:20:33 UTC (rev 4404)
@@ -5,23 +5,17 @@
1
1
3
-1
+1 2
2
-2
1
+1 3
+2 1
+3 4 5
+1 2
1
-3
-2
1
-3
-4
-5
1
-2
1
-1
-1
-1
-Row Count : 22
+Row Count : 16
getColumnName getColumnType getCatalogName getColumnClassName getColumnLabel getColumnTypeName getSchemaName getTableName getColumnDisplaySize getPrecision getScale isAutoIncrement isCaseSensitive isCurrency isDefinitelyWritable isNullable isReadOnly isSearchable isSigned isWritable
indkey 1111 java.lang.Object indkey int2vector 2147483647 2147483647 0 false true false false 1 false true false true
11 years, 7 months
teiid SVN: r4403 - in trunk/engine/src: test/java/org/teiid/query/metadata and 1 other directory.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-06 07:18:06 -0400 (Thu, 06 Sep 2012)
New Revision: 4403
Modified:
trunk/engine/src/main/java/org/teiid/query/metadata/DDLStringVisitor.java
trunk/engine/src/test/java/org/teiid/query/metadata/TestDDLStringVisitor.java
Log:
TEIID-2187 switching to always use the constraint form in ddl and adding options
Modified: trunk/engine/src/main/java/org/teiid/query/metadata/DDLStringVisitor.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/metadata/DDLStringVisitor.java 2012-09-06 10:59:21 UTC (rev 4402)
+++ trunk/engine/src/main/java/org/teiid/query/metadata/DDLStringVisitor.java 2012-09-06 11:18:06 UTC (rev 4403)
@@ -30,6 +30,7 @@
import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
+import java.util.Map;
import java.util.regex.Pattern;
import org.teiid.adminapi.Admin.SchemaObjectType;
@@ -154,7 +155,7 @@
else {
buffer.append(COMMA);
}
- visit(c, table);
+ visit(c);
}
buildContraints(table);
buffer.append(NEWLINE);
@@ -235,7 +236,7 @@
KeyRecord pk = table.getPrimaryKey();
if (pk != null) {
- addConstraint("PK", PRIMARY_KEY, pk); //$NON-NLS-1$
+ addConstraint("PK", PRIMARY_KEY, pk, true); //$NON-NLS-1$
}
addConstraints(table.getUniqueKeys(), UNIQUE, UNIQUE);
@@ -243,28 +244,26 @@
for (int i = 0; i < table.getForeignKeys().size(); i++) {
ForeignKey key = table.getForeignKeys().get(i);
- addConstraint("FK" + i, FOREIGN_KEY, key); //$NON-NLS-1$
+ addConstraint("FK" + i, FOREIGN_KEY, key, false); //$NON-NLS-1$
buffer.append(SPACE).append(REFERENCES);
if (key.getReferenceTableName() != null) {
buffer.append(SPACE).append(key.getReferenceTableName());
}
buffer.append(SPACE);
addNames(buffer, key.getReferenceColumns());
+ appendOptions(key);
}
}
private void addConstraints(List<KeyRecord> constraints, String defaultName, String type) {
for (int i = 0; i < constraints.size(); i++) {
KeyRecord constraint = constraints.get(i);
- addConstraint(defaultName + i, type, constraint);
+ addConstraint(defaultName + i, type, constraint, true);
}
}
private void addConstraint(String defaultName, String type,
- KeyRecord constraint) {
- if (constraint.getType() != KeyRecord.Type.AccessPattern && constraint.getColumns().size() <= 1) {
- return;
- }
+ KeyRecord constraint, boolean addOptions) {
buffer.append(COMMA).append(NEWLINE).append(TAB);
boolean nameMatches = defaultName.equals(constraint.getName());
if (!nameMatches) {
@@ -272,6 +271,9 @@
}
buffer.append(type);
addColumns(buffer, constraint.getColumns(), false);
+ if (addOptions) {
+ appendOptions(constraint);
+ }
}
private void addColumns(StringBuilder builder, List<Column> columns, boolean includeType) {
@@ -309,7 +311,7 @@
}
}
- private void visit(Column column, Table table) {
+ private void visit(Column column) {
buffer.append(NEWLINE).append(TAB);
appendColumn(buffer, column, true, true);
@@ -317,32 +319,6 @@
buffer.append(SPACE).append(AUTO_INCREMENT);
}
- KeyRecord pk = table.getPrimaryKey();
- if (pk != null && pk.getColumns().size() == 1) {
- Column c = pk.getColumns().get(0);
- if (column.equals(c)) {
- buffer.append(SPACE).append(PRIMARY_KEY);
- }
- }
-
- for (KeyRecord key:table.getUniqueKeys()) {
- if (key != null && key.getColumns().size() == 1) {
- Column c = key.getColumns().get(0);
- if (column.equals(c)) {
- buffer.append(SPACE).append(UNIQUE);
- }
- }
- }
-
- for (KeyRecord key:table.getIndexes()) {
- if (key != null && key.getColumns().size() == 1) {
- Column c = key.getColumns().get(0);
- if (column.equals(c)) {
- buffer.append(SPACE).append(INDEX);
- }
- }
- }
-
appendDefault(column);
// options
@@ -460,9 +436,21 @@
addOption(options, DISTINCT_VALUES, column.getDistinctValues());
}
- if (!column.getProperties().isEmpty()) {
- for (String key:column.getProperties().keySet()) {
- addOption(options, key, column.getProperty(key, false));
+ buildOptions(column, options);
+ }
+
+ private void appendOptions(AbstractMetadataRecord record) {
+ StringBuilder options = new StringBuilder();
+ buildOptions(record, options);
+ if (options.length() != 0) {
+ buffer.append(SPACE).append(OPTIONS).append(SPACE).append(LPAREN).append(options).append(RPAREN);
+ }
+ }
+
+ private void buildOptions(AbstractMetadataRecord record, StringBuilder options) {
+ if (!record.getProperties().isEmpty()) {
+ for (Map.Entry<String, String> entry:record.getProperties().entrySet()) {
+ addOption(options, entry.getKey(), entry.getValue());
}
}
}
Modified: trunk/engine/src/test/java/org/teiid/query/metadata/TestDDLStringVisitor.java
===================================================================
--- trunk/engine/src/test/java/org/teiid/query/metadata/TestDDLStringVisitor.java 2012-09-06 10:59:21 UTC (rev 4402)
+++ trunk/engine/src/test/java/org/teiid/query/metadata/TestDDLStringVisitor.java 2012-09-06 11:18:06 UTC (rev 4403)
@@ -44,12 +44,17 @@
public void testForeignTable() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1 (\n" +
- " e1 integer PRIMARY KEY,\n" +
- " e2 string(10) UNIQUE,\n" +
- " e3 date NOT NULL UNIQUE,\n" +
+ " e1 integer,\n" +
+ " e2 string(10),\n" +
+ " e3 date NOT NULL,\n" +
" e4 bigdecimal(12,3),\n" +
- " e5 integer AUTO_INCREMENT INDEX OPTIONS (UUID 'uuid', NAMEINSOURCE 'nis', SELECTABLE false),\n" +
- " e6 string INDEX DEFAULT 'hello'\n" +
+ " e5 integer AUTO_INCREMENT OPTIONS (UUID 'uuid', NAMEINSOURCE 'nis', SELECTABLE false),\n" +
+ " e6 string DEFAULT 'hello',\n" +
+ " PRIMARY KEY(e1),\n" +
+ " UNIQUE(e2),\n" +
+ " UNIQUE(e3),\n" +
+ " INDEX(e5),\n" +
+ " INDEX(e6)\n" +
") OPTIONS (ANNOTATION 'Test Table', CARDINALITY '12', FOO 'BAR', UPDATABLE 'true', UUID 'uuid2');";
MetadataFactory mf = new MetadataFactory("test", 1, "model", TestDDLParser.getDataTypes(), new Properties(), null);
@@ -110,12 +115,12 @@
@Test
public void testConstraints2() throws Exception {
String ddl = "CREATE FOREIGN TABLE G1( e1 integer, e2 varchar, e3 date, " +
- "ACCESSPATTERN(e1), UNIQUE(e1), ACCESSPATTERN(e2, e3))";
+ "ACCESSPATTERN(e1), UNIQUE(e1) options (x true), ACCESSPATTERN(e2, e3))";
String expected = "CREATE FOREIGN TABLE G1 (\n" +
- " e1 integer UNIQUE,\n" +
+ " e1 integer,\n" +
" e2 string,\n" +
" e3 date,\n" +
- " ACCESSPATTERN(e1),\n ACCESSPATTERN(e2, e3)\n" +
+ " ACCESSPATTERN(e1),\n ACCESSPATTERN(e2, e3),\n UNIQUE(e1) OPTIONS (x 'true')\n" +
");";
helpTest(ddl, expected);
}
11 years, 7 months
teiid SVN: r4402 - trunk/engine/src/main/java/org/teiid/query/tempdata.
by teiid-commits@lists.jboss.org
Author: shawkins
Date: 2012-09-06 06:59:21 -0400 (Thu, 06 Sep 2012)
New Revision: 4402
Modified:
trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
Log:
TEIID-2185 correcting cost estimation for index selection
Modified: trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2012-09-06 02:46:11 UTC (rev 4401)
+++ trunk/engine/src/main/java/org/teiid/query/tempdata/TempTable.java 2012-09-06 10:59:21 UTC (rev 4402)
@@ -315,9 +315,9 @@
int startIndex = 0;
if (primaryKeyLength == 0) {
startIndex = 1;
- ElementSymbol id = new ElementSymbol("rowId"); //$NON-NLS-1$
- id.setType(DataTypeManager.DefaultDataClasses.INTEGER);
- columns.add(0, id);
+ ElementSymbol rid = new ElementSymbol("rowId"); //$NON-NLS-1$
+ rid.setType(DataTypeManager.DefaultDataClasses.INTEGER);
+ columns.add(0, rid);
rowId = new AtomicInteger();
tree = bm.createSTree(columns, sessionID, 1);
} else {
@@ -435,10 +435,10 @@
if (indexTables != null && (condition != null || orderBy != null) && ii.valueSet.size() != 1) {
LogManager.logDetail(LogConstants.CTX_DQP, "Considering indexes on table", this, "for query", projectedCols, condition, orderBy); //$NON-NLS-1$ //$NON-NLS-2$
int rowCost = this.tree.getRowCount();
- int bestCost = estimateCost(orderBy, ii, rowCost);
+ long bestCost = estimateCost(orderBy, ii, rowCost);
for (TempTable table : this.indexTables.values()) {
IndexInfo secondary = new IndexInfo(table, projectedCols, condition, orderBy, false);
- int cost = estimateCost(orderBy, secondary, rowCost);
+ long cost = estimateCost(orderBy, secondary, rowCost);
if (cost < bestCost) {
ii = secondary;
bestCost = cost;
@@ -512,25 +512,36 @@
* to compute them, since it minimizes page loads, and is a random sample.
* TODO: this should also factor in the block size
*/
- private int estimateCost(OrderBy orderBy, IndexInfo ii, int rowCost) {
- int initialCost = rowCost;
+ private long estimateCost(OrderBy orderBy, IndexInfo ii, long rowCost) {
+ long initialCost = rowCost;
+ long additionalCost = 0;
if (ii.valueSet.size() != 0) {
int length = ii.valueSet.get(0).size();
- rowCost = ii.valueSet.size() * (ii.table.getPkLength() - length + 1);
+ rowCost = ii.valueSet.size();
+ additionalCost = rowCost * (64 - Long.numberOfLeadingZeros(initialCost - 1));
if (ii.table.uniqueColIndex != length) {
- rowCost *= 3;
+ rowCost *= 3*(ii.table.uniqueColIndex - length);
}
+ if (rowCost > initialCost) {
+ additionalCost = rowCost - initialCost;
+ rowCost = initialCost;
+ }
} else if (ii.upper != null) {
+ additionalCost = (64 - Long.numberOfLeadingZeros(initialCost - 1));
rowCost /= 3;
} else if (ii.lower != null) {
+ additionalCost = (64 - Long.numberOfLeadingZeros(initialCost - 1));
rowCost /= 3;
}
- int additionalCost = Math.max(0, initialCost - rowCost);
- int cost = Math.min(initialCost, Math.max(1, rowCost));
- if (cost > 1 && (!ii.covering || (orderBy != null && ii.ordering == null))) {
- cost *= (32 - Integer.numberOfLeadingZeros(cost - 1));
+ if (rowCost > 1 && (!ii.covering || (orderBy != null && ii.ordering == null))) {
+ //pk order or non-covered ordering
+ rowCost *= (64 - Long.numberOfLeadingZeros(rowCost - 1));
+ if (!ii.covering) {
+ //primary lookup
+ rowCost *= 2;
+ }
}
- return cost + additionalCost;
+ return rowCost + additionalCost;
}
private TupleBrowser createTupleBrower(Criteria condition, boolean direction) throws TeiidComponentException {
11 years, 7 months