Skip to content

Commit

Permalink
TEIID-3136 fully resolving to ensure the metadata is correct
Browse files Browse the repository at this point in the history
Conflicts:
	engine/src/main/java/org/teiid/query/metadata/MetadataValidator.java
  • Loading branch information
johnathonlee committed Sep 25, 2014
1 parent 7e4b594 commit bc1732d
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 39 deletions.
51 changes: 29 additions & 22 deletions build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
Expand Up @@ -296,28 +296,35 @@ <h2><a name="Other">Other Issues</a></h2>

<h4>from ${project.version}</h4>
<ul>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2851'>TEIID-2851</a>] - ODATA POST fails if table column is of IDENTITY type (sql server)
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2852'>TEIID-2852</a>] - Retrieval of AUTO GENERATED Keys does not work with JDBC Translator
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2854'>TEIID-2854</a>] - bounded-queue-thread-pool silently drops tasks after the queue length is exceeded (switching to an unbounded queue)
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2871'>TEIID-2871</a>] - Incorrect datatype conversion for java.lang.Byte
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2911'>TEIID-2911</a>] - fully disabling dtd by default, but offering an option to reenable support/preventing external entity resolving
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2933'>TEIID-2933</a>] - OData skipToken not properly honored
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2939'>TEIID-2939</a>] - Issues with applying row based security
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2977'>TEIID-2977</a>] - class cast exception with odata json format function results
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3010'>TEIID-3010</a>] - odata webapp missing joda time dependency
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3011'>TEIID-3011</a>] - adding a better check as to when to skip rewrite (rewrite skipped)
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3021'>TEIID-3021</a>] - Serialization of long sqlexception/warning next chains can lead to oom
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3136'>TEIID-3136</a>] - Possible threading issues with index metadata loading
</li>
</ul>


<h4>from 8.4.3</h4>
<ul>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2851'>TEIID-2851</a>] - ODATA POST fails if table column is of IDENTITY type (sql server)
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2852'>TEIID-2852</a>] - Retrieval of AUTO GENERATED Keys does not work with JDBC Translator
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2854'>TEIID-2854</a>] - bounded-queue-thread-pool silently drops tasks after the queue length is exceeded (switching to an unbounded queue)
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2871'>TEIID-2871</a>] - Incorrect datatype conversion for java.lang.Byte
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2911'>TEIID-2911</a>] - fully disabling dtd by default, but offering an option to reenable support/preventing external entity resolving
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2933'>TEIID-2933</a>] - OData skipToken not properly honored
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2939'>TEIID-2939</a>] - Issues with applying row based security
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-2977'>TEIID-2977</a>] - class cast exception with odata json format function results
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3010'>TEIID-3010</a>] - odata webapp missing joda time dependency
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3011'>TEIID-3011</a>] - adding a better check as to when to skip rewrite (rewrite skipped)
</li>
<li>[<a href='https://issues.jboss.org/browse/TEIID-3021'>TEIID-3021</a>] - Serialization of long sqlexception/warning next chains can lead to oom
</li>
</ul>

<h4>from 8.4.2</h4>
Expand Down
Expand Up @@ -22,6 +22,7 @@
package org.teiid.query.metadata;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -330,6 +331,7 @@ private Column addColumn(String name, Class<?> type, Table table, MetadataFactor

// this class resolves the artifacts that are dependent upon objects from other schemas
// materialization sources, fk and data types (coming soon..)
// ensures that even if cached metadata is used that we resolve to a single instance
static class CrossSchemaResolver implements MetadataRule {

private boolean keyMatches(List<String> names, KeyRecord record) {
Expand Down Expand Up @@ -359,8 +361,8 @@ public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report

for (Table t:schema.getTables().values()) {
if (t.isVirtual()) {
if (t.isMaterialized() && t.getMaterializedTable() != null && t.getMaterializedTable().getParent() == null) {
String matTableName = t.getMaterializedTable().getName();
if (t.isMaterialized() && t.getMaterializedTable() != null) {
String matTableName = t.getMaterializedTable().getFullName();
int index = matTableName.indexOf(Table.NAME_DELIM_CHAR);
if (index == -1) {
metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31088, matTableName, t.getFullName()));
Expand Down Expand Up @@ -390,23 +392,22 @@ public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report
}

for (ForeignKey fk:fks) {
if (fk.getPrimaryKey() != null) {
//ensure derived fields are set
fk.setPrimaryKey(fk.getPrimaryKey());
continue;
}

String referenceTableName = fk.getReferenceTableName();
if (referenceTableName == null){
metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31091, t.getFullName()));
continue;
}

Table referenceTable = null;
if (fk.getReferenceKey() == null) {
if (referenceTableName == null){
metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31091, t.getFullName()));
continue;
}
//TODO there is an ambiguity here because we don't properly track the name parts
//so we have to first check for a table name that may contain .
referenceTable = schema.getTable(referenceTableName);
} else {
referenceTableName = fk.getReferenceKey().getParent().getFullName();
}

String referenceSchemaName = schema.getName();
//TODO there is an ambiguity here because we don't properly track the name parts
//so we have to first check for a table name that may contain .
Table referenceTable = schema.getTable(referenceTableName);
int index = referenceTableName.indexOf(Table.NAME_DELIM_CHAR);
if (referenceTable == null) {
if (index != -1) {
Expand All @@ -426,14 +427,21 @@ public void execute(VDBMetaData vdb, MetadataStore store, ValidatorReport report

KeyRecord uniqueKey = null;
List<String> referenceColumns = fk.getReferenceColumns();
if (fk.getReferenceKey() != null) {
//index metadata logic sets the key prior to having the column names
List<Column> cols = fk.getReferenceKey().getColumns();
referenceColumns = new ArrayList<String>();
for (Column col : cols) {
referenceColumns.add(col.getName());
}
}
if (referenceColumns == null || referenceColumns.isEmpty()) {
if (referenceTable.getPrimaryKey() == null) {
metadataValidator.log(report, model, QueryPlugin.Util.gs(QueryPlugin.Event.TEIID31094, t.getFullName(), referenceTableName.substring(index+1), referenceSchemaName));
}
else {
uniqueKey = referenceTable.getPrimaryKey();
}

} else {
for (KeyRecord record : referenceTable.getUniqueKeys()) {
if (keyMatches(referenceColumns, record)) {
Expand Down
Expand Up @@ -211,7 +211,7 @@ private synchronized void loadAll(Collection<Datatype> systemDatatypes, Map<Stri
}

@Override
public void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory)
public synchronized void loadMetadata(MetadataFactory factory, ExecutionFactory executionFactory, Object connectionFactory)
throws TranslatorException {
try {
loadAll(factory.getBuiltinDataTypes().values(), factory.getVDBResources());
Expand Down

0 comments on commit bc1732d

Please sign in to comment.