Ignite Custom SQL functions not working with Generic function return type

classic Classic list List threaded Threaded
2 messages Options
siva siva
Reply | Threaded
Open this post in threaded view
|

Ignite Custom SQL functions not working with Generic function return type

This post was updated on .
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/
ilya.kasnacheev ilya.kasnacheev
Reply | Threaded
Open this post in threaded view
|

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

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 <[hidden email]>:
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/