Hello!

Seems to work for me:

~/Downloads/apache-ignite-slim-2.9.0-bin% mkdir -p org/mycustomsqlfunction
~/Downloads/apache-ignite-slim-2.9.0-bin% cd org/mycustomsqlfunction
~/Downloads/apache-ignite-slim-2.9.0-bin/org/mycustomsqlfunction% cat >
MyCustomSQLFunction.java
package org.mycustomsqlfunction;

import org.apache.ignite.cache.query.annotations.QuerySqlFunction;

public class MyCustomSQLFunction {
       @QuerySqlFunction
   public static String Custom_Json_Value(String payload,String fieldName)
{
               System.out.println(payload);
               System.out.println(fieldName);
       return "Test";
   }
}%
~/Downloads/apache-ignite-slim-2.9.0-bin/org/mycustomsqlfunction% cd ../..
~/Downloads/apache-ignite-slim-2.9.0-bin% javac -cp
libs/ignite-core-2.9.0.jar:libs/ignite-indexing/ignite-indexing-2.9.0.jar:libs/ignite-indexing/h2-1.4.197.jar
org/mycustomsqlfunction/MyCustomSQLFunction.java
~/Downloads/apache-ignite-slim-2.9.0-bin% jar vcf
libs/mycustomsqlfunction.jar
org/mycustomsqlfunction/MyCustomSQLFunction.class
org/mycustomsqlfunction/MyCustomSQLFunction.class
~/Downloads/apache-ignite-slim-2.9.0-bin% vim config/default-config.xml
...
~/Downloads/apache-ignite-slim-2.9.0-bin% javac -cp
libs/ignite-core-2.9.0.jar:libs/ignite-indexing/ignite-indexing-2.9.0.jar:libs/ignite-indexing/h2-1.4.197.jar
org/mycustomsqlfunction/MyCustomSQLFunction.java
(130)~/Downloads/apache-ignite-slim-2.9.0-bin% bin/ignite.sh
....

~/Downloads/apache-ignite-slim-2.9.0-bin% bin/sqlline.sh
0: jdbc:ignite:thin://localhost/MyTemplateFun> !connect
jdbc:ignite:thin://localhost/"MyTemplateFunction"
Enter username for jdbc:ignite:thin://localhost/"MyTemplateFunction":
Enter password for jdbc:ignite:thin://localhost/"MyTemplateFunction":
1: jdbc:ignite:thin://localhost/"MyTemplateFu> select
custom_json_value('','') foo;
+--------------------------------+
|              FOO               |
+--------------------------------+
| Test                           |
+--------------------------------+
1 row selected (0,108 seconds)

Regards,
-- 
Ilya Kasnacheev


пн, 21 дек. 2020 г. в 17:39, siva <[email protected]>:

> Hi,
>
>
> i have tried like below in both case i am getting error
>
> 1.Without cache name
>
> 0: jdbc:ignite:thin://127.0.0.1/> select Custom_Json_Value("","");
> Error: Failed to parse query. Function "CUSTOM_JSON_VALUE" not found; SQL
> statement:
> select Custom_Json_Value("","") [90022-197] (state=42000,code=1001)
> java.sql.SQLException: Failed to parse query. Function "CUSTOM_JSON_VALUE"
> not found; SQL statement:
> select Custom_Json_Value("","") [90022-197]
>         at
>
> org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:750)
>         at
>
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:212)
>         at
>
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:475)
>         at sqlline.Commands.execute(Commands.java:823)
>         at sqlline.Commands.sql(Commands.java:733)
>         at sqlline.SqlLine.dispatch(SqlLine.java:795)
>         at sqlline.SqlLine.begin(SqlLine.java:668)
>         at sqlline.SqlLine.start(SqlLine.java:373)
>         at sqlline.SqlLine.main(SqlLine.java:265)
>
> 2.i logged in with customfunction cache name 'MyTemplateFunction'
>
> select Custom_Json_Value("","");
>
> 0: jdbc:ignite:thin://127.0.0.1/MyTemplateFun> select
> Custom_Json_Value("","");
> Error: Failed to set schema for DB connection for thread
> [schema=MYTEMPLATEFUNCTION] (state=50000,code=1)
> java.sql.SQLException: Failed to set schema for DB connection for thread
> [schema=MYTEMPLATEFUNCTION]
>         at
>
> org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:750)
>         at
>
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:212)
>         at
>
> org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:475)
>         at sqlline.Commands.execute(Commands.java:823)
>         at sqlline.Commands.sql(Commands.java:733)
>         at sqlline.SqlLine.dispatch(SqlLine.java:795)
>         at sqlline.SqlLine.begin(SqlLine.java:668)
>         at sqlline.SqlLine.start(SqlLine.java:373)
>         at sqlline.SqlLine.main(SqlLine.java:265)
> 0: jdbc:ignite:thin://127.0.0.1/MyTemplateFun>
>
>
> Thanks.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>

Reply via email to