Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Sheets Query support in sql processor #1472

Merged
merged 13 commits into from
Nov 17, 2023
Merged

Google Sheets Query support in sql processor #1472

merged 13 commits into from
Nov 17, 2023

Conversation

harshdoesdev
Copy link
Contributor

@harshdoesdev harshdoesdev commented Nov 9, 2023

Background

We are adding support for Google Sheets Query to the sql processor. You can find more information on this and participate in the related discussion.

How it Works

The Google Charts API allows you to query a Google Sheet much like you would with an SQL database, though it currently only supports data retrieval queries such as "SELECT." Our primary objective is to enable users to provide the URL of their Google Sheet as the db parameter for the sql processor. Currently, only public sheets are supported, but we plan to add support for private sheets in the future.

Example:

-- import: fastn/processors as pr

-- record user:
string Name:
integer Age:
string Gender:

-- user list users:
$processor$: pr.sql
db: https://docs.google.com/spreadsheets/d/1FOSZWtfQni0sNLLzbyhHGqzpZcRJx0_TLO8UGtnDXiY
sheet: Sheet1

SELECT *

-- ftd.text: $u.Name
for: $u in $users

Todos

  • Basic Processor Setup
  • Google Charts API Integration
  • Data type conversion
  • Getting a basic demo running
  • Resolve Named parameters
  • Move from CSV to JSON
  • Handle Formatted values
  • Query specific sheet by passing sheet name as sheet
  • Documentation

Updates

  • For now I am going ahead with sheet and db instead of $sheet$ and $db$, we will deprecate these in a follow up PR and replace these with $sheet$and$db$`.
  • Skipping the fbt tests for now, will do manual testing instead. will add fbt tests in a follow up PR

@harshdoesdev harshdoesdev added the In Progress Development is in progress label Nov 9, 2023
@amitu
Copy link
Contributor

amitu commented Nov 13, 2023

@Arpita-Jaiswal can you take a look at the fastn-core/src/library2022/processor/google_sheets.rs, there is a lot of stuff happening there and I want your opinion.

@harshdoesdev
Copy link
Contributor Author

harshdoesdev commented Nov 13, 2023

@amitu I have temporarily removed the timestamp conversion for now. also, I have added a new optional processor argument named sheet where the user can specify the name of the sheet they want to query.

Example:

-- user list users:
$processor$: pr.sql
db: https://docs.google.com/spreadsheets/d/1FOSZWtfQni0sNLLzbyhHGqzpZcRJx0_TLO8UGtnDXiY
sheet: Users
name: John Doe

SELECT * WHERE A = $name::STRING

@amitu
Copy link
Contributor

amitu commented Nov 13, 2023

The sheet argument conflicts if the sheet is a column name. Should we name processor arguments as $<arg-name>$, eg $sheet$: <sheet name> and same with db.

@harshdoesdev
Copy link
Contributor Author

The sheet argument conflicts if the sheet is a column name. Should we name processor arguments as $<arg-name>$, eg $sheet$: <sheet name> and same with db.

I agree, but it should not conflict with the column name because these words are rarely used, and this looks cleaner without '$'. However, this is just my opinion.

@amitu
Copy link
Contributor

amitu commented Nov 13, 2023

It looks cleaner, but if conflict happens user will have no choice. sheet and db are both common enough terms. Let's switch to $foo$ for all processor arguments as this is a general problem and we need a general / consistent solution.

@harshdoesdev
Copy link
Contributor Author

It looks cleaner, but if conflict happens user will have no choice. sheet and db are both common enough terms. Let's switch to $foo$ for all processor arguments as this is a general problem and we need a general / consistent solution.

Yes, although these argument names need not be the same as the column name, many users choose to name them to match the column name. Therefore, I agree that it can lead to conflicts.

@Heulitig Heulitig removed the In Progress Development is in progress label Nov 17, 2023
@Heulitig Heulitig merged commit b9f27a4 into main Nov 17, 2023
1 check passed
@Heulitig Heulitig deleted the google-sheets branch November 17, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants