bigfunctions > generate_sql
generate_sql¶
Signature
generate_sql(question, fully_qualified_table)
Description
Transform question
to a SQL query.
This function sends the following enriched question to
ask_ai
(the schema offully_qualified_table
is sent so that the generated SQL query is adapted to your data):Question: {{question}} Table: {{fully_qualified_table}} Columns: {{columns of fully_qualified_table}} Answer: bigquery sql query
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.generate_sql('get the 3 products which generated the most revenue in 2023', 'eu.sales');
select * from bigfunction_result;
call bigfunctions.us.generate_sql('get the 3 products which generated the most revenue in 2023', 'us.sales');
select * from bigfunction_result;
call bigfunctions.europe_west1.generate_sql('get the 3 products which generated the most revenue in 2023', 'europe_west1.sales');
select * from bigfunction_result;
+---------------+-------------------+-------------------------+
| generated_sql | question | raw_answer_before_clean |
+---------------+-------------------+-------------------------+
+ SELECT ... + Question: get ... | sql``` SELECT... |
+---------------+-------------------+-------------------------+