Author: shawkins
Date: 2011-02-07 13:50:57 -0500 (Mon, 07 Feb 2011)
New Revision: 2898
Modified:
trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
trunk/build/kits/jboss-container/teiid-releasenotes.html
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
trunk/engine/src/main/resources/org/teiid/query/i18n.properties
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
trunk/hibernate-dialect/src/main/java/org/teiid/dialect/TeiidDialect.java
Log:
TEIID-1464 adding support for a uuid function
Modified: trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java
===================================================================
--- trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2011-02-03
22:15:05 UTC (rev 2897)
+++ trunk/api/src/main/java/org/teiid/translator/SourceSystemFunctions.java 2011-02-07
18:50:57 UTC (rev 2898)
@@ -145,5 +145,7 @@
public static final String XMLPI = "xmlpi"; //$NON-NLS-1$
public static final String JSONTOXML = "jsontoxml"; //$NON-NLS-1$
+
+ public static final String UUID = "uuid"; //$NON-NLS-1$
}
Modified: trunk/build/kits/jboss-container/teiid-releasenotes.html
===================================================================
--- trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-02-03 22:15:05 UTC (rev
2897)
+++ trunk/build/kits/jboss-container/teiid-releasenotes.html 2011-02-07 18:50:57 UTC (rev
2898)
@@ -29,6 +29,7 @@
<LI><B>Virtual procedure out params</B> - virtual procedures can now
have RETURN/OUT/INOUT parameters to return values.
<LI><B>OLAP</B> - OLAP translator is now part of Teiid kit using
OLAP4J
<LI><B>Multi-source procedures</B> - multi-source handling was
expanded to cover stored procedure execution. See the Reference for more.
+ <LI><B>UUID function</B> - was added to generate type 4 UUIDs and the
Hibernate dialect was updated to support the GUIDGenerator.
</UL>
<h2><a name="Compatibility">Compatibility
Issues</a></h2>
Modified:
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml
===================================================================
---
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-02-03
22:15:05 UTC (rev 2897)
+++
trunk/documentation/reference/src/main/docbook/en-US/content/scalar_functions.xml 2011-02-07
18:50:57 UTC (rev 2898)
@@ -2074,6 +2074,17 @@
<para>The two argument form is provided for backwards compatibility.
roleType is a string and must be 'data'</para>
</section>
</section>
+ <section>
+ <title>Miscellaneous Functions</title>
+ <para>Other functions.</para>
+ <section>
+ <title>uuid</title>
+ <para>Retuns a universally unique identifier.</para>
+ <para><synopsis>uuid()</synopsis></para>
+ <para>the return type is string.</para>
+ <para>Generates a type 4 (pseudo randomly generated) UUID using a
cryptographically strong random number generator. The format is
XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX where each X is a hex digit.</para>
+ </section>
+ </section>
<section id="nondeterministic_functions">
<title>Nondeterministic Function Handling</title>
<para>Teiid categorizes functions by varying degrees of determinism.
Modified: trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java
===================================================================
--- trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-02-03
22:15:05 UTC (rev 2897)
+++ trunk/engine/src/main/java/org/teiid/query/function/FunctionMethods.java 2011-02-07
18:50:57 UTC (rev 2898)
@@ -41,6 +41,7 @@
import java.util.Date;
import java.util.Properties;
import java.util.TimeZone;
+import java.util.UUID;
import org.teiid.api.exception.query.ExpressionEvaluationException;
import org.teiid.api.exception.query.FunctionExecutionException;
@@ -1375,4 +1376,8 @@
return i;
}
+ public static String uuid() {
+ return UUID.randomUUID().toString();
+ }
+
}
Modified: trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java
===================================================================
---
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2011-02-03
22:15:05 UTC (rev 2897)
+++
trunk/engine/src/main/java/org/teiid/query/function/source/SystemSource.java 2011-02-07
18:50:57 UTC (rev 2898)
@@ -193,6 +193,7 @@
}
addUnescape();
+ addUuidFunction();
}
private void addUnescape() {
@@ -284,6 +285,14 @@
rand.setDeterminism(Determinism.NONDETERMINISTIC);
functions.add(rand);
}
+
+ private void addUuidFunction() {
+ FunctionMethod rand = new FunctionMethod(SourceSystemFunctions.UUID,
QueryPlugin.Util.getString("SystemSource.uuid_desc"), MISCELLANEOUS,
FUNCTION_CLASS, "uuid", //$NON-NLS-1$ //$NON-NLS-2$
+ new FunctionParameter[] {},
+ new FunctionParameter("result",
DataTypeManager.DefaultDataTypes.STRING,
QueryPlugin.Util.getString("SystemSource.uuid_result_desc")) );
//$NON-NLS-1$ //$NON-NLS-2$
+ rand.setDeterminism(Determinism.NONDETERMINISTIC);
+ functions.add(rand);
+ }
private void addDoubleFunction(String name, String description) {
functions.add(
Modified: trunk/engine/src/main/resources/org/teiid/query/i18n.properties
===================================================================
--- trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-02-03 22:15:05
UTC (rev 2897)
+++ trunk/engine/src/main/resources/org/teiid/query/i18n.properties 2011-02-07 18:50:57
UTC (rev 2898)
@@ -386,6 +386,8 @@
SystemSource.Rand_desc=Random Number
SystemSource.Rand_arg=Number
SystemSource.Rand_result_desc=Generated Random Number
+SystemSource.uuid_desc=UUID
+SystemSource.uuid_result_desc=type 4 UUID
SystemSource.Double_arg2=Number
SystemSource.Atan_arg1=Number parameter1
SystemSource.Atan_arg2=Number parameter2
Modified: trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java
===================================================================
---
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2011-02-03
22:15:05 UTC (rev 2897)
+++
trunk/engine/src/test/java/org/teiid/query/function/TestFunctionLibrary.java 2011-02-07
18:50:57 UTC (rev 2898)
@@ -1405,4 +1405,8 @@
assertEquals("\r\t", helpInvokeMethod("unescape", new Class[]
{DefaultDataClasses.STRING}, new Object[] { "\r\\\t" }, null)); //$NON-NLS-1$
}
+ @Test() public void testUuid() throws Exception {
+ assertNotNull(helpInvokeMethod("uuid", new Class[] {}, new Object[] {},
null)); //$NON-NLS-1$
+ }
+
}
Modified: trunk/hibernate-dialect/src/main/java/org/teiid/dialect/TeiidDialect.java
===================================================================
--- trunk/hibernate-dialect/src/main/java/org/teiid/dialect/TeiidDialect.java 2011-02-03
22:15:05 UTC (rev 2897)
+++ trunk/hibernate-dialect/src/main/java/org/teiid/dialect/TeiidDialect.java 2011-02-07
18:50:57 UTC (rev 2898)
@@ -138,6 +138,14 @@
registerFunction("modifytimezone", new
StandardSQLFunction("modifytimezone", Hibernate.TIMESTAMP)); //$NON-NLS-1$
//$NON-NLS-2$
registerFunction("convert", new
StandardSQLFunction("convert")); //$NON-NLS-1$ //$NON-NLS-2$
+
+ registerFunction("to_bytes", new
StandardSQLFunction("to_bytes", Hibernate.BLOB)); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunction("to_chars", new
StandardSQLFunction("to_chars", Hibernate.CLOB)); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunction("from_unittime", new
StandardSQLFunction("from_unittime", Hibernate.TIMESTAMP)); //$NON-NLS-1$
//$NON-NLS-2$
+ registerFunction("session_id", new
StandardSQLFunction("session_id", Hibernate.STRING)); //$NON-NLS-1$
//$NON-NLS-2$
+
+ registerFunction("uuid", new StandardSQLFunction("uuid",
Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
+ registerFunction("unescape", new
StandardSQLFunction("unescape", Hibernate.STRING)); //$NON-NLS-1$ //$NON-NLS-2$
}
public boolean dropConstraints() {
@@ -243,6 +251,11 @@
public String getForUpdateString(String aliases) {
return ""; //$NON-NLS-1$
}
+
+ @Override
+ public String getSelectGUIDString() {
+ return "select uuid()"; //$NON-NLS-1$
+ }
}