0

I am using datastax nodejs-driver to get information of a keyspace from cassandra.

const results = await client.execute( `
    DESC KEYSPACE ${keyspace}
` );

The client.execute method returns an object includes lots of information:

ResultSet {
      info: {
        queriedHost: '127.0.0.1:9042',
        triedHosts: { '127.0.0.1:9042': null },
        speculativeExecutions: 0,
        achievedConsistency: 10,
        traceId: undefined,
        warnings: undefined,
        customPayload: undefined,
        isSchemaInAgreement: true
      },
      rows: [
        Row {
          keyspace_name: 'xxxx',
          type: 'keyspace',
          name: 'xxxx',
          create_statement: "CREATE KEYSPACE xxxx WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}  AND durable_writes = true;"
        }
      ],
      rowLength: 1,
      columns: [
        { name: 'keyspace_name', type: [Object] },
        { name: 'type', type: [Object] },
        { name: 'name', type: [Object] },
        { name: 'create_statement', type: [Object] }
      ],
      pageState: null,
      nextPage: undefined,
      nextPageAsync: undefined
    }

But while execute DESC KEYSPACE xxxx, only the create_statement part is responded:

cqlsh> DESC xxxx;

CREATE KEYSPACE xxxx WITH replication = {'class': 'SimpleStrategy', 'replication_factor': '3'}  AND durable_writes = true;
cqlsh>

My questions are:

  1. Why could client driver provide more information of the results.
  2. Can I get the same results by using cqlsh?
  3. The result above includes a Row property, it's structure looks like something like:
interface Row {
    keyspace_name: string;
    type: 'keyspace';
    name: string;
    create_statement: string;
}

Where can I find the declarations of different types of Rows?

Thank you so much.

LCB
  • 971
  • 9
  • 22

1 Answers1

2

CQLSH is an interactive user shell, so it responds with a succinct query response in text. The Node.js driver (or Python driver with CQLSH) returns a ResultSet object and is machine readable. Machine readable results will usually contain a lot of additional information.

CQLSH let's you enable tracing. With tracing you'll get a more verbose level of information.

Brad Schoening
  • 1,281
  • 6
  • 22