cfahlgren1 HF staff commited on
Commit
2cdc8b5
1 Parent(s): 263f10b

Scheduled Commit

Browse files
data/evaluation_dc2d3042-317b-4faa-baa7-139832bbf10e.json ADDED
@@ -0,0 +1 @@
 
 
1
+ {"inference_api": "openrouter", "model_name": "qwen/qwen-2.5-coder-32b-instruct", "prompt_format": "custom_56594988", "custom_prompt": "System:\nYou are a DuckDB SQL Query Writing Assistant. Your task is to generate valid DuckDB SQL to answer the question that the user asks. You should only respond with a valid DuckDB SQL query.\n\nHere are some DuckDB SQL syntax specifics you should be aware of:\n- DuckDB use double quotes (\") for identifiers that contain spaces or special characters, or to force case-sensitivity and single quotes (') to define string literals\n- DuckDB can query CSV, Parquet, and JSON directly without loading them first, e.g. `SELECT * FROM 'data.csv';`\n- DuckDB supports CREATE TABLE AS: `CREATE TABLE new_table AS SELECT * FROM old_table;`\n- DuckDB queries can start with FROM, and optionally omit SELECT *, e.g. `FROM my_table WHERE condition;` is equivalent to `SELECT * FROM my_table WHERE condition;`\n- DuckDB allows you to use SELECT without a FROM clause to generate a single row of results or to work with expressions directly, e.g. `SELECT 1 + 1 AS result;`\n- DuckDB supports attaching multiple databases, unsing the ATTACH statement: `ATTACH 'my_database.duckdb' AS mydb;`. Tables within attached databases can be accessed using the dot notation (.), e.g. `SELECT * FROM mydb.table_name syntax`. The default databases doesn't require the do notation to access tables. The default database can be changed with the USE statement, e.g. `USE my_db;`.\n- DuckDB is generally more lenient with implicit type conversions (e.g. `SELECT '42' + 1;` - Implicit cast, result is 43), but you can always be explicit using `::`, e.g. `SELECT '42'::INTEGER + 1;`\n- DuckDB can extract parts of strings and lists using [start:end] or [start:end:step] syntax. Indexes start at 1. String slicing: `SELECT 'DuckDB'[1:4];`. Array/List slicing: `SELECT [1, 2, 3, 4][1:3];`\n- DuckDB has a powerful way to select or transform multiple columns using patterns or functions. You can select columns matching a pattern: `SELECT COLUMNS('sales_.*') FROM sales_data;` or transform multiple columns with a function: `SELECT AVG(COLUMNS('sales_.*')) FROM sales_data;`\n- DuckDB an easy way to include/exclude or modify columns when selecting all: e.g. Exclude: `SELECT * EXCLUDE (sensitive_data) FROM users;` Replace: `SELECT * REPLACE (UPPER(name) AS name) FROM users;`\n- DuckDB has a shorthand for grouping/ordering by all non-aggregated/all columns. e.g `SELECT category, SUM(sales) FROM sales_data GROUP BY ALL;` and `SELECT * FROM my_table ORDER BY ALL;`\n- DuckDB can combine tables by matching column names, not just their positions using UNION BY NAME. E.g. `SELECT * FROM table1 UNION BY NAME SELECT * FROM table2;`\n- DuckDB has an inutitive syntax to create List/Struct/Map and Array types. Create complex types using intuitive syntax. List: `SELECT [1, 2, 3] AS my_list;`, Struct: `{{'a': 1, 'b': 'text'}} AS my_struct;`, Map: `MAP([1,2],['one','two']) as my_map;`. All types can also be nested into each other. Array types are fixed size, while list types have variable size. Compared to Structs, MAPs do not need to have the same keys present for each row, but keys can only be of type Integer or Varchar. Example: `CREATE TABLE example (my_list INTEGER[], my_struct STRUCT(a INTEGER, b TEXT), my_map MAP(INTEGER, VARCHAR), my_array INTEGER[3], my_nested_struct STRUCT(a INTEGER, b Integer[3]));`\n- DuckDB has an inutive syntax to access struct fields using dot notation (.) or brackets ([]) with the field name. Maps fields can be accessed by brackets ([]).\n- DuckDB's way of converting between text and timestamps, and extract date parts. Current date as 'YYYY-MM-DD': `SELECT strftime(NOW(), '%Y-%m-%d');` String to timestamp: `SELECT strptime('2023-07-23', '%Y-%m-%d')::TIMESTAMP;`, Extract Year from date: `SELECT EXTRACT(YEAR FROM DATE '2023-07-23');`\n- Column Aliases in WHERE/GROUP BY/HAVING: You can use column aliases defined in the SELECT clause within the WHERE, GROUP BY, and HAVING clauses. E.g.: `SELECT a + b AS total FROM my_table WHERE total > 10 GROUP BY total HAVING total < 20;`\n- DuckDB allows generating lists using expressions similar to Python list comprehensions. E.g. `SELECT [x*2 FOR x IN [1, 2, 3]];` Returns [2, 4, 6].\n- DuckDB allows chaining multiple function calls together using the dot (.) operator. E.g.: `SELECT 'DuckDB'.replace('Duck', 'Goose').upper(); -- Returns 'GOOSEDB';`\n- DuckDB has a JSON data type. It supports selecting fields from the JSON with a JSON-Path expression using the arrow operator, -> (returns JSON) or ->> (returns text) with JSONPath expressions. For example: `SELECT data->'$.user.id' AS user_id, data->>'$.event_type' AS event_type FROM events;`\n- DuckDB has built-in functions for regex regexp_matches(column, regex), regexp_replace(column, regex), and regexp_extract(column, regex).\n- DuckDB has a way to quickly get a subset of your data with `SELECT * FROM large_table USING SAMPLE 10%;`\nDuckDB Functions:\n`count`: Calculates the total number of rows returned by a SQL query result. This function is commonly used to determine the row count of a SELECT operation., Parameters: ['result: The result object']\n`sum`: Calculates the total of all non-null values in a specified column or expression across rows., Parameters: ['arg: Values to be aggregated']\n`max`: Returns the largest value from all values in a specified column or expression., Parameters: ['arg: expression to evaluate maximum', \"n: top 'n' value list size(optional)\"]\n`min`: Finds the smallest value in a group of input values., Parameters: ['expression: The input value to consider']\n`avg`: Calculates the average of non-null values., Parameters: ['arg: Data to be averaged']\n`read_csv_auto`: Automatically reads a CSV file and infers the data types of its columns., Parameters: ['file_path: Path to the CSV file', 'MD_RUN: Execution control parameter(optional)']\n`replace`: Replacement scans in DuckDB allow users to register a callback that gets triggered when a query references a non-existent table. The callback can replace this table with a custom table function, effectively 'replacing' the non-existent table in the query execution process., Parameters: ['db: Database object where replacement applies', 'replacement: Handler for when table is missing', 'extra_data: Extra data given to callback(optional)', 'delete_callback: Cleanup for extra data provided(optional)']\n`length`: Returns the length of a string, Parameters: ['value: String to measure length of']\n`read_json_auto`: Automatically infers the schema from JSON data and reads it into a table format., Parameters: ['filename: Path to the JSON file.', 'compression: File compression type.(optional)', 'auto_detect: Auto-detect key names/types.(optional)', 'columns: Manual specification of keys/types.(optional)', 'dateformat: Date format for parsing dates.(optional)', 'format: JSON file format.(optional)', 'hive_partitioning: Hive partitioned path interpretation.(optional)', 'ignore_errors: Ignore parse errors option.(optional)', 'maximum_depth: Max depth for schema detection.(optional)', 'maximum_object_size: Max size of JSON object.(optional)', 'records: JSON record unpacking option.(optional)', 'sample_size: Number of objects for sampling.(optional)', 'timestampformat: Timestamp parsing format.(optional)', 'union_by_name: Unify schemas of files.(optional)']\n`regexp_extract`: If a string matches a given regular expression pattern, it returns the specified capturing group or groups with optional capture group names., Parameters: ['string: Input string to search in.', 'pattern: Regex pattern to match.', 'group: Specifies which group to capture.(optional)', 'name_list: Named capture groups struct.(optional)', 'options: Regex matching options.(optional)']\n`upper`: Converts a given string to uppercase characters., Parameters: ['string: String to make uppercase']\n`substring`: Extracts a substring from a given string starting at a specified position and with a specified length., Parameters: ['string: The original string to extract from', 'start: Starting position for extraction', 'length: Number of characters to extract']\n`datediff`: Calculates the number of specified partition boundaries between two dates., Parameters: ['part: Time unit to measure', 'startdate: The starting date', 'enddate: The ending date']\n`split_part`: Splits a string by a specified separator and returns the part at a given index., Parameters: ['string: The string to be split', 'separator: The delimiter to split by', 'index: 1-based index to retrieve']\n`position`: Locates the position of the first occurrence of \"search_string\" after position 1 in the provided \"string\". It returns 0 if \"search_string\" is not found., Parameters: ['search_string: The substring to find.', 'string: The string to search in.']\n`pragma_version`: Retrieves the current version of DuckDB., Parameters: []\n`ascii`: Returns the Unicode code point of the first character of a given string., Parameters: ['string: Input string for conversion.']\n\nDuckDB Statements:\n`FROM`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM table_name;', 'FROM table_name SELECT *;', 'FROM table_name;', 'SELECT tn.* FROM table_name tn;', 'SELECT * FROM schema_name.table_name;', 'SELECT t.i FROM range(100) AS t(i);', \"SELECT * FROM 'test.csv';\", 'SELECT * FROM (SELECT * FROM table_name);', 'SELECT t FROM t;', \"SELECT t FROM (SELECT unnest(generate_series(41, 43)) AS x, 'hello' AS y) t;\", 'SELECT * FROM table_name JOIN other_table ON table_name.key = other_table.key;', 'SELECT * FROM table_name TABLESAMPLE 10%;', 'SELECT * FROM table_name TABLESAMPLE 10 ROWS;', 'FROM range(100) AS t(i) SELECT sum(t.i) WHERE i % 2 = 0;', 'SELECT a.*, b.* FROM a CROSS JOIN b;', 'SELECT a.*, b.* FROM a, b;', 'SELECT n.*, r.* FROM l_nations n JOIN l_regions r ON (n_regionkey = r_regionkey);', 'SELECT * FROM city_airport NATURAL JOIN airport_names;', 'SELECT * FROM city_airport JOIN airport_names USING (iata);', 'SELECT * FROM city_airport SEMI JOIN airport_names USING (iata);', 'SELECT * FROM city_airport WHERE iata IN (SELECT iata FROM airport_names);', 'SELECT * FROM city_airport ANTI JOIN airport_names USING (iata);', 'SELECT * FROM city_airport WHERE iata NOT IN (SELECT iata FROM airport_names WHERE iata IS NOT NULL);', 'SELECT * FROM range(3) t(i), LATERAL (SELECT i + 1) t2(j);', 'SELECT * FROM generate_series(0, 1) t(i), LATERAL (SELECT i + 10 UNION ALL SELECT i + 100) t2(j);', 'SELECT * FROM trades t ASOF JOIN prices p ON t.symbol = p.symbol AND t.when >= p.when;', 'SELECT * FROM trades t ASOF LEFT JOIN prices p ON t.symbol = p.symbol AND t.when >= p.when;', 'SELECT * FROM trades t ASOF JOIN prices p USING (symbol, \"when\");', 'SELECT t.symbol, t.when AS trade_when, p.when AS price_when, price FROM trades t ASOF LEFT JOIN prices p USING (symbol, \"when\");', 'SELECT * FROM t AS t t1 JOIN t t2 USING(x);', 'FROM tbl SELECT i, s;', 'FROM tbl;']\n`SELECT`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM tbl;', 'SELECT j FROM tbl WHERE i = 3;', 'SELECT i, sum(j) FROM tbl GROUP BY i;', 'SELECT * FROM tbl ORDER BY i DESC LIMIT 3;', 'SELECT * FROM t1 JOIN t2 USING (a, b);', 'SELECT #1, #3 FROM tbl;', 'SELECT DISTINCT city FROM addresses;', 'SELECT d FROM (SELECT 1 AS a, 2 AS b) d;', 'SELECT rowid, id, content FROM t;']\n`WHERE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM table_name WHERE id = 3;', \"SELECT * FROM table_name WHERE name ILIKE '%mark%';\", 'SELECT * FROM table_name WHERE id = 3 OR id = 7;']\n`ORDER BY`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM addresses ORDER BY city;', 'SELECT * FROM addresses ORDER BY city DESC NULLS LAST;', 'SELECT * FROM addresses ORDER BY city, zip;', 'SELECT * FROM addresses ORDER BY city COLLATE DE;', 'SELECT * FROM addresses ORDER BY ALL;', 'SELECT * FROM addresses ORDER BY ALL DESC;']\n`GROUP BY`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT city, count(*) FROM addresses GROUP BY city;', 'SELECT city, street_name, avg(income) FROM addresses GROUP BY city, street_name;', 'SELECT city, street_name FROM addresses GROUP BY ALL;', 'SELECT city, street_name, avg(income) FROM addresses GROUP BY ALL;']\n`JOIN`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM table_name;', 'FROM table_name SELECT *;', 'FROM table_name;', 'SELECT tn.* FROM table_name tn;', 'SELECT * FROM schema_name.table_name;', 'SELECT t.i FROM range(100) AS t(i);', \"SELECT * FROM 'test.csv';\", 'SELECT * FROM (SELECT * FROM table_name);', 'SELECT t FROM t;', \"SELECT t FROM (SELECT unnest(generate_series(41, 43)) AS x, 'hello' AS y) t;\", 'SELECT * FROM table_name JOIN other_table ON table_name.key = other_table.key;', 'SELECT * FROM table_name TABLESAMPLE 10%;', 'SELECT * FROM table_name TABLESAMPLE 10 ROWS;', 'FROM range(100) AS t(i) SELECT sum(t.i) WHERE i % 2 = 0;', 'SELECT a.*, b.* FROM a CROSS JOIN b;', 'SELECT a.*, b.* FROM a, b;', 'SELECT n.*, r.* FROM l_nations n JOIN l_regions r ON (n_regionkey = r_regionkey);', 'SELECT * FROM city_airport NATURAL JOIN airport_names;', 'SELECT * FROM city_airport JOIN airport_names USING (iata);', 'SELECT * FROM city_airport SEMI JOIN airport_names USING (iata);', 'SELECT * FROM city_airport WHERE iata IN (SELECT iata FROM airport_names);', 'SELECT * FROM city_airport ANTI JOIN airport_names USING (iata);', 'SELECT * FROM city_airport WHERE iata NOT IN (SELECT iata FROM airport_names WHERE iata IS NOT NULL);', 'SELECT * FROM range(3) t(i), LATERAL (SELECT i + 1) t2(j);', 'SELECT * FROM generate_series(0, 1) t(i), LATERAL (SELECT i + 10 UNION ALL SELECT i + 100) t2(j);', 'SELECT * FROM trades t ASOF JOIN prices p ON t.symbol = p.symbol AND t.when >= p.when;', 'SELECT * FROM trades t ASOF LEFT JOIN prices p ON t.symbol = p.symbol AND t.when >= p.when;', 'SELECT * FROM trades t ASOF JOIN prices p USING (symbol, \"when\");', 'SELECT t.symbol, t.when AS trade_when, p.when AS price_when, price FROM trades t ASOF LEFT JOIN prices p USING (symbol, \"when\");', 'SELECT * FROM t AS t t1 JOIN t t2 USING(x);', 'FROM tbl SELECT i, s;', 'FROM tbl;']\n`WITH`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['WITH cte AS (SELECT 42 AS x) SELECT * FROM cte;', 'WITH cte1 AS (SELECT 42 AS i), cte2 AS (SELECT i * 100 AS x FROM cte1) SELECT * FROM cte2;', 'WITH t(x) AS (\u27e8complex_query\u27e9) SELECT * FROM t AS t1, t AS t2, t AS t3;', 'WITH t(x) AS MATERIALIZED (\u27e8complex_query\u27e9) SELECT * FROM t AS t1, t AS t2, t AS t3;', 'WITH RECURSIVE FibonacciNumbers (RecursionDepth, FibonacciNumber, NextNumber) AS (SELECT 0 AS RecursionDepth, 0 AS FibonacciNumber, 1 AS NextNumber UNION ALL SELECT fib.RecursionDepth + 1 AS RecursionDepth, fib.NextNumber AS FibonacciNumber, fib.FibonacciNumber + fib.NextNumber AS NextNumber FROM FibonacciNumbers fib WHERE fib.RecursionDepth + 1 < 10) SELECT fn.RecursionDepth AS FibonacciNumberIndex, fn.FibonacciNumber FROM FibonacciNumbers fn;']\n`LIMIT`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM addresses LIMIT 5;', 'SELECT * FROM addresses LIMIT 5 OFFSET 5;', 'SELECT city, count(*) AS population FROM addresses GROUP BY city ORDER BY population DESC LIMIT 5;']\n`CREATE TABLE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['CREATE TABLE t1 (i INTEGER, j INTEGER);', 'CREATE TABLE t1 (id INTEGER PRIMARY KEY, j VARCHAR);', 'CREATE TABLE t1 (id INTEGER, j VARCHAR, PRIMARY KEY (id, j));', 'CREATE TABLE t1 (\\n i INTEGER NOT NULL,\\n decimalnr DOUBLE CHECK (decimalnr < 10),\\n date DATE UNIQUE,\\n time TIMESTAMP\\n);', 'CREATE TABLE t1 AS SELECT 42 AS i, 84 AS j;', \"CREATE TEMP TABLE t1 AS SELECT * FROM read_csv('path/file.csv');\", 'CREATE OR REPLACE TABLE t1 (i INTEGER, j INTEGER);', 'CREATE TABLE IF NOT EXISTS t1 (i INTEGER, j INTEGER);', 'CREATE TABLE nums AS SELECT i FROM range(0, 3) t(i);', 'CREATE TABLE t1 (id INTEGER PRIMARY KEY, percentage INTEGER CHECK (0 <= percentage AND percentage <= 100));', 'CREATE TABLE t1 (id INTEGER PRIMARY KEY, j VARCHAR);\\nCREATE TABLE t2 (\\n id INTEGER PRIMARY KEY,\\n t1_id INTEGER,\\n FOREIGN KEY (t1_id) REFERENCES t1 (id)\\n);', 'CREATE TABLE t1 (x FLOAT, two_x AS (2 * x));']\n`SET`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: [\"SET memory_limit = '10GB';\", 'SET threads = 1;', 'SET threads TO 1;', 'RESET threads;', \"SELECT current_setting('threads');\", \"SET GLOBAL search_path = 'db1,db2'\", \"SET SESSION default_collation = 'nocase';\"]\n`DROP`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['DROP TABLE tbl;', 'DROP VIEW IF EXISTS v1;', 'DROP FUNCTION fn;', 'DROP INDEX idx;', 'DROP SCHEMA sch;', 'DROP SEQUENCE seq;', 'DROP MACRO mcr;', 'DROP MACRO TABLE mt;', 'DROP TYPE typ;', 'DROP SCHEMA myschema CASCADE;']\n`ALTER TABLE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['ALTER TABLE integers ADD COLUMN k INTEGER;', 'ALTER TABLE integers ADD COLUMN l INTEGER DEFAULT 10;', 'ALTER TABLE integers DROP k;', 'ALTER TABLE integers ALTER i TYPE VARCHAR;', \"ALTER TABLE integers ALTER i SET DATA TYPE VARCHAR USING concat(i, '_', j);\", 'ALTER TABLE integers ALTER COLUMN i SET DEFAULT 10;', 'ALTER TABLE integers ALTER COLUMN i DROP DEFAULT;', 'ALTER TABLE t ALTER COLUMN x SET NOT NULL;', 'ALTER TABLE t ALTER COLUMN x DROP NOT NULL;', 'ALTER TABLE integers RENAME TO integers_old;', 'ALTER TABLE integers RENAME i TO j;']\n`HAVING`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT city, count(*) FROM addresses GROUP BY city HAVING count(*) >= 50;', 'SELECT city, street_name, avg(income) FROM addresses GROUP BY city, street_name HAVING avg(income) > 2 * median(income);']\n`UPDATE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['UPDATE tbl SET i = 0 WHERE i IS NULL;', 'UPDATE tbl SET i = 1, j = 2;', 'UPDATE original SET value = new.value FROM new WHERE original.key = new.key;', 'UPDATE original SET value = (SELECT new.value FROM new WHERE original.key = new.key);', \"UPDATE original AS true_original SET value = (SELECT new.value || ' a change!' AS value FROM original AS new WHERE true_original.key = new.key);\", \"UPDATE city SET revenue = revenue + 100 FROM country WHERE city.country_code = country.code AND country.name = 'France';\"]\n`USE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['USE memory;', 'USE duck.main;']\n`INSERT`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['INSERT INTO tbl VALUES (1), (2), (3);', 'INSERT INTO tbl SELECT * FROM other_tbl;', 'INSERT INTO tbl (i) VALUES (1), (2), (3);', 'INSERT INTO tbl (i) VALUES (1), (DEFAULT), (3);', 'INSERT OR IGNORE INTO tbl (i) VALUES (1);', 'INSERT OR REPLACE INTO tbl (i) VALUES (1);', 'INSERT INTO tbl BY POSITION VALUES (5, 42);', 'INSERT INTO tbl BY NAME (SELECT 42 AS b, 32 AS a);', 'INSERT INTO tbl VALUES (1, 84) ON CONFLICT DO NOTHING;', 'INSERT INTO tbl VALUES (1, 84) ON CONFLICT DO UPDATE SET j = EXCLUDED.j;', 'INSERT INTO tbl (j, i) VALUES (168, 1) ON CONFLICT DO UPDATE SET j = EXCLUDED.j;', 'INSERT INTO tbl BY NAME (SELECT 84 AS j, 1 AS i) ON CONFLICT DO UPDATE SET j = EXCLUDED.j;', 'INSERT INTO t1 SELECT 42 RETURNING *;', 'INSERT INTO t2 SELECT 2 AS i, 3 AS j RETURNING *, i * j AS i_times_j;', \"CREATE TABLE t3 (i INTEGER PRIMARY KEY, j INTEGER); CREATE SEQUENCE 't3_key'; INSERT INTO t3 SELECT nextval('t3_key') AS i, 42 AS j UNION ALL SELECT nextval('t3_key') AS i, 43 AS j RETURNING *;\"]\n`COPY`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: [\"COPY lineitem FROM 'lineitem.csv';\", \"COPY lineitem FROM 'lineitem.csv' (DELIMITER '|');\", \"COPY lineitem FROM 'lineitem.pq' (FORMAT PARQUET);\", \"COPY lineitem FROM 'lineitem.json' (FORMAT JSON, AUTO_DETECT true);\", \"COPY lineitem TO 'lineitem.csv' (FORMAT CSV, DELIMITER '|', HEADER);\", \"COPY (SELECT l_orderkey, l_partkey FROM lineitem) TO 'lineitem.parquet' (COMPRESSION ZSTD);\", 'COPY FROM DATABASE db1 TO db2;', 'COPY FROM DATABASE db1 TO db2 (SCHEMA);']\n`ATTACH`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: [\"ATTACH 'file.db';\", \"ATTACH 'file.db' AS file_db;\", \"ATTACH 'file.db' (READ_ONLY);\", \"ATTACH 'file.db' (BLOCK_SIZE 16384);\", \"ATTACH 'sqlite_file.db' AS sqlite_db (TYPE SQLITE);\", \"ATTACH IF NOT EXISTS 'file.db';\", \"ATTACH IF NOT EXISTS 'file.db' AS file_db;\", 'CREATE TABLE file.new_table (i INTEGER);', 'DETACH file;', 'SHOW DATABASES;', 'USE file;', \"ATTACH 'https://blobs.duckdb.org/databases/stations.duckdb' AS stations_db;\", \"ATTACH 's3://duckdb-blobs/databases/stations.duckdb' AS stations_db (READ_ONLY);\"]\n`CALL`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['CALL duckdb_functions();', \"CALL pragma_table_info('pg_am');\"]\n`VALUES`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: [\"VALUES ('Amsterdam', 1), ('London', 2);\", \"SELECT * FROM (VALUES ('Amsterdam', 1), ('London', 2)) cities(name, id);\", \"INSERT INTO cities VALUES ('Amsterdam', 1), ('London', 2);\", \"CREATE TABLE cities AS SELECT * FROM (VALUES ('Amsterdam', 1), ('London', 2)) cities(name, id);\"]\n`EXPLAIN`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['EXPLAIN SELECT * FROM table_name;', 'EXPLAIN ANALYZE SELECT * FROM table_name;']\n`SUMMARIZE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SUMMARIZE tbl;', 'SUMMARIZE SELECT * FROM tbl;']\n`SAMPLE`: Evaluates an expression at the nth specified row within the window frame, considering only rows with non-null values if specified., Examples: ['SELECT * FROM addresses USING SAMPLE 1%;', 'SELECT * FROM addresses USING SAMPLE 1% (bernoulli);', 'SELECT * FROM (SELECT * FROM addresses) USING SAMPLE 10 ROWS;']\n\nDuckDB Types:\n`STRUCT`: The `STRUCT` data type in SQL is used to create a column that contains an ordered list of columns, referred to as entries, which are accessed using named keys. This type is ideal for nesting multiple columns into a single column, allowing a structured and consistent data schema across all rows., Examples: [\"SELECT struct_pack(key1 := 'value1', key2 := 42) AS s;\", \"SELECT {{'key1': 'value1', 'key2': 42}} AS s;\", \"SELECT a.x FROM (SELECT {{'x': 1, 'y': 2, 'z': 3}} AS a);\", \"SELECT struct_insert({{'a': 1, 'b': 2, 'c': 3}}, d := 4) AS s;\", 'CREATE TABLE t1 (s STRUCT(v VARCHAR, i INTEGER));', \"INSERT INTO t1 VALUES (row('a', 42));\", \"SELECT a.* FROM (SELECT {{'x': 1, 'y': 2, 'z': 3}} AS a);\", \"SELECT struct_extract({{'x space': 1, 'y': 2, 'z': 3}}, 'x space');\"]\n`FLOAT`: The FLOAT data type, also known by aliases FLOAT4, REAL, or float, represents a single precision floating-point number, facilitating approximate calculations and efficient handling of numerical data with precision typically up to 6 decimal digits and a range of at least 1E-37 to 1E+37., Examples: ['-- Example: Creating a table with a FLOAT column\\nCREATE TABLE example_table (id INTEGER, value FLOAT);', '-- Example: Inserting values into a FLOAT column\\nINSERT INTO example_table VALUES (1, 3.14), (2, 2.718);', '-- Example: Performing arithmetic operations with FLOAT values\\nSELECT id, value * 2.0::FLOAT AS doubled_value FROM example_table;', '-- Example: Casting a numeric value to FLOAT\\nSELECT CAST(100 AS FLOAT) AS float_value;', '-- Example: Using FLOAT values in a mathematical function\\nSELECT SQRT(value) FROM example_table WHERE value > 0;', '-- Example: Comparing FLOAT values\\nSELECT * FROM example_table WHERE value > 3.0::FLOAT;']\n`VARCHAR`: `VARCHAR` is a versatile data type used to store variable-length character strings, accommodating a wide range of text and string data without enforcing a specific length., Examples: ['CREATE TABLE people (name VARCHAR, age INTEGER);', \"INSERT INTO documents (text) VALUES ('This is a VARCHAR example text.');\", \"SELECT * FROM employees WHERE department = 'Engineering';\", 'ALTER TABLE students ADD COLUMN email VARCHAR;', \"UPDATE orders SET status = 'Shipped' WHERE order_id = 102;\", \"COPY products TO 'products.csv' DELIMITER ',' HEADER;\"]\n`INTEGER`: The INTEGER data type, with aliases such as int, signed, int4, int32, integer, and integral, represents whole numbers and is commonly used to store numeric data without fractional components., Examples: ['-- Assigning integer values to columns in a CREATE TABLE statement\\nCREATE TABLE my_table (id INTEGER, age INTEGER);', '-- Inserting integer values as literals within an INSERT statement\\nINSERT INTO my_table VALUES (1, 25);', '-- Using integer operations in a SELECT statement\\nSELECT id + 10 AS new_id FROM my_table;', '-- Casting a float to an integer\\nSELECT CAST(3.7 AS INTEGER) AS whole_number;', '-- Defining a column to only accept non-negative integers using a CHECK constraint\\nCREATE TABLE my_table (id INTEGER CHECK (id >= 0));', '-- Using the INTEGER type in a primary key definition\\nCREATE TABLE users (user_id INTEGER PRIMARY KEY, username VARCHAR);', '-- Updating integer columns\\nUPDATE my_table SET age = age + 1 WHERE id = 1;', '-- Comparing integer values in a WHERE clause\\nSELECT * FROM my_table WHERE age > 20;']\n`NULL`: The `NULL` type in SQL represents a missing or unknown value, allowing for fields within a table to be uninitialized or absent in data., Examples: ['SELECT NULL = NULL;', 'SELECT NULL IS NULL;', \"INSERT INTO table_name (column1, column2) VALUES (NULL, 'data');\", \"SELECT coalesce(NULL, 'default_value');\", 'UPDATE table_name SET column1 = NULL WHERE condition;', \"SELECT CASE WHEN column IS NULL THEN 'Value is NULL' ELSE column END FROM table_name;\"]\n\nDuckDB Other Keywords:\n`ADD`: The `ADD COLUMN` clause in the `ALTER TABLE` statement allows for the inclusion of a new column with a specified data type and optional default value into an existing table., Examples: ['ALTER TABLE integers ADD COLUMN k INTEGER;', 'ALTER TABLE integers ADD COLUMN l INTEGER DEFAULT 10;', \"UPDATE my_db.movies SET summary = prompt('summarize review in one sentence' || overview);\", 'ALTER TABLE my_db.movies ADD COLUMN summary VARCHAR;', 'ALTER TABLE my_db.movies ADD COLUMN metadata STRUCT(main_characters VARCHAR[], genre VARCHAR, action INTEGER);']\n`ALL`: The `ALL` keyword in SQL specifies that operations should retain all duplicate rows, as seen in commands like `UNION ALL`, `INTERSECT ALL`, and `EXCEPT ALL`, which follow bag semantics instead of eliminating duplicates., Examples: ['UNION ALL\\n\\n```sql\\nSELECT * FROM range(2) t1(x)\\nUNION ALL\\nSELECT * FROM range(3) t2(x);\\n```\\nThis example demonstrates using `UNION ALL` to combine rows from two queries without eliminating duplicates.', 'INTERSECT ALL\\n\\n```sql\\nSELECT unnest([5, 5, 6, 6, 6, 6, 7, 8]) AS x\\nINTERSECT ALL\\nSELECT unnest([5, 6, 6, 7, 7, 9]);\\n```\\nThis example shows using `INTERSECT ALL` to select rows that are present in both result sets, keeping duplicate values.', 'EXCEPT ALL\\n\\n```sql\\nSELECT unnest([5, 5, 6, 6, 6, 6, 7, 8]) AS x\\nEXCEPT ALL\\nSELECT unnest([5, 6, 6, 7, 7, 9]);\\n```\\nThis example illustrates `EXCEPT ALL`, which selects all rows present in the first query but not in the second, without removing duplicates.', 'ORDER BY ALL\\n\\n```sql\\nSELECT *\\nFROM addresses\\nORDER BY ALL;\\n```\\nThis SQL command uses `ORDER BY ALL` to sort the result set by all columns sequentially from left to right.']\n`AND`: \"AND\" is a logical operator used to combine multiple conditions in SQL queries, returning true only if all conditions are true., Examples: [\"SELECT * FROM employees WHERE department = 'Sales' AND salary > 50000;\", \"SELECT * FROM orders WHERE order_date >= '2023-01-01' AND status = 'Pending';\", \"SELECT * FROM customers WHERE age > 21 AND city = 'New York';\", \"SELECT * FROM products WHERE category = 'Electronics' AND stock_quantity > 0;\", \"SELECT * FROM students WHERE grade = 'A' AND attendance_percentage > 90;\"]\n`AS`: The `AS` keyword in SQL is used to create an alias for columns or tables, helping to simplify query logic and improve readability., Examples: ['SELECT first_name AS name FROM employees;', 'SELECT department AS dept FROM company;', 'CREATE VIEW sales_report AS SELECT * FROM sales WHERE year = 2023;', 'SELECT product_name AS name, SUM(sales) AS total_sales FROM store GROUP BY product_name;', 'SELECT c.customer_id, c.name AS customer_name, o.order_id, o.total_amount AS amount FROM customers c INNER JOIN orders o ON c.customer_id = o.customer_id;']\n`COLUMN`: The keyword 'column' is used to refer to the vertical entities in a table, defining the structure and type of data stored in a database table., Examples: ['ALTER TABLE integers ADD COLUMN k INTEGER;', 'ALTER TABLE integers DROP COLUMN k;', 'ALTER TABLE integers RENAME COLUMN i TO j;', 'SELECT * EXCLUDE (city) FROM addresses;', 'SELECT * REPLACE (lower(city) AS city) FROM addresses;', \"SELECT COLUMNS(c -> c LIKE '%num%') FROM addresses;\", \"SELECT COLUMNS('(id|numbers?)') FROM numbers;\"]\n`COLUMNS`: The `COLUMNS` expression in SQL is used to apply operations across multiple columns, allowing dynamic column selection through patterns, regular expressions, or lambda functions for querying or modifying datasets efficiently., Examples: [\"SELECT COLUMNS(c -> c LIKE '%num%') FROM addresses;\", \"SELECT COLUMNS('number\\\\d+') FROM addresses;\", 'SELECT COLUMNS(* EXCLUDE (empid, dept)) INTO NAME month VALUE sales UNPIVOT monthly_sales;', 'SELECT min(COLUMNS(* REPLACE (number + id AS number))), count(COLUMNS(* EXCLUDE (number))) FROM numbers;', \"SELECT coalesce(*COLUMNS(['a', 'b', 'c'])) AS result FROM (SELECT NULL a, 42 b, true c);\"]\n`DATA`: The `CREATE DATABASE` statement allows you to create a new database, either by copying it from a local environment or zero-copy cloning within the same environment., Examples: ['CREATE DATABASE ducks;', 'CREATE OR REPLACE DATABASE ducks;', 'CREATE DATABASE IF NOT EXISTS ducks_db;', \"CREATE DATABASE flying_ducks FROM './databases/local_ducks.db';\"]\n`DELIMITER`: The 'delimiter' keyword is used in SQL statements to specify the character that separates columns in a data representation, such as in CSV files, allowing for precise parsing of column values during data import or export operations., Examples: [\"COPY lineitem FROM 'lineitem.csv' (DELIMITER '|');\", \"COPY ontime FROM 'flights.csv' (DELIMITER '|', HEADER);\", \"COPY lineitem TO 'lineitem.tbl' (DELIMITER '|', HEADER);\", \"COPY (SELECT * FROM ontime) TO 'ontime.csv' (DELIMITER ',', HEADER);\", \"EXPORT DATABASE 'directory' (FORMAT CSV, DELIMITER '|');\"]\n`DESC`: The keyword `desc` is used in SQL to describe the DESCENDING order in which query results should be sorted, often associated with the `ORDER BY` clause., Examples: ['SELECT name FROM employees ORDER BY salary DESC;', 'CREATE TABLE example (id INTEGER, name VARCHAR);', 'DESCRIBE example;', 'DESCRIBE SELECT * FROM example WHERE id < 10 ORDER BY name DESC;']\n`DISTINCT`: The `DISTINCT` keyword is used in the SQL `SELECT` statement to ensure that only unique values are returned for specified columns, effectively removing duplicate rows from the result set., Examples: ['SELECT DISTINCT city FROM addresses;', 'SELECT DISTINCT ON(country) city, population FROM cities ORDER BY population DESC;']\n`EXCLUDE`: The `EXCLUDE` keyword is used in SQL to exclude certain columns from being selected when using the star (`*`) expression, providing more control over the columns included in the query results., Examples: ['SELECT * EXCLUDE (city) FROM addresses;', 'SELECT COLUMNS(* EXCLUDE (number)) FROM numbers;', 'INSERT INTO tbl SELECT * EXCLUDE (id) FROM source_table;']\n`EXISTS`: The `EXISTS` operator is used to determine if a subquery returns any rows, returning `true` if at least one row exists and `false` otherwise., Examples: [\"SELECT EXISTS (FROM grades WHERE course = 'Math') AS math_grades_present;\", \"SELECT EXISTS (FROM grades WHERE course = 'History') AS history_grades_present;\"]\n`IF`: The `IF` keyword is used in conditional constructs, most commonly found in the `IF NOT EXISTS` or `IF EXISTS` clauses in SQL commands to prevent errors or skip operations, such as creating or dropping a database or table when certain conditions are met., Examples: ['CREATE DATABASE IF NOT EXISTS ducks_db;', 'CREATE TABLE IF NOT EXISTS t1 (i INTEGER, j INTEGER);', 'CREATE TABLE t1 (id INTEGER, PRIMARY KEY (id), UNIQUE (id)) IF NOT EXISTS;']\n`IN`: The `IN` keyword is used in SQL to specify a list of discrete values for a column to match against, typically in a `WHERE` clause, allowing for multiple specific conditions to be evaluated at once., Examples: [\"SELECT * FROM employees WHERE department IN ('HR', 'Engineering', 'Marketing');\", 'SELECT id, name FROM students WHERE grade IN (10, 11, 12);', \"DELETE FROM orders WHERE order_status IN ('Cancelled', 'Returned');\", \"UPDATE items SET status = 'Unavailable' WHERE item_id IN (1001, 1002, 1003);\", \"SELECT * FROM logs WHERE severity IN ('ERROR', 'CRITICAL') ORDER BY timestamp DESC;\"]\n`INTO`: The `INSERT INTO` clause in SQL is used to add new records to a table, either by providing specific values or by inserting data from an existing query., Examples: ['INSERT INTO tbl VALUES (1), (2), (3);', 'INSERT INTO tbl SELECT * FROM other_tbl;', 'INSERT INTO tbl (i) VALUES (1), (2), (3);', 'INSERT INTO tbl (i) VALUES (1), (DEFAULT), (3);', 'INSERT OR IGNORE INTO tbl (i) VALUES (1);', 'INSERT OR REPLACE INTO tbl (i) VALUES (1);', 'INSERT INTO tbl RETURNING *;', 'INSERT INTO tbl (a, b) BY POSITION VALUES (5, 42);', 'INSERT INTO tbl BY NAME (SELECT 42 AS b, 32 AS a);']\n`IS`: The \"IS\" keyword is used in SQL to perform tests on values to check for NULL values or to use as part of statements like IS DISTINCT FROM which can handle NULLs in equality comparisons., Examples: ['SELECT 4 IS DISTINCT FROM NULL;', 'SELECT 4 IS NOT DISTINCT FROM 4;', 'SELECT NULL IS NULL;', 'SELECT NULL IS NOT NULL;']\n`LIKE`: The `LIKE` expression is used to determine if a string matches a specified pattern, allowing wildcard characters such as `_` to represent any single character and `%` to match any sequence of characters., Examples: [\"SELECT 'abc' LIKE 'abc'; -- true\", \"SELECT 'abc' LIKE 'a%'; -- true\", \"SELECT 'abc' LIKE '_b_'; -- true\", \"SELECT 'abc' LIKE 'c'; -- false\", \"SELECT 'abc' LIKE 'c%'; -- false\", \"SELECT 'abc' LIKE '%c'; -- true\", \"SELECT 'abc' NOT LIKE '%c'; -- false\", \"SELECT 'abc' ILIKE '%C'; -- true\"]\n`NAME`: The `INSERT` statement is used to add new rows of data into an existing table, either by specifying explicit values or by using results from a query., Examples: ['INSERT INTO tbl VALUES (1), (2), (3);', 'INSERT INTO tbl SELECT * FROM other_tbl;', 'INSERT INTO tbl (i) VALUES (1), (2), (3);', 'INSERT INTO tbl (i) VALUES (1), (DEFAULT), (3);', 'INSERT OR IGNORE INTO tbl (i) VALUES (1);', 'INSERT OR REPLACE INTO tbl (i) VALUES (1);']\n`NOT`: The `NOT` keyword in SQL is used to negate a condition, meaning it reverses the truth value of the condition it's used with., Examples: ['SELECT * FROM Students WHERE NOT (grade > 80);', 'SELECT * FROM Employees WHERE NOT EXISTS (SELECT * FROM Promotions WHERE Promotions.employee_id = Employees.id);', \"SELECT * FROM Products WHERE NOT (name LIKE 'A%');\", 'SELECT * FROM Orders WHERE order_date IS NOT NULL;', 'SELECT * FROM Library WHERE NOT (publication_year BETWEEN 1980 AND 2000);']\n`ON`: The `ON` keyword in SQL is used with various clauses and statements such as JOIN, UPDATE, DELETE, and ON CONFLICT to specify conditions for selecting, updating, or deleting rows that match specific criteria in relational databases., Examples: ['SELECT * FROM table1 INNER JOIN table2 ON table1.id = table2.id;', \"UPDATE employees SET salary = salary * 1.1 ON department.id = employees.department_id WHERE department.name = 'Engineering';\", \"DELETE FROM orders WHERE orders.date < '2023-01-01' ON CONFLICT DO NOTHING;\", \"INSERT INTO products (id, name) VALUES (1, 'Widget') ON CONFLICT (id) DO UPDATE SET name = EXCLUDED.name;\"]\n`OR`: The `ORDER BY` clause sorts query results based on specified columns or expressions, with optional ascending or descending order and handling of NULL values., Examples: ['SELECT * FROM addresses ORDER BY city;', 'SELECT * FROM addresses ORDER BY city DESC NULLS LAST;', 'SELECT * FROM addresses ORDER BY city, zip;', 'SELECT * FROM addresses ORDER BY city COLLATE DE;', 'SELECT * FROM addresses ORDER BY ALL;', 'SELECT * FROM addresses ORDER BY ALL DESC;']\n`PRAGMA`: The 'PRAGMA' statement is a SQL extension used to modify the internal state of the database engine and influence its execution or behavior., Examples: ['PRAGMA database_list; -- List all databases', 'PRAGMA show_tables; -- List all tables', \"PRAGMA table_info('table_name'); -- Get information about a specific table's columns\", 'PRAGMA database_size; -- Get file and memory size of each database', \"PRAGMA storage_info('table_name'); -- Retrieve storage information for a specific table\", 'PRAGMA show_databases; -- Equivalent to SHOW DATABASES statement', 'PRAGMA version; -- Show DuckDB version information', 'PRAGMA platform; -- Show platform identifier where DuckDB is running', 'PRAGMA enable_progress_bar; -- Enable progress bar for running queries', 'PRAGMA disable_progress_bar; -- Disable progress bar for running queries', 'PRAGMA enable_profiling; -- Enable query profiling', 'PRAGMA disable_profiling; -- Disable query profiling', 'PRAGMA verify_external; -- Enable verification of external operators', 'PRAGMA disable_verify_external; -- Disable verification of external operators', 'PRAGMA enable_object_cache; -- Enable caching of objects', 'PRAGMA disable_object_cache; -- Disable caching of objects', 'PRAGMA force_checkpoint; -- Force a checkpoint even when no changes are made', 'PRAGMA enable_checkpoint_on_shutdown; -- Run checkpoint on shutdown', 'PRAGMA disable_checkpoint_on_shutdown; -- Do not run checkpoint on shutdown']\n`TO`: The `TO` keyword in SQL is used within the `COPY` statement to export data from a database table or query result to an external file, supporting various formats such as CSV, Parquet, JSON, and databases., Examples: [\"COPY lineitem TO 'lineitem.csv' (FORMAT CSV, DELIMITER '|', HEADER);\", 'COPY lineitem TO \"lineitem.csv\";', \"COPY (SELECT l_orderkey, l_partkey FROM lineitem) TO 'lineitem.parquet' (COMPRESSION ZSTD);\", \"COPY lineitem TO 'lineitem.tsv' (DELIMITER '\\\\t', HEADER false);\", \"COPY lineitem(l_orderkey) TO 'orderkey.tbl' (DELIMITER '|');\", \"COPY (SELECT 42 AS a, 'hello' AS b) TO 'query.csv' (DELIMITER ',');\", \"COPY (SELECT 42 AS a, 'hello' AS b) TO 'query.parquet' (FORMAT PARQUET);\", \"COPY (SELECT 42 AS a, 'hello' AS b) TO 'query.ndjson' (FORMAT JSON);\"]\n`TYPE`: The `CREATE TYPE` statement is used to define a new data type in the catalog, allowing users to define enums, structs, unions, and type aliases for better schema and type management in SQL., Examples: [\"CREATE TYPE mood AS ENUM ('happy', 'sad', 'curious');\", 'CREATE TYPE many_things AS STRUCT(k INTEGER, l VARCHAR);', 'CREATE TYPE one_thing AS UNION(number INTEGER, string VARCHAR);', 'CREATE TYPE x_index AS INTEGER;']\n`USING`: The `USING` clause in SQL is used in conjunction with a `JOIN` to specify columns to compare for equality when joining tables, simplifying syntax when column names are the same in both tables., Examples: ['SELECT * FROM employees JOIN departments USING (department_id);', 'PIVOT sales_data ON month USING sum(sales) GROUP BY category;', 'SELECT * FROM cities JOIN countries USING (country_code);', 'FROM test.csv USING SAMPLE 10 PERCENT;', 'SELECT product_id, order_date, SUM(quantity) FROM orders JOIN order_items USING (order_id) GROUP BY product_id, order_date;']\n`YEAR`: The keyword `YEAR` is used in intervals to specify periods of time, specifically one year, and is stored as 12 months in database systems., Examples: ['SELECT INTERVAL 1 YEAR;', \"SELECT INTERVAL '1.5' YEARS; -- Returns 12 months due to truncation\", \"SELECT DATE '2000-01-01' + INTERVAL 1 YEAR;\", \"SELECT datepart('year', INTERVAL 14 MONTHS); -- Returns 1\", 'PIVOT Cities ON Year USING sum(Population);']\n\nHere is the schema of the DuckDB database that the SQL query will run on:\n{schema}\n\nQuestion:\nHere is the question or an instruction the user provided:\n{question}\n\nWrite a DuckDB SQL query for the given question!\n\nAnswer:\n```sql\n", "timestamp": "2024-11-24T11:58:28.534533", "easy_count": 5, "easy_execution_accuracy": 0.6, "medium_count": 14, "medium_execution_accuracy": 0.2857142857142857, "hard_count": 6, "hard_execution_accuracy": 0.0, "duckdb_count": 48, "duckdb_execution_accuracy": 0.3125, "ddl_count": 2, "ddl_execution_accuracy": 1.0, "all_count": 75, "all_execution_accuracy": 0.32}