node-clickhouse icon indicating copy to clipboard operation
node-clickhouse copied to clipboard

select format csv not work

Open peaksnail opened this issue 4 years ago • 1 comments

var stream = ch.query ("SELECT 1 FORMAT CSV"); // or var stream = ch.query ("SELECT 1",format: 'CSV'); stream.on ('data', function (row) { console.log(row); });

not work return nothing

when var stream = ch.query ("SELECT 1 ");

it works

peaksnail avatar Jul 08 '21 11:07 peaksnail

yandex/clickhouse-server:20.3.21.2 none of these work:

stream = clickHouseCliento.query('SELECT 1', { format: 'CSV' })
// makes RecordStream with format CSV
stream.on('data',console.log).on('end',()=>console.log('end'))
// console output: end
stream = clickHouseCliento.query('SELECT 1 FORMAT CSV', {})
// makes RecordStream with format JSONCompact
stream.on('data',console.log).on('end',()=>console.log('end'))
// console output: end
stream = clickHouseCliento.query('SELECT 1 FORMAT CSV', {omitFormat:true})
// makes RecordStream with format JSONCompact
stream.on('data',console.log).on('end',()=>console.log('end'))
// console output: end
stream = clickHouseCliento.query('SELECT 1 FORMAT CSV', {omitFormat:true,readonly:true})
// makes RecordStream with format JSONCompact
stream.on('data',console.log).on('end',()=>console.log('end'))
// console output: end

Only JSON streams are working:

clickHouseCliento.query('SELECT 1').on('data',console.log).on('end',()=>console.log('end'))
// [ 1 ]\n end

CURL confirms the sanity:

$ echo 'SELECT 1 FORMAT CSVWithNames' | curl 'http://localhost:8123/' --data-binary @-
"1"
1

api-haus avatar Sep 28 '21 08:09 api-haus