-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added flag for removing the index on the report CSV
- Loading branch information
1 parent
fe3ba12
commit 8e4dad8
Showing
4 changed files
with
88 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
|
||
def remove_post_processed(url: str) -> str: | ||
"""Remove the type=post_processed parameter from the URL query string. | ||
Args: | ||
url (str): The URL to process. | ||
Returns: | ||
str: The URL with the type=post_processed parameter removed.""" | ||
if "?" not in url: | ||
return url | ||
base_url, query_string = url.split("?", 1) | ||
params = query_string.split("&") | ||
filtered_params = [param for param in params if param != "type=post_processed"] | ||
filtered_query_string = "&".join(filtered_params) | ||
filtered_url = f"{base_url}?{filtered_query_string}" | ||
return filtered_url |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Licensed to the Apache Software Foundation (ASF) under one | ||
# or more contributor license agreements. See the NOTICE file | ||
# distributed with this work for additional information | ||
# regarding copyright ownership. The ASF licenses this file | ||
# to you under the Apache License, Version 2.0 (the | ||
# "License"); you may not use this file except in compliance | ||
# with the License. You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, | ||
# software distributed under the License is distributed on an | ||
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
# KIND, either express or implied. See the License for the | ||
# specific language governing permissions and limitations | ||
# under the License. | ||
|
||
from superset.commands.report.utils import remove_post_processed | ||
|
||
|
||
def test_remove_post_processed(): | ||
url = "https://superset.com/?param1=value1&type=post_processed¶m2=value2" | ||
expected = "https://superset.com/?param1=value1¶m2=value2" | ||
assert remove_post_processed(url) == expected | ||
|
||
|
||
def test_retain_other_parameters(): | ||
url = "https://superset.com/?param1=value1¶m2=value2" | ||
expected = "https://superset.com/?param1=value1¶m2=value2" | ||
assert remove_post_processed(url) == expected | ||
|
||
|
||
def test_no_post_processed_present(): | ||
url = "https://superset.com/?param1=value1¶m2=value2" | ||
expected = "https://superset.com/?param1=value1¶m2=value2" | ||
assert remove_post_processed(url) == expected | ||
|
||
|
||
def test_empty_query_string(): | ||
url = "https://superset.com/?" | ||
expected = "https://superset.com/?" | ||
assert remove_post_processed(url) == expected | ||
|
||
|
||
def test_no_query_string(): | ||
url = "https://superset.com" | ||
expected = "https://superset.com" | ||
assert remove_post_processed(url) == expected |