-
1. Re: Mysql TEIID30068 The function is an unknown form. Check that the function name and number of arguments is correct.
shawkins Dec 17, 2013 8:43 AM (in response to jchidiac)Currently there's no automatic import of function information, so you'll need to make Teiid aware of the function. If using a dyanmic vdb/ddl this will be a SQL MED statement in your metadata for dbTest:
CREATE FOREIGN FUNCTION printResult (\"value\" integer) RETURNS integer;
Or if you are using Designer, you can right click on your dbTest source model and add a function.
See also Source Supported Functions - Teiid 8.7 (draft) - Project Documentation Editor
-
2. Re: Mysql TEIID30068 The function is an unknown form. Check that the function name and number of arguments is correct.
jchidiac Dec 18, 2013 7:11 AM (in response to shawkins)I test with the following code :
EmbeddedServer es ;
...............................
//add a vdb
//physical model
ModelMetaData mmd = new ModelMetaData();
mmd.setName("my-schema");
mmd.addSourceMapping("my", "mysql5", "mysql-ds");
//virtual model
ModelMetaData mmd1 = new ModelMetaData();
mmd1.setName("virt");
mmd1.setModelType(Type.VIRTUAL);
mmd1.setSchemaSourceType("ddl");
mmd1.setSchemaText("CREATE FOREIGN FUNCTION printResult(\"value\" integer ) RETURNS integer OPTIONS (\"teiid_rel:native-query\" 'printResult( $1 )'");
es.deployVDB("test", mmd, mmd1);
when i execute this query : select printResult(150) ;
i still have the same error.
-
3. Re: Mysql TEIID30068 The function is an unknown form. Check that the function name and number of arguments is correct.
shawkins Dec 18, 2013 7:57 AM (in response to jchidiac)That's nearly got it - although I don't think we should have allowed you to create a foreign function on a virtual model. Having a function on the virtual model means that translators must advertise support so that we know the function can be pushed down - see also Source Supported Functions - Teiid 8.7 (draft) - Project Documentation Editor extending the translator.
It would be simpler just to put the function on the physical model:
ModelMetaData mmd = new ModelMetaData();
mmd.setName("my-schema");
mmd.addSourceMapping("my", "mysql5", "mysql-ds");
mmd.setSchemaSourceType("DDL,NATIVE");
mmd.setSchemaText("CREATE FOREIGN FUNCTION printResult(\"value\" integer ) RETURNS integer OPTIONS (\"teiid_rel:native-query\" 'printResult( $1 )')");
This will use the translator metadata and defines the function as specific to the mysql source. You also don't really need the native-query extension as the function form matches the default.
The SELECT of the function without a from will work in Teiid 8.5+, in older versions we expected there to be a from clause to direct the query to the appropriate source.
Steve