Skip to content

Commit

Permalink
Merge branch 'main' into private-key-filename-standardize
Browse files Browse the repository at this point in the history
  • Loading branch information
archiewood committed Nov 20, 2024
2 parents a07e32a + dc84c90 commit a78152d
Show file tree
Hide file tree
Showing 4 changed files with 10,085 additions and 14 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/MainDistributionPipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ jobs:
duckdb_version: main
ci_tools_version: main
extension_name: gsheets
exclude_archs: 'windows_amd64_rtools'
exclude_archs: "windows_amd64_rtools"

duckdb-stable-build:
name: Build extension binaries
uses: duckdb/extension-ci-tools/.github/workflows/[email protected].1
uses: duckdb/extension-ci-tools/.github/workflows/[email protected].3
with:
duckdb_version: v1.1.1
ci_tools_version: v1.1.1
duckdb_version: v1.1.3
ci_tools_version: v1.1.3
extension_name: gsheets
exclude_archs: 'windows_amd64_rtools'
exclude_archs: "windows_amd64_rtools"

duckdb-stable-deploy:
name: Deploy extension binaries
needs: duckdb-stable-build
uses: ./.github/workflows/_extension_deploy.yml
secrets: inherit
with:
duckdb_version: v1.1.1
duckdb_version: v1.1.3
extension_name: gsheets
exclude_archs: 'windows_amd64_rtools'
exclude_archs: "windows_amd64_rtools"
deploy_latest: ${{ startsWith(github.ref, 'refs/tags/v') || github.ref == 'refs/heads/main' }}
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[submodule "duckdb"]
path = duckdb
url = https://github.com/duckdb/duckdb
branch = main
branch = v1.1-eatoni
[submodule "extension-ci-tools"]
path = extension-ci-tools
url = https://github.com/duckdb/extension-ci-tools
branch = main
branch = v1.1.3
33 changes: 28 additions & 5 deletions src/gsheets_copy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,33 @@ namespace duckdb

// If writing, clear out the entire sheet first.
// Do this here in the initialization so that it only happens once
std::string response = delete_sheet_data(spreadsheet_id, token, encoded_sheet_name);
std::string delete_response = delete_sheet_data(spreadsheet_id, token, encoded_sheet_name);

// Write out the headers to the file here in the Initialize so they are only written once
// Create object ready to write to Google Sheet
json sheet_data;

sheet_data["range"] = sheet_name;
sheet_data["majorDimension"] = "ROWS";

vector<string> headers = bind_data.Cast<GSheetWriteBindData>().options.name_list;

vector<vector<string>> values;
values.push_back(headers);
sheet_data["values"] = values;

// Convert the JSON object to a string
std::string request_body = sheet_data.dump();

// Make the API call to write data to the Google Sheet
// Today, this is only append.
std::string response = call_sheets_api(spreadsheet_id, token, encoded_sheet_name, HttpMethod::POST, request_body);

// Check for errors in the response
json response_json = parseJson(response);
if (response_json.contains("error")) {
throw duckdb::IOException("Error writing to Google Sheet: " + response_json["error"]["message"].get<std::string>());
}

return make_uniq<GSheetCopyGlobalState>(context, spreadsheet_id, token, encoded_sheet_name);
}
Expand All @@ -119,12 +145,9 @@ namespace duckdb
json sheet_data;

sheet_data["range"] = sheet_name;
sheet_data["majorDimension"] = "ROWS";

vector<string> headers = bind_data_p.Cast<GSheetWriteBindData>().options.name_list;
sheet_data["majorDimension"] = "ROWS";

vector<vector<string>> values;
values.push_back(headers);

for (idx_t r = 0; r < input.size(); r++)
{
Expand Down
Loading

0 comments on commit a78152d

Please sign in to comment.