我有一个在javascript文件中执行的Cassandra SQL语句,其中包含几个参数,包括networkInterfaces TEXT:

client.execute("CREATE TABLE IF NOT EXISTS testdb.networkData (latitude DOUBLE, longitude DOUBLE, allowsVoIP BOOLEAN, speed DOUBLE, uuid TEXT, timestamp TIMESTAMP PRIMARY KEY, networkType TEXT, carrierName TEXT, altitude DOUBLE, macAddress TEXT, publicIP TEXT, ssidLabel TEXT, networkInterfaces TEXT)", function (err, result) {
    if (!err){
        if ( result.rowLength > 0 ) {
            var data = result.rows[0];
            console.log("Total rows : "+ data.count);
        } else {
            console.log("No rows");
        }
    }else{
        console.log("count results err : "+err);
    }
});


在出现networkInterfaces的所有其他实例中使用相同的情况“ networkInterfaces”。这包括将数据插入表中的代码:

// TODO: Save LAN interfaces as well
const recordCommand = 'INSERT INTO testdb.networkData (latitude, longitude, allowsVoIP, speed, uuid, timestamp, networkType, carrierName, altitude, macAddress, publicIP, ssidLabel, networkInterfaces) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)';
const params = [
    request.body.latitude,
    request.body.longitude,
    request.body.allowsVoIP,
    request.body.speed,
    request.body.uuid,
    request.body.timestamp,
    request.body.networkType,
    request.body.carrierName,
    request.body.altitude,
    request.body.macAddress,
    request.body.publicIP,
    request.body.ssidLabel,
    request.body.networkInterfaces
];

client.execute(recordCommand, params, { prepare: true }, function (error) {
    assert.ifError(error);
    //Inserted in the cluster
  });


但是,执行该命令时,它表明存在以下未处理的错误:


  错误:未定义的列名称networkinterfaces


未定义的列名似乎是大小写不匹配的,但是networkInterfaces的所有实例都具有相同的大小写。还会有其他问题吗?

最佳答案

默认情况下,Cassandra会将所有表/列名称转换为小写。
如果需要区分大小写的表/列名,则将其用双引号引起来。
使用desc table_name检查表的详细信息。

Eg:
Create table test(Column1 text primary key,"Column2" text);
 will result in cassandra table with 2 columns (column1 [Note all are lower case] and Column2 [C is uppercase])

关于javascript - Cassandra错误:尽管Java语言中的大小写一致,但由于看似大小写而导致未定义的列名,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46843538/

10-12 12:44
查看更多