Search code examples
ignitegridgain

Query Ignite cache created in Java with sqlline


I am using ignite's CacheQueryExample:

public class CacheQueryExample {
    /** Organizations cache name. */
    private static final String ORG_CACHE = CacheQueryExample.class.getSimpleName() + "Organizations";

    /** Persons collocated with Organizations cache name. */
    private static final String PERSON_CACHE = CacheQueryExample.class.getSimpleName() + "Persons";

    /**
     * Executes example.
     *
     * @param args Command line arguments, none required.
     * @throws Exception If example execution failed.
     */
    public static void main(String[] args) throws Exception {
        try (Ignite ignite = Ignition.start("examples/config/example-ignite.xml")) {
            System.out.println();
            System.out.println(">>> Cache query example started.");

            CacheConfiguration<Long, Organization> orgCacheCfg = new CacheConfiguration<>(ORG_CACHE);

            orgCacheCfg.setCacheMode(CacheMode.PARTITIONED); // Default.
            orgCacheCfg.setIndexedTypes(Long.class, Organization.class);
...

Using sqlline, the following tables are created:

+-----------+--------------------------------+-----------------------------+------------+---------+----------+------------+-----------+---------------------------+---------------+
| TABLE_CAT |          TABLE_SCHEM           |         TABLE_NAME          | TABLE_TYPE | REMARKS | TYPE_CAT | TYPE_SCHEM | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATIO |
+-----------+--------------------------------+-----------------------------+------------+---------+----------+------------+-----------+---------------------------+---------------+
| IGNITE    | CacheQueryExampleOrganizations | ORGANIZATION                | TABLE      |         |          |            |           |                           |               |
| IGNITE    | CacheQueryExamplePersons       | PERSON                      | TABLE      

How do I query these tables in sqlline? I have tried the following and none works:

0: jdbc:ignite:thin://127.0.0.1:10800> select * from person;
Error: Failed to parse query. Table "PERSON" not found; SQL statement:
select * from person [42102-197] (state=42000,code=1001)
0: jdbc:ignite:thin://127.0.0.1:10800> select * from CacheQueryExamplePersons.person;
Error: Failed to parse query. Schema "CACHEQUERYEXAMPLEPERSONS" not found; SQL statement:
select * from CacheQueryExamplePersons.person [90079-197] (state=42000,code=1001)

And logging to sqlline for the specific schema:

0: jdbc:ignite:thin://127.0.0.1:10800/CacheQu> select * from person;
Error: Failed to set schema for DB connection for thread [schema=CACHEQUERYEXAMPLEPERSONS] (state=50000,code=1)


Solution

  • Try enclosing the table scheme name with double quotes.