Uploaded image for project: 'Teiid'
  1. Teiid
  2. TEIID-2722

Cassandra: ORDER BY should do it in memory instead of trying to push down Cassandra in some cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 8.6
    • 8.6
    • Query Engine
    • Hide

      Create keyspace and tables
      cqlsh> CREATE KEYSPACE mykeyspace WITH REPLICATION =

      { 'class' : 'SimpleStrategy', 'replication_fact or' : 1}

      ;
      cqlsh> use mykeyspace;
      cqlsh:mykeyspace> CREATE TABLE users (user_id int PRIMARY KEY, fname text, lname text);
      cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith');
      cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname) VALUES (1744, 'john', 'doe');
      cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname) VALUES (1746, 'john', 'smith');
      cqlsh:mykeyspace> CREATE TABLE invoice (invoice_id int PRIMARY KEY, user_id int, sale double);
      cqlsh:mykeyspace> INSERT INTO invoice (invoice_id, user_id, sale) VALUES (1001, 1745, 10000);
      cqlsh:mykeyspace> INSERT INTO invoice (invoice_id, user_id, sale) VALUES (1002, 1745, 5000);
      cqlsh:mykeyspace> INSERT INTO invoice (invoice_id, user_id, sale) VALUES (1003, 1746, 20000);

      Build VDS for Cassandra mykeyspace

      Run the following SQL using teiid:

      select "cassandraDS_users"."user_id" as "cassandraDS_users_user_id",
      "cassandraDS_invoice"."sale" as "cassandraDS_invoice_sale"
      from "cassandraDS"."invoice" "cassandraDS_invoice"
      inner join "cassandraDS"."users" "cassandraDS_users" on ("cassandraDS_invoice"."user_id" = "cassandraDS_users"."user_id")

      Show
      Create keyspace and tables cqlsh> CREATE KEYSPACE mykeyspace WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_fact or' : 1} ; cqlsh> use mykeyspace; cqlsh:mykeyspace> CREATE TABLE users (user_id int PRIMARY KEY, fname text, lname text); cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname) VALUES (1745, 'john', 'smith'); cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname) VALUES (1744, 'john', 'doe'); cqlsh:mykeyspace> INSERT INTO users (user_id, fname, lname) VALUES (1746, 'john', 'smith'); cqlsh:mykeyspace> CREATE TABLE invoice (invoice_id int PRIMARY KEY, user_id int, sale double); cqlsh:mykeyspace> INSERT INTO invoice (invoice_id, user_id, sale) VALUES (1001, 1745, 10000); cqlsh:mykeyspace> INSERT INTO invoice (invoice_id, user_id, sale) VALUES (1002, 1745, 5000); cqlsh:mykeyspace> INSERT INTO invoice (invoice_id, user_id, sale) VALUES (1003, 1746, 20000); Build VDS for Cassandra mykeyspace Run the following SQL using teiid: select "cassandraDS_users"."user_id" as "cassandraDS_users_user_id", "cassandraDS_invoice"."sale" as "cassandraDS_invoice_sale" from "cassandraDS"."invoice" "cassandraDS_invoice" inner join "cassandraDS"."users" "cassandraDS_users" on ("cassandraDS_invoice"."user_id" = "cassandraDS_users"."user_id")

    Description

      When I tried to join 2 tables together from same keyspace using Teiid 8.6 Alpha with Cassandra 1.2.11. It broke down SQL into 2 CQLs. However, teiid SQL transformer adds order by clause to the CQL which is not supported.

      Original SQL:

      select "cassandraDS_users"."user_id" as "cassandraDS_users_user_id",
      "cassandraDS_invoice"."sale" as "cassandraDS_invoice_sale"
      from "cassandraDS"."invoice" "cassandraDS_invoice"
      inner join "cassandraDS"."users" "cassandraDS_users" on ("cassandraDS_invoice"."user_id" = "cassandraDS_users"."user_id")

      Break Down CQL:

      SELECT cassandraDS.invoice.user_id, cassandraDS.invoice.sale FROM cassandraDS.i
      nvoice ORDER BY cassandraDS.invoice.user_id

      SELECT cassandraDS.users.user_id FROM cassandraDS.users ORDER BY cassandraDS.us
      ers.user_id

      Error from CQL Driver:

      com.datastax.driver.core.exceptions.InvalidQueryException: ORDER BY is only supported when the partition key is restricted by an EQ or an IN.

      Attachments

        Activity

          People

            rhn-engineering-rareddy Ramesh Reddy
            mchantibco Ivan Chan (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: