You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ignite.apache.org by siva <si...@bizruntime.com> on 2020/12/23 15:50:52 UTC

Ignite Custom SQL functions not working with Generic function return type

Hi,
I am using .Net Client and Server app with Ignite v2.7.6.

i have created custom sql function and when doing query with custom function
using where clause getting an errors.
here is the table,record,query and function are given below.

*table*

CREATE TABLE Student (
  ID LONG PRIMARY KEY, PAYLOAD VARCHAR, SCORE INTEGER)
  WITH "template=MyTemplate";

*insert record*
  INSERT INTO Student (ID, PAYLOAD,SCORE) VALUES (2,
'{"array":[1,2,3],"boolean":false,"color":"gold1","null":null,"number":4123,"object":{"a":"b","c":"d"},"string":"Hello
World","test":{"test2":{"test3":"hello"}},"test2":{"test2":{"test3":"hello"}},"teststring":"{\"test1\":\"abc\"}"}',
80);

*Error while doing query*

SELECT *, Custom_Json_Value(PAYLOAD ,'$.number') foo FROM Student
WHERE Custom_Json_Value(PAYLOAD ,'$.number') = 4123;

*custom function*

public class MyCustomSQLFunction {		
	
	@QuerySqlFunction
    public static <T> T Custom_Json_Value(String expression ,String
path,String... mode) throws Exception{
    	
		return (T)JsonPath.read(expression, path);   	
    }
}



i am getting different different error like

Error1:SQL Error [1] [50000]: javax.cache.CacheException: Failed to execute
map query on remote node [nodeId=aec3cafd-acbb-4c0e-9b3b-8e219f2a303b,
errMsg=Failed to execute SQL query. Deserialization failed, cause: "class
org.apache.ignite.IgniteCheckedException: Invalid flag value: 65"; SQL
statement:

Error2:Failed to execute SQL query. Hexadecimal string contains non-hex
character:


Thanks.



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Re: Ignite Custom SQL functions not working with Generic function return type

Posted by Ilya Kasnacheev <il...@gmail.com>.
Hello!

65 is RAWTOHEX.

You can't return Object from the function. You have to return some
supported SQL type.

Regards,
-- 
Ilya Kasnacheev


ср, 23 дек. 2020 г. в 18:50, siva <si...@bizruntime.com>:

> Hi,
> I am using .Net Client and Server app with Ignite v2.7.6.
>
> i have created custom sql function and when doing query with custom
> function
> using where clause getting an errors.
> here is the table,record,query and function are given below.
>
> *table*
>
> CREATE TABLE Student (
>   ID LONG PRIMARY KEY, PAYLOAD VARCHAR, SCORE INTEGER)
>   WITH "template=MyTemplate";
>
> *insert record*
>   INSERT INTO Student (ID, PAYLOAD,SCORE) VALUES (2,
>
> '{"array":[1,2,3],"boolean":false,"color":"gold1","null":null,"number":4123,"object":{"a":"b","c":"d"},"string":"Hello
>
> World","test":{"test2":{"test3":"hello"}},"test2":{"test2":{"test3":"hello"}},"teststring":"{\"test1\":\"abc\"}"}',
> 80);
>
> *Error while doing query*
>
> SELECT *, Custom_Json_Value(PAYLOAD ,'$.number') foo FROM Student
> WHERE Custom_Json_Value(PAYLOAD ,'$.number') = 4123;
>
> *custom function*
>
> public class MyCustomSQLFunction {
>
>         @QuerySqlFunction
>     public static <T> T Custom_Json_Value(String expression ,String
> path,String... mode) throws Exception{
>
>                 return (T)JsonPath.read(expression, path);
>     }
> }
>
>
>
> i am getting different different error like
>
> Error1:SQL Error [1] [50000]: javax.cache.CacheException: Failed to execute
> map query on remote node [nodeId=aec3cafd-acbb-4c0e-9b3b-8e219f2a303b,
> errMsg=Failed to execute SQL query. Deserialization failed, cause: "class
> org.apache.ignite.IgniteCheckedException: Invalid flag value: 65"; SQL
> statement:
>
> Error2:Failed to execute SQL query. Hexadecimal string contains non-hex
> character:
>
>
> Thanks.
>
>
>
> --
> Sent from: http://apache-ignite-users.70518.x6.nabble.com/
>