Skip to content

Commit

Permalink
TEIID-2571 allowing must pushdown functions to evaluate even if not
Browse files Browse the repository at this point in the history
pushed to an access node
  • Loading branch information
shawkins committed Jul 5, 2013
1 parent f4e4b99 commit 6db1c92
Show file tree
Hide file tree
Showing 31 changed files with 433 additions and 55 deletions.
Expand Up @@ -483,4 +483,8 @@ public int getDependentJoinMinimum() {
public boolean supportsFullDependentJoins() {
return delegate.supportsFullDependentJoins();
}
@Override
public boolean supportsSelectWithoutFrom() {
return delegate.supportsSelectWithoutFrom();
}
}
4 changes: 4 additions & 0 deletions api/src/main/java/org/teiid/translator/ExecutionFactory.java
Expand Up @@ -1137,4 +1137,8 @@ public void setNativeQueryProcedureName(String name) {
public boolean supportsOnlyCorrelatedSubqueries() {
return false;
}

public boolean supportsSelectWithoutFrom() {
return false;
}
}
1 change: 1 addition & 0 deletions build/kits/jboss-as7/docs/teiid/teiid-releasenotes.html
Expand Up @@ -29,6 +29,7 @@ <H2><A NAME="Highlights"></A>Highlights</H2>
<li>TEIID-2528 <b>Encrypted Buffer Files</b> - the buffer manager now supports an option to encrypt Teiid temp data files using 128-bit AES.</li>
<li>TEIID-2249 TEIID-2559 TEIID-2555 <b>Dependent Join Enhancements</b> - greater control over full depdendent join pushdown has been added including make dep hint options max and min to control the extent of depdendent join pushdown. The join hint is also available to pushdown the entire dependent join when supported by the source.</li>
<li>TEIID-2527 <b>Configurable Runtime Multisource</b> - the server will now allow multisource models to have sources added and removed at runtime. See the admin addSource and removeSource methods.
<li>TEIID-2571 <b>Broader Must Pushdown</b> - must pushdown functions tied to a particular model that supports selects without from can now be called without at any time.
</ul>

<h2><a name="Compatibility">Compatibility Issues</a></h2>
Expand Down
Expand Up @@ -22,17 +22,11 @@

package org.teiid.translator.jdbc.db2;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.teiid.language.DerivedColumn;
import org.teiid.language.Expression;
import org.teiid.language.Function;
import org.teiid.language.Join;
import org.teiid.language.LanguageFactory;
import org.teiid.language.LanguageObject;
import org.teiid.language.Limit;
import org.teiid.language.Literal;
import org.teiid.language.*;
import org.teiid.language.Comparison.Operator;
import org.teiid.language.Join.JoinType;
import org.teiid.translator.ExecutionContext;
Expand Down Expand Up @@ -178,4 +172,31 @@ public boolean supportsSubqueryInOn() {
return false;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}

@Override
public List<?> translateCommand(Command command, ExecutionContext context) {
if (command instanceof Select) {
Select select = (Select)command;
if (select.getFrom() == null || select.getFrom().isEmpty()) {
List<Object> result = new ArrayList<Object>();
result.add("VALUES("); //$NON-NLS-1$
for (int i = 0; i < select.getDerivedColumns().size(); i++) {
DerivedColumn dc = select.getDerivedColumns().get(i);
if (i != 0) {
result.add(", "); //$NON-NLS-1$
}
result.add(dc.getExpression());

}
result.add(")"); //$NON-NLS-1$
return result;
}
}
return super.translateCommand(command, context);
}

}
Expand Up @@ -236,4 +236,9 @@ public List<?> translate(LanguageObject obj, ExecutionContext context) {
}
return super.translate(obj, context);
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}
}
Expand Up @@ -186,4 +186,9 @@ public boolean supportsIntersect() {
public boolean supportsAggregatesEnhancedNumeric() {
return true;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}
}
Expand Up @@ -134,4 +134,9 @@ public boolean supportsRowOffset() {
public NullOrder getDefaultNullOrder() {
return NullOrder.UNKNOWN;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}
}
Expand Up @@ -374,5 +374,10 @@ public boolean supportsRowLimit() {
@Override
public boolean supportsRowOffset() {
return true;
}
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}
}
Expand Up @@ -508,6 +508,14 @@ public boolean supportsOrderByNullOrdering() {
public SQLConversionVisitor getSQLConversionVisitor() {
return new SQLConversionVisitor(this) {

@Override
public void visit(Select select) {
if (select.getFrom() == null || select.getFrom().isEmpty()) {
select.setFrom(Arrays.asList((TableReference)new NamedTable(DUAL, null, null)));
}
super.visit(select);
}

@Override
public void visit(Comparison obj) {
if (isFixedChar(obj.getLeftExpression())) {
Expand Down Expand Up @@ -826,5 +834,10 @@ public boolean supportsCommonTableExpressions() {
protected boolean usesDatabaseVersion() {
return true;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}

}
Expand Up @@ -569,5 +569,10 @@ protected boolean usesDatabaseVersion() {
public boolean supportsStringAgg() {
return getVersion().compareTo(NINE_0) >= 0;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}

}
Expand Up @@ -356,5 +356,10 @@ protected boolean usesDatabaseVersion() {
public boolean useStreamsForLobs() {
return true;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}

}
Expand Up @@ -416,5 +416,10 @@ public void initCapabilities(Connection connection)
protected boolean usesDatabaseVersion() {
return true;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}

}
Expand Up @@ -273,5 +273,10 @@ public boolean supportsOrderByNullOrdering() {
protected boolean usesDatabaseVersion() {
return true;
}

@Override
public boolean supportsSelectWithoutFrom() {
return true;
}

}
Expand Up @@ -448,5 +448,12 @@ public void defer_testPreparedStatementCreationWithLeftConstant() {
"SELECT PARTS.PART_NAME FROM PARTS WHERE concat(ifnull(PARTS.PART_NAME, ''), 'x') = CASE WHEN PARTS.PART_WEIGHT IS NULL AND PARTS.PART_ID IS NULL THEN NULL ELSE concat(ifnull(PARTS.PART_WEIGHT, ''), ifnull(PARTS.PART_ID, '')) END", //$NON-NLS-1$
true);
}

@Test public void testSelectWithoutFrom() {
helpTestVisitor(getTestVDB(),
"select 1", //$NON-NLS-1$
"SELECT 1", //$NON-NLS-1$
true);
}

}
Expand Up @@ -69,6 +69,14 @@ public void testConcat2() throws Exception {
String input = "select concat2(stringnum, stringnum) from BQT1.Smalla"; //$NON-NLS-1$
String output = "SELECT CASE WHEN SmallA.StringNum IS NULL AND SmallA.StringNum IS NULL THEN NULL ELSE {fn concat(coalesce(SmallA.StringNum, ''), coalesce(SmallA.StringNum, ''))} END FROM SmallA"; //$NON-NLS-1$

TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}

@Test
public void testSelectWithNoFrom() throws Exception {
String input = "select 1, 2"; //$NON-NLS-1$
String output = "VALUES(1, 2)"; //$NON-NLS-1$

TranslationHelper.helpTestVisitor(TranslationHelper.BQT_VDB, input, output, TRANSLATOR);
}

Expand Down
Expand Up @@ -1048,5 +1048,14 @@ public void helpTestVisitor(String vdb, String input, String expectedOutput) thr
oef.start();
assertTrue(oef.supportsCommonTableExpressions());
}

@Test public void testSelectWithoutFrom() throws Exception {
String input = "SELECT 1"; //$NON-NLS-1$
String output = "SELECT 1 FROM DUAL"; //$NON-NLS-1$

QueryMetadataInterface metadata = getOracleSpecificMetadata();

helpTestVisitor(metadata, input, EMPTY_CONTEXT, null, output);
}

}
Expand Up @@ -117,6 +117,7 @@ public static BasicSourceCapabilities convertCapabilities(ExecutionFactory srcCa
tgtCaps.setCapabilitySupport(Capability.ARRAY_TYPE, srcCaps.supportsArrayType());
tgtCaps.setCapabilitySupport(Capability.QUERY_SUBQUERIES_ONLY_CORRELATED, srcCaps.supportsOnlyCorrelatedSubqueries());
tgtCaps.setCapabilitySupport(Capability.QUERY_AGGREGATES_STRING, srcCaps.supportsStringAgg());
tgtCaps.setCapabilitySupport(Capability.SELECT_WITHOUT_FROM, srcCaps.supportsSelectWithoutFrom());

List<String> functions = srcCaps.getSupportedFunctions();
if(functions != null && functions.size() > 0) {
Expand Down
Expand Up @@ -111,4 +111,9 @@ public PreparedPlan getPreparedPlan(String query, String recursionGroup,
return pp;
}

@Override
public CapabilitiesFinder getCapabiltiesFinder() {
return finder;
}

}

0 comments on commit 6db1c92

Please sign in to comment.