summaryrefslogtreecommitdiff
path: root/internal/mapr/query_test.go
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2022-03-15 11:18:02 +0000
committerPaul Buetow <pbuetow@mimecast.com>2022-03-15 11:18:02 +0000
commit5b8f5b0835fd41ae9a74d2ebce5e9d522de83cb1 (patch)
treed50ab31411a1a13d8fd352aeb670f636cd26b908 /internal/mapr/query_test.go
parent45b2e60f7206f90af977e95e44e2529aa2ce8081 (diff)
parentd9601ca860367ec8ddf6bc5c108c826723a81abd (diff)
Merge branch 'append-query-results-to-outfile-when-in-streaming-mode' into 'master'
Add "append" modifier to "outfile" keyword in mapreduce query. See merge request Storage/dtail!6
Diffstat (limited to 'internal/mapr/query_test.go')
-rw-r--r--internal/mapr/query_test.go46
1 files changed, 45 insertions, 1 deletions
diff --git a/internal/mapr/query_test.go b/internal/mapr/query_test.go
index a0913fd..f03ccba 100644
--- a/internal/mapr/query_test.go
+++ b/internal/mapr/query_test.go
@@ -5,6 +5,48 @@ import (
"time"
)
+func TestParseQueryOutfile(t *testing.T) {
+ queryStr := "select foo from bar outfile \"baz.csv\""
+
+ q, err := NewQuery(queryStr)
+ if err != nil {
+ t.Errorf("Query parse error: %s\n%v: %v", queryStr, q, err)
+ }
+
+ if q.Outfile == nil {
+ t.Errorf("Expected non-nil outfile: %s\n%v", queryStr, q)
+ }
+
+ if q.Outfile.FilePath != "baz.csv" {
+ t.Errorf("Expected \"baz.csv\" as outfile file path: %s\n%v", queryStr, q)
+ }
+
+ if q.Outfile.AppendMode {
+ t.Errorf("Expected append mode of outfile to be false: %s\n%v", queryStr, q)
+ }
+}
+
+func TestParseQueryOutfileAppend(t *testing.T) {
+ queryStr := "select foo from bar outfile append \"baz.csv\""
+
+ q, err := NewQuery(queryStr)
+ if err != nil {
+ t.Errorf("Query parse error: %s\n%v: %v", queryStr, q, err)
+ }
+
+ if q.Outfile == nil {
+ t.Errorf("Expected non-nil outfile: %s\n%v", queryStr, q)
+ }
+
+ if q.Outfile.FilePath != "baz.csv" {
+ t.Errorf("Expected \"baz.csv\" as outfile file path: %s\n%v", queryStr, q)
+ }
+
+ if !q.Outfile.AppendMode {
+ t.Errorf("Expected append mode of outfile to be true: %s\n%v", queryStr, q)
+ }
+}
+
func TestParseQuerySimple(t *testing.T) {
errorQueries := []string{
"select",
@@ -30,7 +72,9 @@ func TestParseQuerySimple(t *testing.T) {
"select foo from bar where baz < 100 bay eq 12 group by foo, bar, baz " +
"order by foo limit 23 outfile \"result.csv\"",
"select foo from bar where baz < 100 bay eq 12 group by foo, bar, baz " +
- "order by foo limit 23 outfile \"result.csv\" " +
+ "order by foo limit 23 outfile append \"result.csv\"",
+ "select foo from bar where baz < 100 bay eq 12 group by foo, bar, baz " +
+ "order by foo limit 23 outfile append \"result.csv\" " +
"set $foo = maskdigits(bar), $baz = 12, $bay = $foo;",
}