villebro commented on a change in pull request #10684:
URL:
https://github.com/apache/incubator-superset/pull/10684#discussion_r477261207
##########
File path: tests/charts/api_tests.py
##########
@@ -901,3 +901,26 @@ def test_query_exec_not_allowed(self):
payload = get_query_context(table.name, table.id, table.type)
rv = self.post_assert_metric(CHART_DATA_URI, payload, "data")
self.assertEqual(rv.status_code, 401)
+
+ @mock.patch(
+ "superset.common.query_context.config", {**app.config,
"SAMPLES_ROW_LIMIT": 5},
+ )
+ def test_chart_data_jinja_filter_request(self):
+ """
+ Chart data API: Ensure request referencing filters via jinja renders a
correct query
+ """
+ self.login(username="admin")
+ table = self.get_table_by_name("birth_names")
+ request_payload = get_query_context(table.name, table.id, table.type)
+ request_payload["result_type"] = utils.ChartDataResultType.QUERY
+ request_payload["queries"][0]["filters"] = [
+ {"col": "gender", "op": "==", "val": "boy"}
+ ]
+ request_payload["queries"][0]["extras"][
+ "where"
+ ] = "('boy' = '{{ filter_values('gender', 'xyz' )[0] }}')"
+ rv = self.post_assert_metric(CHART_DATA_URI, request_payload, "data")
+ response_payload = json.loads(rv.data.decode("utf-8"))
+ result = response_payload["result"][0]["query"]
+ if get_example_database().backend != "presto":
+ assert "('boy' = 'boy')" in result
Review comment:
@bkyryliuk I looked at why this test wasn't passing for Presto, and it
seems jinja templates aren't being rendered in the Presto CI workflow, which is
apparently also the problem in the other tests that had to be disabled. Not
sure why..
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]