From a2c4bd0d8c82bb9d04e16a087b214f059179c74f Mon Sep 17 00:00:00 2001 From: Calvin Metcalf Date: Wed, 7 Mar 2018 13:33:20 -0500 Subject: [PATCH] remove distinct because aparently that is much more expensive then I thought --- index.js | 2 +- test.js | 24 ------------------------ 2 files changed, 1 insertion(+), 25 deletions(-) diff --git a/index.js b/index.js index 8738629..d5c528f 100644 --- a/index.js +++ b/index.js @@ -87,7 +87,7 @@ var swap = Bluebird.coroutine(function * swap(table, tempTable, remove, db, conf return db.raw(` ${remove ? escape('DELETE from %I', table) : ''}; INSERT into ?? (${toFields.join(',')}) - SELECT DISTINCT ${fromFields.join(',')} from ?? + SELECT ${fromFields.join(',')} from ?? ${groupFields.length ? `group by ${groupFields.join(',')}` : ''}; `,[table, tempTable]).batch().onSuccess(db.raw('DROP TABLE ??;', [tempTable])).onError(db.raw('DROP TABLE ??;', [tempTable])); }); diff --git a/test.js b/test.js index 360d267..4ba4582 100644 --- a/test.js +++ b/test.js @@ -439,31 +439,7 @@ test('crud', function (t) { t.error(err, 'no error'); }); }); - t.test('test dedupping', function (t) { - t.plan(3); - var stream1 = intoCartodb(auth.user, auth.key, table, function (err) { - t.error(err); - cartodb(table).count('*').exec(function (err, resp) { - t.error(err); - t.deepEquals(resp, [{count: 3}]); - }); - }); - var i = -1; - while (++i < 100) { - stream1.write({ - type: 'Feature', - properties: { - num: i % 3 - }, - geometry: { - type: 'Point', - coordinates: [i % 3, i % 3] - } - }); - } - stream1.end(); - }); t.test('maybe delete with dash', function (t) { t.plan(1); cartodb.schema.dropTableIfExists(tablewithOutDash).exec(function (err) {