summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2022-03-14 16:31:19 +0000
committerPaul Buetow <pbuetow@mimecast.com>2022-03-14 16:31:19 +0000
commite085a61ca70932a3670381e2d6b5919e9108441d (patch)
tree02635c4a7b0e24a900d790cb247c7bab14b139b7
parentbee83cd299b3259790d62b9f22347498f70206b7 (diff)
add integration test for "outfile append.."
-rw-r--r--integrationtests/dmap4.csv.expected407
-rw-r--r--integrationtests/dmap4.csv.query.expected1
-rw-r--r--integrationtests/dmap_test.go56
-rw-r--r--internal/mapr/groupsetresult.go30
4 files changed, 485 insertions, 9 deletions
diff --git a/integrationtests/dmap4.csv.expected b/integrationtests/dmap4.csv.expected
new file mode 100644
index 0000000..f6dc4cc
--- /dev/null
+++ b/integrationtests/dmap4.csv.expected
@@ -0,0 +1,407 @@
+count($time),$time,max($goroutines),avg($goroutines),min($goroutines)
+23,1002-071147,16.000000,14.391304,12.000000
+20,1002-071213,17.000000,14.100000,12.000000
+20,1002-071143,17.000000,15.000000,13.000000
+11,1002-071948,15.000000,14.272727,11.000000
+10,1002-071913,13.000000,13.000000,13.000000
+10,1002-071912,15.000000,15.000000,15.000000
+9,1002-071921,15.000000,13.333333,12.000000
+7,1002-071920,15.000000,15.000000,15.000000
+4,1002-071922,13.000000,12.500000,12.000000
+3,1002-071837,11.000000,11.000000,11.000000
+3,1002-071536,11.000000,11.000000,11.000000
+3,1002-071448,11.000000,11.000000,11.000000
+3,1002-071418,11.000000,11.000000,11.000000
+3,1002-071809,11.000000,11.000000,11.000000
+3,1002-071847,11.000000,11.000000,11.000000
+3,1002-071619,11.000000,11.000000,11.000000
+3,1002-071919,11.000000,11.000000,11.000000
+3,1002-071629,11.000000,11.000000,11.000000
+3,1002-071739,11.000000,11.000000,11.000000
+3,1002-071216,11.000000,11.000000,11.000000
+3,1002-071438,11.000000,11.000000,11.000000
+3,1002-071819,11.000000,11.000000,11.000000
+3,1002-071529,11.000000,11.000000,11.000000
+3,1002-071606,11.000000,11.000000,11.000000
+3,1002-071609,11.000000,11.000000,11.000000
+3,1002-071156,11.000000,11.000000,11.000000
+3,1002-071939,11.000000,11.000000,11.000000
+3,1002-071406,11.000000,11.000000,11.000000
+3,1002-071637,11.000000,11.000000,11.000000
+3,1002-071717,11.000000,11.000000,11.000000
+3,1002-071218,11.000000,11.000000,11.000000
+3,1002-071228,11.000000,11.000000,11.000000
+3,1002-071909,11.000000,11.000000,11.000000
+3,1002-071408,11.000000,11.000000,11.000000
+3,1002-071526,11.000000,11.000000,11.000000
+3,1002-071426,11.000000,11.000000,11.000000
+3,1002-071617,11.000000,11.000000,11.000000
+3,1002-071556,11.000000,11.000000,11.000000
+3,1002-071328,11.000000,11.000000,11.000000
+3,1002-071649,11.000000,11.000000,11.000000
+3,1002-071807,11.000000,11.000000,11.000000
+3,1002-071707,11.000000,11.000000,11.000000
+3,1002-071839,11.000000,11.000000,11.000000
+3,1002-071458,11.000000,11.000000,11.000000
+3,1002-071647,11.000000,11.000000,11.000000
+3,1002-071206,11.000000,11.000000,11.000000
+3,1002-071917,11.000000,11.000000,11.000000
+3,1002-071827,11.000000,11.000000,11.000000
+3,1002-071146,11.000000,11.000000,11.000000
+3,1002-071258,11.000000,11.000000,11.000000
+3,1002-071326,11.000000,11.000000,11.000000
+3,1002-071246,11.000000,11.000000,11.000000
+3,1002-071729,11.000000,11.000000,11.000000
+3,1002-071927,11.000000,11.000000,11.000000
+3,1002-071316,11.000000,11.000000,11.000000
+3,1002-071709,11.000000,11.000000,11.000000
+3,1002-071446,11.000000,11.000000,11.000000
+3,1002-071757,11.000000,11.000000,11.000000
+3,1002-071356,11.000000,11.000000,11.000000
+3,1002-071719,11.000000,11.000000,11.000000
+3,1002-071358,11.000000,11.000000,11.000000
+3,1002-071849,11.000000,11.000000,11.000000
+3,1002-071318,11.000000,11.000000,11.000000
+3,1002-071747,11.000000,11.000000,11.000000
+3,1002-071657,11.000000,11.000000,11.000000
+3,1002-071248,11.000000,11.000000,11.000000
+3,1002-071346,11.000000,11.000000,11.000000
+3,1002-071428,11.000000,11.000000,11.000000
+3,1002-071157,11.000000,11.000000,11.000000
+3,1002-071236,11.000000,11.000000,11.000000
+3,1002-071817,11.000000,11.000000,11.000000
+3,1002-071456,11.000000,11.000000,11.000000
+3,1002-071737,11.000000,11.000000,11.000000
+3,1002-071238,11.000000,11.000000,11.000000
+3,1002-071256,11.000000,11.000000,11.000000
+3,1002-071336,11.000000,11.000000,11.000000
+3,1002-071208,11.000000,11.000000,11.000000
+3,1002-071859,11.000000,11.000000,11.000000
+3,1002-071519,11.000000,11.000000,11.000000
+3,1002-071907,11.000000,11.000000,11.000000
+3,1002-071546,11.000000,11.000000,11.000000
+3,1002-071727,11.000000,11.000000,11.000000
+3,1002-071226,11.000000,11.000000,11.000000
+3,1002-071559,11.000000,11.000000,11.000000
+3,1002-071508,11.000000,11.000000,11.000000
+3,1002-071857,11.000000,11.000000,11.000000
+3,1002-071308,11.000000,11.000000,11.000000
+3,1002-071506,11.000000,11.000000,11.000000
+3,1002-071516,11.000000,11.000000,11.000000
+3,1002-071829,11.000000,11.000000,11.000000
+3,1002-071947,11.000000,11.000000,11.000000
+3,1002-071929,11.000000,11.000000,11.000000
+3,1002-071338,11.000000,11.000000,11.000000
+3,1002-071759,11.000000,11.000000,11.000000
+3,1002-071749,11.000000,11.000000,11.000000
+3,1002-071436,11.000000,11.000000,11.000000
+3,1002-071306,11.000000,11.000000,11.000000
+3,1002-071659,11.000000,11.000000,11.000000
+3,1002-071937,11.000000,11.000000,11.000000
+3,1002-071639,11.000000,11.000000,11.000000
+3,1002-071348,11.000000,11.000000,11.000000
+3,1002-071416,11.000000,11.000000,11.000000
+3,1002-071549,11.000000,11.000000,11.000000
+3,1002-071539,11.000000,11.000000,11.000000
+3,1002-071627,11.000000,11.000000,11.000000
+2,1002-071548,11.000000,11.000000,11.000000
+2,1002-071217,11.000000,11.000000,11.000000
+2,1002-071209,11.000000,11.000000,11.000000
+2,1002-071848,11.000000,11.000000,11.000000
+2,1002-071507,11.000000,11.000000,11.000000
+2,1002-071858,11.000000,11.000000,11.000000
+2,1002-071219,11.000000,11.000000,11.000000
+2,1002-071317,11.000000,11.000000,11.000000
+2,1002-071928,11.000000,11.000000,11.000000
+2,1002-071527,11.000000,11.000000,11.000000
+2,1002-071207,11.000000,11.000000,11.000000
+2,1002-071149,11.000000,11.000000,11.000000
+2,1002-071409,11.000000,11.000000,11.000000
+2,1002-071227,11.000000,11.000000,11.000000
+2,1002-071658,11.000000,11.000000,11.000000
+2,1002-071846,11.000000,11.000000,11.000000
+2,1002-071309,11.000000,11.000000,11.000000
+2,1002-071736,11.000000,11.000000,11.000000
+2,1002-071616,11.000000,11.000000,11.000000
+2,1002-071249,11.000000,11.000000,11.000000
+2,1002-071836,11.000000,11.000000,11.000000
+2,1002-071648,11.000000,11.000000,11.000000
+2,1002-071818,11.000000,11.000000,11.000000
+2,1002-071706,11.000000,11.000000,11.000000
+2,1002-071337,11.000000,11.000000,11.000000
+2,1002-071816,11.000000,11.000000,11.000000
+2,1002-071618,11.000000,11.000000,11.000000
+2,1002-071607,11.000000,11.000000,11.000000
+2,1002-071708,11.000000,11.000000,11.000000
+2,1002-071327,11.000000,11.000000,11.000000
+2,1002-071518,11.000000,11.000000,11.000000
+2,1002-071806,11.000000,11.000000,11.000000
+2,1002-071808,11.000000,11.000000,11.000000
+2,1002-071407,11.000000,11.000000,11.000000
+2,1002-071307,11.000000,11.000000,11.000000
+2,1002-071826,11.000000,11.000000,11.000000
+2,1002-071908,11.000000,11.000000,11.000000
+2,1002-071718,11.000000,11.000000,11.000000
+2,1002-071329,11.000000,11.000000,11.000000
+2,1002-071437,11.000000,11.000000,11.000000
+2,1002-071906,11.000000,11.000000,11.000000
+2,1002-071159,11.000000,11.000000,11.000000
+2,1002-071359,11.000000,11.000000,11.000000
+2,1002-071656,11.000000,11.000000,11.000000
+2,1002-071449,11.000000,11.000000,11.000000
+2,1002-071936,11.000000,11.000000,11.000000
+2,1002-071626,11.000000,11.000000,11.000000
+2,1002-071349,11.000000,11.000000,11.000000
+2,1002-071357,11.000000,11.000000,11.000000
+2,1002-071748,11.000000,11.000000,11.000000
+2,1002-071838,11.000000,11.000000,11.000000
+2,1002-071347,11.000000,11.000000,11.000000
+2,1002-071517,11.000000,11.000000,11.000000
+2,1002-071938,11.000000,11.000000,11.000000
+2,1002-071239,11.000000,11.000000,11.000000
+2,1002-071856,11.000000,11.000000,11.000000
+2,1002-071537,11.000000,11.000000,11.000000
+2,1002-071259,11.000000,11.000000,11.000000
+2,1002-071447,11.000000,11.000000,11.000000
+2,1002-071608,11.000000,11.000000,11.000000
+2,1002-071148,11.000000,11.000000,11.000000
+2,1002-071916,11.000000,11.000000,11.000000
+2,1002-071417,11.000000,11.000000,11.000000
+2,1002-071509,11.000000,11.000000,11.000000
+2,1002-071646,11.000000,11.000000,11.000000
+2,1002-071557,11.000000,11.000000,11.000000
+2,1002-071758,11.000000,11.000000,11.000000
+2,1002-071237,11.000000,11.000000,11.000000
+2,1002-071726,11.000000,11.000000,11.000000
+2,1002-071638,11.000000,11.000000,11.000000
+2,1002-071946,11.000000,11.000000,11.000000
+2,1002-071558,11.000000,11.000000,11.000000
+2,1002-071746,11.000000,11.000000,11.000000
+2,1002-071429,11.000000,11.000000,11.000000
+2,1002-071628,11.000000,11.000000,11.000000
+2,1002-071738,11.000000,11.000000,11.000000
+2,1002-071756,11.000000,11.000000,11.000000
+2,1002-071427,11.000000,11.000000,11.000000
+2,1002-071257,11.000000,11.000000,11.000000
+2,1002-071247,11.000000,11.000000,11.000000
+2,1002-071158,11.000000,11.000000,11.000000
+2,1002-071439,11.000000,11.000000,11.000000
+2,1002-071926,11.000000,11.000000,11.000000
+2,1002-071547,11.000000,11.000000,11.000000
+2,1002-071457,11.000000,11.000000,11.000000
+2,1002-071728,11.000000,11.000000,11.000000
+2,1002-071828,11.000000,11.000000,11.000000
+2,1002-071319,11.000000,11.000000,11.000000
+2,1002-071538,11.000000,11.000000,11.000000
+2,1002-071528,11.000000,11.000000,11.000000
+2,1002-071419,11.000000,11.000000,11.000000
+2,1002-071716,11.000000,11.000000,11.000000
+2,1002-071229,11.000000,11.000000,11.000000
+2,1002-071339,11.000000,11.000000,11.000000
+2,1002-071636,11.000000,11.000000,11.000000
+2,1002-071459,11.000000,11.000000,11.000000
+2,1002-071918,11.000000,11.000000,11.000000
+1,1002-071949,15.000000,15.000000,15.000000
+23,1002-071147,16.000000,14.391304,12.000000
+20,1002-071143,17.000000,15.000000,13.000000
+20,1002-071213,17.000000,14.100000,12.000000
+11,1002-071948,15.000000,14.272727,11.000000
+10,1002-071913,13.000000,13.000000,13.000000
+10,1002-071912,15.000000,15.000000,15.000000
+9,1002-071921,15.000000,13.333333,12.000000
+7,1002-071920,15.000000,15.000000,15.000000
+4,1002-071922,13.000000,12.500000,12.000000
+3,1002-071156,11.000000,11.000000,11.000000
+3,1002-071907,11.000000,11.000000,11.000000
+3,1002-071258,11.000000,11.000000,11.000000
+3,1002-071526,11.000000,11.000000,11.000000
+3,1002-071837,11.000000,11.000000,11.000000
+3,1002-071649,11.000000,11.000000,11.000000
+3,1002-071428,11.000000,11.000000,11.000000
+3,1002-071549,11.000000,11.000000,11.000000
+3,1002-071727,11.000000,11.000000,11.000000
+3,1002-071619,11.000000,11.000000,11.000000
+3,1002-071506,11.000000,11.000000,11.000000
+3,1002-071218,11.000000,11.000000,11.000000
+3,1002-071739,11.000000,11.000000,11.000000
+3,1002-071226,11.000000,11.000000,11.000000
+3,1002-071749,11.000000,11.000000,11.000000
+3,1002-071458,11.000000,11.000000,11.000000
+3,1002-071436,11.000000,11.000000,11.000000
+3,1002-071759,11.000000,11.000000,11.000000
+3,1002-071909,11.000000,11.000000,11.000000
+3,1002-071238,11.000000,11.000000,11.000000
+3,1002-071456,11.000000,11.000000,11.000000
+3,1002-071338,11.000000,11.000000,11.000000
+3,1002-071556,11.000000,11.000000,11.000000
+3,1002-071709,11.000000,11.000000,11.000000
+3,1002-071606,11.000000,11.000000,11.000000
+3,1002-071609,11.000000,11.000000,11.000000
+3,1002-071408,11.000000,11.000000,11.000000
+3,1002-071216,11.000000,11.000000,11.000000
+3,1002-071206,11.000000,11.000000,11.000000
+3,1002-071256,11.000000,11.000000,11.000000
+3,1002-071717,11.000000,11.000000,11.000000
+3,1002-071438,11.000000,11.000000,11.000000
+3,1002-071849,11.000000,11.000000,11.000000
+3,1002-071539,11.000000,11.000000,11.000000
+3,1002-071546,11.000000,11.000000,11.000000
+3,1002-071426,11.000000,11.000000,11.000000
+3,1002-071519,11.000000,11.000000,11.000000
+3,1002-071157,11.000000,11.000000,11.000000
+3,1002-071737,11.000000,11.000000,11.000000
+3,1002-071308,11.000000,11.000000,11.000000
+3,1002-071757,11.000000,11.000000,11.000000
+3,1002-071508,11.000000,11.000000,11.000000
+3,1002-071639,11.000000,11.000000,11.000000
+3,1002-071917,11.000000,11.000000,11.000000
+3,1002-071647,11.000000,11.000000,11.000000
+3,1002-071807,11.000000,11.000000,11.000000
+3,1002-071859,11.000000,11.000000,11.000000
+3,1002-071939,11.000000,11.000000,11.000000
+3,1002-071248,11.000000,11.000000,11.000000
+3,1002-071416,11.000000,11.000000,11.000000
+3,1002-071817,11.000000,11.000000,11.000000
+3,1002-071358,11.000000,11.000000,11.000000
+3,1002-071659,11.000000,11.000000,11.000000
+3,1002-071336,11.000000,11.000000,11.000000
+3,1002-071857,11.000000,11.000000,11.000000
+3,1002-071839,11.000000,11.000000,11.000000
+3,1002-071326,11.000000,11.000000,11.000000
+3,1002-071146,11.000000,11.000000,11.000000
+3,1002-071847,11.000000,11.000000,11.000000
+3,1002-071829,11.000000,11.000000,11.000000
+3,1002-071819,11.000000,11.000000,11.000000
+3,1002-071809,11.000000,11.000000,11.000000
+3,1002-071316,11.000000,11.000000,11.000000
+3,1002-071627,11.000000,11.000000,11.000000
+3,1002-071937,11.000000,11.000000,11.000000
+3,1002-071947,11.000000,11.000000,11.000000
+3,1002-071356,11.000000,11.000000,11.000000
+3,1002-071629,11.000000,11.000000,11.000000
+3,1002-071707,11.000000,11.000000,11.000000
+3,1002-071827,11.000000,11.000000,11.000000
+3,1002-071236,11.000000,11.000000,11.000000
+3,1002-071228,11.000000,11.000000,11.000000
+3,1002-071529,11.000000,11.000000,11.000000
+3,1002-071747,11.000000,11.000000,11.000000
+3,1002-071418,11.000000,11.000000,11.000000
+3,1002-071346,11.000000,11.000000,11.000000
+3,1002-071927,11.000000,11.000000,11.000000
+3,1002-071919,11.000000,11.000000,11.000000
+3,1002-071536,11.000000,11.000000,11.000000
+3,1002-071657,11.000000,11.000000,11.000000
+3,1002-071348,11.000000,11.000000,11.000000
+3,1002-071406,11.000000,11.000000,11.000000
+3,1002-071306,11.000000,11.000000,11.000000
+3,1002-071446,11.000000,11.000000,11.000000
+3,1002-071617,11.000000,11.000000,11.000000
+3,1002-071448,11.000000,11.000000,11.000000
+3,1002-071719,11.000000,11.000000,11.000000
+3,1002-071637,11.000000,11.000000,11.000000
+3,1002-071208,11.000000,11.000000,11.000000
+3,1002-071559,11.000000,11.000000,11.000000
+3,1002-071328,11.000000,11.000000,11.000000
+3,1002-071318,11.000000,11.000000,11.000000
+3,1002-071729,11.000000,11.000000,11.000000
+3,1002-071516,11.000000,11.000000,11.000000
+3,1002-071246,11.000000,11.000000,11.000000
+3,1002-071929,11.000000,11.000000,11.000000
+2,1002-071337,11.000000,11.000000,11.000000
+2,1002-071429,11.000000,11.000000,11.000000
+2,1002-071327,11.000000,11.000000,11.000000
+2,1002-071906,11.000000,11.000000,11.000000
+2,1002-071607,11.000000,11.000000,11.000000
+2,1002-071247,11.000000,11.000000,11.000000
+2,1002-071317,11.000000,11.000000,11.000000
+2,1002-071158,11.000000,11.000000,11.000000
+2,1002-071409,11.000000,11.000000,11.000000
+2,1002-071726,11.000000,11.000000,11.000000
+2,1002-071858,11.000000,11.000000,11.000000
+2,1002-071728,11.000000,11.000000,11.000000
+2,1002-071616,11.000000,11.000000,11.000000
+2,1002-071638,11.000000,11.000000,11.000000
+2,1002-071537,11.000000,11.000000,11.000000
+2,1002-071209,11.000000,11.000000,11.000000
+2,1002-071219,11.000000,11.000000,11.000000
+2,1002-071818,11.000000,11.000000,11.000000
+2,1002-071926,11.000000,11.000000,11.000000
+2,1002-071249,11.000000,11.000000,11.000000
+2,1002-071808,11.000000,11.000000,11.000000
+2,1002-071547,11.000000,11.000000,11.000000
+2,1002-071826,11.000000,11.000000,11.000000
+2,1002-071756,11.000000,11.000000,11.000000
+2,1002-071309,11.000000,11.000000,11.000000
+2,1002-071357,11.000000,11.000000,11.000000
+2,1002-071928,11.000000,11.000000,11.000000
+2,1002-071856,11.000000,11.000000,11.000000
+2,1002-071207,11.000000,11.000000,11.000000
+2,1002-071359,11.000000,11.000000,11.000000
+2,1002-071217,11.000000,11.000000,11.000000
+2,1002-071648,11.000000,11.000000,11.000000
+2,1002-071517,11.000000,11.000000,11.000000
+2,1002-071447,11.000000,11.000000,11.000000
+2,1002-071347,11.000000,11.000000,11.000000
+2,1002-071437,11.000000,11.000000,11.000000
+2,1002-071626,11.000000,11.000000,11.000000
+2,1002-071608,11.000000,11.000000,11.000000
+2,1002-071159,11.000000,11.000000,11.000000
+2,1002-071646,11.000000,11.000000,11.000000
+2,1002-071946,11.000000,11.000000,11.000000
+2,1002-071936,11.000000,11.000000,11.000000
+2,1002-071628,11.000000,11.000000,11.000000
+2,1002-071527,11.000000,11.000000,11.000000
+2,1002-071229,11.000000,11.000000,11.000000
+2,1002-071548,11.000000,11.000000,11.000000
+2,1002-071557,11.000000,11.000000,11.000000
+2,1002-071419,11.000000,11.000000,11.000000
+2,1002-071746,11.000000,11.000000,11.000000
+2,1002-071558,11.000000,11.000000,11.000000
+2,1002-071656,11.000000,11.000000,11.000000
+2,1002-071417,11.000000,11.000000,11.000000
+2,1002-071918,11.000000,11.000000,11.000000
+2,1002-071836,11.000000,11.000000,11.000000
+2,1002-071658,11.000000,11.000000,11.000000
+2,1002-071848,11.000000,11.000000,11.000000
+2,1002-071916,11.000000,11.000000,11.000000
+2,1002-071538,11.000000,11.000000,11.000000
+2,1002-071239,11.000000,11.000000,11.000000
+2,1002-071427,11.000000,11.000000,11.000000
+2,1002-071636,11.000000,11.000000,11.000000
+2,1002-071148,11.000000,11.000000,11.000000
+2,1002-071237,11.000000,11.000000,11.000000
+2,1002-071518,11.000000,11.000000,11.000000
+2,1002-071708,11.000000,11.000000,11.000000
+2,1002-071736,11.000000,11.000000,11.000000
+2,1002-071319,11.000000,11.000000,11.000000
+2,1002-071528,11.000000,11.000000,11.000000
+2,1002-071738,11.000000,11.000000,11.000000
+2,1002-071307,11.000000,11.000000,11.000000
+2,1002-071449,11.000000,11.000000,11.000000
+2,1002-071459,11.000000,11.000000,11.000000
+2,1002-071748,11.000000,11.000000,11.000000
+2,1002-071407,11.000000,11.000000,11.000000
+2,1002-071938,11.000000,11.000000,11.000000
+2,1002-071618,11.000000,11.000000,11.000000
+2,1002-071828,11.000000,11.000000,11.000000
+2,1002-071509,11.000000,11.000000,11.000000
+2,1002-071227,11.000000,11.000000,11.000000
+2,1002-071908,11.000000,11.000000,11.000000
+2,1002-071339,11.000000,11.000000,11.000000
+2,1002-071758,11.000000,11.000000,11.000000
+2,1002-071149,11.000000,11.000000,11.000000
+2,1002-071838,11.000000,11.000000,11.000000
+2,1002-071349,11.000000,11.000000,11.000000
+2,1002-071716,11.000000,11.000000,11.000000
+2,1002-071718,11.000000,11.000000,11.000000
+2,1002-071806,11.000000,11.000000,11.000000
+2,1002-071706,11.000000,11.000000,11.000000
+2,1002-071507,11.000000,11.000000,11.000000
+2,1002-071816,11.000000,11.000000,11.000000
+2,1002-071439,11.000000,11.000000,11.000000
+2,1002-071257,11.000000,11.000000,11.000000
+2,1002-071846,11.000000,11.000000,11.000000
+2,1002-071457,11.000000,11.000000,11.000000
+2,1002-071329,11.000000,11.000000,11.000000
+2,1002-071259,11.000000,11.000000,11.000000
+1,1002-071949,15.000000,15.000000,15.000000
diff --git a/integrationtests/dmap4.csv.query.expected b/integrationtests/dmap4.csv.query.expected
new file mode 100644
index 0000000..84b37e3
--- /dev/null
+++ b/integrationtests/dmap4.csv.query.expected
@@ -0,0 +1 @@
+from STATS select count($time),$time,max($goroutines),avg($goroutines),min($goroutines) group by $time order by count($time) outfile append dmap4.csv.tmp \ No newline at end of file
diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go
index 346a872..600aaa9 100644
--- a/integrationtests/dmap_test.go
+++ b/integrationtests/dmap_test.go
@@ -189,3 +189,59 @@ func TestDMap3(t *testing.T) {
os.Remove(csvFile)
os.Remove(queryFile)
}
+
+func TestDMap4Append(t *testing.T) {
+ if !config.Env("DTAIL_INTEGRATION_TEST_RUN_MODE") {
+ t.Log("Skipping")
+ return
+ }
+ inFile := "mapr_testdata.log"
+ outFile := "dmap4.stdout.tmp"
+ csvFile := "dmap4.csv.tmp"
+ expectedCsvFile := "dmap4.csv.expected"
+ queryFile := fmt.Sprintf("%s.query", csvFile)
+ expectedQueryFile := "dmap4.csv.query.expected"
+
+ // Delete in case it exists already. Otherwise, test will fail.
+ os.Remove(csvFile)
+
+ query := fmt.Sprintf("from STATS select count($time),$time,max($goroutines),"+
+ "avg($goroutines),min($goroutines) group by $time order by count($time) "+
+ "outfile append %s", csvFile)
+
+ ctx, cancel := context.WithCancel(context.Background())
+ defer cancel()
+
+ // Run dmap command twice, it should append in the 2nd iteration the new results to the already existing
+ // fille as we specified "outfile append". That works transparently for any mapreduce query
+ // (e.g. also for the dtail command in streaming mode). But it is easier to test with the dmap
+ // command.
+ for i := 0; i < 2; i++ {
+ stdoutCh, stderrCh, cmdErrCh, err := startCommand(ctx, t,
+ "", "../dmap",
+ "--query", query,
+ "--cfg", "none",
+ "--logger", "stdout",
+ "--logLevel", "info",
+ "--noColor", inFile)
+
+ if err != nil {
+ t.Error(err)
+ return
+ }
+ waitForCommand(ctx, t, stdoutCh, stderrCh, cmdErrCh)
+ }
+
+ if err := compareFilesContents(t, csvFile, expectedCsvFile); err != nil {
+ t.Error(err)
+ return
+ }
+ if err := compareFiles(t, queryFile, expectedQueryFile); err != nil {
+ t.Error(err)
+ return
+ }
+
+ os.Remove(outFile)
+ os.Remove(csvFile)
+ os.Remove(queryFile)
+}
diff --git a/internal/mapr/groupsetresult.go b/internal/mapr/groupsetresult.go
index 40c10fe..4b86025 100644
--- a/internal/mapr/groupsetresult.go
+++ b/internal/mapr/groupsetresult.go
@@ -187,13 +187,23 @@ func (g *GroupSet) WriteResult(query *Query) error {
return err
}
+ // By default, also write the CSV header.
+ writeHeader := true
+
+ // In append mode, only write CSV header when file doesn't exist yet or is empty.
+ if query.Outfile.AppendMode {
+ if info, err := os.Stat(query.Outfile.FilePath); err == nil && info.Size() > 0 {
+ writeHeader = false
+ }
+ }
+
fd, err := g.getOutfileFD(query)
if err != nil {
return err
}
defer fd.Close()
- return g.resultWriteUnformatted(query, rows, fd)
+ return g.resultWriteUnformatted(query, rows, fd, writeHeader)
}
func (g *GroupSet) getOutfileFD(query *Query) (*os.File, error) {
@@ -208,17 +218,19 @@ func (g *GroupSet) getOutfileFD(query *Query) (*os.File, error) {
return os.OpenFile(query.Outfile.FilePath, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644)
}
-func (g *GroupSet) resultWriteUnformatted(query *Query, rows []result, fd *os.File) error {
- // Generate header now
+func (g *GroupSet) resultWriteUnformatted(query *Query, rows []result, fd *os.File, writeHeader bool) error {
lastColumn := len(query.Select) - 1
- for i, sc := range query.Select {
- fd.WriteString(sc.FieldStorage)
- if i == lastColumn {
- continue
+
+ if writeHeader {
+ for i, sc := range query.Select {
+ fd.WriteString(sc.FieldStorage)
+ if i == lastColumn {
+ continue
+ }
+ fd.WriteString(protocol.CSVDelimiter)
}
- fd.WriteString(protocol.CSVDelimiter)
+ fd.WriteString("\n")
}
- fd.WriteString("\n")
// And now write the data
for i, r := range rows {