]> source.dussan.org Git - rspamd.git/commitdiff
[Minor] Fix various issues with the clickhouse support
authorVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Aug 2018 13:54:53 +0000 (14:54 +0100)
committerVsevolod Stakhov <vsevolod@highsecure.ru>
Tue, 7 Aug 2018 13:54:53 +0000 (14:54 +0100)
lualib/lua_clickhouse.lua
src/plugins/lua/clickhouse.lua

index 4be2c430fdebfcfd1d3d5ea4b9e29e09fb539626..37c9ebb7a32e834c403107d299d2e56d438f5e4c 100644 (file)
@@ -243,9 +243,10 @@ exports.insert = function (upstream, settings, params, query, rows,
   http_params.no_ssl_verify = settings.no_ssl_verify
   http_params.user = settings.user
   http_params.password = settings.password
+  http_params.method = 'POST'
   http_params.body = {table.concat(fun.totable(fun.map(function(row)
     return row_to_tsv(row)
-  end), rows), '\n'), '\n'}
+  end, rows)), '\n'), '\n'}
   http_params.log_obj = params.task or params.config
 
   if not http_params.url then
index 3eebd5b5d7dae49754c26572217d0eecebbfe3de..b54c1a2163a96e889bea4c1f6976f23abe27e123 100644 (file)
@@ -181,7 +181,7 @@ local function clickhouse_main_row(tname)
     'ListId',
     'Digest'
   }
-  local elt = string.format('INSERT INTO %s (%s) VALUES ',
+  local elt = string.format('INSERT INTO %s (%s) ',
     tname, table.concat(fields, ','))
 
   return elt
@@ -196,7 +196,7 @@ local function clickhouse_attachments_row(tname)
     'Attachments.Length',
     'Attachments.Digest',
   }
-  local elt = string.format('INSERT INTO %s (%s) VALUES ',
+  local elt = string.format('INSERT INTO %s (%s) ',
     tname, table.concat(attachement_fields, ','))
   return elt
 end
@@ -208,7 +208,7 @@ local function clickhouse_urls_row(tname)
     'Urls.Tld',
     'Urls.Url',
   }
-  local elt = string.format('INSERT INTO %s (%s) VALUES ',
+  local elt = string.format('INSERT INTO %s (%s) ',
     tname, table.concat(urls_fields, ','))
   return elt
 end
@@ -219,7 +219,7 @@ local function clickhouse_emails_row(tname)
     'Digest',
     'Emails',
   }
-  local elt = string.format('INSERT INTO %s (%s) VALUES ',
+  local elt = string.format('INSERT INTO %s (%s) ',
       tname, table.concat(emails_fields, ','))
   return elt
 end
@@ -232,7 +232,7 @@ local function clickhouse_symbols_row(tname)
     'Symbols.Scores',
     'Symbols.Options',
   }
-  local elt = string.format('INSERT INTO %s (%s) VALUES ',
+  local elt = string.format('INSERT INTO %s (%s) ',
     tname, table.concat(symbols_fields, ','))
   return elt
 end
@@ -245,7 +245,7 @@ local function clickhouse_asn_row(tname)
     'Country',
     'IPNet',
   }
-  local elt = string.format('INSERT INTO %s (%s) VALUES ',
+  local elt = string.format('INSERT INTO %s (%s) ',
     tname, table.concat(asn_fields, ','))
   return elt
 end
@@ -293,6 +293,7 @@ local function clickhouse_send_data(task)
     local ch_params = {
       task = task,
     }
+
     local ret = lua_clickhouse.insert(upstream, settings, ch_params,
         query, tbl,
         gen_success_cb(what, #tbl),
@@ -657,6 +658,7 @@ local function clickhouse_collect(task)
   end
 
   nrows = nrows + 1
+  rspamd_logger.debugm(N, task, "add clickhouse row %s / %s", nrows, settings.limit)
 
   if nrows > settings['limit'] then
     clickhouse_send_data(task)