Created
February 22, 2018 11:58
-
-
Save alexott/98337bf651294902afeff09882758ae7 to your computer and use it in GitHub Desktop.
Test code for https://stackoverflow.com/questions/48903314/nodejs-cassandra-driver-getting-error-unconfigured-table-when-trying-to
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cqlsh:test> DESCRIBE table log; | |
CREATE TABLE test.log ( | |
module text, | |
yyyymmdd text, | |
created timeuuid, | |
logmessage text, | |
PRIMARY KEY ((module, yyyymmdd), created) | |
) WITH CLUSTERING ORDER BY (created ASC) | |
AND bloom_filter_fp_chance = 0.01 | |
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} | |
AND comment = '' | |
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_thresho | |
ld': '32', 'min_threshold': '4'} | |
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} | |
AND crc_check_chance = 1.0 | |
AND dclocal_read_repair_chance = 0.1 | |
AND default_time_to_live = 0 | |
AND gc_grace_seconds = 864000 | |
AND max_index_interval = 2048 | |
AND memtable_flush_period_in_ms = 0 | |
AND min_index_interval = 128 | |
AND read_repair_chance = 0.0 | |
AND speculative_retry = '99PERCENTILE'; | |
CREATE MATERIALIZED VIEW test.log_mv AS | |
SELECT yyyymmdd, module, created, logmessage | |
FROM test.log | |
WHERE yyyymmdd IS NOT NULL AND module IS NOT NULL AND created IS NOT NULL | |
PRIMARY KEY ((yyyymmdd, module), created) | |
WITH CLUSTERING ORDER BY (created ASC) | |
AND bloom_filter_fp_chance = 0.01 | |
AND caching = {'keys': 'ALL', 'rows_per_partition': 'NONE'} | |
AND comment = '' | |
AND compaction = {'class': 'org.apache.cassandra.db.compaction.SizeTieredCompactionStrategy', 'max_threshold': '32', 'min_threshold': '4'} | |
AND compression = {'chunk_length_in_kb': '64', 'class': 'org.apache.cassandra.io.compress.LZ4Compressor'} | |
AND crc_check_chance = 1.0 | |
AND dclocal_read_repair_chance = 0.1 | |
AND default_time_to_live = 0 | |
AND gc_grace_seconds = 864000 | |
AND max_index_interval = 2048 | |
AND memtable_flush_period_in_ms = 0 | |
AND min_index_interval = 128 | |
AND read_repair_chance = 0.0 | |
AND speculative_retry = '99PERCENTILE'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>node test.js 12:56 130 | |
Obtained result after table: ResultSet { | |
info: | |
{ queriedHost: '192.168.0.10:9042', | |
triedHosts: | |
{ '172.19.0.3:9042': 'Host considered as DOWN', | |
'172.19.0.2:9042': 'Host considered as DOWN', | |
'192.168.0.10:9042': null }, | |
speculativeExecutions: 0, | |
achievedConsistency: 10, | |
traceId: undefined, | |
warnings: undefined, | |
customPayload: undefined }, | |
rows: undefined, | |
rowLength: undefined, | |
columns: null, | |
pageState: null, | |
nextPage: undefined } | |
Obtained result after MV: ResultSet { | |
info: | |
{ queriedHost: '192.168.0.10:9042', | |
triedHosts: | |
{ '172.19.0.2:9042': 'Host considered as DOWN', | |
'192.168.0.10:9042': null }, | |
speculativeExecutions: 0, | |
achievedConsistency: 10, | |
traceId: undefined, | |
warnings: undefined, | |
customPayload: undefined }, | |
rows: undefined, | |
rowLength: undefined, | |
columns: null, | |
pageState: null, | |
nextPage: undefined } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"use strict"; | |
const cassandra = require('cassandra-driver'); | |
const client = new cassandra.Client({ contactPoints: ['192.168.0.10']}); | |
client.connect() | |
.then(function () { | |
return client.execute('CREATE TABLE test.log(yyyymmdd varchar, created timeuuid, logMessage text, module text, PRIMARY KEY((module,yyyymmdd), created));'); | |
}) | |
.then(function (result) { | |
console.log('Obtained result after table: ', result); | |
return client.execute('create MATERIALIZED VIEW test.log_mv AS SELECT yyyymmdd,module,created,logmessage FROM test.log where yyyymmdd is not null and module is not null and created is not null PRIMARY KEY ((yyyymmdd,module),created);'); | |
}) | |
.then(function (result) { | |
console.log('Obtained result after MV: ', result); | |
return client.shutdown(); | |
}) | |
.catch(function (err) { | |
console.error('There was an error when connecting', err); | |
return client.shutdown(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment