无法读取未定义的属性'omitformat'

tuwxkamq  于 2021-07-15  发布在  ClickHouse
关注(0)|答案(1)|浏览(446)

我在中创建了一个表 clickhouse 如下所示:

let clickhouse = new ClickHouse (sails.config.clickhouse);
let query = `CREATE TABLE table1(category String,subcategory String,title String,id Int64) Engine=Log`

我试着运行上面的查询:

return new Promise((resolve, reject) => {
            clickhouse.query (query, function (err, result) {
                if (err) {
                    console.log(err);
                }
                resolve('success');
            });
        });
let test = await createTable();

但后来我犯了一个错误:
无法读取未定义的属性'omitformat'
这个错误有什么解决办法吗?谢谢
p、 s:我试过在中运行查询 Clickhouse 客户和它的工作。

44u64gxh

44u64gxh1#

传递未初始化的sails.config.clickhouse-param。
将未定义的选项传递给clickhouse构造函数会导致此行出错。
查看控制台以查看相关警告:

> You must provide at least host name to query ClickHouse // <---- !!!
> 
> Error: TypeError: Cannot read property 'omitFormat' of undefined
>     at ClickHouse.query (/home/runner/node_modules/@apla/clickhouse/src/clickhouse.js:257:60)
>     at Promise (evalmachine.<anonymous>:8:26)
>     at new Promise (<anonymous>)
>     at createTable (evalmachine.<anonymous>:7:10)
>     at evalmachine.<anonymous>:17:1
>     at Script.runInContext (vm.js:133:20)
>     at Object.runInContext (vm.js:311:6)
>     at evaluate (/run_dir/repl.js:133:14)
>     at ReadStream.<anonymous> (/run_dir/repl.js:116:5)
>     at ReadStream.emit (events.js:198:13)

再现这个错误的代码(参见https://repl.it/repls/fakeportlyexponent):

const ClickHouse = require('@apla/clickhouse')

let clickhouse = new ClickHouse (/*sails.config.clickhouse*/null); // <----- !!!
let query = `CREATE TABLE table1(category String,subcategory String,title String,id Int64) Engine=Log`;

async function createTable() {
  return new Promise((resolve, reject) => {
              clickhouse.query (query, function (err, result) {
                  if (err) {
                      console.log(err);
                  }
                  resolve('success');
              });
          });
}

createTable()
    .then(() => {
        console.info('Success.');
    })
    .catch(err => {
        console.error('Error:', err);
    });

相关问题