DataTypes in UDF
rokhmanov Jul 22, 2012 11:28 PMHi,
I see some strange behavior with data types in UDF in latest Teiid. I am trying to define a non-pushdown UDF, using this example: https://docs.jboss.org/author/display/TEIID/Support+for+User-Defined+Functions+%28Non-Pushdown%29
I noticed that example will work on my Teiid 8.1.0.Alpha3-SNAPSHOT when instead of (as described) passing and returning Double to 'celsiusToFahrenheit' method I replace it with BigDecimal in my java class.
My problem is that I want to pass and retrieve String, so I define my UDF this way:
CREATE VIRTUAL FUNCTION RepTest(testmsg varchar) RETURNS varchar OPTIONS (JAVA_CLASS 'com.test.teiid.udf.TestTeiidFunction', JAVA_METHOD 'test');
And here is my sample java code:
package com.test.teiid.udf; public class TestTeiidFunction { public static String test(String testvar) { return testvar; } }
Here is what I see in logs:
22:13:22,039 ERROR [org.jboss.threads.executor] (teiid-async-threads - 2) Task execution failed for task org.teiid.jboss.VDBService$6@561a8b04: org.teiid.core.TeiidRuntimeException: TEIID30388 UDF "RepTest(entities testmsg) : entities result" could not loaded, since no method on class "com.test.teiid.udf.TestTeiidFunction" with name "test" has a matching type signature. at org.teiid.query.function.FunctionTree.createFunctionDescriptor(FunctionTree.java:323) [teiid-engine-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.query.function.FunctionTree.addFunction(FunctionTree.java:232) [teiid-engine-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.query.function.FunctionTree.(FunctionTree.java:106) [teiid-engine-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.deployers.CompositeVDB.buildTransformationMetaData(CompositeVDB.java:81) [teiid-runtime-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.deployers.CompositeVDB.metadataLoadFinished(CompositeVDB.java:326) [teiid-runtime-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.deployers.VDBRepository.finishDeployment(VDBRepository.java:301) [teiid-runtime-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.runtime.AbstractVDBDeployer.metadataLoaded(AbstractVDBDeployer.java:163) [teiid-runtime-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.jboss.VDBService.access$800(VDBService.java:69) [teiid-jboss-integration-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.jboss.VDBService$6.run(VDBService.java:374) [teiid-jboss-integration-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.jboss.threads.SimpleDirectExecutor.execute(SimpleDirectExecutor.java:33) at org.jboss.threads.QueueExecutor.runTask(QueueExecutor.java:801) at org.jboss.threads.QueueExecutor.access$100(QueueExecutor.java:45) at org.jboss.threads.QueueExecutor$Worker.run(QueueExecutor.java:821) at java.lang.Thread.run(Thread.java:722) [rt.jar:1.7.0_05] at org.jboss.threads.JBossThread.run(JBossThread.java:122) Caused by: java.lang.NoSuchMethodException: test Args: [class org.teiid.query.util.CommandContext, class java.lang.Object] at org.teiid.core.util.ReflectionHelper.findBestMethodWithSignature(ReflectionHelper.java:191) [teiid-common-core-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] at org.teiid.query.function.FunctionTree.createFunctionDescriptor(FunctionTree.java:317) [teiid-engine-8.1.0.Alpha3-SNAPSHOT.jar:8.1.0.Alpha3-SNAPSHOT] ... 14 more
I tried to use 'string' instead of 'varchar' in UDF definition in VDB - the same effect.