[teiid-commits] teiid SVN: r3737 - in branches/7.6.x: documentation/reference/src/main/docbook/en-US/content and 2 other directories.
teiid-commits at lists.jboss.org
teiid-commits at lists.jboss.org
Wed Dec 14 11:57:04 EST 2011
Author: shawkins
Date: 2011-12-14 11:57:03 -0500 (Wed, 14 Dec 2011)
New Revision: 3737
Modified:
branches/7.6.x/build/kits/jboss-container/teiid-releasenotes.html
branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
branches/7.6.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
branches/7.6.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
Log:
TEIID-1869 fix for decodeinteger. and deprecating the decode functions
Modified: branches/7.6.x/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- branches/7.6.x/build/kits/jboss-container/teiid-releasenotes.html 2011-12-13 19:07:25 UTC (rev 3736)
+++ branches/7.6.x/build/kits/jboss-container/teiid-releasenotes.html 2011-12-14 16:57:03 UTC (rev 3737)
@@ -53,6 +53,7 @@
<li>TRANSLATE/HAS CRITERIA has been deprecated. INSTEAD OF trigger actions should be used instead.
<li>Support for named parameter syntax using param=value has been deprecated, since it is ambiguous with a comparison predicate boolean value expression. param<b>=></b>value should be used instead.
<li>Support for using the FROM clause post item hints MAKEDEP/MAKENOTDEP has been deprecated. Use the pre item comment hint syntax instead, e.g. /*+ MAKEDEP */ tbl
+ <li>decodeinteger/decodestring have been deprecated. A CASE expression should be used instead.
</ul>
<h4>from 7.5</h4>
Modified: branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
--- branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-12-13 19:07:25 UTC (rev 3736)
+++ branches/7.6.x/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-12-14 16:57:03 UTC (rev 3737)
@@ -1716,24 +1716,16 @@
<tbody>
<row>
<entry>
- <para>DECODESTRING(x, y)</para>
+ <para>DECODESTRING(x, y [, z])</para>
</entry>
<entry>
<para>Decode column x using string of value pairs y
- and return the decoded column as a string</para>
- </entry>
- <entry>
- <para>all string</para>
- </entry>
- </row>
- <row>
- <entry>
- <para>DECODESTRING(x, y, z)</para>
- </entry>
- <entry>
- <para>Decode column x using string of value pairs y
- with delimiter z and return the decoded column as a string
+ with optional delimiter z and return the decoded column as a string.
+ If a delimiter is not specified , is used.
+ y has the formate SearchDelimResultDelimSearchDelimResult[DelimDefault]
+ Returns Default if specified or x if there are no matches.
</para>
+ <warning><para>Deprecated. Use a CASE expression instead.</para></warning>
</entry>
<entry>
<para>all string</para>
@@ -1741,29 +1733,21 @@
</row>
<row>
<entry>
- <para>DECODEINTEGER(x, y)</para>
+ <para>DECODEINTEGER(x, y [, z])</para>
</entry>
<entry>
<para>Decode column x using string of value pairs y
- and return the decoded column as an integer</para>
+ with optional delimiter z and return the decoded column as an
+ integer. If a delimiter is not specified , is used.
+ y has the formate SearchDelimResultDelimSearchDelimResult[DelimDefault]
+ Returns Default if specified or x if there are no matches.
+ </para>
+ <warning><para>Deprecated. Use a CASE expression instead.</para></warning>
</entry>
<entry>
<para>all string parameters, return integer</para>
</entry>
</row>
- <row>
- <entry>
- <para>DECODEINTEGER(x,y,z)</para>
- </entry>
- <entry>
- <para>Decode column x using string of value pairs y
- with delimiter z and return the decoded column as an
- integer</para>
- </entry>
- <entry>
- <para>all string parameters, return integer</para>
- </entry>
- </row>
</tbody>
</tgroup>
</informaltable>
Modified: branches/7.6.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java
===================================================================
--- branches/7.6.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-12-13 19:07:25 UTC (rev 3736)
+++ branches/7.6.x/engine/src/main/java/org/teiid/query/rewriter/QueryRewriter.java 2011-12-14 16:57:03 UTC (rev 3737)
@@ -53,6 +53,7 @@
import org.teiid.core.TeiidRuntimeException;
import org.teiid.core.types.DataTypeManager;
import org.teiid.core.types.Transform;
+import org.teiid.core.types.DataTypeManager.DefaultDataClasses;
import org.teiid.core.util.Assertion;
import org.teiid.core.util.TimestampWithTimezone;
import org.teiid.language.SQLConstants;
@@ -2533,7 +2534,10 @@
newCaseExpr.setElseExpression(exprs[0]);
}
- newCaseExpr.setType(function.getType());
+ newCaseExpr.setType(DefaultDataClasses.STRING);
+ if (function.getName().equalsIgnoreCase(FunctionLibrary.DECODEINTEGER)) {
+ return ResolverUtil.getConversion(newCaseExpr, DataTypeManager.DefaultDataTypes.STRING, DataTypeManager.DefaultDataTypes.INTEGER, false, metadata.getFunctionLibrary());
+ }
return newCaseExpr;
}
Modified: branches/7.6.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java
===================================================================
--- branches/7.6.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-12-13 19:07:25 UTC (rev 3736)
+++ branches/7.6.x/engine/src/test/java/org/teiid/query/rewriter/TestQueryRewriter.java 2011-12-14 16:57:03 UTC (rev 3737)
@@ -1755,23 +1755,23 @@
}
@Test public void testDefect16879_3(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_4(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, c, d') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_5(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d') FROM pm1.g1", "SELECT CASE WHEN e1 IS NULL THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'null, b, c, d') FROM pm1.g1", "SELECT convert(CASE WHEN e1 IS NULL THEN 'b' WHEN e1 = 'c' THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_6(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE e1 END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE e1 END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testDefect16879_7(){
- helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e') FROM pm1.g1", "SELECT CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE 'e' END FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
+ helpTestRewriteCommand("SELECT decodeinteger(e1, 'a, b, null, d, e') FROM pm1.g1", "SELECT convert(CASE WHEN e1 = 'a' THEN 'b' WHEN e1 IS NULL THEN 'd' ELSE 'e' END, integer) FROM pm1.g1"); //$NON-NLS-1$ //$NON-NLS-2$
}
@Test public void testCaseExpressionThatResolvesToNull() {
More information about the teiid-commits
mailing list