diff --git a/executor_test.go b/executor_test.go index d3b959302..e20d92fe9 100644 --- a/executor_test.go +++ b/executor_test.go @@ -7246,6 +7246,15 @@ toronto,2,11 }, csvVerifier: "pilosa\nzebra\nicecream\n", }, + { + query: "Rows(affinity<0),field=likes)", + qrVerifier: func(t *testing.T, resp pilosa.QueryResponse) { + if !reflect.DeepEqual(resp.Results[0].(*pilosa.Row).Keys, []string{"pilosa", "zebra", "icecream"}) { + t.Errorf("wrong values: %+v", resp.Results[0]) + } + }, + csvVerifier: "pilosa\nzebra\nicecream\n", + }, { query: "Distinct(Row(affinity>0),field=likes)", qrVerifier: func(t *testing.T, resp pilosa.QueryResponse) { diff --git a/pql/pql.peg b/pql/pql.peg index ec6241398..8d7841f5f 100644 --- a/pql/pql.peg +++ b/pql/pql.peg @@ -54,7 +54,7 @@ singlequotedstring <- ( '\\\'' / '\\\\' / '\\n' / '\\t' / [^'\\] )* fieldExpr <- ( [[A-Z]] / '_' ) ( [[A-Z]] / [0-9] / '_' / '-' )* field <- { p.addField(text) } reserved <- '_row' / '_col' / '_start' / '_end' / '_timestamp' / '_field' -posfield <- { p.addPosStr("_field", text) } +posfield <- 'field='? { p.addPosStr("_field", text) } col <- < digits > {p.addPosNum("_col", text)} / < '\'' singlequotedstring '\'' > {p.addPosStr("_col", text)} / < '"' doublequotedstring '"' > {p.addPosStr("_col", text)} diff --git a/pql/pqlpeg_test.go b/pql/pqlpeg_test.go index 12b9e4b15..bbac8337e 100644 --- a/pql/pqlpeg_test.go +++ b/pql/pqlpeg_test.go @@ -425,6 +425,54 @@ func TestPQLDeepEquality(t *testing.T) { {Name: "Row", Args: map[string]interface{}{"unicode": "Æ�漢д ☮♬ ♞🜻💣"}}, }, }}, + { + name: "TopK", + call: "TopK(myfield, Row(), a=7)", + exp: &Call{ + Name: "TopK", + Args: map[string]interface{}{ + "a": int64(7), + "_field": "myfield", + }, + Children: []*Call{ + {Name: "Row"}, + }, + }}, + { + name: "TopKWithField=", + call: "TopK(field=myfield, Row(), a=7)", + exp: &Call{ + Name: "TopK", + Args: map[string]interface{}{ + "a": int64(7), + "_field": "myfield", + }, + Children: []*Call{ + {Name: "Row"}, + }, + }}, + { + name: "Rows", + call: "Rows(myfield, 9, z=4)", + exp: &Call{ + Name: "Rows", + Args: map[string]interface{}{ + "z": int64(4), + "_field": "myfield", + "_row": int64(9), + }, + }}, + { + name: "RowsWithField=", + call: "Rows(field=myfield, 9, z=4)", + exp: &Call{ + Name: "Rows", + Args: map[string]interface{}{ + "z": int64(4), + "_field": "myfield", + "_row": int64(9), + }, + }}, { name: "SetRowAttrs", call: "SetRowAttrs(myfield, 9, z=4)", @@ -436,6 +484,17 @@ func TestPQLDeepEquality(t *testing.T) { "_row": int64(9), }, }}, + { + name: "SetRowAttrsWithField=", + call: "SetRowAttrs(field=myfield, 9, z=4)", + exp: &Call{ + Name: "SetRowAttrs", + Args: map[string]interface{}{ + "z": int64(4), + "_field": "myfield", + "_row": int64(9), + }, + }}, { name: "SetRowAttrsWithRowKeySingleQuote", call: "SetRowAttrs(myfield, 'rowKey', z=4)", @@ -522,6 +581,19 @@ func TestPQLDeepEquality(t *testing.T) { {Name: "Row"}, }, }}, + { + name: "TopNwithField=", + call: "TopN(field=myfield, Row(), a=7)", + exp: &Call{ + Name: "TopN", + Args: map[string]interface{}{ + "a": int64(7), + "_field": "myfield", + }, + Children: []*Call{ + {Name: "Row"}, + }, + }}, { name: "RangeEQ", call: "Row(a==7)",