Repository: joshtemple/lkml

Issue:
Simple Parser unnests `dimensions` and `measures` in `query` fields
For [query](https://docs.looker.com/reference/explore-params/query) fields, the dimensions and measures keys are special - they are kept in plural form, with a list as the value.

When the simple parser parses this field, it sees that it's a pluralized key, and unnests them. Example:
```
In [98]: lkml.dump(
    ...:   {
    ...:     "explores": [
    ...:       {
    ...:         "name": "queried_explore",
    ...:         "queries": [
    ...:           {
    ...:             "dimensions": ["first_dim"],
    ...:             "measures": ["first_meas"],
    ...:             "pivots": ["first_pivot"],
    ...:             "name": "aquery"
    ...:           }
    ...:         ]
    ...:       }
    ...:     ]
    ...:   }
    ...: )
Out[98]: 'explore: queried_explore {\n  query: aquery {\n    dimension: first_dim\n    measure: first_meas\n    pivots: [first_pivot]\n  }\n}'
```

Discussion:

Patch:
diff --git a/lkml/simple.py b/lkml/simple.py
index 0d3b651..275b85c 100644
--- a/lkml/simple.py
+++ b/lkml/simple.py
@@ -226,7 +226,7 @@ class DictParser:
                 singular_key == "allowed_value"
                 and self.parent_key.rstrip("s") == "access_grant"
             )
-            and not (self.parent_key == "query")
+            and not (self.parent_key == "query" and singular_key != "filters")
         )
 
     def resolve_filters(self, values: List[dict]) -> Union[List[BlockNode], ListNode]:


Test patch:
diff --git a/tests/test_simple.py b/tests/test_simple.py
index 2c5a748..be7e84d 100644
--- a/tests/test_simple.py
+++ b/tests/test_simple.py
@@ -268,7 +268,7 @@ def test_parse_query(parser):
             {
                 "name": "query_one",
                 "dimensions": ["dimension_one", "dimension_two"],
-                "measures": ["measure_one"]
+                "measures": ["measure_one"],
             }
         ]
     }
@@ -284,6 +284,32 @@ def test_parse_query(parser):
     )
 
 
+def test_parse_query_with_filters(parser):
+    obj = {
+        "explores": [
+            {
+                "queries": [{"filters__all": [[{"baz": "expression"}, {"qux": "expression"}]], "name": "bar"}],
+                "name": "foo",
+            }
+        ]
+    }
+    node = parser.parse(obj)
+    result = str(node)
+    print(result)
+    assert result == "\n".join(
+        (
+            "explore: foo {",
+            "  query: bar {",
+            "    filters: [",
+            '      baz: "expression",',
+            '      qux: "expression",',
+            "    ]",
+            "  }",
+            "}",
+        )
+    )
+
+
 def test_resolve_filters_filter_only_field(parser):
     nodes = parser.resolve_filters(
         [{"name": "filter_a", "type": "string"}, {"name": "filter_b", "type": "number"}]