mirror of
https://github.com/apache/superset.git
synced 2026-04-18 07:35:09 +00:00
fix(gsheets): add column names on file upload (#24963)
This commit is contained in:
@@ -410,10 +410,12 @@ class GSheetsEngineSpec(ShillelaghEngineSpec):
|
||||
spreadsheet_url = payload["spreadsheetUrl"]
|
||||
|
||||
# insert data
|
||||
data = df.fillna("").values.tolist()
|
||||
data.insert(0, df.columns.values.tolist())
|
||||
body = {
|
||||
"range": range_,
|
||||
"majorDimension": "ROWS",
|
||||
"values": df.fillna("").values.tolist(),
|
||||
"values": data,
|
||||
}
|
||||
url = (
|
||||
"https://sheets.googleapis.com/v4/spreadsheets/"
|
||||
|
||||
@@ -333,7 +333,7 @@ def test_upload_new(mocker: MockFixture) -> None:
|
||||
database = mocker.MagicMock()
|
||||
database.get_extra.return_value = {}
|
||||
|
||||
df = pd.DataFrame([1, "foo", 3.0])
|
||||
df = pd.DataFrame({"col": [1, "foo", 3.0]})
|
||||
table = Table("sample_data")
|
||||
|
||||
GSheetsEngineSpec.df_to_sql(database, table, df, {})
|
||||
@@ -367,7 +367,7 @@ def test_upload_existing(mocker: MockFixture) -> None:
|
||||
"engine_params": {"catalog": {"sample_data": "https://docs.example.org"}}
|
||||
}
|
||||
|
||||
df = pd.DataFrame([1, "foo", 3.0])
|
||||
df = pd.DataFrame({"col": [1, "foo", 3.0]})
|
||||
table = Table("sample_data")
|
||||
|
||||
with pytest.raises(SupersetException) as excinfo:
|
||||
@@ -392,7 +392,7 @@ def test_upload_existing(mocker: MockFixture) -> None:
|
||||
json={
|
||||
"range": "sheet0",
|
||||
"majorDimension": "ROWS",
|
||||
"values": [[1], ["foo"], [3.0]],
|
||||
"values": [["col"], [1], ["foo"], [3.0]],
|
||||
},
|
||||
params={"valueInputOption": "USER_ENTERED"},
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user