Also sql scan query is not working with the following rest call. http://127.0.0.1:8080/ignite?cmd=qryscanexe&pageSize=10&cacheName=person&className=IgniteTest$Person And the error response is { "successStatus": 1, "error": "Failed to find target class: IgniteTest$Person", "response": null, "sessionToken": null }
But sql fields query is working with the following rest call. http://127.0.0.1:8080/ignite?cmd=qryfldexe&pageSize=10&cacheName=person&qry=select+firstName%2C+lastName+from+Person So I’m guessing the Person class should be somehow uploaded to the lib folder under Ignitehome folder? From: "Ray Liu (rayliu)" <[email protected]> Reply-To: "[email protected]" <[email protected]> Date: Wednesday, 13 September 2017 at 14:56 To: "[email protected]" <[email protected]> Subject: Issue when executing sql query using REST API Hi all, I’m trying to execute a sql query using REST API with the following url. http://127.0.0.1:8080/ignite?cacheName=person&pageSize=1&qry=limit+2&cmd=qryexe&type=Person& But I got the following error response { "successStatus": 1, "error": "IgniteTest$Person", "response": null, "sessionToken": null } Here’s the code I used to ingest data to ignite. public class IgniteTest { public static void main(String[] args) throws Exception { try (Ignite ignite = Ignition.start("example-ignite.xml")) { CacheConfiguration<Integer, Person> personCacheCfg = new CacheConfiguration<>("person"); personCacheCfg.setIndexedTypes(Integer.class, Person.class); IgniteCache<Integer, Person> personCache = ignite.getOrCreateCache(personCacheCfg); Person p1 = new Person(1, "John", "Doe", 2000); Person p2 = new Person(1, "Jane", "Doe", 1000); Person p3 = new Person(2, "John", "Smith", 1000); Person p4 = new Person(2, "Jane", "Smith", 2000); personCache.put(p1.getId(), p1); personCache.put(p2.getId(), p2); personCache.put(p3.getId(), p3); personCache.put(p4.getId(), p4); } } /** * Person class. */ public static class Person implements Serializable { /** Person id. */ private static int PERSON_ID = 0; /** Person ID (indexed). */ @QuerySqlField(index = true) private Integer id; /** Organization id. */ @QuerySqlField(index = true) private Integer orgId; /** First name (not-indexed). */ @QuerySqlField private String firstName; /** Last name (not indexed). */ @QuerySqlField private String lastName; /** Salary (indexed). */ @QuerySqlField(index = true) private double salary; /** * @param firstName First name. * @param lastName Last name. * @param salary Salary. */ Person(Integer orgId, String firstName, String lastName, double salary) { id = PERSON_ID++; this.orgId = orgId; this.firstName = firstName; this.lastName = lastName; this.salary = salary; } /** * @return Organization ID. */ public Integer getOrganizationId() { return orgId; } /** * @return First name. */ public String getFirstName() { return firstName; } /** * @return Last name. */ public String getLastName() { return lastName; } /** * @return Salary. */ public double getSalary() { return salary; } /** * @return Id. */ public Integer getId() { return id; } } } And debug log generated by ignite [2017-09-13T14:42:33,059][DEBUG][qtp379430898-73][GridJettyRestProtocol] Handling request [target=/ignite, req=(GET /ignite?cacheName=person&pageSize=1&qry=limit+2&cmd=qryexe&type=Person)@1162648735 org.eclipse.jetty.server.Request@454c9c9f, srvReq=(GET /ignite?cacheName=person&pageSize=1&qry=limit+2&cmd=qryexe&type=Person)@1162648735 org.eclipse.jetty.server.Request@454c9c9f] [2017-09-13T14:42:33,059][DEBUG][qtp379430898-73][GridJettyRestProtocol] Initialized command request: GridRestRequest [destId=null, clientId=null, addr=/127.0.0.1:50853, cmd=EXECUTE_SQL_QUERY] [2017-09-13T14:42:33,060][DEBUG][rest-#42%null%][GridRestProcessor] Grid runnable started: rest-proc-worker [2017-09-13T14:42:33,060][DEBUG][rest-#42%null%][GridRestProcessor] Received request from client: GridRestRequest [destId=null, clientId=null, addr=/127.0.0.1:50853, cmd=EXECUTE_SQL_QUERY] [2017-09-13T14:42:33,060][DEBUG][rest-#42%null%][GridResourceProcessor] Injecting resources [target=org.apache.ignite.internal.processors.rest.handlers.query.QueryCommandHandler$ExecuteQueryCallable@12f55fbb] [2017-09-13T14:42:33,060][DEBUG][rest-#42%null%][GridRestProcessor] Grid runnable finished normally: rest-proc-worker [2017-09-13T14:42:33,060][DEBUG][pub-#310%null%][GridClosureProcessor] Grid runnable started: closure-proc-worker [2017-09-13T14:42:33,061][DEBUG][pub-#310%null%][GridCacheProcessor] Getting public cache for name: person [2017-09-13T14:42:33,063][DEBUG][pub-#310%null%][IgniteH2Indexing] Set schema: person [2017-09-13T14:42:33,064][DEBUG][grid-timeout-worker-#15%null%][GridTimeoutProcessor] Timeout has occurred: CancelableTask [id=a5584d97e51-9027a323-d2b1-49c5-962d-e0dd53b5eba0, endTime=1505284953057, period=3000, cancel=false, task=org.apache.ignite.internal.processors.query.GridQueryProcessor$2@df38437] [2017-09-13T14:42:33,070][DEBUG][pub-#310%null%][IgniteH2Indexing] Parsed query: `SELECT "person"."PERSON"._KEY, "person"."PERSON"._VAL FROM "person"."PERSON" limit 2` into two step query: GridCacheTwoStepQuery [mapQrys=[GridCacheSqlQuery [qry=SELECT "person".__Z0._KEY __C0_0, "person".__Z0._VAL __C0_1 FROM "person".PERSON __Z0 LIMIT 2, paramIdxs=[], cols={__C0_0=GridSqlType [type=4, scale=0, precision=10, displaySize=11, sql=INTEGER], __C0_1=GridSqlType [type=19, scale=0, precision=2147483647, displaySize=2147483647, sql=OTHER]}, alias=null, sort=[], partitioned=true, node=null, derivedPartitions=null]], rdc=GridCacheSqlQuery [qry=SELECT __C0_0 _KEY, __C0_1 _VAL FROM PUBLIC.__T0 LIMIT 2, paramIdxs=[], cols=null, alias=null, sort=null, partitioned=false, node=null, derivedPartitions=null], pageSize=1000, explain=false, originalSql=SELECT "person".PERSON._KEY, "person".PERSON._VAL FROM "person".PERSON LIMIT 2, distributedJoins=false, skipMergeTbl=false, local=false] [2017-09-13T14:42:33,071][DEBUG][pub-#310%null%][GridReduceQueryExecutor] Sending: [msg=GridH2QueryRequest [reqId=12, caches=[-991716523], topVer=AffinityTopologyVersion [topVer=9, minorTopVer=0], parts=null, qryParts=null, pageSize=1024, qrys=[GridCacheSqlQuery [qry=SELECT "person".__Z0._KEY __C0_0, "person".__Z0._VAL __C0_1 FROM "person".PERSON __Z0 LIMIT 2, paramIdxs=[], cols={__C0_0=GridSqlType [type=4, scale=0, precision=10, displaySize=11, sql=INTEGER], __C0_1=GridSqlType [type=19, scale=0, precision=2147483647, displaySize=2147483647, sql=OTHER]}, alias=null, sort=[], partitioned=true, node=null, derivedPartitions=null]], flags=2, tbls=null, timeout=0, params=[], schemaName=person], nodes=[TcpDiscoveryNode [id=ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685, addrs=[0:0:0:0:0:0:0:1, 10.140.48.140, 127.0.0.1, 2001:420:589a:1250:516a:c5d4:fe7d:863c], sockAddrs=[/10.140.48.140:47500, /0:0:0:0:0:0:0:1:47500, /127.0.0.1:47500, /2001:420:589a:1250:516a:c5d4:fe7d:863c:47500], discPort=47500, order=1, intOrder=1, lastExchangeTime=1505284895513, loc=true, ver=2.1.0#20170721-sha1:a6ca5c8a, isClient=false]], specialize=null] [2017-09-13T14:42:33,078][DEBUG][pub-#310%null%][GridCacheProcessor] Getting internal cache adapter: person [2017-09-13T14:42:33,084][DEBUG][pub-#310%null%][GridReduceQueryExecutor] Processed response: ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685->ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685 GridQueryNextPageResponse [qryReqId=12, segmentId=0, qry=0, page=0, allRows=2, cols=2, retry=null, valsSize=0, rowsSize=2] [2017-09-13T14:42:33,085][DEBUG][pub-#310%null%][GridMapQueryExecutor] Processed request: ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685->ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685 GridH2QueryRequest [reqId=12, caches=[-991716523], topVer=AffinityTopologyVersion [topVer=9, minorTopVer=0], parts=null, qryParts=null, pageSize=1024, qrys=[GridCacheSqlQuery [qry=SELECT "person".__Z0._KEY __C0_0, "person".__Z0._VAL __C0_1 FROM "person".PERSON __Z0 LIMIT 2, paramIdxs=[], cols={__C0_0=GridSqlType [type=4, scale=0, precision=10, displaySize=11, sql=INTEGER], __C0_1=GridSqlType [type=19, scale=0, precision=2147483647, displaySize=2147483647, sql=OTHER]}, alias=null, sort=[], partitioned=true, node=null, derivedPartitions=null]], flags=2, tbls=null, timeout=0, params=[], schemaName=person] [2017-09-13T14:42:33,086][DEBUG][pub-#310%null%][GridReduceQueryExecutor] Sending: [msg=GridQueryCancelRequest [qryReqId=12], nodes=[TcpDiscoveryNode [id=ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685, addrs=[0:0:0:0:0:0:0:1, 10.140.48.140, 127.0.0.1, 2001:420:589a:1250:516a:c5d4:fe7d:863c], sockAddrs=[/10.140.48.140:47500, /0:0:0:0:0:0:0:1:47500, /127.0.0.1:47500, /2001:420:589a:1250:516a:c5d4:fe7d:863c:47500], discPort=47500, order=1, intOrder=1, lastExchangeTime=1505284895513, loc=true, ver=2.1.0#20170721-sha1:a6ca5c8a, isClient=false]], specialize=null] [2017-09-13T14:42:33,087][DEBUG][pub-#310%null%][GridMapQueryExecutor] Processed request: ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685->ad9ca7a8-4ed2-47ac-b5fe-074f3b4a7685 GridQueryCancelRequest [qryReqId=12] [2017-09-13T14:42:33,088][DEBUG][pub-#310%null%][GridClosureProcessor] Grid runnable finished normally: closure-proc-worker [2017-09-13T14:42:33,088][DEBUG][qtp379430898-73][GridJettyRestProtocol] Parsed command response into JSON object: {"successStatus":1,"error":"IgniteTest$Person","response":null,"sessionToken":null} [2017-09-13T14:42:33,089][DEBUG][qtp379430898-73][GridJettyRestProtocol] Processed HTTP request [action=/ignite, jsonRes=GridRestResponse [successStatus=1, sesTokStr=null, err=IgniteTest$Person, obj=null], req=(GET /ignite?cacheName=person&pageSize=1&qry=limit+2&cmd=qryexe&type=Person)@1162648735 org.eclipse.jetty.server.Request@454c9c9f<mailto:org.eclipse.jetty.server.Request@454c9c9f>] Please help me. Thanks
