bigfunctions > ask_my_data
ask_my_data¶
Call or Deploy ask_my_data
?
✅ You can call this ask_my_data
bigfunction directly from your Google Cloud Project (no install required).
- This
ask_my_data
function is deployed inbigfunctions
GCP project in 39 datasets for all of the 39 BigQuery regions. You need to use the dataset in the same region as your datasets (otherwise you may have a function not found error). - Function is public, so it can be called by anyone. Just copy / paste examples below in your BigQuery console. It just works!
- You may prefer to deploy the BigFunction in your own project if you want to build and manage your own catalog of functions. This is particularly useful if you want to create private functions (for example calling your internal APIs). Discover the framework
Public BigFunctions Datasets:
Region | Dataset |
---|---|
eu |
bigfunctions.eu |
us |
bigfunctions.us |
europe-west1 |
bigfunctions.europe_west1 |
asia-east1 |
bigfunctions.asia_east1 |
... | ... |
Description¶
Signature
ask_my_data(question, fully_qualified_table)
Description
Ask your data any question
in natural language.
This function calls
generate_sql
to convert thequestion
into a SQL query adapted to your data and execute it.
(If the execution fails, the temporary tablebigfunction_result
gives details).
Param | Description |
---|---|
question |
A question to ask over your data. It may start with a verb |
fully_qualified_table |
A table whose schema will be given to the generative AI model for context. - fully_qualified_table format must be like PROJECT.DATASET.TABLE .- fully_qualified_table must exist.- You must have read permission on the table schema |
Examples¶
call bigfunctions.eu.ask_my_data('get the 3 products which generated the most revenue in 2023', 'bigfunctions.eu.sales');
select * from bigfunction_result;
call bigfunctions.us.ask_my_data('get the 3 products which generated the most revenue in 2023', 'bigfunctions.us.sales');
select * from bigfunction_result;
call bigfunctions.europe_west1.ask_my_data('get the 3 products which generated the most revenue in 2023', 'bigfunctions.europe_west1.sales');
select * from bigfunction_result;
+------------+---------+
| product_id | revenue |
+------------+---------+
+ 8 + 50286 |
+ 6 + 46172 |
+ 10 + 27972 |
+------------+---------+
Need help using ask_my_data
?
The community can help! Engage the conversation on Slack
For professional suppport, don't hesitate to chat with us.
Found a bug using ask_my_data
?
If the function does not work as expected, please
- report a bug so that it can be improved.
- or open the discussion with the community on Slack.
For professional suppport, don't hesitate to chat with us.
Use cases¶
A business analyst wants to understand sales data for 2023, specifically which products generated the most revenue. They have a BigQuery table named sales
in their project (e.g., my-project.sales_data.sales
) containing product IDs, revenue figures, and other sales-related information.
Instead of writing a complex SQL query, the analyst uses the ask_my_data
function like so:
CALL bigfunctions.us.ask_my_data(
'Get the 3 products which generated the most revenue in 2023',
'my-project.sales_data.sales'
);
SELECT * FROM bigfunction_result;
This function call takes two arguments:
'Get the 3 products which generated the most revenue in 2023'
: The natural language question the analyst wants to ask the data.'my-project.sales_data.sales'
: The fully qualified name of the table the question pertains to. This allows the function to understand the structure of the data and generate the appropriate SQL query.
The ask_my_data
function then internally translates the natural language question into a SQL query (likely involving aggregation, filtering, and ordering), executes it against the specified table, and stores the results in a temporary table named bigfunction_result
. The analyst can then retrieve the results by querying bigfunction_result
.
This simplified approach allows users without extensive SQL knowledge to extract insights from their data using natural language, making data analysis more accessible and efficient.
Spread the word¶
BigFunctions is fully open-source. Help make it a success by spreading the word!