summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <pbuetow@mimecast.com>2021-12-08 10:19:42 +0000
committerPaul Buetow <pbuetow@mimecast.com>2021-12-08 10:19:42 +0000
commit9a3a005c916479faef417f8e9437f2bf1b38ecdd (patch)
treeba6463e4c44eb623552bc8adfe011b78a291da6b
parente70adfe0d309d511ae7598683003c92795192fe1 (diff)
add where clause integration test to dmap1, all mapreduce token fields are lower case
-rw-r--r--integrationtests/dmap1b.csv.query.expected1
-rw-r--r--integrationtests/dmap_test.go31
-rw-r--r--internal/mapr/token.go4
-rw-r--r--internal/mapr/wherecondition.go1
4 files changed, 23 insertions, 14 deletions
diff --git a/integrationtests/dmap1b.csv.query.expected b/integrationtests/dmap1b.csv.query.expected
new file mode 100644
index 0000000..f6b2d8b
--- /dev/null
+++ b/integrationtests/dmap1b.csv.query.expected
@@ -0,0 +1 @@
+from STATS select count($line),last($time),avg($goroutines),min(concurrentConnections),max(lifetimeConnections) group by $hostname where lifetimeConnections >= 3 outfile dmap1b.csv.tmp \ No newline at end of file
diff --git a/integrationtests/dmap_test.go b/integrationtests/dmap_test.go
index ec14cfb..e408b74 100644
--- a/integrationtests/dmap_test.go
+++ b/integrationtests/dmap_test.go
@@ -15,19 +15,26 @@ func TestDMap1(t *testing.T) {
return
}
- query := fmt.Sprintf("from STATS select count($line),last($time)," +
- "avg($goroutines),min(concurrentConnections),max(lifetimeConnections) " +
- "group by $hostname")
-
- t.Log("Testing dmap with input file")
- if err := testDmap1(t, query, "a", false); err != nil {
- t.Error(err)
- return
+ testTable := map[string]string{
+ "a": "from STATS select count($line),last($time)," +
+ "avg($goroutines),min(concurrentConnections),max(lifetimeConnections) " +
+ "group by $hostname",
+ "b": "from STATS select count($line),last($time)," +
+ "avg($goroutines),min(concurrentConnections),max(lifetimeConnections) " +
+ "group by $hostname where lifetimeConnections >= 3",
}
- t.Log("Testing dmap with stdin input pipe")
- if err := testDmap1(t, query, "a", true); err != nil {
- t.Error(err)
- return
+
+ for subtestName, query := range testTable {
+ t.Log("Testing dmap with input file")
+ if err := testDmap1(t, query, subtestName, false); err != nil {
+ t.Error(err)
+ return
+ }
+ t.Log("Testing dmap with stdin input pipe")
+ if err := testDmap1(t, query, subtestName, true); err != nil {
+ t.Error(err)
+ return
+ }
}
}
diff --git a/internal/mapr/token.go b/internal/mapr/token.go
index 6ac7631..bbf4890 100644
--- a/internal/mapr/token.go
+++ b/internal/mapr/token.go
@@ -37,7 +37,7 @@ func tokenize(queryStr string) []token {
commasStripped := strings.Replace(part, ",", " ", -1)
for _, tokenStr := range strings.Fields(commasStripped) {
token := token{
- str: tokenStr,
+ str: strings.ToLower(tokenStr),
isBareword: true,
}
tokens = append(tokens, token)
@@ -71,7 +71,7 @@ func tokensConsume(tokens []token) ([]token, []token) {
stripped := t.str[1 : length-1]
//dlog.Common.Trace("stripped", stripped)
t := token{
- str: stripped,
+ str: strings.ToLower(stripped),
isBareword: t.isBareword,
}
consumed = append(consumed, t)
diff --git a/internal/mapr/wherecondition.go b/internal/mapr/wherecondition.go
index 280dcfb..c2dd2a1 100644
--- a/internal/mapr/wherecondition.go
+++ b/internal/mapr/wherecondition.go
@@ -54,6 +54,7 @@ func (wc *whereCondition) String() string {
func makeWhereConditions(tokens []token) (where []whereCondition, err error) {
parse := func(tokens []token) (whereCondition, []token, error) {
+
var wc whereCondition
if len(tokens) < 3 {
err := errors.New(invalidQuery + "Not enough arguments in 'where' clause")