{"question": "Write the DDL statement from PostgreSQL regression test 'update' (example 214).", "schema": null, "sql": "CREATE TABLE list_parted (\n\ta text,\n\tb int\n) PARTITION BY list (a);", "explanation": "DDL from PostgreSQL core regression test for Update.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "advanced", "category": "ddl_table", "is_postgresql_specific": true, "sql_length": 67, "num_statements": 1}
{"question": "pgTAP test for Hastap (assertion 40).", "schema": null, "sql": "SELECT * FROM check_test(\n hasnt_table( '__SDFSDFD__', 'lol'::name ),\n true,\n 'hasnt_table(non-existent schema, tab)',\n 'Table \"__SDFSDFD__\".lol should not exist',\n ''\n);", "explanation": "SQL assertion from pgTAP test suite for Hastap.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 185, "num_statements": 1}
{"question": "PostgreSQL regression test 'xml': Write the SELECT query (example 186).", "schema": null, "sql": "SELECT COUNT(id) FROM xmltest, query WHERE xmlexists(expr PASSING BY REF data);", "explanation": "Regression test for Xml in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT COUNT(id) FROM xmltest, query WHERE xmlexists(expr PASSING BY REF data)) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "intermediate", "category": "query_select", "is_postgresql_specific": false, "sql_length": 79, "num_statements": 1}
{"question": "PostgreSQL regression test 'float4': Write the SELECT query (example 35).", "schema": null, "sql": "SELECT ' -INFINiTY '::float4;", "explanation": "Regression test for Float4 in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT ' -INFINiTY '::float4) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 40, "num_statements": 1}
{"question": "Write the DML statement from PostgreSQL regression test 'incremental_sort' (example 124).", "schema": null, "sql": "insert into prt_tbl select i%200, i from generate_series(1,1000)i;", "explanation": "DML from PostgreSQL core regression test for Incremental Sort.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 66, "num_statements": 1}
{"question": "PostgreSQL regression test 'privileges': Write the SELECT query (example 152).", "schema": null, "sql": "SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) );", "explanation": "Regression test for Privileges in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT * FROM atest2 WHERE ( col1 IN ( SELECT b FROM atest1 ) )) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 64, "num_statements": 1}
{"question": "PL/pgSQL test: Plpgsql Domain (example 31).", "schema": null, "sql": "SELECT * FROM test_argresult_array_domain(ARRAY[0, 100]::ordered_pair_domain);", "explanation": "PL/pgSQL example from PostgreSQL source test for Plpgsql Domain.", "validation_query": null, "source": "plpgsql_source", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 78, "num_statements": 1}
{"question": "PostgreSQL regression test 'foreign_key': Write the SELECT query (example 505).", "schema": null, "sql": "select conname from pg_constraint where conrelid = 'fktable2'::regclass order by conname;", "explanation": "Regression test for Foreign Key in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select conname from pg_constraint where conrelid = 'fktable2'::regclass order by conname) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 89, "num_statements": 1}
{"question": "PL/pgSQL test: Pltcl Setup (example 4).", "schema": null, "sql": "create function tcl_argisnull(text) returns bool as '\n argisnull 1\n' language pltcl;", "explanation": "PL/pgSQL example from PostgreSQL source test for Pltcl Setup.", "validation_query": null, "source": "plpgsql_source", "difficulty": "basic", "category": "other", "is_postgresql_specific": false, "sql_length": 87, "num_statements": 1}
{"question": "Write the DML statement from PostgreSQL regression test 'sequence' (example 38).", "schema": null, "sql": "INSERT INTO serialTest2 (f1, f6)\n VALUES ('bogus', -9223372036854775809);", "explanation": "DML from PostgreSQL core regression test for Sequence.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 74, "num_statements": 1}
{"question": "pgTAP test for Resultset (assertion 93).", "schema": null, "sql": "INSERT INTO names (name) VALUES ('Makayla');", "explanation": "SQL assertion from pgTAP test suite for Resultset.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 44, "num_statements": 1}
{"question": "PostgreSQL regression test 'horology': Write the SELECT query (example 364).", "schema": null, "sql": "SELECT to_date('-100000000', 'CC');", "explanation": "Regression test for Horology in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT to_date('-100000000', 'CC')) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 35, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'sequence' (example 4).", "schema": null, "sql": "CREATE SEQUENCE sequence_testx INCREMENT BY -1 START 10;", "explanation": "DDL from PostgreSQL core regression test for Sequence.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "other", "is_postgresql_specific": false, "sql_length": 56, "num_statements": 1}
{"question": "Write the DML statement from PostgreSQL regression test 'create_misc' (example 19).", "schema": null, "sql": "INSERT INTO d_star (class, a, b, c)\n VALUES ('d', 8, 'stumble'::text, 'hi koko'::name);", "explanation": "DML from PostgreSQL core regression test for Create Misc.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 89, "num_statements": 1}
{"question": "PostgreSQL regression test 'errors': Write the SELECT query (example 10).", "schema": null, "sql": "select null from pg_database group by grouping sets (()) for update;", "explanation": "Regression test for Errors in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select null from pg_database group by grouping sets (()) for update) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "advanced", "category": "query_aggregation", "is_postgresql_specific": true, "sql_length": 68, "num_statements": 1}
{"question": "pgTAP test for Aretap (assertion 108).", "schema": null, "sql": "SELECT * FROM check_test(\n languages_are( array_append(___mylangs(''), 'plomgwtf'), 'whatever' ),\n false,\n 'languages_are(languages, desc) missing',\n 'whatever',\n ' Missing languages:\n plomgwtf'\n);", "explanation": "SQL assertion from pgTAP test suite for Aretap.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 222, "num_statements": 1}
{"question": "PL/pgSQL test: Plpgsql Simple (example 5).", "schema": null, "sql": "create function simple1.simpletarget(int) returns int language plpgsql\nas $$begin return $1; end$$;\n\ncreate function simpletarget(int) returns int language plpgsql\nas $$begin return $1 + 100; end$$;", "explanation": "PL/pgSQL example from PostgreSQL source test for Plpgsql Simple.", "validation_query": null, "source": "plpgsql_source", "difficulty": "basic", "category": "plpgsql_function", "is_postgresql_specific": true, "sql_length": 198, "num_statements": 4}
{"question": "PostgreSQL regression test 'rowsecurity': Write the SELECT query (example 830).", "schema": null, "sql": "SELECT attname, most_common_vals FROM pg_stats\n WHERE tablename = 'current_check'\n ORDER BY 1;", "explanation": "Regression test for Rowsecurity in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT attname, most_common_vals FROM pg_stats\n WHERE tablename = 'current_check'\n ORDER BY 1) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 96, "num_statements": 1}
{"question": "PostgreSQL regression test 'arrays': Write the SELECT query (example 327).", "schema": null, "sql": "select array_fill('juhu'::text, array[3,3]);", "explanation": "Regression test for Arrays in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select array_fill('juhu'::text, array[3,3])) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 44, "num_statements": 1}
{"question": "Write the DML statement from PostgreSQL regression test 'timestamptz' (example 38).", "schema": null, "sql": "INSERT INTO TIMESTAMPTZ_TBL VALUES ('1997-02-10 17:32:01-08');", "explanation": "DML from PostgreSQL core regression test for Timestamptz.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 62, "num_statements": 1}
{"question": "Show a query using PostgreSQL contrib extension 'ltree' (example 195).", "schema": null, "sql": "SELECT 'a.b.c.d.e'::ltree ~ 'a{,}.!a{,}';", "explanation": "Example query from the 'ltree' extension test/demo.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 41, "num_statements": 1}
{"question": "Write the PL/pgSQL object from PostgreSQL regression test 'triggers' (example 49).", "schema": null, "sql": "begin\n\tnew.description = 'updated in trigger';", "explanation": "PL/pgSQL object from PostgreSQL core test for Triggers.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "plpgsql_trigger", "is_postgresql_specific": true, "sql_length": 46, "num_statements": 1}
{"question": "PostgreSQL regression test 'int8': Write the SELECT query (example 139).", "schema": null, "sql": "SELECT (-9223372036854775808)::int8 / (-1)::int2;", "explanation": "Regression test for Int8 in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT (-9223372036854775808)::int8 / (-1)::int2) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 49, "num_statements": 1}
{"question": "PostgreSQL regression test 'sqljson_queryfuncs': Write the SELECT query (example 193).", "schema": null, "sql": "SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING json);", "explanation": "Regression test for Sqljson Queryfuncs in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT JSON_QUERY(jsonb 'null', '$ts' PASSING timestamptz '2018-02-21 12:34:56 +10' AS ts RETURNING json)) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 106, "num_statements": 1}
{"question": "pgTAP test for Functap (assertion 275).", "schema": null, "sql": "SELECT * FROM check_test(\n isnt_window( 'pg_catalog', 'dense_rank', '{}'::name[] ),\n false,\n 'isnt_window(schema, win, noargs)',\n 'Function pg_catalog.dense_rank() should not be a window function',\n ''\n);", "explanation": "SQL assertion from pgTAP test suite for Functap.", "validation_query": null, "source": "pgtap_tests", "difficulty": "intermediate", "category": "query_select", "is_postgresql_specific": true, "sql_length": 219, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'constraints' (example 199).", "schema": null, "sql": "CREATE TABLE parted_uniq_tbl_2 PARTITION OF parted_uniq_tbl FOR VALUES FROM (20) TO (30);", "explanation": "DDL from PostgreSQL core regression test for Constraints.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": false, "sql_length": 89, "num_statements": 1}
{"question": "pgTAP test for Aretap (assertion 122).", "schema": null, "sql": "SELECT * FROM check_test(\n rules_are( 'public', 'fou', ARRAY['ins_me', 'upd_me'] ),\n true,\n 'rules_are(schema, table, rules)',\n 'Relation public.fou should have the correct rules',\n ''\n);", "explanation": "SQL assertion from pgTAP test suite for Aretap.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 202, "num_statements": 1}
{"question": "PostgreSQL regression test 'jsonb_jsonpath': Write the SELECT query (example 741).", "schema": null, "sql": "select jsonb_path_query_tz(\n\t'[\"2017-03-10 12:34:00\", \"2017-03-10 12:35:00\", \"2017-03-10 12:36:00\", \"2017-03-10 12:35:00+01\", \"2017-03-10 13:35:00+01\", \"2017-03-10 12:35:00-01\", \"2017-03-10\", \"2017-03-11\", \"12:34:56\", \"12:34:56+01\"]',\n\t'$[*].datetime() ? (@ >= \"10.03.2017 12:35\".datetime(\"dd.mm.yyyy HH24:MI\"))');", "explanation": "Regression test for Jsonb Jsonpath in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select jsonb_path_query_tz(\n\t'[\"2017-03-10 12:34:00\", \"2017-03-10 12:35:00\", \"2017-03-10 12:36:00\", \"2017-03-10 12:35:00+01\", \"2017-03-10 13:35:00+01\", \"2017-03-10 12:35:00-01\", \"2017-03-10\", \"2017-03-11\", \"12:34:56\", \"12:34:56+01\"]',\n\t'$[*].datetime() ? (@ >= \"10.03.2017 12:35\".datetime(\"dd.mm.yyyy HH24:MI\"))')) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "advanced", "category": "query_select", "is_postgresql_specific": false, "sql_length": 314, "num_statements": 1}
{"question": "PostgreSQL regression test 'subselect': Write the SELECT query (example 9).", "schema": null, "sql": "SELECT ((SELECT 2) UNION SELECT 2);", "explanation": "Regression test for Subselect in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT ((SELECT 2) UNION SELECT 2)) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "intermediate", "category": "query_select", "is_postgresql_specific": false, "sql_length": 35, "num_statements": 1}
{"question": "Write the SQL definition from PostgreSQL contrib extension 'contrib' (item 132).", "schema": null, "sql": "-- Create the operator class\nCREATE OPERATOR CLASS gist_time_ops\nDEFAULT FOR TYPE time USING gist\nAS\n\tOPERATOR\t1\t< ,\n\tOPERATOR\t2\t<= ,\n\tOPERATOR\t3\t= ,\n\tOPERATOR\t4\t>= ,\n\tOPERATOR\t5\t> ,\n\tOPERATOR\t6\t<> ,\n\tOPERATOR\t15\t<-> FOR ORDER BY pg_catalog.interval_ops ,\n\tFUNCTION\t1\tgbt_time_consistent (internal, time, int2, oid, internal),\n\tFUNCTION\t2\tgbt_time_union (internal, internal),\n\tFUNCTION\t3\tgbt_time_compress (internal),\n\tFUNCTION\t4\tgbt_decompress (internal),\n\tFUNCTION\t5\tgbt_time_penalty (internal, internal, internal),\n\tFUNCTION\t6\tgbt_time_picksplit (internal, internal),\n\tFUNCTION\t7\tgbt_time_same (gbtreekey16, gbtreekey16, internal),\n\tFUNCTION\t8\tgbt_time_distance (internal, time, int2, oid, internal),\n\tFUNCTION\t9\tgbt_time_fetch (internal),\n\tFUNCTION\t11\tgbt_time_sortsupport (internal),\n\tFUNCTION\t12 (\"any\", \"any\") gist_translate_cmptype_btree (int),\n\tSTORAGE\t\tgbtreekey16;", "explanation": "SQL definition from the 'contrib' PostgreSQL contrib extension.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "advanced", "category": "ddl_advanced", "is_postgresql_specific": true, "sql_length": 878, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'without_overlaps' (example 392).", "schema": null, "sql": "CREATE TABLE temporal_rng2 (\n id1 int4range,\n id2 int4range,\n valid_at daterange,\n CONSTRAINT temporal_rng2_pk PRIMARY KEY (id1, id2, valid_at WITHOUT OVERLAPS)\n);", "explanation": "DDL from PostgreSQL core regression test for Without Overlaps.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": false, "sql_length": 167, "num_statements": 1}
{"question": "PostgreSQL regression test 'tstypes': Write the SELECT query (example 138).", "schema": null, "sql": "SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s');", "explanation": "Regression test for Tstypes in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT ts_rank_cd(' a:1 s:2B d g'::tsvector, 'a & s')) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "advanced", "category": "query_select", "is_postgresql_specific": true, "sql_length": 54, "num_statements": 1}
{"question": "PostgreSQL regression test 'stats': Write the SELECT query (example 248).", "schema": null, "sql": "SELECT wal_bytes > :wal_bytes_before FROM pg_stat_wal;", "explanation": "Regression test for Stats in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT wal_bytes > :wal_bytes_before FROM pg_stat_wal) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 54, "num_statements": 1}
{"question": "PostgreSQL regression test 'polymorphism': Write the SELECT query (example 204).", "schema": null, "sql": "select formarray(1.1, variadic array[1.2,55.5]);", "explanation": "Regression test for Polymorphism in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select formarray(1.1, variadic array[1.2,55.5])) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 48, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'indexing' (example 459).", "schema": null, "sql": "create table pk51 partition of pk5 for values from (4000) to (4500);", "explanation": "DDL from PostgreSQL core regression test for Indexing.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": false, "sql_length": 68, "num_statements": 1}
{"question": "Write the PL/pgSQL object from PostgreSQL regression test 'drop_if_exists' (example 68).", "schema": null, "sql": "DROP FUNCTION IF EXISTS test_function_exists(int, text, int[]);", "explanation": "PL/pgSQL object from PostgreSQL core test for Drop If Exists.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "intermediate", "category": "other", "is_postgresql_specific": false, "sql_length": 63, "num_statements": 1}
{"question": "pgTAP test for Ownership (assertion 59).", "schema": null, "sql": "SELECT * FROM check_test(\n view_owner_is('public', '__not__someview', current_user, 'mumble'),\n\tfalse,\n 'view_owner_is(sch, non-view, user)',\n 'mumble',\n ' View public.__not__someview does not exist'\n);", "explanation": "SQL assertion from pgTAP test suite for Ownership.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 217, "num_statements": 1}
{"question": "Show a SQL definition from the zombodb project (_mappings, item 6).", "schema": null, "sql": "CREATE TABLE zdb.type_mappings\n(\n type_name regtype NOT NULL PRIMARY KEY,\n definition jsonb DEFAULT NULL,\n is_default boolean DEFAULT false NOT NULL,\n funcid regproc DEFAULT null\n);", "explanation": "SQL definition from the open-source zombodb PostgreSQL project.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": true, "sql_length": 214, "num_statements": 1}
{"question": "PostgreSQL regression test 'truncate': Write the SELECT query (example 151).", "schema": null, "sql": "select tp_ins_data();", "explanation": "Regression test for Truncate in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select tp_ins_data()) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 21, "num_statements": 1}
{"question": "Write the DML statement from PostgreSQL regression test 'numeric' (example 204).", "schema": null, "sql": "INSERT INTO num_exp_add VALUES (4,8,'7874342.4119');", "explanation": "DML from PostgreSQL core regression test for Numeric.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 52, "num_statements": 1}
{"question": "Show a query using PostgreSQL contrib extension 'earthdistance' (example 18).", "schema": null, "sql": "SELECT gc_to_sec(1000)::numeric(20,5);", "explanation": "Example query from the 'earthdistance' extension test/demo.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 38, "num_statements": 1}
{"question": "pgTAP test for Hastap (assertion 207).", "schema": null, "sql": "SELECT * FROM check_test(\n has_leftop( '+', 'text', 'inte', 'desc' ),\n false,\n 'has_leftop( name, right, result, desc ) fail',\n 'desc',\n ''\n);", "explanation": "SQL assertion from pgTAP test suite for Hastap.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 147, "num_statements": 1}
{"question": "PostgreSQL regression test 'tstypes': Write the SELECT query (example 188).", "schema": null, "sql": "SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c');", "explanation": "Regression test for Tstypes in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT setweight('a:1,3A asd:1C w:5,6,12B,13A zxc:81,222A,567'::tsvector, 'c')) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 79, "num_statements": 1}
{"question": "PostgreSQL regression test 'name': Write the SELECT query (example 19).", "schema": null, "sql": "SELECT c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*';", "explanation": "Regression test for Name in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT c.f1 FROM NAME_TBL c WHERE c.f1 !~ '.*') AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 47, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'partition_merge' (example 118).", "schema": null, "sql": "CREATE TABLE sales_apr2022_10_20 PARTITION OF sales_apr2022 FOR VALUES FROM ('2022-04-10') TO ('2022-04-20');", "explanation": "DDL from PostgreSQL core regression test for Partition Merge.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": false, "sql_length": 109, "num_statements": 1}
{"question": "Show a query using PostgreSQL contrib extension 'btree_gin' (example 3).", "schema": null, "sql": "INSERT INTO test_timestamptz VALUES\n\t( '2004-10-26 03:55:08' ),\n\t( '2004-10-26 04:55:08' ),\n\t( '2004-10-26 05:55:08' ),\n\t( '2004-10-26 08:55:08' ),\n\t( '2004-10-27 09:55:08' ),\n\t( '2004-10-27 10:55:08' )\n;", "explanation": "Example query from the 'btree_gin' extension test/demo.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 204, "num_statements": 1}
{"question": "Write the SQL definition from PostgreSQL contrib extension 'contrib' (item 1).", "schema": null, "sql": "/* contrib/btree_gin/btree_gin--1.0.sql */\n\n-- complain if script is sourced in psql, rather than via CREATE EXTENSION\n\\echo Use \"CREATE EXTENSION btree_gin\" to load this file. \\quit\n\nCREATE FUNCTION gin_btree_consistent(internal, int2, anyelement, int4, internal, internal)\nRETURNS bool\nAS 'MODULE_PATHNAME'\nLANGUAGE C STRICT IMMUTABLE;", "explanation": "SQL definition from the 'contrib' PostgreSQL contrib extension.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_advanced", "is_postgresql_specific": true, "sql_length": 337, "num_statements": 1}
{"question": "pgTAP test for Pgtap--Unpackaged--0.91.0 (assertion 165).", "schema": null, "sql": "ALTER EXTENSION pgtap ADD FUNCTION _ckeys ( NAME, CHAR );", "explanation": "SQL assertion from pgTAP test suite for Pgtap--Unpackaged--0.91.0.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "other", "is_postgresql_specific": false, "sql_length": 57, "num_statements": 1}
{"question": "PostgreSQL regression test 'stats': Write the SELECT query (example 381).", "schema": null, "sql": "SELECT sum(evictions) + sum(reuses) + sum(extends) + sum(fsyncs) + sum(reads) + sum(writes) + sum(writebacks) + sum(hits) AS my_io_stats_post_reset\n FROM pg_stat_get_backend_io(pg_backend_pid()) \\gset\n-- pg_stat_reset_shared() did not reset backend IO stats\nSELECT :my_io_stats_pre_reset <= :my_io_stats_post_reset;", "explanation": "Regression test for Stats in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT sum(evictions) + sum(reuses) + sum(extends) + sum(fsyncs) + sum(reads) + sum(writes) + sum(writebacks) + sum(hits) AS my_io_stats_post_reset\n FROM pg_stat_get_backend_io(pg_backend_pid()) \\gset\n-- pg_stat_reset_shared() did not reset backend IO stats\nSELECT :my_io_stats_pre_reset <= :my_io_stats_post_reset) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 316, "num_statements": 1}
{"question": "PostgreSQL regression test 'money': Write the SELECT query (example 90).", "schema": null, "sql": "SELECT (-12345678901234567)::money;", "explanation": "Regression test for Money in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT (-12345678901234567)::money) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 35, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'constraints' (example 379).", "schema": null, "sql": "CREATE TABLE notnull_tbl4_cld () INHERITS (notnull_tbl4);", "explanation": "DDL from PostgreSQL core regression test for Constraints.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": true, "sql_length": 57, "num_statements": 1}
{"question": "PostgreSQL regression test 'pg_ndistinct': Write the SELECT query (example 18).", "schema": null, "sql": "SELECT * FROM pg_input_error_info('[{\"attributes\" : [2,3], \"ndistinct\" : 4, \"ndistinct\" : 4}]', 'pg_ndistinct');", "explanation": "Regression test for Pg Ndistinct in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT * FROM pg_input_error_info('[{\"attributes\" : [2,3], \"ndistinct\" : 4, \"ndistinct\" : 4}]', 'pg_ndistinct')) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 112, "num_statements": 1}
{"question": "PostgreSQL regression test 'arrays': Write the SELECT query (example 435).", "schema": null, "sql": "select unnest('11 22 33'::oidvector);", "explanation": "Regression test for Arrays in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select unnest('11 22 33'::oidvector)) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 37, "num_statements": 1}
{"question": "Show a query using PostgreSQL contrib extension 'intarray' (example 24).", "schema": null, "sql": "SELECT '{123,623,445}'::int[] | '{1623,623}';", "explanation": "Example query from the 'intarray' extension test/demo.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 45, "num_statements": 1}
{"question": "PostgreSQL Plpgsql: show example 48.", "schema": null, "sql": "DECLARE curs1 refcursor; curs2 CURSOR FOR SELECT * FROM tenk1; curs3 CURSOR (key integer) FOR SELECT * FROM tenk1 WHERE unique1 = key;", "explanation": "Example from PostgreSQL documentation on Plpgsql.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "plpgsql", "is_postgresql_specific": false, "sql_length": 134, "num_statements": 3}
{"question": "Write the PL/pgSQL object from PostgreSQL regression test 'plpgsql' (example 680).", "schema": null, "sql": "drop function inner_func(int);", "explanation": "PL/pgSQL object from PostgreSQL core test for Plpgsql.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "other", "is_postgresql_specific": false, "sql_length": 30, "num_statements": 1}
{"question": "PostgreSQL regression test 'jsonb': Write the SELECT query (example 806).", "schema": null, "sql": "select ('{\"a\": 1, \"b\": \"c\", \"d\": [1, 2, 3]}'::jsonb)['d'];", "explanation": "Regression test for Jsonb in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select ('{\"a\": 1, \"b\": \"c\", \"d\": [1, 2, 3]}'::jsonb)['d']) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": true, "sql_length": 58, "num_statements": 1}
{"question": "pgTAP test for Index (assertion 109).", "schema": null, "sql": "SELECT * FROM check_test(\n is_indexed( 'public', 'sometab'::name, 'myint'::name ),\n false,\n 'is_indexed( schema, table, column ) fail',\n 'Should have an index on public.sometab(myint)',\n ''\n);", "explanation": "SQL assertion from pgTAP test suite for Index.", "validation_query": null, "source": "pgtap_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 207, "num_statements": 1}
{"question": "PostgreSQL regression test 'jsonb_jsonpath': Write the SELECT query (example 486).", "schema": null, "sql": "select jsonb_path_query('[]', '$.number()');", "explanation": "Regression test for Jsonb Jsonpath in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (select jsonb_path_query('[]', '$.number()')) AS _sub;", "source": "postgresql_regression_tests", "difficulty": "advanced", "category": "query_select", "is_postgresql_specific": false, "sql_length": 44, "num_statements": 1}
{"question": "Write the SQL definition from PostgreSQL contrib extension 'contrib' (item 1).", "schema": null, "sql": "/* contrib/ltree/ltree--1.1.sql */\n\n-- complain if script is sourced in psql, rather than via CREATE EXTENSION\n\\echo Use \"CREATE EXTENSION ltree\" to load this file. \\quit\n\nCREATE FUNCTION ltree_in(cstring)\nRETURNS ltree\nAS 'MODULE_PATHNAME'\nLANGUAGE C STRICT IMMUTABLE PARALLEL SAFE;", "explanation": "SQL definition from the 'contrib' PostgreSQL contrib extension.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_advanced", "is_postgresql_specific": true, "sql_length": 283, "num_statements": 1}
{"question": "Write the DDL statement from PostgreSQL regression test 'stats_ext' (example 525).", "schema": null, "sql": "CREATE STATISTICS mcv_lists_stats_3 ON (mod(c,5)) FROM mcv_lists;", "explanation": "DDL from PostgreSQL core regression test for Stats Ext.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "other", "is_postgresql_specific": false, "sql_length": 65, "num_statements": 1}
{"question": "Write the DML statement from PostgreSQL regression test 'numeric' (example 361).", "schema": null, "sql": "INSERT INTO num_exp_sub VALUES (8,7,'83103366');", "explanation": "DML from PostgreSQL core regression test for Numeric.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "dml_insert", "is_postgresql_specific": false, "sql_length": 48, "num_statements": 1}
{"question": "PostgreSQL regression test 'jsonb': Write the SELECT query (example 22).", "schema": null, "sql": "SELECT test_json ->> 'field4' FROM test_jsonb WHERE json_type = 'object';", "explanation": "Regression test for Jsonb in PostgreSQL core test suite.", "validation_query": "SELECT count(*) FROM (SELECT test_json ->> 'field4' FROM test_jsonb WHERE json_type = 'object') AS _sub;", "source": "postgresql_regression_tests", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 73, "num_statements": 1}
{"question": "Show a query using PostgreSQL contrib extension 'intarray' (example 66).", "schema": null, "sql": "SELECT '1&(2&(4&(5|6)))'::query_int;", "explanation": "Example query from the 'intarray' extension test/demo.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "query_select", "is_postgresql_specific": false, "sql_length": 36, "num_statements": 1}
{"question": "Write the SQL definition from PostgreSQL contrib extension 'contrib' (item 191).", "schema": null, "sql": "CREATE FUNCTION isnle(upc, upc)\n\tRETURNS boolean\n\tAS 'int8le'\n\tLANGUAGE 'internal'\n\tIMMUTABLE STRICT\n\tPARALLEL SAFE;", "explanation": "SQL definition from the 'contrib' PostgreSQL contrib extension.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "other", "is_postgresql_specific": false, "sql_length": 116, "num_statements": 1}
{"question": "PostgreSQL Ddl: show example 2.", "schema": null, "sql": "CREATE TABLE products ( product_no integer, name text, price numeric );", "explanation": "Example from PostgreSQL documentation on Ddl.", "validation_query": null, "source": "community_sql_datasets", "difficulty": "basic", "category": "ddl_table", "is_postgresql_specific": false, "sql_length": 71, "num_statements": 1}
{"question": "PostgreSQL regression test 'xml': Write the SELECT query (example 74).", "schema": null, "sql": "SELECT xmlroot(xml '