Skip to content
Snippets Groups Projects
Verified Commit 752fb97e authored by David Hoese's avatar David Hoese
Browse files

Fix handling of missing influxdb columns

parent 8a9d2850
No related branches found
No related tags found
No related merge requests found
......@@ -337,6 +337,21 @@ def test_shorthand_one_symbol_json_column(client):
assert len(res["results"]["timestamps"]) == 9
@pytest.mark.usefixtures("influxdb_air_temp_9_values")
def test_shorthand_fill_symbol_json_column(client):
"""Test that a valid column that is not available is still present in the result."""
res = client.get("/api/data.json?site=aoss&inst=tower&symbols=air_temp:wind_speed&begin=-00:10:00&order=column")
res = json.loads(res.data.decode())
assert res["code"] == 200
assert res["num_results"] == 9
assert "air_temp" in res["results"]["data"]
assert "wind_speed" in res["results"]["data"]
assert len(res["results"]["data"]["air_temp"]) == 9
assert len(res["results"]["data"]["wind_speed"]) == 9
assert np.isnan(res["results"]["data"]["wind_speed"]).all()
assert len(res["results"]["timestamps"]) == 9
@pytest.mark.usefixtures("influxdb_3_symbols_9_values")
def test_shorthand_two_symbols_json_column_order_check(client):
res1 = _query_with_symbols(client, "air_temp:rel_hum:wind_speed")
......
......@@ -90,7 +90,7 @@ class QueryHandler:
data_frame = frames_for_inst[0]
data_frame = data_frame.drop(columns=["site", "inst"])
# get dataframe into the same order that was requested
data_frame = data_frame[symbol_names]
data_frame = data_frame.reindex(columns=symbol_names)
# "_time" should already be set as the index, so we don't need to rename it
new_column_names = [f"{site}.{inst}.{col_name}" for col_name in data_frame.columns]
data_frame.columns = new_column_names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment