diff --git a/tests/gen_data/init_defog_mysql.sql b/tests/gen_data/init_defog_mysql.sql index 0cc34fc2a..5ed64ff9f 100644 --- a/tests/gen_data/init_defog_mysql.sql +++ b/tests/gen_data/init_defog_mysql.sql @@ -906,3 +906,151 @@ VALUES (13, 12, 'Vitamin D', '2022-12-01', NULL, 1000, 'IU', 24), (14, 13, 'Acetaminophen', '2023-01-08', '2023-01-14', 500, 'mg', 6), (15, 14, 'Hydrocortisone cream', '2023-02-25', '2023-03-07', 10, 'g', 12); + + +DROP DATABASE IF EXISTS `Academic`; +CREATE DATABASE `Academic`; +USE `Academic`; + +CREATE TABLE `author` ( + `aid` BIGINT NOT NULL, + `homepage` TEXT, + `name` TEXT, + `oid` BIGINT, + PRIMARY KEY (`aid`) +); + +CREATE TABLE `cite` ( + `cited` BIGINT, + `citing` BIGINT +); + +CREATE TABLE `conference` ( + `cid` BIGINT NOT NULL, + `homepage` TEXT, + `name` TEXT, + PRIMARY KEY (`cid`) +); + +CREATE TABLE `domain` ( + `did` BIGINT NOT NULL, + `name` TEXT, + PRIMARY KEY (`did`) +); + +CREATE TABLE `domain_author` ( + `aid` BIGINT NOT NULL, + `did` BIGINT NOT NULL +); + +CREATE TABLE `domain_conference` ( + `cid` BIGINT NOT NULL, + `did` BIGINT NOT NULL +); + +CREATE TABLE `domain_journal` ( + `did` BIGINT NOT NULL, + `jid` BIGINT NOT NULL +); + +CREATE TABLE `domain_keyword` ( + `did` BIGINT NOT NULL, + `kid` BIGINT NOT NULL +); + +CREATE TABLE `domain_publication` ( + `did` BIGINT NOT NULL, + `pid` BIGINT NOT NULL +); + +CREATE TABLE `journal` ( + `homepage` TEXT, + `jid` BIGINT NOT NULL, + `name` TEXT, + PRIMARY KEY (`jid`) +); + +CREATE TABLE `keyword` ( + `keyword` TEXT, + `kid` BIGINT NOT NULL, + PRIMARY KEY (`kid`) +); + +CREATE TABLE `organization` ( + `continent` TEXT, + `homepage` TEXT, + `name` TEXT, + `oid` BIGINT NOT NULL, + PRIMARY KEY (`oid`) +); + +CREATE TABLE `publication` ( + `abstract` TEXT, + `cid` BIGINT, + `citation_num` BIGINT, + `jid` BIGINT, + `pid` BIGINT NOT NULL, + `reference_num` BIGINT, + `title` TEXT, + `year` BIGINT, + PRIMARY KEY (`pid`) +); + +CREATE TABLE `publication_keyword` ( + `pid` BIGINT NOT NULL, + `kid` BIGINT NOT NULL +); + +CREATE TABLE `writes` ( + `aid` BIGINT NOT NULL, + `pid` BIGINT NOT NULL +); + +INSERT INTO `author` (`aid`, `homepage`, `name`, `oid`) VALUES +(1, 'www.larry.com', 'Larry Summers', 2), +(2, 'www.ashish.com', 'Ashish Vaswani', 3), +(3, 'www.noam.com', 'Noam Shazeer', 3), +(4, 'www.martin.com', 'Martin Odersky', 4), +(5, NULL, 'Kempinski', NULL); + +INSERT INTO `cite` (`cited`, `citing`) VALUES +(1, 2), (1, 3), (1, 4), (1, 5), (2, 3), (2, 5), (3, 4), (3, 5), (4, 5); + +INSERT INTO `conference` (`cid`, `homepage`, `name`) VALUES +(1, 'www.isa.com', 'ISA'), (2, 'www.aaas.com', 'AAAS'), (3, 'www.icml.com', 'ICML'); + +INSERT INTO `domain` (`did`, `name`) VALUES +(1, 'Data Science'), (2, 'Natural Sciences'), (3, 'Computer Science'), (4, 'Sociology'), (5, 'Machine Learning'); + +INSERT INTO `domain_author` (`aid`, `did`) VALUES +(1, 2), (1, 4), (2, 3), (2, 1), (2, 5), (3, 5), (3, 3), (4, 3); + +INSERT INTO `domain_conference` (`cid`, `did`) VALUES +(1, 2), (2, 4), (3, 5); + +INSERT INTO `domain_journal` (`did`, `jid`) VALUES +(1, 2), (2, 3), (5, 4); + +INSERT INTO `domain_keyword` (`did`, `kid`) VALUES +(1, 2), (2, 3); + +INSERT INTO `domain_publication` (`did`, `pid`) VALUES +(4, 1), (2, 2), (1, 3), (3, 4), (3, 5), (5, 5); + +INSERT INTO `journal` (`homepage`, `jid`, `name`) VALUES +('www.aijournal.com', 1, 'Journal of Artificial Intelligence Research'), ('www.nature.com', 2, 'Nature'), ('www.science.com', 3, 'Science'), ('www.ml.com', 4, 'Journal of Machine Learning Research'); + +INSERT INTO `keyword` (`keyword`, `kid`) VALUES +('AI', 1), ('Neuroscience', 2), ('Machine Learning', 3), ('Keyword 4', 4); + +INSERT INTO `organization` (`continent`, `homepage`, `name`, `oid`) VALUES +('Asia', 'www.organization1.com', 'Organization 1', 1), ('North America', 'www.organization2.com', 'Organization 2', 2), ('North America', 'www.organization3.com', 'Organization 3', 3), ('Europe', 'www.epfl.com', 'École Polytechnique Fédérale de Lausanne 4', 4), ('Europe', 'www.organization5.com', 'Organization 5', 5); + +INSERT INTO `publication` (`abstract`, `cid`, `citation_num`, `jid`, `pid`, `reference_num`, `title`, `year`) VALUES +('Abstract 1', 1, 4, 1, 1, 0, 'The Effects of Climate Change on Agriculture', 2020), ('Abstract 2', 2, 2, 2, 2, 1, 'A Study on the Effects of Social Media on Mental Health', 2020), ('Abstract 3', 3, 2, 2, 3, 2, 'Data Mining Techniques', 2021), ('Abstract 4', 3, 1, 2, 4, 2, 'Optimizing GPU Throughput', 2021), ('Abstract 5', 3, 0, 4, 5, 4, 'Attention is all you need', 2021); + +INSERT INTO `publication_keyword` (`pid`, `kid`) VALUES +(1, 2), (2, 3); + +INSERT INTO `writes` (`aid`, `pid`) VALUES +(1, 1), (1, 2), (2, 3), (2, 4), (2, 5), (3, 5); diff --git a/tests/gen_data/init_defog_postgres.sql b/tests/gen_data/init_defog_postgres.sql index fb4863225..c78b07b8e 100644 --- a/tests/gen_data/init_defog_postgres.sql +++ b/tests/gen_data/init_defog_postgres.sql @@ -1058,3 +1058,232 @@ VALUES (13, 12, 'Vitamin D', '2022-12-01', NULL, 1000, 'IU', 24), (14, 13, 'Acetaminophen', '2023-01-08', '2023-01-14', 500, 'mg', 6), (15, 14, 'Hydrocortisone cream', '2023-02-25', '2023-03-07', 10, 'g', 12); + +-- ACADEMIC +DROP TABLE IF EXISTS main.author CASCADE; +CREATE TABLE main.author ( + aid bigint NOT NULL, + homepage text, + name text, + oid bigint +); + +DROP TABLE IF EXISTS main.cite CASCADE; +CREATE TABLE main.cite ( + cited bigint, + citing bigint +); + +DROP TABLE IF EXISTS main.conference CASCADE; +CREATE TABLE main.conference ( + cid bigint NOT NULL, + homepage text, + name text +); + +DROP TABLE IF EXISTS main.domain CASCADE; +CREATE TABLE main.domain ( + did bigint NOT NULL, + name text +); + + +DROP TABLE IF EXISTS main.domain_author CASCADE; +CREATE TABLE main.domain_author ( + aid bigint NOT NULL, + did bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.domain_conference CASCADE; +CREATE TABLE main.domain_conference ( + cid bigint NOT NULL, + did bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.domain_journal CASCADE; +CREATE TABLE main.domain_journal ( + did bigint NOT NULL, + jid bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.domain_keyword CASCADE; +CREATE TABLE main.domain_keyword ( + did bigint NOT NULL, + kid bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.domain_publication CASCADE; +CREATE TABLE main.domain_publication ( + did bigint NOT NULL, + pid bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.journal CASCADE; +CREATE TABLE main.journal ( + homepage text, + jid bigint NOT NULL, + name text +); + + +DROP TABLE IF EXISTS main.keyword CASCADE; +CREATE TABLE main.keyword ( + keyword text, + kid bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.organization CASCADE; +CREATE TABLE main.organization ( + continent text, + homepage text, + name text, + oid bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.publication CASCADE; +CREATE TABLE main.publication ( + abstract text, + cid bigint, + citation_num bigint, + jid bigint, + pid bigint NOT NULL, + reference_num bigint, + title text, + year bigint +); + + +DROP TABLE IF EXISTS main.publication_keyword CASCADE; +CREATE TABLE main.publication_keyword ( + pid bigint NOT NULL, + kid bigint NOT NULL +); + + +DROP TABLE IF EXISTS main.writes CASCADE; +CREATE TABLE main.writes ( + aid bigint NOT NULL, + pid bigint NOT NULL +); + + +INSERT INTO main.author (aid, homepage, name, oid) VALUES +(1, 'www.larry.com', 'Larry Summers', 2), +(2, 'www.ashish.com', 'Ashish Vaswani', 3), +(3, 'www.noam.com', 'Noam Shazeer', 3), +(4, 'www.martin.com', 'Martin Odersky', 4), +(5, NULL, 'Kempinski', NULL); + + +INSERT INTO main.cite (cited, citing) VALUES +(1, 2), +(1, 3), +(1, 4), +(1, 5), +(2, 3), +(2, 5), +(3, 4), +(3, 5), +(4, 5); + + +INSERT INTO main.conference (cid, homepage, name) VALUES +(1, 'www.isa.com', 'ISA'), +(2, 'www.aaas.com', 'AAAS'), +(3, 'www.icml.com', 'ICML'); + + +INSERT INTO main.domain (did, name) VALUES +(1, 'Data Science'), +(2, 'Natural Sciences'), +(3, 'Computer Science'), +(4, 'Sociology'), +(5, 'Machine Learning'); + + +INSERT INTO main.domain_author (aid, did) VALUES +(1, 2), +(1, 4), +(2, 3), +(2, 1), +(2, 5), +(3, 5), +(3, 3), +(4, 3); + + +INSERT INTO main.domain_conference (cid, did) VALUES +(1, 2), +(2, 4), +(3, 5); + + +INSERT INTO main.domain_journal (did, jid) VALUES +(1, 2), +(2, 3), +(5, 4); + + +INSERT INTO main.domain_keyword (did, kid) VALUES +(1, 2), +(2, 3); + + +INSERT INTO main.domain_publication (did, pid) VALUES +(4, 1), +(2, 2), +(1, 3), +(3, 4), +(3, 5), +(5, 5); + + +INSERT INTO main.journal (homepage, jid, name) VALUES +('www.aijournal.com', 1, 'Journal of Artificial Intelligence Research'), +('www.nature.com', 2, 'Nature'), +('www.science.com', 3, 'Science'), +('www.ml.com', 4, 'Journal of Machine Learning Research'); + + +INSERT INTO main.keyword (keyword, kid) VALUES +('AI', 1), +('Neuroscience', 2), +('Machine Learning', 3), +('Keyword 4', 4); + + +INSERT INTO main.organization (continent, homepage, name, oid) VALUES +('Asia', 'www.organization1.com', 'Organization 1', 1), +('North America', 'www.organization2.com', 'Organization 2', 2), +('North America', 'www.organization3.com', 'Organization 3', 3), +('Europe', 'www.epfl.com', 'École Polytechnique Fédérale de Lausanne 4', 4), +('Europe', 'www.organization5.com', 'Organization 5', 5); + + +INSERT INTO main.publication (abstract, cid, citation_num, jid, pid, reference_num, title, year) VALUES +('Abstract 1', 1, 4, 1, 1, 0, 'The Effects of Climate Change on Agriculture', 2020), +('Abstract 2', 2, 2, 2, 2, 1, 'A Study on the Effects of Social Media on Mental Health', 2020), +('Abstract 3', 3, 2, 2, 3, 2, 'Data Mining Techniques', 2021), +('Abstract 4', 3, 1, 2, 4, 2, 'Optimizing GPU Throughput', 2021), +('Abstract 5', 3, 0, 4, 5, 4, 'Attention is all you need', 2021); + + +INSERT INTO main.publication_keyword (pid, kid) VALUES +(1, 2), +(2, 3); + + +INSERT INTO main.writes (aid, pid) VALUES +(1, 1), +(1, 2), +(2, 3), +(2, 4), +(2, 5), +(3, 5); diff --git a/tests/gen_data/init_defog_sf.sql b/tests/gen_data/init_defog_sf.sql index 6f7632f6c..4f5f53f05 100644 --- a/tests/gen_data/init_defog_sf.sql +++ b/tests/gen_data/init_defog_sf.sql @@ -813,4 +813,231 @@ VALUES (9, '2023-06-07', 150.00, 1000.00, 2, 'bcryptHash(Gl0wUp7!9zy)', NULL, 'mobile_g3mjfz', '203.96.81.36', true, true, '2023-06-07 00:00:00'), (10, '2023-06-07', 300.00, 2000.00, 1, 'bcryptHash(GamzRu1ez*&99!)', NULL, 'web_d8180kaf', '8.26.53.165', false, true, '2023-06-07 00:00:00'), (1, '2023-06-01', 502.00, 1000.00, 2, 'bcryptHash($2yz9!&ka1)', '9d61c49b-8977-4914-a36b-80d1445e38fa', 'mobile_8fh2k1', '192.168.0.1', false, true, '2023-06-01 06:00:00'), -(2, '2023-06-01', 500.00, 2500.00, 1, 'bcryptHash(qpwo9874zyGk!)', NULL, 'mobile_yjp08q', '198.51.100.233, 70.121.39.25', true, false, '2023-06-01 09:00:00'); \ No newline at end of file +(2, '2023-06-01', 500.00, 2500.00, 1, 'bcryptHash(qpwo9874zyGk!)', NULL, 'mobile_yjp08q', '198.51.100.233, 70.121.39.25', true, false, '2023-06-01 09:00:00'); + + +------------------------------------------------------------------------------- +-- For the Academic SCHEMA +-- https://github.com/defog-ai/defog-data/blob/main/defog_data/academic/academic.sql + +-- Snowflake dialect compatibility replace: +-- - SERIAL PRIMARY KEY -> INTEGER AUTOINCREMENT PRIMARY KEY +-- - NOW() -> CURRENT_TIMESTAMP +------------------------------------------------------------------------------- +CREATE SCHEMA ACADEMIC; + +CREATE TABLE author ( + aid BIGINT NOT NULL, + homepage VARCHAR, + name VARCHAR, + oid BIGINT +); + + +CREATE TABLE cite ( + cited BIGINT, + citing BIGINT +); + + +CREATE TABLE conference ( + cid BIGINT NOT NULL, + homepage VARCHAR, + name VARCHAR +); + + +CREATE TABLE domain ( + did BIGINT NOT NULL, + name VARCHAR +); + + +CREATE TABLE domain_author ( + aid BIGINT NOT NULL, + did BIGINT NOT NULL +); + + +CREATE TABLE domain_conference ( + cid BIGINT NOT NULL, + did BIGINT NOT NULL +); + + +CREATE TABLE domain_journal ( + did BIGINT NOT NULL, + jid BIGINT NOT NULL +); + + +CREATE TABLE domain_keyword ( + did BIGINT NOT NULL, + kid BIGINT NOT NULL +); + + +CREATE TABLE domain_publication ( + did BIGINT NOT NULL, + pid BIGINT NOT NULL +); + + +CREATE TABLE journal ( + homepage VARCHAR, + jid BIGINT NOT NULL, + name VARCHAR +); + + +CREATE TABLE keyword ( + keyword VARCHAR, + kid BIGINT NOT NULL +); + + +CREATE TABLE organization ( + continent VARCHAR, + homepage VARCHAR, + name VARCHAR, + oid BIGINT NOT NULL +); + + +CREATE TABLE publication ( + abstract VARCHAR, + cid BIGINT, + citation_num BIGINT, + jid BIGINT, + pid BIGINT NOT NULL, + reference_num BIGINT, + title VARCHAR, + year BIGINT +); + + +CREATE TABLE publication_keyword ( + pid BIGINT NOT NULL, + kid BIGINT NOT NULL +); + + +CREATE TABLE writes ( + aid BIGINT NOT NULL, + pid BIGINT NOT NULL +); + + +INSERT INTO author (aid, homepage, name, oid) VALUES +(1, 'www.larry.com', 'Larry Summers', 2), +(2, 'www.ashish.com', 'Ashish Vaswani', 3), +(3, 'www.noam.com', 'Noam Shazeer', 3), +(4, 'www.martin.com', 'Martin Odersky', 4), +(5, NULL, 'Kempinski', NULL); + + +INSERT INTO cite (cited, citing) VALUES +(1, 2), +(1, 3), +(1, 4), +(1, 5), +(2, 3), +(2, 5), +(3, 4), +(3, 5), +(4, 5); + + +INSERT INTO conference (cid, homepage, name) VALUES +(1, 'www.isa.com', 'ISA'), +(2, 'www.aaas.com', 'AAAS'), +(3, 'www.icml.com', 'ICML'); + + +INSERT INTO domain (did, name) VALUES +(1, 'Data Science'), +(2, 'Natural Sciences'), +(3, 'Computer Science'), +(4, 'Sociology'), +(5, 'Machine Learning'); + + +INSERT INTO domain_author (aid, did) VALUES +(1, 2), +(1, 4), +(2, 3), +(2, 1), +(2, 5), +(3, 5), +(3, 3), +(4, 3); + + +INSERT INTO domain_conference (cid, did) VALUES +(1, 2), +(2, 4), +(3, 5); + + +INSERT INTO domain_journal (did, jid) VALUES +(1, 2), +(2, 3), +(5, 4); + + +INSERT INTO domain_keyword (did, kid) VALUES +(1, 2), +(2, 3); + + +INSERT INTO domain_publication (did, pid) VALUES +(4, 1), +(2, 2), +(1, 3), +(3, 4), +(3, 5), +(5, 5); + + +INSERT INTO journal (homepage, jid, name) VALUES +('www.aijournal.com', 1, 'Journal of Artificial Intelligence Research'), +('www.nature.com', 2, 'Nature'), +('www.science.com', 3, 'Science'), +('www.ml.com', 4, 'Journal of Machine Learning Research'); + + +INSERT INTO keyword (keyword, kid) VALUES +('AI', 1), +('Neuroscience', 2), +('Machine Learning', 3), +('Keyword 4', 4); + + +INSERT INTO organization (continent, homepage, name, oid) VALUES +('Asia', 'www.organization1.com', 'Organization 1', 1), +('North America', 'www.organization2.com', 'Organization 2', 2), +('North America', 'www.organization3.com', 'Organization 3', 3), +('Europe', 'www.epfl.com', 'École Polytechnique Fédérale de Lausanne 4', 4), +('Europe', 'www.organization5.com', 'Organization 5', 5); + + +INSERT INTO publication (abstract, cid, citation_num, jid, pid, reference_num, title, year) VALUES +('Abstract 1', 1, 4, 1, 1, 0, 'The Effects of Climate Change on Agriculture', 2020), +('Abstract 2', 2, 2, 2, 2, 1, 'A Study on the Effects of Social Media on Mental Health', 2020), +('Abstract 3', 3, 2, 2, 3, 2, 'Data Mining Techniques', 2021), +('Abstract 4', 3, 1, 2, 4, 2, 'Optimizing GPU Throughput', 2021), +('Abstract 5', 3, 0, 4, 5, 4, 'Attention is all you need', 2021); + + +INSERT INTO publication_keyword (pid, kid) VALUES +(1, 2), +(2, 3); + + +INSERT INTO writes (aid, pid) VALUES +(1, 1), +(1, 2), +(2, 3), +(2, 4), +(2, 5), +(3, 5); diff --git a/tests/gen_data/init_defog_sqlite.sql b/tests/gen_data/init_defog_sqlite.sql index f1abf115f..b38618e7d 100644 --- a/tests/gen_data/init_defog_sqlite.sql +++ b/tests/gen_data/init_defog_sqlite.sql @@ -866,3 +866,222 @@ VALUES (13, 12, 'Vitamin D', '2022-12-01', NULL, 1000, 'IU', 24), (14, 13, 'Acetaminophen', '2023-01-08', '2023-01-14', 500, 'mg', 6), (15, 14, 'Hydrocortisone cream', '2023-02-25', '2023-03-07', 10, 'g', 12); + +------------------------------------------------------------------------------- +--ACADEMIC SCHEMA + +CREATE TABLE author ( + aid INTEGER NOT NULL, + homepage TEXT, + name TEXT, + oid INTEGER +); + + +CREATE TABLE cite ( + cited INTEGER, + citing INTEGER +); + + +CREATE TABLE conference ( + cid INTEGER NOT NULL, + homepage TEXT, + name TEXT +); + + +CREATE TABLE domain ( + did INTEGER NOT NULL, + name TEXT +); + + +CREATE TABLE domain_author ( + aid INTEGER NOT NULL, + did INTEGER NOT NULL +); + + +CREATE TABLE domain_conference ( + cid INTEGER NOT NULL, + did INTEGER NOT NULL +); + + +CREATE TABLE domain_journal ( + did INTEGER NOT NULL, + jid INTEGER NOT NULL +); + + +CREATE TABLE domain_keyword ( + did INTEGER NOT NULL, + kid INTEGER NOT NULL +); + + +CREATE TABLE domain_publication ( + did INTEGER NOT NULL, + pid INTEGER NOT NULL +); + + +CREATE TABLE journal ( + homepage TEXT, + jid INTEGER NOT NULL, + name TEXT +); + + +CREATE TABLE keyword ( + keyword TEXT, + kid INTEGER NOT NULL +); + + +CREATE TABLE organization ( + continent TEXT, + homepage TEXT, + name TEXT, + oid INTEGER NOT NULL +); + + +CREATE TABLE publication ( + abstract TEXT, + cid INTEGER, + citation_num INTEGER, + jid INTEGER, + pid INTEGER NOT NULL, + reference_num INTEGER, + title TEXT, + year INTEGER +); + + +CREATE TABLE publication_keyword ( + pid INTEGER NOT NULL, + kid INTEGER NOT NULL +); + + +CREATE TABLE writes ( + aid INTEGER NOT NULL, + pid INTEGER NOT NULL +); + + +INSERT INTO author (aid, homepage, name, oid) VALUES +(1, 'www.larry.com', 'Larry Summers', 2), +(2, 'www.ashish.com', 'Ashish Vaswani', 3), +(3, 'www.noam.com', 'Noam Shazeer', 3), +(4, 'www.martin.com', 'Martin Odersky', 4), +(5, NULL, 'Kempinski', NULL); + + +INSERT INTO cite (cited, citing) VALUES +(1, 2), +(1, 3), +(1, 4), +(1, 5), +(2, 3), +(2, 5), +(3, 4), +(3, 5), +(4, 5); + + +INSERT INTO conference (cid, homepage, name) VALUES +(1, 'www.isa.com', 'ISA'), +(2, 'www.aaas.com', 'AAAS'), +(3, 'www.icml.com', 'ICML'); + + +INSERT INTO domain (did, name) VALUES +(1, 'Data Science'), +(2, 'Natural Sciences'), +(3, 'Computer Science'), +(4, 'Sociology'), +(5, 'Machine Learning'); + + +INSERT INTO domain_author (aid, did) VALUES +(1, 2), +(1, 4), +(2, 3), +(2, 1), +(2, 5), +(3, 5), +(3, 3), +(4, 3); + + +INSERT INTO domain_conference (cid, did) VALUES +(1, 2), +(2, 4), +(3, 5); + + +INSERT INTO domain_journal (did, jid) VALUES +(1, 2), +(2, 3), +(5, 4); + + +INSERT INTO domain_keyword (did, kid) VALUES +(1, 2), +(2, 3); + + +INSERT INTO domain_publication (did, pid) VALUES +(4, 1), +(2, 2), +(1, 3), +(3, 4), +(3, 5), +(5, 5); + + +INSERT INTO journal (homepage, jid, name) VALUES +('www.aijournal.com', 1, 'Journal of Artificial Intelligence Research'), +('www.nature.com', 2, 'Nature'), +('www.science.com', 3, 'Science'), +('www.ml.com', 4, 'Journal of Machine Learning Research'); + + +INSERT INTO keyword (keyword, kid) VALUES +('AI', 1), +('Neuroscience', 2), +('Machine Learning', 3), +('Keyword 4', 4); + + +INSERT INTO organization (continent, homepage, name, oid) VALUES +('Asia', 'www.organization1.com', 'Organization 1', 1), +('North America', 'www.organization2.com', 'Organization 2', 2), +('North America', 'www.organization3.com', 'Organization 3', 3), +('Europe', 'www.epfl.com', 'École Polytechnique Fédérale de Lausanne 4', 4), +('Europe', 'www.organization5.com', 'Organization 5', 5); + + +INSERT INTO publication (abstract, cid, citation_num, jid, pid, reference_num, title, year) VALUES +('Abstract 1', 1, 4, 1, 1, 0, 'The Effects of Climate Change on Agriculture', 2020), +('Abstract 2', 2, 2, 2, 2, 1, 'A Study on the Effects of Social Media on Mental Health', 2020), +('Abstract 3', 3, 2, 2, 3, 2, 'Data Mining Techniques', 2021), +('Abstract 4', 3, 1, 2, 4, 2, 'Optimizing GPU Throughput', 2021), +('Abstract 5', 3, 0, 4, 5, 4, 'Attention is all you need', 2021); + + +INSERT INTO publication_keyword (pid, kid) VALUES +(1, 2), +(2, 3); + + +INSERT INTO writes (aid, pid) VALUES +(1, 1), +(1, 2), +(2, 3), +(2, 4), +(2, 5), +(3, 5); diff --git a/tests/test_metadata/defog_graphs.json b/tests/test_metadata/defog_graphs.json index 09c2860db..fba3cd76f 100644 --- a/tests/test_metadata/defog_graphs.json +++ b/tests/test_metadata/defog_graphs.json @@ -3392,5 +3392,1045 @@ "additional definitions": [], "verified pydough analysis": [], "extra semantic info": {} + }, + { + "name": "Academic", + "version": "V2", + "collections": [ + { + "name": "authors", + "type": "simple table", + "table path": "main.author", + "unique properties": [ + "author_id" + ], + "properties": [ + { + "name": "author_id", + "type": "table column", + "column name": "aid", + "data type": "numeric", + "description": "Unique identifier for each author", + "sample values": [1, 3, 5], + "synonyms": ["author id", "author identification"] + }, + { + "name": "homepage", + "type": "table column", + "column name": "homepage", + "data type": "string", + "description": "The hostname used for the author's website", + "sample values": ["www.larry.com", "www.noam.com"], + "synonyms": ["author url", "author website"] + }, + { + "name": "name", + "type": "table column", + "column name": "name", + "data type": "string", + "description": "The name and lastname of the author", + "sample values": ["Larry Summers", "Noam Shazeer"], + "synonyms": ["full name"] + }, + { + "name": "organization_id", + "type": "table column", + "column name": "oid", + "data type": "numeric", + "description": "The id of the organization the author is related to", + "sample values": [1, 2, 5], + "synonyms": ["oid", "org_id"] + } + ], + "description": "Contains details about the authors, including their id, name, homepage, and organization id.", + "synonyms": [] + }, + { + "name": "citations", + "type": "simple table", + "table path": "main.cite", + "unique properties": [ + ["cited", + "citing"] + ], + "properties": [ + { + "name": "cited", + "type": "table column", + "column name": "cited", + "data type": "numeric", + "description": "The id of the publication being referenced or cited.", + "sample values": [1, 2, 4], + "synonyms": [] + }, + { + "name": "citing", + "type": "table column", + "column name": "citing", + "data type": "numeric", + "description": "The id of the publication that is doing the referencing (the source paper that contains the citation).", + "sample values": [1, 2, 3], + "synonyms": [] + } + ], + "description": "Records of citation relationships between publications.", + "synonyms": [] + }, + { + "name": "conferences", + "type": "simple table", + "table path": "main.conference", + "unique properties": [ + "conference_id" + ], + "properties": [ + { + "name": "conference_id", + "type": "table column", + "column name": "cid", + "data type": "numeric", + "description": "Unique identifier for the conference.", + "sample values": [1, 2, 3], + "synonyms": ["conference id"] + }, + { + "name": "homepage", + "type": "table column", + "column name": "homepage", + "data type": "string", + "description": "The URL or homepage of the conference.", + "sample values": ["www.isa.com", "www.icml.com"], + "synonyms": ["conference website"] + }, + { + "name": "name", + "type": "table column", + "column name": "name", + "data type": "string", + "description": "The full name or abbreviation of the conference.", + "sample values": ["ISA", "ICML"], + "synonyms": [] + } + ], + "description": "Contains details about academic conferences.", + "synonyms": ["meeting", "symposium"] + }, + { + "name": "domains", + "type": "simple table", + "table path": "main.domain", + "unique properties": [ + "domain_id" + ], + "properties": [ + { + "name": "domain_id", + "type": "table column", + "column name": "did", + "data type": "numeric", + "description": "Unique identifier for the academic domain or field.", + "sample values": [1, 3, 5], + "synonyms": [] + }, + { + "name": "name", + "type": "table column", + "column name": "name", + "data type": "string", + "description": "The name of the academic domain", + "sample values": ["Data Science", "Computer Science"], + "synonyms": ["field name", "subject"] + } + ], + "description": "Records of different academic domains or areas of study", + "synonyms": ["field", "subject"] + }, + { + "name": "domains_authors", + "type": "simple table", + "table path": "main.domain_author", + "unique properties": [ + ["author_id", + "domain_id"] + ], + "properties": [ + { + "name": "author_id", + "type": "table column", + "column name": "aid", + "data type": "numeric", + "description": "The id of the author related to this domain", + "sample values": [1, 3, 5], + "synonyms": [] + }, + { + "name": "domain_id", + "type": "table column", + "column name": "did", + "data type": "numeric", + "description": "The id of the domain related to the author", + "sample values": [1, 3, 5], + "synonyms": [] + } + ], + "description": "The records of each author being associated with domains", + "synonyms": [] + }, + { + "name": "domains_conferences", + "type": "simple table", + "table path": "main.domain_conference", + "unique properties": [ + ["conference_id", + "domain_id"] + ], + "properties": [ + { + "name": "conference_id", + "type": "table column", + "column name": "cid", + "data type": "numeric", + "description": "The id for the conference related to this domain", + "sample values": [1, 2, 3], + "synonyms": [] + }, + { + "name": "domain_id", + "type": "table column", + "column name": "did", + "data type": "numeric", + "description": "The id for the domain related to the conference.", + "sample values": [2, 4, 5], + "synonyms": [] + } + ], + "description": "Describes the domains related to the different conferences", + "synonyms": ["conference subject"] + }, + { + "name": "domains_journals", + "type": "simple table", + "table path": "main.domain_journal", + "unique properties": [ + ["domain_id", + "journal_id"] + ], + "properties": [ + { + "name": "domain_id", + "type": "table column", + "column name": "did", + "data type": "numeric", + "description": "The id of the domain realated to this journal", + "sample values": [1,2,5], + "synonyms": [] + }, + { + "name": "journal_id", + "type": "table column", + "column name": "jid", + "data type": "numeric", + "description": "The id of the jornal that published about this domain", + "sample values": [2, 3, 4], + "synonyms": [] + } + ], + "description": "Records of domains being used by a journal", + "synonyms": ["journal domain", "journal field"] + }, + { + "name": "domains_keywords", + "type": "simple table", + "table path": "main.domain_keyword", + "unique properties": [ + ["domain_id", + "keyword_id"] + ], + "properties": [ + { + "name": "domain_id", + "type": "table column", + "column name": "did", + "data type": "numeric", + "description": "The id of the domain which is related to this keyword", + "sample values": [1, 2], + "synonyms": [] + }, + { + "name": "keyword_id", + "type": "table column", + "column name": "kid", + "data type": "numeric", + "description": "The id of the keyword used or connected to this domain or field", + "sample values": [2, 3], + "synonyms": [] + } + ], + "description": "Contains records of keywords that is related to a domain", + "synonyms": ["keyword domain"] + }, + { + "name": "domains_publications", + "type": "simple table", + "table path": "main.domain_publication", + "unique properties": [["domain_id", "publication_id"]], + "properties": [ + { + "name": "domain_id", + "type": "table column", + "column name": "did", + "data type": "numeric", + "description": "The id of the domain related to this publication", + "sample values": [1, 2, 3], + "synonyms": [] + }, + { + "name": "publication_id", + "type": "table column", + "column name": "pid", + "data type": "numeric", + "description": "The id of the publication about this domain", + "sample values": [2, 4, 5], + "synonyms": [] + } + ], + "description": "Records of the publication and its related domain or field", + "synonyms": ["publication field"] + }, + { + "name": "journals", + "type": "simple table", + "table path": "main.journal", + "unique properties": [ + "journal_id" + ], + "properties": [ + { + "name": "homepage", + "type": "table column", + "column name": "homepage", + "data type": "string", + "description": "The url of the journal", + "sample values": ["www.aijournal.com", "www.ml.com"], + "synonyms": ["website", "url"] + }, + { + "name": "journal_id", + "type": "table column", + "column name": "jid", + "data type": "numeric", + "description": "The id of the journal", + "sample values": [1, 2, 3], + "synonyms": ["journal id", "identification"] + }, + { + "name": "name", + "type": "table column", + "column name": "name", + "data type": "string", + "description": "The name of the journal", + "sample values": ["Nature", "Journal of Machine Learning Research"], + "synonyms": [] + } + ], + "description": "Contains details about the journals", + "synonyms": ["magazines", "newspapers"] + }, + { + "name": "keywords", + "type": "simple table", + "table path": "main.keyword", + "unique properties": [ + "keyword_id" + ], + "properties": [ + { + "name": "keyword", + "type": "table column", + "column name": "keyword", + "data type": "string", + "description": "The keyword itself", + "sample values": ["Neuroscience", "AI"], + "synonyms": [] + }, + { + "name": "keyword_id", + "type": "table column", + "column name": "kid", + "data type": "numeric", + "description": "The identificator of the keyword", + "sample values": [1, 2, 4], + "synonyms": ["keyword id"] + } + ], + "description": "Collection of keywords used in publications and domains", + "synonyms": [] + }, + { + "name": "organizations", + "type": "simple table", + "table path": "main.organization", + "unique properties": [ + "organization_id" + ], + "properties": [ + { + "name": "continent", + "type": "table column", + "column name": "continent", + "data type": "string", + "description": "The continent where the organization resides", + "sample values": ["North America", "Asia"], + "synonyms": ["location"] + }, + { + "name": "homepage", + "type": "table column", + "column name": "homepage", + "data type": "string", + "description": "The url of the organization's website", + "sample values": ["www.organization2.com", "www.epfl.com"], + "synonyms": ["website link"] + }, + { + "name": "name", + "type": "table column", + "column name": "name", + "data type": "string", + "description": "The name of the organization", + "sample values": ["École Polytechnique Fédérale de Lausanne 4", "Organization 2"], + "synonyms": ["oranization name"] + }, + { + "name": "organization_id", + "type": "table column", + "column name": "oid", + "data type": "numeric", + "description": "The identifier for the organization", + "sample values": [1, 3, 5], + "synonyms": ["id", "oid"] + } + ], + "description": "Records of the existing organizations, including continent, name, homepage and id", + "synonyms": ["institutions"] + }, + { + "name": "publications", + "type": "simple table", + "table path": "main.publication", + "unique properties": [ + "publication_id" + ], + "properties": [ + { + "name": "abstract", + "type": "table column", + "column name": "abstract", + "data type": "string", + "description": "Summary of the publication", + "sample values": ["Abstract 1", "Abstract 2"], + "synonyms": ["summary"] + }, + { + "name": "conference_id", + "type": "table column", + "column name": "cid", + "data type": "numeric", + "description": "The id of the conference related to this publication", + "sample values": [1, 2, 3], + "synonyms": [] + }, + { + "name": "citation_num", + "type": "table column", + "column name": "citation_num", + "data type": "numeric", + "description": "The number of times this publication was cited", + "sample values": [4, 2, 0], + "synonyms": [] + }, + { + "name": "journal_id", + "type": "table column", + "column name": "jid", + "data type": "numeric", + "description": "The id of the journal that publish this publication", + "sample values": [1, 2, 4], + "synonyms": [] + }, + { + "name": "publication_id", + "type": "table column", + "column name": "pid", + "data type": "numeric", + "description": "The unique idetifier for the publication", + "sample values": [1, 2, 5], + "synonyms": [] + }, + { + "name": "reference_num", + "type": "table column", + "column name": "reference_num", + "data type": "numeric", + "description": "The total number of external references made by this publication.", + "sample values": [0, 1, 4], + "synonyms": [] + }, + { + "name": "title", + "type": "table column", + "column name": "title", + "data type": "string", + "description": "The title of the paper or article.", + "sample values": ["Attention is all you need", "Optimizing GPU Throughput"], + "synonyms": [] + }, + { + "name": "year", + "type": "table column", + "column name": "year", + "data type": "numeric", + "description": "The year when the publication was published", + "sample values": [2021, 2020], + "synonyms": [] + } + ], + "description": "Stores core information about academic papers, articles, or other publications.", + "synonyms": [] + }, + { + "name": "publications_keywords", + "type": "simple table", + "table path": "main.publication_keyword", + "unique properties": [["publication_id", "keyword_id"]], + "properties": [ + { + "name": "publication_id", + "type": "table column", + "column name": "pid", + "data type": "numeric", + "description": "The id of the publication related to the keyword", + "sample values": [1, 2], + "synonyms": [] + }, + { + "name": "keyword_id", + "type": "table column", + "column name": "kid", + "data type": "numeric", + "description": "The id of the keyword used in the publication", + "sample values": [2, 3], + "synonyms": [] + } + ], + "description": "Records of keyword used in publication", + "synonyms": [] + }, + { + "name": "writes", + "type": "simple table", + "table path": "main.writes", + "unique properties": [["author_id", "publication_id"]], + "properties": [ + { + "name": "author_id", + "type": "table column", + "column name": "aid", + "data type": "numeric", + "description": "The author or co-author of the publication", + "sample values": [1, 2, 3], + "synonyms": [] + }, + { + "name": "publication_id", + "type": "table column", + "column name": "pid", + "data type": "numeric", + "description": "The publication related to the author", + "sample values": [1, 2, 3], + "synonyms": [] + } + ], + "description": "Records of authors and its publications", + "synonyms": [] + } + ], + "relationships": [ + { + "type": "simple join", + "name": "authors", + "parent collection": "organizations", + "child collection": "authors", + "singular": false, + "always matches": false, + "keys": { + "organization_id": [ + "organization_id" + ] + }, + "description": "All authors that belongs to this organization", + "synonyms": [] + }, + { + "type": "reverse", + "name": "organization", + "original parent": "organizations", + "original property": "authors", + "singular": true, + "always matches": false, + "description": "The oranization that the author belongs to", + "synonyms": [] + }, + { + "type": "simple join", + "name": "references", + "parent collection": "publications", + "child collection": "citations", + "singular": true, + "always matches": false, + "keys": { + "publication_id": [ + "citing" + ] + }, + "description": "All the citations this publication contains", + "synonyms": [] + }, + { + "type": "reverse", + "name": "publication_citing", + "original parent": "publications", + "original property": "references", + "singular": true, + "always matches": true, + "description": "The publication citing", + "synonyms": [] + }, + { + "type": "simple join", + "name": "cited_by", + "parent collection": "publications", + "child collection": "citations", + "singular": false, + "always matches": false, + "keys": { + "publication_id": [ + "cited" + ] + }, + "description": "All citations of the publication", + "synonyms": [] + }, + { + "type": "reverse", + "name": "publication_cited", + "original parent": "publications", + "original property": "cited_by", + "singular": true, + "always matches": true, + "description": "The publication cited", + "synonyms": [] + }, + { + "type": "simple join", + "name": "domain_authors", + "parent collection": "domains", + "child collection": "domains_authors", + "singular": false, + "always matches": false, + "keys": { + "domain_id": [ + "domain_id" + ] + }, + "description": "The id of the authors related to the domain", + "synonyms": [] + }, + { + "type": "reverse", + "name": "authors_domain", + "original parent": "domains", + "original property": "domain_authors", + "singular": true, + "always matches": true, + "description": "The domain related to the author id", + "synonyms": [] + }, + { + "type": "simple join", + "name": "author_domains", + "parent collection": "authors", + "child collection": "domains_authors", + "singular": false, + "always matches": false, + "keys": { + "author_id": [ + "author_id" + ] + }, + "description": "The domains id for this author", + "synonyms": [] + }, + { + "type": "reverse", + "name": "domains_author", + "original parent": "authors", + "original property": "author_domains", + "singular": true, + "always matches": true, + "description": "The author related to this domain_author", + "synonyms": [] + }, + { + "type": "simple join", + "name": "domain_conferences", + "parent collection": "domains", + "child collection": "domains_conferences", + "singular": false, + "always matches": true, + "keys": { + "domain_id": [ + "domain_id" + ] + }, + "description": "The domain_conferences related to the domain", + "synonyms": [] + }, + { + "type": "reverse", + "name": "conference_domain", + "original parent": "domains", + "original property": "domain_conferences", + "singular": true, + "always matches": true, + "description": "The domain related to the domain_conference", + "synonyms": [] + }, + { + "type": "simple join", + "name": "conference_domains", + "parent collection": "conferences", + "child collection": "domains_conferences", + "singular": false, + "always matches": false, + "keys": { + "conference_id": [ + "conference_id" + ] + }, + "description": "The domain_conference related to the conference", + "synonyms": [] + }, + { + "type": "reverse", + "name": "domain_conference", + "original parent": "conferences", + "original property": "conference_domains", + "singular": true, + "always matches": true, + "description": "The conference related to the domain_conference", + "synonyms": [] + }, + { + "type": "simple join", + "name": "journal_domains", + "parent collection": "journals", + "child collection": "domains_journals", + "singular": false, + "always matches": false, + "keys": { + "journal_id": [ + "journal_id" + ] + }, + "description": "The domains_journal related to the journal", + "synonyms": [] + }, + { + "type": "reverse", + "name": "domain_journal", + "original parent": "journals", + "original property": "journal_domains", + "singular": true, + "always matches": true, + "description": "The journal related to the domain_journal", + "synonyms": [] + }, + { + "type": "simple join", + "name": "domain_journals", + "parent collection": "domains", + "child collection": "domains_journals", + "singular": false, + "always matches": false, + "keys": { + "domain_id": [ + "domain_id" + ] + }, + "description": "The domain_journal related to the domain", + "synonyms": [] + }, + { + "type": "reverse", + "name": "jornal_domain", + "original parent": "domains", + "original property": "domain_journals", + "singular": true, + "always matches": true, + "description": "The domain linked with the domain_journal", + "synonyms": [] + }, + { + "type": "simple join", + "name": "keyword_domains", + "parent collection": "keywords", + "child collection": "domains_keywords", + "singular": false, + "always matches": false, + "keys": { + "keyword_id": [ + "keyword_id" + ] + }, + "description": "The domain_keywords related to the keyword", + "synonyms": [] + }, + { + "type": "reverse", + "name": "domain_keyword", + "original parent": "keywords", + "original property": "keyword_domains", + "singular": true, + "always matches": true, + "description": "The keyword related to the domain_keyword", + "synonyms": [] + }, + { + "type": "simple join", + "name": "domain_keywords", + "parent collection": "domains", + "child collection": "domains_keywords", + "singular": false, + "always matches": false, + "keys": { + "domain_id": [ + "domain_id" + ] + }, + "description": "The domain_keywords related to the domain", + "synonyms": [] + }, + { + "type": "reverse", + "name": "keyword_domain", + "original parent": "domains", + "original property": "domain_keywords", + "singular": true, + "always matches": true, + "description": "The keyword linked to the domain_keyword", + "synonyms": [] + }, + { + "type": "simple join", + "name": "publication_domains", + "parent collection": "publications", + "child collection": "domains_publications", + "singular": false, + "always matches": false, + "keys": { + "publication_id": [ + "publication_id" + ] + }, + "description": "The domain_publications related to the publication", + "synonyms": [] + }, + { + "type": "reverse", + "name": "domain_publication", + "original parent": "publications", + "original property": "publication_domains", + "singular": true, + "always matches": true, + "description": "The publication related to the domain_publication", + "synonyms": [] + }, + { + "type": "simple join", + "name": "domain_publications", + "parent collection": "domains", + "child collection": "domains_publications", + "singular": false, + "always matches": false, + "keys": { + "domain_id": [ + "domain_id" + ] + }, + "description": "The domain_publications related to the domain", + "synonyms": [] + }, + { + "type": "reverse", + "name": "publication_domain", + "original parent": "domains", + "original property": "domain_publications", + "singular": true, + "always matches": true, + "description": "The domain related to the domain_publication", + "synonyms": [] + }, + { + "type": "simple join", + "name": "archives", + "parent collection": "journals", + "child collection": "publications", + "singular": false, + "always matches": false, + "keys": { + "journal_id": [ + "journal_id" + ] + }, + "description": "The publications related to the journal", + "synonyms": [] + }, + { + "type": "reverse", + "name": "publisher", + "original parent": "journals", + "original property": "archives", + "singular": true, + "always matches": true, + "description": "The journal the published the publication", + "synonyms": [] + }, + { + "type": "simple join", + "name": "proceedings", + "parent collection": "conferences", + "child collection": "publications", + "singular": false, + "always matches": false, + "keys": { + "conference_id": [ + "conference_id" + ] + }, + "description": "The publications presented in the conference", + "synonyms": [] + }, + { + "type": "reverse", + "name": "conference", + "original parent": "conferences", + "original property": "proceedings", + "singular": true, + "always matches": false, + "description": "The conference where the publication was presented", + "synonyms": [] + }, + { + "type": "simple join", + "name": "keyword_publications", + "parent collection": "keywords", + "child collection": "publications_keywords", + "singular": false, + "always matches": false, + "keys": { + "keyword_id": [ + "keyword_id" + ] + }, + "description": "All publication_keywords related to the keyword", + "synonyms": [] + }, + { + "type": "reverse", + "name": "publication_keyword", + "original parent": "keywords", + "original property": "keyword_publications", + "singular": true, + "always matches": true, + "description": "The keyword linked to the publication_keyword", + "synonyms": [] + }, + { + "type": "simple join", + "name": "publication_keywords", + "parent collection": "publications", + "child collection": "publications_keywords", + "singular": false, + "always matches": false, + "keys": { + "publication_id": [ + "publication_id" + ] + }, + "description": "All publication_keywords related to the publication", + "synonyms": [] + }, + { + "type": "reverse", + "name": "keyword_publication", + "original parent": "publications", + "original property": "publication_keywords", + "singular": true, + "always matches": true, + "description": "The publication linked to the publication_keyword", + "synonyms": [] + }, + { + "type": "simple join", + "name": "publication_authors", + "parent collection": "publications", + "child collection": "writes", + "singular": false, + "always matches": false, + "keys": { + "publication_id": [ + "publication_id" + ] + }, + "description": "All authors id related to the publication", + "synonyms": [] + }, + { + "type": "reverse", + "name": "author_publication", + "original parent": "publications", + "original property": "publication_authors", + "singular": true, + "always matches": true, + "description": "The publication linked to the writes", + "synonyms": [] + }, + { + "type": "simple join", + "name": "author_publications", + "parent collection": "authors", + "child collection": "writes", + "singular": false, + "always matches": false, + "keys": { + "author_id": [ + "author_id" + ] + }, + "description": "The publications' id of the write related to the author", + "synonyms": [] + }, + { + "type": "reverse", + "name": "publication_author", + "original parent": "authors", + "original property": "author_publications", + "singular": true, + "always matches": true, + "description": "The author related to the written", + "synonyms": [] + } + ] } ] \ No newline at end of file diff --git a/tests/test_pipeline_defog.py b/tests/test_pipeline_defog.py index 563d60b6b..0cf29fe9d 100644 --- a/tests/test_pipeline_defog.py +++ b/tests/test_pipeline_defog.py @@ -14,6 +14,31 @@ UnqualifiedNode, ) from tests.test_pydough_functions.defog_outputs import ( + defog_sql_text_academic_gen1, + defog_sql_text_academic_gen2, + defog_sql_text_academic_gen3, + defog_sql_text_academic_gen4, + defog_sql_text_academic_gen5, + defog_sql_text_academic_gen6, + defog_sql_text_academic_gen7, + defog_sql_text_academic_gen8, + defog_sql_text_academic_gen9, + defog_sql_text_academic_gen10, + defog_sql_text_academic_gen11, + defog_sql_text_academic_gen12, + defog_sql_text_academic_gen13, + defog_sql_text_academic_gen14, + defog_sql_text_academic_gen15, + defog_sql_text_academic_gen16, + defog_sql_text_academic_gen17, + defog_sql_text_academic_gen18, + defog_sql_text_academic_gen19, + defog_sql_text_academic_gen20, + defog_sql_text_academic_gen21, + defog_sql_text_academic_gen22, + defog_sql_text_academic_gen23, + defog_sql_text_academic_gen24, + defog_sql_text_academic_gen25, defog_sql_text_broker_adv1, defog_sql_text_broker_adv2, defog_sql_text_broker_adv3, @@ -140,6 +165,31 @@ defog_sql_text_ewallet_gen5, ) from tests.test_pydough_functions.defog_test_functions import ( + impl_defog_academic_gen1, + impl_defog_academic_gen2, + impl_defog_academic_gen3, + impl_defog_academic_gen4, + impl_defog_academic_gen5, + impl_defog_academic_gen6, + impl_defog_academic_gen7, + impl_defog_academic_gen8, + impl_defog_academic_gen9, + impl_defog_academic_gen10, + impl_defog_academic_gen11, + impl_defog_academic_gen12, + impl_defog_academic_gen13, + impl_defog_academic_gen14, + impl_defog_academic_gen15, + impl_defog_academic_gen16, + impl_defog_academic_gen17, + impl_defog_academic_gen18, + impl_defog_academic_gen19, + impl_defog_academic_gen20, + impl_defog_academic_gen21, + impl_defog_academic_gen22, + impl_defog_academic_gen23, + impl_defog_academic_gen24, + impl_defog_academic_gen25, impl_defog_broker_adv1, impl_defog_broker_adv2, impl_defog_broker_adv3, @@ -1441,6 +1491,239 @@ def test_graph_structure_defog(defog_graphs: graph_fetcher, graph_name: str) -> ), id="dermtreatment_gen5", ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen1, + "Academic", + defog_sql_text_academic_gen1, + "academic_gen1", + ), + id="academic_gen1", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen2, + "Academic", + defog_sql_text_academic_gen2, + "academic_gen2", + ), + id="academic_gen2", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen3, + "Academic", + defog_sql_text_academic_gen3, + "academic_gen3", + ), + id="academic_gen3", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen4, + "Academic", + defog_sql_text_academic_gen4, + "academic_gen4", + ), + id="academic_gen4", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen5, + "Academic", + defog_sql_text_academic_gen5, + "academic_gen5", + ), + id="academic_gen5", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen6, + "Academic", + defog_sql_text_academic_gen6, + "academic_gen6", + ), + id="academic_gen6", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen7, + "Academic", + defog_sql_text_academic_gen7, + "academic_gen7", + order_sensitive=True, + ), + id="academic_gen7", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen8, + "Academic", + defog_sql_text_academic_gen8, + "academic_gen8", + order_sensitive=True, + ), + id="academic_gen8", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen9, + "Academic", + defog_sql_text_academic_gen9, + "academic_gen9", + order_sensitive=True, + ), + id="academic_gen9", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen10, + "Academic", + defog_sql_text_academic_gen10, + "academic_gen10", + order_sensitive=True, + ), + id="academic_gen10", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen11, + "Academic", + defog_sql_text_academic_gen11, + "academic_gen11", + ), + id="academic_gen11", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen12, + "Academic", + defog_sql_text_academic_gen12, + "academic_gen12", + ), + id="academic_gen12", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen13, + "Academic", + defog_sql_text_academic_gen13, + "academic_gen13", + ), + id="academic_gen13", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen14, + "Academic", + defog_sql_text_academic_gen14, + "academic_gen14", + order_sensitive=True, + ), + id="academic_gen14", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen15, + "Academic", + defog_sql_text_academic_gen15, + "academic_gen15", + ), + id="academic_gen15", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen16, + "Academic", + defog_sql_text_academic_gen16, + "academic_gen16", + ), + id="academic_gen16", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen17, + "Academic", + defog_sql_text_academic_gen17, + "academic_gen17", + order_sensitive=True, + ), + id="academic_gen17", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen18, + "Academic", + defog_sql_text_academic_gen18, + "academic_gen18", + order_sensitive=True, + ), + id="academic_gen18", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen19, + "Academic", + defog_sql_text_academic_gen19, + "academic_gen19", + order_sensitive=True, + ), + id="academic_gen19", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen20, + "Academic", + defog_sql_text_academic_gen20, + "academic_gen20", + ), + id="academic_gen20", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen21, + "Academic", + defog_sql_text_academic_gen21, + "academic_gen21", + ), + id="academic_gen21", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen22, + "Academic", + defog_sql_text_academic_gen22, + "academic_gen22", + ), + id="academic_gen22", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen23, + "Academic", + defog_sql_text_academic_gen23, + "academic_gen23", + ), + id="academic_gen23", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen24, + "Academic", + defog_sql_text_academic_gen24, + "academic_gen24", + ), + id="academic_gen24", + ), + pytest.param( + PyDoughSQLComparisonTest( + impl_defog_academic_gen25, + "Academic", + defog_sql_text_academic_gen25, + "academic_gen25", + ), + id="academic_gen25", + ), ], ) def defog_pipeline_test_data( diff --git a/tests/test_pydough_functions/defog_outputs.py b/tests/test_pydough_functions/defog_outputs.py index f87474eef..6f9da69bb 100644 --- a/tests/test_pydough_functions/defog_outputs.py +++ b/tests/test_pydough_functions/defog_outputs.py @@ -2486,3 +2486,411 @@ def defog_sql_text_dermtreatment_gen5() -> str: dr.fda_appr_dt IS NOT NULL AND t.end_dt >= DATE('now', '-6 months'); """ + + +def defog_sql_text_academic_gen1() -> str: + """ + SQLite query text for the following question for the Academic graph: + + Which authors have written publications in both the domain + 'Machine Learning' and the domain 'Data Science'? + """ + return """ + SELECT author.name + FROM author + WHERE author.aid IN ( + SELECT domain_author.aid + FROM domain_author + WHERE domain_author.did IN ( + SELECT domain.did + FROM DOMAIN + WHERE domain.name IN ('Machine Learning', 'Data Science') + ) + GROUP BY 1 HAVING COUNT(DISTINCT domain_author.did) = 2 + ); + """ + + +def defog_sql_text_academic_gen2() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the total number of citations received by each author? + """ + return """ + SELECT author.name, SUM(publication.citation_num) AS total_citations + FROM author + JOIN writes ON author.aid = writes.aid + JOIN publication ON writes.pid = publication.pid + GROUP BY author.name + ORDER BY total_citations DESC; + """ + + +def defog_sql_text_academic_gen3() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the total number of publications published in each year? + """ + return """ + SELECT publication.year, COUNT(DISTINCT publication.pid) AS total_publications + FROM publication + GROUP BY publication.year + ORDER BY publication.year NULLS LAST; + """ + + +def defog_sql_text_academic_gen4() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the average number of references cited by publications in each + domain name? + """ + return """ + SELECT domain.name, AVG(publication.reference_num) AS average_references + FROM domain_publication + JOIN publication ON domain_publication.pid = publication.pid + JOIN domain ON domain.did = domain_publication.did + GROUP BY domain.name; + """ + + +def defog_sql_text_academic_gen5() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the average number of citations received by publications in each year? + """ + return """ + SELECT publication.year, AVG(publication.citation_num) AS average_citations + FROM publication + GROUP BY publication.year + ORDER BY publication.year NULLS LAST; + """ + + +def defog_sql_text_academic_gen6() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the title of the publication that has received the highest number of + citations? + """ + return """ + SELECT publication.title FROM publication ORDER BY publication.citation_num + DESC LIMIT 1; + """ + + +def defog_sql_text_academic_gen7() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What are the top 5 domains with the highest number of authors associated + with them? + """ + return """ + SELECT d.name, COUNT(DISTINCT a.aid) AS author_count + FROM author AS a JOIN domain_author AS da ON a.aid = da.aid + JOIN domain AS d ON da.did = d.did + GROUP BY d.name + ORDER BY author_count DESC NULLS FIRST LIMIT 5; + """ + + +def defog_sql_text_academic_gen8() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What are the top 3 titles of the publications that have the highest number + of references cited, ordered by the number of references cited in descending + order? + """ + return """ + SELECT publication.title + FROM publication + ORDER BY publication.reference_num DESC NULLS FIRST LIMIT 3; + """ + + +def defog_sql_text_academic_gen9() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What are the top 3 publications with the highest number of citations? + """ + return """ + SELECT publication.title, publication.citation_num + FROM publication + ORDER BY publication.citation_num DESC NULLS FIRST LIMIT 3; + """ + + +def defog_sql_text_academic_gen10() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What are the titles of all publications ordered alphabetically? + """ + return """ + SELECT DISTINCT publication.title + FROM publication + ORDER BY publication.title ASC NULLS LAST; + """ + + +def defog_sql_text_academic_gen11() -> str: + """ + SQLite query text for the following question for the Academic graph: + + + What is the ratio of publications to authors in the database? + """ + return """ + SELECT CAST( + COUNT( + DISTINCT publication.pid + ) AS REAL + ) / NULLIF(COUNT(DISTINCT author.aid), 0) AS publication_to_author_ratio + FROM publication, author; + """ + + +def defog_sql_text_academic_gen12() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the ratio of publications presented in conferences to publications + published in journals? + """ + return """ + SELECT CAST( + COUNT( + DISTINCT CASE WHEN NOT cid IS NULL THEN pid END + ) AS REAL + ) / NULLIF(COUNT(DISTINCT CASE WHEN NOT jid IS NULL THEN pid END), 0) AS ratio + FROM publication; + """ + + +def defog_sql_text_academic_gen13() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the ratio of the total number of publications to the total number of + keywords within each domain ID? Show all domain IDs. + """ + return """ + SELECT domain_publication.did, + CAST( + COUNT( + DISTINCT domain_publication.pid + ) AS REAL + ) / NULLIF(COUNT(DISTINCT domain_keyword.kid), 0) AS publication_to_keyword_ratio + FROM domain_publication + LEFT JOIN domain_keyword ON domain_publication.did = domain_keyword.did + GROUP BY domain_publication.did + ORDER BY publication_to_keyword_ratio DESC; + """ + + +def defog_sql_text_academic_gen14() -> str: + """ + SQLite query text for the following question for the Academic graph: + + How does the ratio of publications to journals change over the years? Return + the annual numbers of publications and journals as well. + """ + return """ + SELECT publication.year, + COUNT(DISTINCT publication.pid) AS num_publications, + COUNT(DISTINCT publication.jid) AS num_journals, + CAST(COUNT(DISTINCT publication.pid) AS REAL) / NULLIF(COUNT(DISTINCT publication.jid), 0) AS ratio + FROM publication + GROUP BY publication.year + ORDER BY publication.year NULLS LAST; + """ + + +def defog_sql_text_academic_gen15() -> str: + """ + SQLite query text for the following question for the Academic graph: + + How does the ratio of authors to organizations differ by continent? + """ + return """ + SELECT organization.continent, + CAST(COUNT(DISTINCT author.aid) AS REAL) / NULLIF(COUNT(DISTINCT organization.oid), 0) AS ratio + FROM organization + LEFT JOIN author ON author.oid = organization.oid + GROUP BY organization.continent + ORDER BY ratio DESC; + """ + + +def defog_sql_text_academic_gen16() -> str: + """ + SQLite query text for the following question for the Academic graph: + + Which author had the most publications in the year 2021 and how many + publications did he/she have that year? + """ + return """ + SELECT author.name, + COUNT(publication.pid) AS publication_count + FROM writes + JOIN author ON writes.aid = author.aid + JOIN publication ON writes.pid = publication.pid + WHERE publication.year = 2021 + GROUP BY author.name + ORDER BY publication_count DESC LIMIT 1; + """ + + +def defog_sql_text_academic_gen17() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the total number of publications presented in each conference? + """ + return """ + SELECT conference.name, COUNT(publication.pid) AS total_publications + FROM publication + JOIN conference ON publication.cid = conference.cid + GROUP BY conference.name + ORDER BY total_publications DESC NULLS FIRST; + """ + + +def defog_sql_text_academic_gen18() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What is the total number of publications in each journal, ordered by the + number of publications in descending order? + """ + return """ + SELECT journal.name, journal.jid, COUNT(publication.pid) AS total_publications + FROM journal + LEFT JOIN publication ON journal.jid = publication.jid + GROUP BY journal.name, journal.jid + ORDER BY total_publications DESC; + """ + + +def defog_sql_text_academic_gen19() -> str: + """ + SQLite query text for the following question for the Academic graph: + + How many publications were presented at each conference, ordered by the + number of publications in descending order? Give the names of the conferences + and their corresponding number of publications. + """ + return """ + SELECT conference.name, COUNT(publication.pid) AS num_publications + FROM publication + JOIN conference ON publication.cid = conference.cid + GROUP BY conference.name, conference.cid + ORDER BY num_publications DESC; + """ + + +def defog_sql_text_academic_gen20() -> str: + """ + SQLite query text for the following question for the Academic graph: + + How many publications were published in journals whose names start with the + letter 'J'? + """ + return """ + SELECT COUNT(DISTINCT publication.pid) + FROM publication + JOIN journal ON publication.jid = journal.jid + WHERE LOWER(journal.name) LIKE LOWER('J%'); + """ + + +def defog_sql_text_academic_gen21() -> str: + """ + SQLite query text for the following question for the Academic graph: + + Which organizations have authors who have written publications in the + domain 'Machine Learning'? + """ + return """ + SELECT DISTINCT organization.name, organization.oid + FROM organization + JOIN author ON organization.oid = author.oid + JOIN writes ON author.aid = writes.aid + JOIN domain_publication ON writes.pid = domain_publication.pid + JOIN domain ON domain_publication.did = domain.did + WHERE domain.name = 'Machine Learning'; + """ + + +def defog_sql_text_academic_gen22() -> str: + """ + SQLite query text for the following question for the Academic graph: + + Which authors belong to the same domain as Martin?,Always filter names using + LIKE with percent sign wildcards + """ + return """ + SELECT DISTINCT a2.name, a2.aid + FROM author AS a1 + JOIN domain_author AS da1 ON a1.aid = da1.aid + JOIN domain_author AS da2 ON da1.did = da2.did + JOIN author AS a2 ON da2.aid = a2.aid + WHERE LOWER(LOWER(a1.name)) LIKE LOWER('%martin%'); + """ + + +def defog_sql_text_academic_gen23() -> str: + """ + SQLite query text for the following question for the Academic graph: + + Which authors are not part of any organization? + """ + return """ + SELECT DISTINCT name, aid FROM author WHERE oid IS NULL; + """ + + +def defog_sql_text_academic_gen24() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What are the publications written by authors from the 'Sociology' domain and + presented at conferences in the year 2020? + """ + return """ + SELECT DISTINCT publication.title + FROM domain + JOIN domain_author ON domain.did = domain_author.did + JOIN writes ON domain_author.aid = writes.aid + JOIN publication ON writes.pid = publication.pid + JOIN domain_conference ON domain.did = domain_conference.did + WHERE LOWER(domain.name) LIKE LOWER('%Sociology%') + AND publication.year = 2020 + AND publication.cid = domain_conference.cid; + """ + + +def defog_sql_text_academic_gen25() -> str: + """ + SQLite query text for the following question for the Academic graph: + + What are the names of the authors who have written publications in the + domain 'Computer Science'? + """ + return """ + SELECT DISTINCT author.name + FROM author + JOIN writes ON author.aid = writes.aid + JOIN publication ON writes.pid = publication.pid + JOIN domain_publication ON publication.pid = domain_publication.pid + JOIN domain ON domain_publication.did = domain.did + WHERE LOWER(domain.name) LIKE LOWER('%computer%science%'); + """ diff --git a/tests/test_pydough_functions/defog_test_functions.py b/tests/test_pydough_functions/defog_test_functions.py index 2b699e354..9429dce45 100644 --- a/tests/test_pydough_functions/defog_test_functions.py +++ b/tests/test_pydough_functions/defog_test_functions.py @@ -2430,3 +2430,348 @@ def impl_defog_dermtreatment_gen5(): ) ) ) + + +def impl_defog_academic_gen1(): + """ + PyDough implementation of the following question for the Academic + graph: + + Which authors have written publications in both the domain + 'Machine Learning' and the domain 'Data Science'? + """ + selected_domains = author_publications.author_publication.publication_domains.WHERE( + ISIN(publication_domain.name, ("Data Science", "Machine Learning")) + ) + + return authors.WHERE(NDISTINCT(selected_domains.domain_id) == 2).CALCULATE(name) + + +def impl_defog_academic_gen2(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the total number of citations received by each author? + """ + publications = author_publications.author_publication + + return authors.WHERE(HAS(publications)).CALCULATE( + name, total_citations=SUM(publications.citation_num) + ) + + +def impl_defog_academic_gen3(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the total number of publications published in each year? + """ + return publications.PARTITION(name="years", by=year).CALCULATE( + year, COUNT(publications) + ) + + +def impl_defog_academic_gen4(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the average number of references cited by publications in each + domain name? + """ + return domains.CALCULATE( + name, + average_references=AVG(domain_publications.domain_publication.reference_num), + ) + + +def impl_defog_academic_gen5(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the average number of citations received by publications in each year? + """ + return publications.PARTITION(name="years", by=year).CALCULATE( + year, average_citations=AVG(publications.citation_num) + ) + + +def impl_defog_academic_gen6(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the title of the publication that has received the highest number of + citations? + """ + return publications.CALCULATE(title).TOP_K(1, by=citation_num.DESC()) + + +def impl_defog_academic_gen7(): + """ + PyDough implementation of the following question for the Academic + graph: + + What are the top 5 domains with the highest number of authors associated + with them? + """ + return ( + domains.PARTITION(name="names", by=name) + .CALCULATE(name, author_count=NDISTINCT(domains.domain_authors.author_id)) + .TOP_K(5, by=author_count) + .ORDER_BY(author_count.DESC(), name.DESC()) + ) + + +def impl_defog_academic_gen8(): + """ + PyDough implementation of the following question for the Academic + graph: + + What are the top 3 titles of the publications that have the highest number + of references cited, ordered by the number of references cited in descending + order? + """ + return publications.CALCULATE(title).TOP_K(3, by=reference_num.DESC()) + + +def impl_defog_academic_gen9(): + """ + PyDough implementation of the following question for the Academic + graph: + + What are the top 3 publications with the highest number of citations? + """ + return publications.CALCULATE(title, citation_num).TOP_K(3, by=citation_num.DESC()) + + +def impl_defog_academic_gen10(): + """ + PyDough implementation of the following question for the Academic + graph: + + What are the titles of all publications ordered alphabetically? + """ + return publications.CALCULATE(title).ORDER_BY(title.ASC()) + + +def impl_defog_academic_gen11(): + """ + PyDough implementation of the following question for the Academic + graph: + + + What is the ratio of publications to authors in the database? + """ + return Academic.CALCULATE( + publication_to_author_ratio=NDISTINCT(publications.publication_id) + / NDISTINCT(authors.author_id) + ) + + +def impl_defog_academic_gen12(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the ratio of publications presented in conferences to publications + published in journals? + """ + return Academic.CALCULATE( + ratio=NDISTINCT(publications.conference_id) / NDISTINCT(publications.journal_id) + ) + + +def impl_defog_academic_gen13(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the ratio of the total number of publications to the total number of + keywords within each domain ID? Show all domain IDs. + """ + + ratio_calc = IFF( + HAS(domains_publications.publication_domain.domain_keywords), + COUNT(domains_publications.domain_publication) + / COUNT(domains_publications.publication_domain.domain_keywords), + None, + ) + return domains_publications.PARTITION(name="domains", by=domain_id).CALCULATE( + domain_id, ratio=ratio_calc + ) + + +def impl_defog_academic_gen14(): + """ + PyDough implementation of the following question for the Academic + graph: + + How does the ratio of publications to journals change over the years? Return + the annual numbers of publications and journals as well. + """ + return ( + publications.PARTITION(name="years", by=year) + .CALCULATE( + year, + num_publications=NDISTINCT(publications.publication_id), + num_journals=NDISTINCT(publications.journal_id), + ) + .CALCULATE( + year, + num_publications, + num_journals, + ratio=IFF(num_journals > 0, num_publications / num_journals, None), + ) + ) + + +def impl_defog_academic_gen15(): + """ + PyDough implementation of the following question for the Academic + graph: + + How does the ratio of authors to organizations differ by continent? + """ + return ( + organizations.PARTITION(name="continents", by=continent) + .CALCULATE( + continent, + ratio=IFF( + HAS(organizations.authors), + NDISTINCT(organizations.authors.author_id) + / NDISTINCT(organizations.organization_id), + 0, + ), + ) + .ORDER_BY(ratio.DESC()) + ) + + +def impl_defog_academic_gen16(): + """ + PyDough implementation of the following question for the Academic + graph: + + Which author had the most publications in the year 2021 and how many + publications did he/she have that year? + """ + return ( + writes.CALCULATE(author_name=publication_author.name) + .PARTITION(name="authors", by=author_name) + .CALCULATE( + name=author_name, + count_publication=NDISTINCT( + writes.WHERE(author_publication.year == 2021).publication_id + ), + ) + .TOP_K(1, by=count_publication.DESC()) + ) + + +def impl_defog_academic_gen17(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the total number of publications presented in each conference? + """ + return conferences.CALCULATE(name, count_publications=COUNT(proceedings)).ORDER_BY( + count_publications.DESC(), name.DESC() + ) + + +def impl_defog_academic_gen18(): + """ + PyDough implementation of the following question for the Academic + graph: + + What is the total number of publications in each journal, ordered by the + number of publications in descending order? + """ + return journals.CALCULATE( + name, jid=journal_id, num_publications=COUNT(archives) + ).ORDER_BY(num_publications.DESC()) + + +def impl_defog_academic_gen19(): + """ + PyDough implementation of the following question for the Academic + graph: + + How many publications were presented at each conference, ordered by the + number of publications in descending order? Give the names of the conferences + and their corresponding number of publications. + """ + return conferences.CALCULATE(name, num_publications=COUNT(proceedings)).ORDER_BY( + num_publications.DESC(), name + ) + + +def impl_defog_academic_gen20(): + """ + PyDough implementation of the following question for the Academic + graph: + + How many publications were published in journals whose names start with the + letter 'J'? + """ + selected_publications = publications.WHERE(STARTSWITH(LOWER(publisher.name), "j")) + return Academic.CALCULATE(n=COUNT(selected_publications)) + + +def impl_defog_academic_gen21(): + """ + PyDough implementation of the following question for the Academic + graph: + + Which organizations have authors who have written publications in the + domain 'Machine Learning'? + """ + return + + +def impl_defog_academic_gen22(): + """ + PyDough implementation of the following question for the Academic + graph: + + Which authors belong to the same domain as Martin?,Always filter names using + LIKE with percent sign wildcards + """ + return + + +def impl_defog_academic_gen23(): + """ + PyDough implementation of the following question for the Academic + graph: + + Which authors are not part of any organization? + """ + return + + +def impl_defog_academic_gen24(): + """ + PyDough implementation of the following question for the Academic + graph: + + What are the publications written by authors from the 'Sociology' domain and + presented at conferences in the year 2020? + """ + return + + +def impl_defog_academic_gen25(): + """ + PyDough implementation of the following question for the Academic + graph: + + What are the names of the authors who have written publications in the + domain 'Computer Science'? + """ + return diff --git a/tests/test_sql_refsols/defog_academic_gen10_ansi.sql b/tests/test_sql_refsols/defog_academic_gen10_ansi.sql new file mode 100644 index 000000000..769ac8c2d --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen10_ansi.sql @@ -0,0 +1,5 @@ +SELECT + title +FROM main.publication +ORDER BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen10_mysql.sql b/tests/test_sql_refsols/defog_academic_gen10_mysql.sql new file mode 100644 index 000000000..2cea8eea3 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen10_mysql.sql @@ -0,0 +1,5 @@ +SELECT + title COLLATE utf8mb4_bin AS title +FROM main.publication +ORDER BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen10_postgres.sql b/tests/test_sql_refsols/defog_academic_gen10_postgres.sql new file mode 100644 index 000000000..1626c5df3 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen10_postgres.sql @@ -0,0 +1,5 @@ +SELECT + title +FROM main.publication +ORDER BY + 1 NULLS FIRST diff --git a/tests/test_sql_refsols/defog_academic_gen10_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen10_snowflake.sql new file mode 100644 index 000000000..1626c5df3 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen10_snowflake.sql @@ -0,0 +1,5 @@ +SELECT + title +FROM main.publication +ORDER BY + 1 NULLS FIRST diff --git a/tests/test_sql_refsols/defog_academic_gen10_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen10_sqlite.sql new file mode 100644 index 000000000..769ac8c2d --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen10_sqlite.sql @@ -0,0 +1,5 @@ +SELECT + title +FROM main.publication +ORDER BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen11_ansi.sql b/tests/test_sql_refsols/defog_academic_gen11_ansi.sql new file mode 100644 index 000000000..6ae7b3468 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen11_ansi.sql @@ -0,0 +1,13 @@ +WITH _s0 AS ( + SELECT + COUNT(DISTINCT pid) AS ndistinct_pid + FROM main.publication +), _s1 AS ( + SELECT + COUNT(DISTINCT aid) AS ndistinct_aid + FROM main.author +) +SELECT + _s0.ndistinct_pid / _s1.ndistinct_aid AS publication_to_author_ratio +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 diff --git a/tests/test_sql_refsols/defog_academic_gen11_mysql.sql b/tests/test_sql_refsols/defog_academic_gen11_mysql.sql new file mode 100644 index 000000000..6ae7b3468 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen11_mysql.sql @@ -0,0 +1,13 @@ +WITH _s0 AS ( + SELECT + COUNT(DISTINCT pid) AS ndistinct_pid + FROM main.publication +), _s1 AS ( + SELECT + COUNT(DISTINCT aid) AS ndistinct_aid + FROM main.author +) +SELECT + _s0.ndistinct_pid / _s1.ndistinct_aid AS publication_to_author_ratio +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 diff --git a/tests/test_sql_refsols/defog_academic_gen11_postgres.sql b/tests/test_sql_refsols/defog_academic_gen11_postgres.sql new file mode 100644 index 000000000..94b5c2735 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen11_postgres.sql @@ -0,0 +1,13 @@ +WITH _s0 AS ( + SELECT + COUNT(DISTINCT pid) AS ndistinct_pid + FROM main.publication +), _s1 AS ( + SELECT + COUNT(DISTINCT aid) AS ndistinct_aid + FROM main.author +) +SELECT + CAST(_s0.ndistinct_pid AS DOUBLE PRECISION) / _s1.ndistinct_aid AS publication_to_author_ratio +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 diff --git a/tests/test_sql_refsols/defog_academic_gen11_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen11_snowflake.sql new file mode 100644 index 000000000..6ae7b3468 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen11_snowflake.sql @@ -0,0 +1,13 @@ +WITH _s0 AS ( + SELECT + COUNT(DISTINCT pid) AS ndistinct_pid + FROM main.publication +), _s1 AS ( + SELECT + COUNT(DISTINCT aid) AS ndistinct_aid + FROM main.author +) +SELECT + _s0.ndistinct_pid / _s1.ndistinct_aid AS publication_to_author_ratio +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 diff --git a/tests/test_sql_refsols/defog_academic_gen11_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen11_sqlite.sql new file mode 100644 index 000000000..4e7938208 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen11_sqlite.sql @@ -0,0 +1,13 @@ +WITH _s0 AS ( + SELECT + COUNT(DISTINCT pid) AS ndistinct_pid + FROM main.publication +), _s1 AS ( + SELECT + COUNT(DISTINCT aid) AS ndistinct_aid + FROM main.author +) +SELECT + CAST(_s0.ndistinct_pid AS REAL) / _s1.ndistinct_aid AS publication_to_author_ratio +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 diff --git a/tests/test_sql_refsols/defog_academic_gen12_ansi.sql b/tests/test_sql_refsols/defog_academic_gen12_ansi.sql new file mode 100644 index 000000000..83b3d3201 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen12_ansi.sql @@ -0,0 +1,3 @@ +SELECT + COUNT(DISTINCT cid) / COUNT(DISTINCT jid) AS ratio +FROM main.publication diff --git a/tests/test_sql_refsols/defog_academic_gen12_mysql.sql b/tests/test_sql_refsols/defog_academic_gen12_mysql.sql new file mode 100644 index 000000000..83b3d3201 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen12_mysql.sql @@ -0,0 +1,3 @@ +SELECT + COUNT(DISTINCT cid) / COUNT(DISTINCT jid) AS ratio +FROM main.publication diff --git a/tests/test_sql_refsols/defog_academic_gen12_postgres.sql b/tests/test_sql_refsols/defog_academic_gen12_postgres.sql new file mode 100644 index 000000000..934f4f1ce --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen12_postgres.sql @@ -0,0 +1,3 @@ +SELECT + CAST(COUNT(DISTINCT cid) AS DOUBLE PRECISION) / COUNT(DISTINCT jid) AS ratio +FROM main.publication diff --git a/tests/test_sql_refsols/defog_academic_gen12_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen12_snowflake.sql new file mode 100644 index 000000000..83b3d3201 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen12_snowflake.sql @@ -0,0 +1,3 @@ +SELECT + COUNT(DISTINCT cid) / COUNT(DISTINCT jid) AS ratio +FROM main.publication diff --git a/tests/test_sql_refsols/defog_academic_gen12_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen12_sqlite.sql new file mode 100644 index 000000000..05199d7c3 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen12_sqlite.sql @@ -0,0 +1,3 @@ +SELECT + CAST(COUNT(DISTINCT cid) AS REAL) / COUNT(DISTINCT jid) AS ratio +FROM main.publication diff --git a/tests/test_sql_refsols/defog_academic_gen13_ansi.sql b/tests/test_sql_refsols/defog_academic_gen13_ansi.sql new file mode 100644 index 000000000..f7365d715 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen13_ansi.sql @@ -0,0 +1,24 @@ +WITH _s3 AS ( + SELECT + domain.did, + COUNT(*) AS n_rows + FROM main.domain AS domain + JOIN main.domain_keyword AS domain_keyword + ON domain.did = domain_keyword.did + GROUP BY + 1 +) +SELECT + domain_publication.did AS domain_id, + CASE + WHEN ( + NOT SUM(_s3.n_rows) IS NULL AND SUM(_s3.n_rows) > 0 + ) + THEN COUNT(*) / COALESCE(SUM(_s3.n_rows), 0) + ELSE NULL + END AS ratio +FROM main.domain_publication AS domain_publication +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain_publication.did +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen13_mysql.sql b/tests/test_sql_refsols/defog_academic_gen13_mysql.sql new file mode 100644 index 000000000..f7365d715 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen13_mysql.sql @@ -0,0 +1,24 @@ +WITH _s3 AS ( + SELECT + domain.did, + COUNT(*) AS n_rows + FROM main.domain AS domain + JOIN main.domain_keyword AS domain_keyword + ON domain.did = domain_keyword.did + GROUP BY + 1 +) +SELECT + domain_publication.did AS domain_id, + CASE + WHEN ( + NOT SUM(_s3.n_rows) IS NULL AND SUM(_s3.n_rows) > 0 + ) + THEN COUNT(*) / COALESCE(SUM(_s3.n_rows), 0) + ELSE NULL + END AS ratio +FROM main.domain_publication AS domain_publication +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain_publication.did +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen13_postgres.sql b/tests/test_sql_refsols/defog_academic_gen13_postgres.sql new file mode 100644 index 000000000..b258bd844 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen13_postgres.sql @@ -0,0 +1,24 @@ +WITH _s3 AS ( + SELECT + domain.did, + COUNT(*) AS n_rows + FROM main.domain AS domain + JOIN main.domain_keyword AS domain_keyword + ON domain.did = domain_keyword.did + GROUP BY + 1 +) +SELECT + domain_publication.did AS domain_id, + CASE + WHEN ( + NOT SUM(_s3.n_rows) IS NULL AND SUM(_s3.n_rows) > 0 + ) + THEN CAST(COUNT(*) AS DOUBLE PRECISION) / COALESCE(SUM(_s3.n_rows), 0) + ELSE NULL + END AS ratio +FROM main.domain_publication AS domain_publication +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain_publication.did +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen13_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen13_snowflake.sql new file mode 100644 index 000000000..5885606cb --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen13_snowflake.sql @@ -0,0 +1,24 @@ +WITH _s3 AS ( + SELECT + domain.did, + COUNT(*) AS n_rows + FROM main.domain AS domain + JOIN main.domain_keyword AS domain_keyword + ON domain.did = domain_keyword.did + GROUP BY + 1 +) +SELECT + domain_publication.did AS domain_id, + IFF( + ( + NOT SUM(_s3.n_rows) IS NULL AND SUM(_s3.n_rows) > 0 + ), + COUNT(*) / COALESCE(SUM(_s3.n_rows), 0), + NULL + ) AS ratio +FROM main.domain_publication AS domain_publication +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain_publication.did +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen13_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen13_sqlite.sql new file mode 100644 index 000000000..370125c83 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen13_sqlite.sql @@ -0,0 +1,24 @@ +WITH _s3 AS ( + SELECT + domain.did, + COUNT(*) AS n_rows + FROM main.domain AS domain + JOIN main.domain_keyword AS domain_keyword + ON domain.did = domain_keyword.did + GROUP BY + 1 +) +SELECT + domain_publication.did AS domain_id, + IIF( + ( + NOT SUM(_s3.n_rows) IS NULL AND SUM(_s3.n_rows) > 0 + ), + CAST(COUNT(*) AS REAL) / COALESCE(SUM(_s3.n_rows), 0), + NULL + ) AS ratio +FROM main.domain_publication AS domain_publication +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain_publication.did +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen14_ansi.sql b/tests/test_sql_refsols/defog_academic_gen14_ansi.sql new file mode 100644 index 000000000..23c6815d2 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen14_ansi.sql @@ -0,0 +1,12 @@ +SELECT + year, + COUNT(DISTINCT pid) AS num_publications, + COUNT(DISTINCT jid) AS num_journals, + CASE + WHEN COUNT(DISTINCT jid) > 0 + THEN COUNT(DISTINCT pid) / COUNT(DISTINCT jid) + ELSE NULL + END AS ratio +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen14_mysql.sql b/tests/test_sql_refsols/defog_academic_gen14_mysql.sql new file mode 100644 index 000000000..23c6815d2 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen14_mysql.sql @@ -0,0 +1,12 @@ +SELECT + year, + COUNT(DISTINCT pid) AS num_publications, + COUNT(DISTINCT jid) AS num_journals, + CASE + WHEN COUNT(DISTINCT jid) > 0 + THEN COUNT(DISTINCT pid) / COUNT(DISTINCT jid) + ELSE NULL + END AS ratio +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen14_postgres.sql b/tests/test_sql_refsols/defog_academic_gen14_postgres.sql new file mode 100644 index 000000000..e3ed11f71 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen14_postgres.sql @@ -0,0 +1,12 @@ +SELECT + year, + COUNT(DISTINCT pid) AS num_publications, + COUNT(DISTINCT jid) AS num_journals, + CASE + WHEN COUNT(DISTINCT jid) > 0 + THEN CAST(COUNT(DISTINCT pid) AS DOUBLE PRECISION) / COUNT(DISTINCT jid) + ELSE NULL + END AS ratio +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen14_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen14_snowflake.sql new file mode 100644 index 000000000..36f2b46e6 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen14_snowflake.sql @@ -0,0 +1,8 @@ +SELECT + year, + COUNT(DISTINCT pid) AS num_publications, + COUNT(DISTINCT jid) AS num_journals, + IFF(COUNT(DISTINCT jid) > 0, COUNT(DISTINCT pid) / COUNT(DISTINCT jid), NULL) AS ratio +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen14_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen14_sqlite.sql new file mode 100644 index 000000000..85481df74 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen14_sqlite.sql @@ -0,0 +1,12 @@ +SELECT + year, + COUNT(DISTINCT pid) AS num_publications, + COUNT(DISTINCT jid) AS num_journals, + IIF( + COUNT(DISTINCT jid) > 0, + CAST(COUNT(DISTINCT pid) AS REAL) / COUNT(DISTINCT jid), + NULL + ) AS ratio +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen15_ansi.sql b/tests/test_sql_refsols/defog_academic_gen15_ansi.sql new file mode 100644 index 000000000..8f073f4d5 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen15_ansi.sql @@ -0,0 +1,37 @@ +WITH _t1 AS ( + SELECT + continent, + oid + FROM main.organization +), _s2 AS ( + SELECT + continent, + COUNT(DISTINCT oid) AS ndistinct_oid + FROM _t1 + GROUP BY + 1 +), _s3 AS ( + SELECT + _s0.continent, + COUNT(*) AS n_rows, + COUNT(DISTINCT author.aid) AS ndistinct_aid + FROM _t1 AS _s0 + JOIN main.author AS author + ON _s0.oid = author.oid + GROUP BY + 1 +) +SELECT + _s2.continent, + CASE + WHEN ( + NOT _s3.n_rows IS NULL AND _s3.n_rows > 0 + ) + THEN COALESCE(_s3.ndistinct_aid, 0) / _s2.ndistinct_oid + ELSE 0 + END AS ratio +FROM _s2 AS _s2 +LEFT JOIN _s3 AS _s3 + ON _s2.continent = _s3.continent +ORDER BY + 2 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen15_mysql.sql b/tests/test_sql_refsols/defog_academic_gen15_mysql.sql new file mode 100644 index 000000000..8f073f4d5 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen15_mysql.sql @@ -0,0 +1,37 @@ +WITH _t1 AS ( + SELECT + continent, + oid + FROM main.organization +), _s2 AS ( + SELECT + continent, + COUNT(DISTINCT oid) AS ndistinct_oid + FROM _t1 + GROUP BY + 1 +), _s3 AS ( + SELECT + _s0.continent, + COUNT(*) AS n_rows, + COUNT(DISTINCT author.aid) AS ndistinct_aid + FROM _t1 AS _s0 + JOIN main.author AS author + ON _s0.oid = author.oid + GROUP BY + 1 +) +SELECT + _s2.continent, + CASE + WHEN ( + NOT _s3.n_rows IS NULL AND _s3.n_rows > 0 + ) + THEN COALESCE(_s3.ndistinct_aid, 0) / _s2.ndistinct_oid + ELSE 0 + END AS ratio +FROM _s2 AS _s2 +LEFT JOIN _s3 AS _s3 + ON _s2.continent = _s3.continent +ORDER BY + 2 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen15_postgres.sql b/tests/test_sql_refsols/defog_academic_gen15_postgres.sql new file mode 100644 index 000000000..512d7bfba --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen15_postgres.sql @@ -0,0 +1,37 @@ +WITH _t1 AS ( + SELECT + continent, + oid + FROM main.organization +), _s2 AS ( + SELECT + continent, + COUNT(DISTINCT oid) AS ndistinct_oid + FROM _t1 + GROUP BY + 1 +), _s3 AS ( + SELECT + _s0.continent, + COUNT(*) AS n_rows, + COUNT(DISTINCT author.aid) AS ndistinct_aid + FROM _t1 AS _s0 + JOIN main.author AS author + ON _s0.oid = author.oid + GROUP BY + 1 +) +SELECT + _s2.continent, + CASE + WHEN ( + NOT _s3.n_rows IS NULL AND _s3.n_rows > 0 + ) + THEN CAST(COALESCE(_s3.ndistinct_aid, 0) AS DOUBLE PRECISION) / _s2.ndistinct_oid + ELSE 0 + END AS ratio +FROM _s2 AS _s2 +LEFT JOIN _s3 AS _s3 + ON _s2.continent = _s3.continent +ORDER BY + 2 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen15_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen15_snowflake.sql new file mode 100644 index 000000000..73231f949 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen15_snowflake.sql @@ -0,0 +1,37 @@ +WITH _t1 AS ( + SELECT + continent, + oid + FROM main.organization +), _s2 AS ( + SELECT + continent, + COUNT(DISTINCT oid) AS ndistinct_oid + FROM _t1 + GROUP BY + 1 +), _s3 AS ( + SELECT + _s0.continent, + COUNT(*) AS n_rows, + COUNT(DISTINCT author.aid) AS ndistinct_aid + FROM _t1 AS _s0 + JOIN main.author AS author + ON _s0.oid = author.oid + GROUP BY + 1 +) +SELECT + _s2.continent, + IFF( + ( + NOT _s3.n_rows IS NULL AND _s3.n_rows > 0 + ), + COALESCE(_s3.ndistinct_aid, 0) / _s2.ndistinct_oid, + 0 + ) AS ratio +FROM _s2 AS _s2 +LEFT JOIN _s3 AS _s3 + ON _s2.continent = _s3.continent +ORDER BY + 2 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen15_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen15_sqlite.sql new file mode 100644 index 000000000..997234fb8 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen15_sqlite.sql @@ -0,0 +1,37 @@ +WITH _t1 AS ( + SELECT + continent, + oid + FROM main.organization +), _s2 AS ( + SELECT + continent, + COUNT(DISTINCT oid) AS ndistinct_oid + FROM _t1 + GROUP BY + 1 +), _s3 AS ( + SELECT + _s0.continent, + COUNT(*) AS n_rows, + COUNT(DISTINCT author.aid) AS ndistinct_aid + FROM _t1 AS _s0 + JOIN main.author AS author + ON _s0.oid = author.oid + GROUP BY + 1 +) +SELECT + _s2.continent, + IIF( + ( + NOT _s3.n_rows IS NULL AND _s3.n_rows > 0 + ), + CAST(COALESCE(_s3.ndistinct_aid, 0) AS REAL) / _s2.ndistinct_oid, + 0 + ) AS ratio +FROM _s2 AS _s2 +LEFT JOIN _s3 AS _s3 + ON _s2.continent = _s3.continent +ORDER BY + 2 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen16_ansi.sql b/tests/test_sql_refsols/defog_academic_gen16_ansi.sql new file mode 100644 index 000000000..8144e728e --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen16_ansi.sql @@ -0,0 +1,32 @@ +WITH _s1 AS ( + SELECT + aid, + name + FROM main.author +), _s6 AS ( + SELECT DISTINCT + _s1.name + FROM main.writes AS writes + JOIN _s1 AS _s1 + ON _s1.aid = writes.aid +), _s7 AS ( + SELECT + _s3.name, + COUNT(DISTINCT writes.pid) AS ndistinct_pid + FROM main.writes AS writes + JOIN _s1 AS _s3 + ON _s3.aid = writes.aid + JOIN main.publication AS publication + ON publication.pid = writes.pid AND publication.year = 2021 + GROUP BY + 1 +) +SELECT + _s6.name, + COALESCE(_s7.ndistinct_pid, 0) AS count_publication +FROM _s6 AS _s6 +LEFT JOIN _s7 AS _s7 + ON _s6.name = _s7.name +ORDER BY + 2 DESC +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen16_mysql.sql b/tests/test_sql_refsols/defog_academic_gen16_mysql.sql new file mode 100644 index 000000000..8144e728e --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen16_mysql.sql @@ -0,0 +1,32 @@ +WITH _s1 AS ( + SELECT + aid, + name + FROM main.author +), _s6 AS ( + SELECT DISTINCT + _s1.name + FROM main.writes AS writes + JOIN _s1 AS _s1 + ON _s1.aid = writes.aid +), _s7 AS ( + SELECT + _s3.name, + COUNT(DISTINCT writes.pid) AS ndistinct_pid + FROM main.writes AS writes + JOIN _s1 AS _s3 + ON _s3.aid = writes.aid + JOIN main.publication AS publication + ON publication.pid = writes.pid AND publication.year = 2021 + GROUP BY + 1 +) +SELECT + _s6.name, + COALESCE(_s7.ndistinct_pid, 0) AS count_publication +FROM _s6 AS _s6 +LEFT JOIN _s7 AS _s7 + ON _s6.name = _s7.name +ORDER BY + 2 DESC +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen16_postgres.sql b/tests/test_sql_refsols/defog_academic_gen16_postgres.sql new file mode 100644 index 000000000..91d013130 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen16_postgres.sql @@ -0,0 +1,32 @@ +WITH _s1 AS ( + SELECT + aid, + name + FROM main.author +), _s6 AS ( + SELECT DISTINCT + _s1.name + FROM main.writes AS writes + JOIN _s1 AS _s1 + ON _s1.aid = writes.aid +), _s7 AS ( + SELECT + _s3.name, + COUNT(DISTINCT writes.pid) AS ndistinct_pid + FROM main.writes AS writes + JOIN _s1 AS _s3 + ON _s3.aid = writes.aid + JOIN main.publication AS publication + ON publication.pid = writes.pid AND publication.year = 2021 + GROUP BY + 1 +) +SELECT + _s6.name, + COALESCE(_s7.ndistinct_pid, 0) AS count_publication +FROM _s6 AS _s6 +LEFT JOIN _s7 AS _s7 + ON _s6.name = _s7.name +ORDER BY + 2 DESC NULLS LAST +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen16_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen16_snowflake.sql new file mode 100644 index 000000000..91d013130 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen16_snowflake.sql @@ -0,0 +1,32 @@ +WITH _s1 AS ( + SELECT + aid, + name + FROM main.author +), _s6 AS ( + SELECT DISTINCT + _s1.name + FROM main.writes AS writes + JOIN _s1 AS _s1 + ON _s1.aid = writes.aid +), _s7 AS ( + SELECT + _s3.name, + COUNT(DISTINCT writes.pid) AS ndistinct_pid + FROM main.writes AS writes + JOIN _s1 AS _s3 + ON _s3.aid = writes.aid + JOIN main.publication AS publication + ON publication.pid = writes.pid AND publication.year = 2021 + GROUP BY + 1 +) +SELECT + _s6.name, + COALESCE(_s7.ndistinct_pid, 0) AS count_publication +FROM _s6 AS _s6 +LEFT JOIN _s7 AS _s7 + ON _s6.name = _s7.name +ORDER BY + 2 DESC NULLS LAST +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen16_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen16_sqlite.sql new file mode 100644 index 000000000..8144e728e --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen16_sqlite.sql @@ -0,0 +1,32 @@ +WITH _s1 AS ( + SELECT + aid, + name + FROM main.author +), _s6 AS ( + SELECT DISTINCT + _s1.name + FROM main.writes AS writes + JOIN _s1 AS _s1 + ON _s1.aid = writes.aid +), _s7 AS ( + SELECT + _s3.name, + COUNT(DISTINCT writes.pid) AS ndistinct_pid + FROM main.writes AS writes + JOIN _s1 AS _s3 + ON _s3.aid = writes.aid + JOIN main.publication AS publication + ON publication.pid = writes.pid AND publication.year = 2021 + GROUP BY + 1 +) +SELECT + _s6.name, + COALESCE(_s7.ndistinct_pid, 0) AS count_publication +FROM _s6 AS _s6 +LEFT JOIN _s7 AS _s7 + ON _s6.name = _s7.name +ORDER BY + 2 DESC +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen17_ansi.sql b/tests/test_sql_refsols/defog_academic_gen17_ansi.sql new file mode 100644 index 000000000..f0641b802 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen17_ansi.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS count_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC, + 1 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen17_mysql.sql b/tests/test_sql_refsols/defog_academic_gen17_mysql.sql new file mode 100644 index 000000000..d5b70427f --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen17_mysql.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + name COLLATE utf8mb4_bin AS name, + COALESCE(_s1.n_rows, 0) AS count_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC, + 1 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen17_postgres.sql b/tests/test_sql_refsols/defog_academic_gen17_postgres.sql new file mode 100644 index 000000000..4339e1f73 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen17_postgres.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS count_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC NULLS LAST, + 1 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen17_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen17_snowflake.sql new file mode 100644 index 000000000..4339e1f73 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen17_snowflake.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS count_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC NULLS LAST, + 1 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen17_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen17_sqlite.sql new file mode 100644 index 000000000..f0641b802 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen17_sqlite.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS count_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC, + 1 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen18_ansi.sql b/tests/test_sql_refsols/defog_academic_gen18_ansi.sql new file mode 100644 index 000000000..17dff49a9 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen18_ansi.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + jid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + journal.name, + journal.jid, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.journal AS journal +LEFT JOIN _s1 AS _s1 + ON _s1.jid = journal.jid +ORDER BY + 3 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen18_mysql.sql b/tests/test_sql_refsols/defog_academic_gen18_mysql.sql new file mode 100644 index 000000000..17dff49a9 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen18_mysql.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + jid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + journal.name, + journal.jid, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.journal AS journal +LEFT JOIN _s1 AS _s1 + ON _s1.jid = journal.jid +ORDER BY + 3 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen18_postgres.sql b/tests/test_sql_refsols/defog_academic_gen18_postgres.sql new file mode 100644 index 000000000..bdcc5fe1c --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen18_postgres.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + jid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + journal.name, + journal.jid, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.journal AS journal +LEFT JOIN _s1 AS _s1 + ON _s1.jid = journal.jid +ORDER BY + 3 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen18_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen18_snowflake.sql new file mode 100644 index 000000000..bdcc5fe1c --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen18_snowflake.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + jid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + journal.name, + journal.jid, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.journal AS journal +LEFT JOIN _s1 AS _s1 + ON _s1.jid = journal.jid +ORDER BY + 3 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen18_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen18_sqlite.sql new file mode 100644 index 000000000..17dff49a9 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen18_sqlite.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + jid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + journal.name, + journal.jid, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.journal AS journal +LEFT JOIN _s1 AS _s1 + ON _s1.jid = journal.jid +ORDER BY + 3 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen19_ansi.sql b/tests/test_sql_refsols/defog_academic_gen19_ansi.sql new file mode 100644 index 000000000..fdcb1ec05 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen19_ansi.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC, + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen19_mysql.sql b/tests/test_sql_refsols/defog_academic_gen19_mysql.sql new file mode 100644 index 000000000..3677a3657 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen19_mysql.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + name COLLATE utf8mb4_bin AS name, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC, + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen19_postgres.sql b/tests/test_sql_refsols/defog_academic_gen19_postgres.sql new file mode 100644 index 000000000..a55f1326e --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen19_postgres.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC NULLS LAST, + 1 NULLS FIRST diff --git a/tests/test_sql_refsols/defog_academic_gen19_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen19_snowflake.sql new file mode 100644 index 000000000..a55f1326e --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen19_snowflake.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC NULLS LAST, + 1 NULLS FIRST diff --git a/tests/test_sql_refsols/defog_academic_gen19_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen19_sqlite.sql new file mode 100644 index 000000000..fdcb1ec05 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen19_sqlite.sql @@ -0,0 +1,17 @@ +WITH _s1 AS ( + SELECT + cid, + COUNT(*) AS n_rows + FROM main.publication + GROUP BY + 1 +) +SELECT + conference.name, + COALESCE(_s1.n_rows, 0) AS num_publications +FROM main.conference AS conference +LEFT JOIN _s1 AS _s1 + ON _s1.cid = conference.cid +ORDER BY + 2 DESC, + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen1_ansi.sql b/tests/test_sql_refsols/defog_academic_gen1_ansi.sql new file mode 100644 index 000000000..75c2544bc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen1_ansi.sql @@ -0,0 +1,20 @@ +WITH _t0 AS ( + SELECT + writes.aid, + COUNT(DISTINCT domain_publication.did) AS ndistinct_did + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + JOIN main.domain_publication AS domain_publication + ON domain_publication.pid = publication.pid + JOIN main.domain AS domain + ON domain.did = domain_publication.did + AND domain.name IN ('Data Science', 'Machine Learning') + GROUP BY + 1 +) +SELECT + author.name +FROM main.author AS author +JOIN _t0 AS _t0 + ON _t0.aid = author.aid AND _t0.ndistinct_did = 2 diff --git a/tests/test_sql_refsols/defog_academic_gen1_mysql.sql b/tests/test_sql_refsols/defog_academic_gen1_mysql.sql new file mode 100644 index 000000000..75c2544bc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen1_mysql.sql @@ -0,0 +1,20 @@ +WITH _t0 AS ( + SELECT + writes.aid, + COUNT(DISTINCT domain_publication.did) AS ndistinct_did + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + JOIN main.domain_publication AS domain_publication + ON domain_publication.pid = publication.pid + JOIN main.domain AS domain + ON domain.did = domain_publication.did + AND domain.name IN ('Data Science', 'Machine Learning') + GROUP BY + 1 +) +SELECT + author.name +FROM main.author AS author +JOIN _t0 AS _t0 + ON _t0.aid = author.aid AND _t0.ndistinct_did = 2 diff --git a/tests/test_sql_refsols/defog_academic_gen1_postgres.sql b/tests/test_sql_refsols/defog_academic_gen1_postgres.sql new file mode 100644 index 000000000..75c2544bc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen1_postgres.sql @@ -0,0 +1,20 @@ +WITH _t0 AS ( + SELECT + writes.aid, + COUNT(DISTINCT domain_publication.did) AS ndistinct_did + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + JOIN main.domain_publication AS domain_publication + ON domain_publication.pid = publication.pid + JOIN main.domain AS domain + ON domain.did = domain_publication.did + AND domain.name IN ('Data Science', 'Machine Learning') + GROUP BY + 1 +) +SELECT + author.name +FROM main.author AS author +JOIN _t0 AS _t0 + ON _t0.aid = author.aid AND _t0.ndistinct_did = 2 diff --git a/tests/test_sql_refsols/defog_academic_gen1_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen1_snowflake.sql new file mode 100644 index 000000000..75c2544bc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen1_snowflake.sql @@ -0,0 +1,20 @@ +WITH _t0 AS ( + SELECT + writes.aid, + COUNT(DISTINCT domain_publication.did) AS ndistinct_did + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + JOIN main.domain_publication AS domain_publication + ON domain_publication.pid = publication.pid + JOIN main.domain AS domain + ON domain.did = domain_publication.did + AND domain.name IN ('Data Science', 'Machine Learning') + GROUP BY + 1 +) +SELECT + author.name +FROM main.author AS author +JOIN _t0 AS _t0 + ON _t0.aid = author.aid AND _t0.ndistinct_did = 2 diff --git a/tests/test_sql_refsols/defog_academic_gen1_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen1_sqlite.sql new file mode 100644 index 000000000..75c2544bc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen1_sqlite.sql @@ -0,0 +1,20 @@ +WITH _t0 AS ( + SELECT + writes.aid, + COUNT(DISTINCT domain_publication.did) AS ndistinct_did + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + JOIN main.domain_publication AS domain_publication + ON domain_publication.pid = publication.pid + JOIN main.domain AS domain + ON domain.did = domain_publication.did + AND domain.name IN ('Data Science', 'Machine Learning') + GROUP BY + 1 +) +SELECT + author.name +FROM main.author AS author +JOIN _t0 AS _t0 + ON _t0.aid = author.aid AND _t0.ndistinct_did = 2 diff --git a/tests/test_sql_refsols/defog_academic_gen20_ansi.sql b/tests/test_sql_refsols/defog_academic_gen20_ansi.sql new file mode 100644 index 000000000..c466047dc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen20_ansi.sql @@ -0,0 +1,5 @@ +SELECT + COUNT(*) AS n +FROM main.publication AS publication +JOIN main.journal AS journal + ON LOWER(journal.name) LIKE 'j%' AND journal.jid = publication.jid diff --git a/tests/test_sql_refsols/defog_academic_gen20_mysql.sql b/tests/test_sql_refsols/defog_academic_gen20_mysql.sql new file mode 100644 index 000000000..c466047dc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen20_mysql.sql @@ -0,0 +1,5 @@ +SELECT + COUNT(*) AS n +FROM main.publication AS publication +JOIN main.journal AS journal + ON LOWER(journal.name) LIKE 'j%' AND journal.jid = publication.jid diff --git a/tests/test_sql_refsols/defog_academic_gen20_postgres.sql b/tests/test_sql_refsols/defog_academic_gen20_postgres.sql new file mode 100644 index 000000000..c466047dc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen20_postgres.sql @@ -0,0 +1,5 @@ +SELECT + COUNT(*) AS n +FROM main.publication AS publication +JOIN main.journal AS journal + ON LOWER(journal.name) LIKE 'j%' AND journal.jid = publication.jid diff --git a/tests/test_sql_refsols/defog_academic_gen20_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen20_snowflake.sql new file mode 100644 index 000000000..b9c6be9ae --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen20_snowflake.sql @@ -0,0 +1,5 @@ +SELECT + COUNT(*) AS n +FROM main.publication AS publication +JOIN main.journal AS journal + ON STARTSWITH(LOWER(journal.name), 'j') AND journal.jid = publication.jid diff --git a/tests/test_sql_refsols/defog_academic_gen20_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen20_sqlite.sql new file mode 100644 index 000000000..c466047dc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen20_sqlite.sql @@ -0,0 +1,5 @@ +SELECT + COUNT(*) AS n +FROM main.publication AS publication +JOIN main.journal AS journal + ON LOWER(journal.name) LIKE 'j%' AND journal.jid = publication.jid diff --git a/tests/test_sql_refsols/defog_academic_gen2_ansi.sql b/tests/test_sql_refsols/defog_academic_gen2_ansi.sql new file mode 100644 index 000000000..fd86a1bce --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen2_ansi.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + writes.aid, + SUM(publication.citation_num) AS sum_citation_num + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + GROUP BY + 1 +) +SELECT + author.name, + COALESCE(_s3.sum_citation_num, 0) AS total_citations +FROM main.author AS author +JOIN _s3 AS _s3 + ON _s3.aid = author.aid diff --git a/tests/test_sql_refsols/defog_academic_gen2_mysql.sql b/tests/test_sql_refsols/defog_academic_gen2_mysql.sql new file mode 100644 index 000000000..fd86a1bce --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen2_mysql.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + writes.aid, + SUM(publication.citation_num) AS sum_citation_num + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + GROUP BY + 1 +) +SELECT + author.name, + COALESCE(_s3.sum_citation_num, 0) AS total_citations +FROM main.author AS author +JOIN _s3 AS _s3 + ON _s3.aid = author.aid diff --git a/tests/test_sql_refsols/defog_academic_gen2_postgres.sql b/tests/test_sql_refsols/defog_academic_gen2_postgres.sql new file mode 100644 index 000000000..fd86a1bce --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen2_postgres.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + writes.aid, + SUM(publication.citation_num) AS sum_citation_num + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + GROUP BY + 1 +) +SELECT + author.name, + COALESCE(_s3.sum_citation_num, 0) AS total_citations +FROM main.author AS author +JOIN _s3 AS _s3 + ON _s3.aid = author.aid diff --git a/tests/test_sql_refsols/defog_academic_gen2_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen2_snowflake.sql new file mode 100644 index 000000000..fd86a1bce --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen2_snowflake.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + writes.aid, + SUM(publication.citation_num) AS sum_citation_num + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + GROUP BY + 1 +) +SELECT + author.name, + COALESCE(_s3.sum_citation_num, 0) AS total_citations +FROM main.author AS author +JOIN _s3 AS _s3 + ON _s3.aid = author.aid diff --git a/tests/test_sql_refsols/defog_academic_gen2_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen2_sqlite.sql new file mode 100644 index 000000000..fd86a1bce --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen2_sqlite.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + writes.aid, + SUM(publication.citation_num) AS sum_citation_num + FROM main.writes AS writes + JOIN main.publication AS publication + ON publication.pid = writes.pid + GROUP BY + 1 +) +SELECT + author.name, + COALESCE(_s3.sum_citation_num, 0) AS total_citations +FROM main.author AS author +JOIN _s3 AS _s3 + ON _s3.aid = author.aid diff --git a/tests/test_sql_refsols/defog_academic_gen3_ansi.sql b/tests/test_sql_refsols/defog_academic_gen3_ansi.sql new file mode 100644 index 000000000..4a1ae7ad1 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen3_ansi.sql @@ -0,0 +1,6 @@ +SELECT + year, + COUNT(*) AS _expr0 +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen3_mysql.sql b/tests/test_sql_refsols/defog_academic_gen3_mysql.sql new file mode 100644 index 000000000..4a1ae7ad1 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen3_mysql.sql @@ -0,0 +1,6 @@ +SELECT + year, + COUNT(*) AS _expr0 +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen3_postgres.sql b/tests/test_sql_refsols/defog_academic_gen3_postgres.sql new file mode 100644 index 000000000..4a1ae7ad1 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen3_postgres.sql @@ -0,0 +1,6 @@ +SELECT + year, + COUNT(*) AS _expr0 +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen3_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen3_snowflake.sql new file mode 100644 index 000000000..4a1ae7ad1 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen3_snowflake.sql @@ -0,0 +1,6 @@ +SELECT + year, + COUNT(*) AS _expr0 +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen3_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen3_sqlite.sql new file mode 100644 index 000000000..4a1ae7ad1 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen3_sqlite.sql @@ -0,0 +1,6 @@ +SELECT + year, + COUNT(*) AS _expr0 +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen4_ansi.sql b/tests/test_sql_refsols/defog_academic_gen4_ansi.sql new file mode 100644 index 000000000..bfd766151 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen4_ansi.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + SUM(publication.reference_num) / SUM(CASE WHEN NOT publication.reference_num IS NULL THEN 1 ELSE 0 END) AS avg_reference_num, + domain_publication.did + FROM main.domain_publication AS domain_publication + JOIN main.publication AS publication + ON domain_publication.pid = publication.pid + GROUP BY + 2 +) +SELECT + domain.name, + _s3.avg_reference_num AS average_references +FROM main.domain AS domain +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain.did diff --git a/tests/test_sql_refsols/defog_academic_gen4_mysql.sql b/tests/test_sql_refsols/defog_academic_gen4_mysql.sql new file mode 100644 index 000000000..bfd766151 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen4_mysql.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + SUM(publication.reference_num) / SUM(CASE WHEN NOT publication.reference_num IS NULL THEN 1 ELSE 0 END) AS avg_reference_num, + domain_publication.did + FROM main.domain_publication AS domain_publication + JOIN main.publication AS publication + ON domain_publication.pid = publication.pid + GROUP BY + 2 +) +SELECT + domain.name, + _s3.avg_reference_num AS average_references +FROM main.domain AS domain +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain.did diff --git a/tests/test_sql_refsols/defog_academic_gen4_postgres.sql b/tests/test_sql_refsols/defog_academic_gen4_postgres.sql new file mode 100644 index 000000000..323be75bc --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen4_postgres.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + CAST(SUM(publication.reference_num) AS DOUBLE PRECISION) / SUM(CASE WHEN NOT publication.reference_num IS NULL THEN 1 ELSE 0 END) AS avg_reference_num, + domain_publication.did + FROM main.domain_publication AS domain_publication + JOIN main.publication AS publication + ON domain_publication.pid = publication.pid + GROUP BY + 2 +) +SELECT + domain.name, + _s3.avg_reference_num AS average_references +FROM main.domain AS domain +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain.did diff --git a/tests/test_sql_refsols/defog_academic_gen4_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen4_snowflake.sql new file mode 100644 index 000000000..e14d69f65 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen4_snowflake.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + SUM(publication.reference_num) / SUM(IFF(NOT publication.reference_num IS NULL, 1, 0)) AS avg_reference_num, + domain_publication.did + FROM main.domain_publication AS domain_publication + JOIN main.publication AS publication + ON domain_publication.pid = publication.pid + GROUP BY + 2 +) +SELECT + domain.name, + _s3.avg_reference_num AS average_references +FROM main.domain AS domain +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain.did diff --git a/tests/test_sql_refsols/defog_academic_gen4_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen4_sqlite.sql new file mode 100644 index 000000000..7d5e02967 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen4_sqlite.sql @@ -0,0 +1,16 @@ +WITH _s3 AS ( + SELECT + CAST(SUM(publication.reference_num) AS REAL) / SUM(IIF(NOT publication.reference_num IS NULL, 1, 0)) AS avg_reference_num, + domain_publication.did + FROM main.domain_publication AS domain_publication + JOIN main.publication AS publication + ON domain_publication.pid = publication.pid + GROUP BY + 2 +) +SELECT + domain.name, + _s3.avg_reference_num AS average_references +FROM main.domain AS domain +LEFT JOIN _s3 AS _s3 + ON _s3.did = domain.did diff --git a/tests/test_sql_refsols/defog_academic_gen5_ansi.sql b/tests/test_sql_refsols/defog_academic_gen5_ansi.sql new file mode 100644 index 000000000..8dc5824dd --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen5_ansi.sql @@ -0,0 +1,6 @@ +SELECT + year, + AVG(citation_num) AS average_citations +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen5_mysql.sql b/tests/test_sql_refsols/defog_academic_gen5_mysql.sql new file mode 100644 index 000000000..8dc5824dd --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen5_mysql.sql @@ -0,0 +1,6 @@ +SELECT + year, + AVG(citation_num) AS average_citations +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen5_postgres.sql b/tests/test_sql_refsols/defog_academic_gen5_postgres.sql new file mode 100644 index 000000000..5aa9009ab --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen5_postgres.sql @@ -0,0 +1,6 @@ +SELECT + year, + AVG(CAST(citation_num AS DECIMAL)) AS average_citations +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen5_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen5_snowflake.sql new file mode 100644 index 000000000..8dc5824dd --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen5_snowflake.sql @@ -0,0 +1,6 @@ +SELECT + year, + AVG(citation_num) AS average_citations +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen5_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen5_sqlite.sql new file mode 100644 index 000000000..8dc5824dd --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen5_sqlite.sql @@ -0,0 +1,6 @@ +SELECT + year, + AVG(citation_num) AS average_citations +FROM main.publication +GROUP BY + 1 diff --git a/tests/test_sql_refsols/defog_academic_gen6_ansi.sql b/tests/test_sql_refsols/defog_academic_gen6_ansi.sql new file mode 100644 index 000000000..5e08ea7b2 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen6_ansi.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + citation_num DESC +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen6_mysql.sql b/tests/test_sql_refsols/defog_academic_gen6_mysql.sql new file mode 100644 index 000000000..5e08ea7b2 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen6_mysql.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + citation_num DESC +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen6_postgres.sql b/tests/test_sql_refsols/defog_academic_gen6_postgres.sql new file mode 100644 index 000000000..983d3f1cd --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen6_postgres.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + citation_num DESC NULLS LAST +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen6_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen6_snowflake.sql new file mode 100644 index 000000000..983d3f1cd --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen6_snowflake.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + citation_num DESC NULLS LAST +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen6_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen6_sqlite.sql new file mode 100644 index 000000000..5e08ea7b2 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen6_sqlite.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + citation_num DESC +LIMIT 1 diff --git a/tests/test_sql_refsols/defog_academic_gen7_ansi.sql b/tests/test_sql_refsols/defog_academic_gen7_ansi.sql new file mode 100644 index 000000000..15e8e9a04 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen7_ansi.sql @@ -0,0 +1,31 @@ +WITH _s2 AS ( + SELECT DISTINCT + name + FROM main.domain +), _s3 AS ( + SELECT + domain.name, + COUNT(DISTINCT domain_author.aid) AS ndistinct_aid + FROM main.domain AS domain + JOIN main.domain_author AS domain_author + ON domain.did = domain_author.did + GROUP BY + 1 +), _t0 AS ( + SELECT + _s2.name, + _s3.ndistinct_aid + FROM _s2 AS _s2 + LEFT JOIN _s3 AS _s3 + ON _s2.name = _s3.name + ORDER BY + COALESCE(ndistinct_aid, 0) + LIMIT 5 +) +SELECT + name, + COALESCE(ndistinct_aid, 0) AS author_count +FROM _t0 +ORDER BY + 2 DESC, + 1 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen7_mysql.sql b/tests/test_sql_refsols/defog_academic_gen7_mysql.sql new file mode 100644 index 000000000..f2830f287 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen7_mysql.sql @@ -0,0 +1,31 @@ +WITH _s2 AS ( + SELECT DISTINCT + name + FROM main.domain +), _s3 AS ( + SELECT + domain.name, + COUNT(DISTINCT domain_author.aid) AS ndistinct_aid + FROM main.domain AS domain + JOIN main.domain_author AS domain_author + ON domain.did = domain_author.did + GROUP BY + 1 +), _t0 AS ( + SELECT + _s2.name, + _s3.ndistinct_aid + FROM _s2 AS _s2 + LEFT JOIN _s3 AS _s3 + ON _s2.name = _s3.name + ORDER BY + COALESCE(ndistinct_aid, 0) + LIMIT 5 +) +SELECT + name COLLATE utf8mb4_bin AS name, + COALESCE(ndistinct_aid, 0) AS author_count +FROM _t0 +ORDER BY + 2 DESC, + 1 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen7_postgres.sql b/tests/test_sql_refsols/defog_academic_gen7_postgres.sql new file mode 100644 index 000000000..dcb3bfc01 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen7_postgres.sql @@ -0,0 +1,31 @@ +WITH _s2 AS ( + SELECT DISTINCT + name + FROM main.domain +), _s3 AS ( + SELECT + domain.name, + COUNT(DISTINCT domain_author.aid) AS ndistinct_aid + FROM main.domain AS domain + JOIN main.domain_author AS domain_author + ON domain.did = domain_author.did + GROUP BY + 1 +), _t0 AS ( + SELECT + _s2.name, + _s3.ndistinct_aid + FROM _s2 AS _s2 + LEFT JOIN _s3 AS _s3 + ON _s2.name = _s3.name + ORDER BY + COALESCE(ndistinct_aid, 0) NULLS FIRST + LIMIT 5 +) +SELECT + name, + COALESCE(ndistinct_aid, 0) AS author_count +FROM _t0 +ORDER BY + 2 DESC NULLS LAST, + 1 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen7_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen7_snowflake.sql new file mode 100644 index 000000000..dcb3bfc01 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen7_snowflake.sql @@ -0,0 +1,31 @@ +WITH _s2 AS ( + SELECT DISTINCT + name + FROM main.domain +), _s3 AS ( + SELECT + domain.name, + COUNT(DISTINCT domain_author.aid) AS ndistinct_aid + FROM main.domain AS domain + JOIN main.domain_author AS domain_author + ON domain.did = domain_author.did + GROUP BY + 1 +), _t0 AS ( + SELECT + _s2.name, + _s3.ndistinct_aid + FROM _s2 AS _s2 + LEFT JOIN _s3 AS _s3 + ON _s2.name = _s3.name + ORDER BY + COALESCE(ndistinct_aid, 0) NULLS FIRST + LIMIT 5 +) +SELECT + name, + COALESCE(ndistinct_aid, 0) AS author_count +FROM _t0 +ORDER BY + 2 DESC NULLS LAST, + 1 DESC NULLS LAST diff --git a/tests/test_sql_refsols/defog_academic_gen7_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen7_sqlite.sql new file mode 100644 index 000000000..15e8e9a04 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen7_sqlite.sql @@ -0,0 +1,31 @@ +WITH _s2 AS ( + SELECT DISTINCT + name + FROM main.domain +), _s3 AS ( + SELECT + domain.name, + COUNT(DISTINCT domain_author.aid) AS ndistinct_aid + FROM main.domain AS domain + JOIN main.domain_author AS domain_author + ON domain.did = domain_author.did + GROUP BY + 1 +), _t0 AS ( + SELECT + _s2.name, + _s3.ndistinct_aid + FROM _s2 AS _s2 + LEFT JOIN _s3 AS _s3 + ON _s2.name = _s3.name + ORDER BY + COALESCE(ndistinct_aid, 0) + LIMIT 5 +) +SELECT + name, + COALESCE(ndistinct_aid, 0) AS author_count +FROM _t0 +ORDER BY + 2 DESC, + 1 DESC diff --git a/tests/test_sql_refsols/defog_academic_gen8_ansi.sql b/tests/test_sql_refsols/defog_academic_gen8_ansi.sql new file mode 100644 index 000000000..eb520cb36 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen8_ansi.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + reference_num DESC +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen8_mysql.sql b/tests/test_sql_refsols/defog_academic_gen8_mysql.sql new file mode 100644 index 000000000..eb520cb36 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen8_mysql.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + reference_num DESC +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen8_postgres.sql b/tests/test_sql_refsols/defog_academic_gen8_postgres.sql new file mode 100644 index 000000000..d116305de --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen8_postgres.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + reference_num DESC NULLS LAST +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen8_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen8_snowflake.sql new file mode 100644 index 000000000..d116305de --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen8_snowflake.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + reference_num DESC NULLS LAST +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen8_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen8_sqlite.sql new file mode 100644 index 000000000..eb520cb36 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen8_sqlite.sql @@ -0,0 +1,6 @@ +SELECT + title +FROM main.publication +ORDER BY + reference_num DESC +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen9_ansi.sql b/tests/test_sql_refsols/defog_academic_gen9_ansi.sql new file mode 100644 index 000000000..66a2dc9ba --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen9_ansi.sql @@ -0,0 +1,7 @@ +SELECT + title, + citation_num +FROM main.publication +ORDER BY + 2 DESC +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen9_mysql.sql b/tests/test_sql_refsols/defog_academic_gen9_mysql.sql new file mode 100644 index 000000000..66a2dc9ba --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen9_mysql.sql @@ -0,0 +1,7 @@ +SELECT + title, + citation_num +FROM main.publication +ORDER BY + 2 DESC +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen9_postgres.sql b/tests/test_sql_refsols/defog_academic_gen9_postgres.sql new file mode 100644 index 000000000..3f96ea6e7 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen9_postgres.sql @@ -0,0 +1,7 @@ +SELECT + title, + citation_num +FROM main.publication +ORDER BY + 2 DESC NULLS LAST +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen9_snowflake.sql b/tests/test_sql_refsols/defog_academic_gen9_snowflake.sql new file mode 100644 index 000000000..3f96ea6e7 --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen9_snowflake.sql @@ -0,0 +1,7 @@ +SELECT + title, + citation_num +FROM main.publication +ORDER BY + 2 DESC NULLS LAST +LIMIT 3 diff --git a/tests/test_sql_refsols/defog_academic_gen9_sqlite.sql b/tests/test_sql_refsols/defog_academic_gen9_sqlite.sql new file mode 100644 index 000000000..66a2dc9ba --- /dev/null +++ b/tests/test_sql_refsols/defog_academic_gen9_sqlite.sql @@ -0,0 +1,7 @@ +SELECT + title, + citation_num +FROM main.publication +ORDER BY + 2 DESC +LIMIT 3