Skip to content
Closed
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
612396c
Initial commit
andylam-db Nov 29, 2023
83e6a51
Add CrossDbmsQueryTestSuite
andylam-db Nov 29, 2023
c691f83
Small changes for niceness
andylam-db Nov 29, 2023
24a02f0
Save point
andylam-db Nov 29, 2023
315847a
Add sqllogictest-select1.sql in postgres-crosstest input file
andylam-db Nov 29, 2023
5e087e1
Add header for class suite
andylam-db Nov 29, 2023
33b52b2
Small changes
andylam-db Nov 29, 2023
81202c4
Trying to get the input files set up..
andylam-db Nov 29, 2023
c9fba5b
Passing test!!
andylam-db Nov 29, 2023
8b5ed22
Ignore all earlier tests first
andylam-db Nov 29, 2023
fea3975
Small comment changes
andylam-db Nov 30, 2023
678a0ef
More comments
andylam-db Nov 30, 2023
309a7e2
Address simple comments
andylam-db Nov 30, 2023
5c52b9c
A little more small changes..
andylam-db Nov 30, 2023
ad867df
More small changes and removal of redundant code
andylam-db Nov 30, 2023
bef8011
Generate golden files for SQLQueryTestSuite
andylam-db Nov 30, 2023
a6e7e2a
Revert "Generate golden files for SQLQueryTestSuite"
andylam-db Nov 30, 2023
1409d63
Ignore "postgres-crosstest" in SQLQueryTestSuite
andylam-db Nov 30, 2023
a552d86
Add comment to clarify why it is ignored
andylam-db Nov 30, 2023
7a9cb80
Fix compilation failures
andylam-db Nov 30, 2023
66f41a5
Regenerate golden files for sqllogictest-select1.sql.out
andylam-db Nov 30, 2023
69614d3
Tiny changes..
andylam-db Nov 30, 2023
2bf43df
Add postgresql back to ignorelist
andylam-db Nov 30, 2023
aba83b8
Add exception handling in CrossDbmsQueryTestSuite
andylam-db Nov 30, 2023
bf4036d
Do refactoring so that we can add an additional input argument for Cr…
andylam-db Dec 1, 2023
08e2cfb
Generate with postgres
andylam-db Dec 1, 2023
2ec381c
Fix compilation error with ThriftServerQueryTestSuite
andylam-db Dec 1, 2023
9c2d283
Generate golden files with SQLQueryTestSuite
andylam-db Dec 1, 2023
ab4ab12
Fixed a bug where tests weren't running against the golden file
andylam-db Dec 4, 2023
0166aed
Use local spark session
andylam-db Dec 4, 2023
2e45a67
Small comment change
andylam-db Dec 4, 2023
496cd82
Merge master
andylam-db Dec 4, 2023
dd4597e
Revert change in ThriftServerQueryTestSuite
andylam-db Dec 4, 2023
cb71979
Remove DialectConverter..
andylam-db Dec 4, 2023
6cd52f1
Don't run the tests if the cross dbms is not specified
andylam-db Dec 5, 2023
7f39707
Remove sqllogictest
andylam-db Dec 18, 2023
615f4d9
Small niceness changes
andylam-db Dec 18, 2023
cf345bd
Do null -> NULL replacement, and put 2 tests in
andylam-db Dec 18, 2023
cdef387
Add docker compose and bash scripts for easy postgres instance
andylam-db Dec 18, 2023
36be209
Trivial changes
andylam-db Dec 18, 2023
d037331
Trivial changes
andylam-db Dec 18, 2023
750a1de
Fix typo
andylam-db Dec 19, 2023
089c292
Add header comments, and make CrossDbmsQuerySuite an abstract class
andylam-db Dec 19, 2023
62d1760
Trivial changes
andylam-db Dec 19, 2023
def270b
Use prepared statements
andylam-db Dec 19, 2023
fdb90a4
Remove sql file changes for now
andylam-db Dec 19, 2023
8c21ceb
Header comment improvements
andylam-db Dec 19, 2023
50c2dfb
Trivial changes
andylam-db Dec 19, 2023
939b8f2
Add custom postgres command
andylam-db Dec 19, 2023
db01061
Modify exists-having to be compatible with psql
andylam-db Dec 19, 2023
d8c7bc9
Merge branch 'master' into crossdbms
andylam-db Dec 19, 2023
7200f7d
Modify query slightly
andylam-db Dec 19, 2023
1d79345
Add readme and add ONLY_IF for most sql files in subquery dir
andylam-db Dec 20, 2023
83cd8d4
Rewrite exists-having
andylam-db Dec 20, 2023
f491d1f
Update comment
andylam-db Dec 20, 2023
cc039ae
Merge master
andylam-db Dec 21, 2023
ce0e106
Ignore subquery-offset.sql
andylam-db Dec 21, 2023
1d7c620
Create new file PostgreSQLQueryTestSuite.scala and fix indent
andylam-db Dec 22, 2023
0e542cf
Move from postgres-results -> crossdbms-results
andylam-db Jan 2, 2024
5d4c577
Fix silly paste
andylam-db Jan 3, 2024
68ea6f2
Fix unintended removal of results file
andylam-db Jan 3, 2024
1e1a283
In middle of refactoring..
andylam-db Jan 3, 2024
5756c8e
Major refactoring in progress..
andylam-db Jan 3, 2024
81a61f7
Passing tests
andylam-db Jan 3, 2024
cf7b044
Add documnetation and delete previous files
andylam-db Jan 3, 2024
a32a693
Move functions from PostgreSQLQueryTestSuite -> CrossDbmsQueryTestSuite
andylam-db Jan 3, 2024
e08f7a4
Merge master..
andylam-db Jan 3, 2024
18f821f
Merge branch 'master' into crossdbms
andylam-db Jan 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
-- First 6 queries of the sql-logic-tests with some minor changes for compatibility, available here:
-- https://www.sqlite.org/sqllogictest/file?name=test/select1.test&ci=tip.

CREATE VIEW t1(a, b, c, d, e) AS VALUES
(103,102,100,101,104),
(107,106,108,109,105),
(110,114,112,111,113),
(116,119,117,115,118),
(123,122,124,120,121),
(127,128,129,126,125),
(132,134,131,133,130),
(138,136,139,135,137),
(144,141,140,142,143),
(145,149,146,148,147),
(151,150,153,154,152),
(155,157,159,156,158),
(161,160,163,164,162),
(167,169,168,165,166),
(171,170,172,173,174),
(177,176,179,178,175),
(181,180,182,183,184),
(187,188,186,189,185),
(190,194,193,192,191),
(199,197,198,196,195),
(200,202,203,201,204),
(208,209,205,206,207),
(214,210,213,212,211),
(218,215,216,217,219),
(223,221,222,220,224),
(226,227,228,229,225),
(234,231,232,230,233),
(237,236,239,235,238),
(242,244,240,243,241),
(246,248,247,249,245);

SELECT CASE WHEN c>(SELECT avg(c) FROM t1) THEN a*2 ELSE b*10 END
FROM t1
ORDER BY 1;

SELECT a+b*2+c*3+d*4+e*5,
CAST((a+b+c+d+e)/5 AS INT)
FROM t1
ORDER BY 1,2;

SELECT a+b*2+c*3+d*4+e*5,
CASE WHEN a<b-3 THEN 111 WHEN a<=b THEN 222
WHEN a<b+3 THEN 333 ELSE 444 END,
abs(b-c),
CAST((a+b+c+d+e)/5 AS INT),
a+b*2+c*3
FROM t1
WHERE (e>c OR e<d)
AND d>e
AND EXISTS(SELECT 1 FROM t1 AS x WHERE x.b<t1.b)
ORDER BY 4,2,1,3,5;

SELECT c,
d-e,
CASE a+1 WHEN b THEN 111 WHEN c THEN 222
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END,
a+b*2+c*3+d*4,
e
FROM t1
WHERE d NOT BETWEEN 110 AND 150
OR c BETWEEN b-2 AND d+2
OR (e>c OR e<d)
ORDER BY 1,5,3,2,4;

SELECT a+b*2+c*3+d*4,
CAST((a+b+c+d+e)/5 AS INT),
abs(a),
e,
CASE a+1 WHEN b THEN 111 WHEN c THEN 222
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END,
d
FROM t1
WHERE b>c
AND c>d
ORDER BY 3,4,5,1,2,6;

SELECT a+b*2+c*3+d*4,
CASE a+1 WHEN b THEN 111 WHEN c THEN 222
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END,
(SELECT count(*) FROM t1 AS x WHERE x.c>t1.c AND x.d<t1.d),
c
FROM t1
WHERE (c<=d-2 OR c>=d+2)
ORDER BY 4,2,1,3;

DROP VIEW IF EXISTS t1;
Original file line number Diff line number Diff line change
@@ -0,0 +1,236 @@
-- Automatically generated by CrossDbmsQueryTestSuite
-- !query
CREATE VIEW t1(a, b, c, d, e) AS VALUES
(103,102,100,101,104),
(107,106,108,109,105),
(110,114,112,111,113),
(116,119,117,115,118),
(123,122,124,120,121),
(127,128,129,126,125),
(132,134,131,133,130),
(138,136,139,135,137),
(144,141,140,142,143),
(145,149,146,148,147),
(151,150,153,154,152),
(155,157,159,156,158),
(161,160,163,164,162),
(167,169,168,165,166),
(171,170,172,173,174),
(177,176,179,178,175),
(181,180,182,183,184),
(187,188,186,189,185),
(190,194,193,192,191),
(199,197,198,196,195),
(200,202,203,201,204),
(208,209,205,206,207),
(214,210,213,212,211),
(218,215,216,217,219),
(223,221,222,220,224),
(226,227,228,229,225),
(234,231,232,230,233),
(237,236,239,235,238),
(242,244,240,243,241),
(246,248,247,249,245)
-- !query output



-- !query
SELECT CASE WHEN c>(SELECT avg(c) FROM t1) THEN a*2 ELSE b*10 END
FROM t1
ORDER BY 1
-- !query output
354
362
374
380
398
400
416
428
436
446
452
468
474
484
492
1020
1060
1140
1190
1220
1280
1340
1360
1410
1490
1500
1570
1600
1690
1700


-- !query
SELECT a+b*2+c*3+d*4+e*5,
CAST((a+b+c+d+e)/5 AS INT)
FROM t1
ORDER BY 1,2
-- !query output
1531 102
1604 107
1683 112
1755 117
1824 122
1899 127
1975 132
2052 137
2129 142
2208 147
2286 152
2360 157
2436 162
2499 167
2589 172
2653 177
2739 182
2802 187
2880 192
2946 197
3037 202
3100 207
3176 212
3259 217
3331 222
3405 227
3477 232
3556 237
3627 242
3704 247


-- !query
SELECT a+b*2+c*3+d*4+e*5,
CASE WHEN a<b-3 THEN 111 WHEN a<=b THEN 222
WHEN a<b+3 THEN 333 ELSE 444 END,
abs(b-c),
CAST((a+b+c+d+e)/5 AS INT),
a+b*2+c*3
FROM t1
WHERE (e>c OR e<d)
AND d>e
AND EXISTS(SELECT 1 FROM t1 AS x WHERE x.b<t1.b)
ORDER BY 4,2,1,3,5
-- !query output
1604 333 2 107 643
1899 222 1 127 770
1975 222 3 132 793
2208 111 3 147 881
2286 333 3 152 910
2436 333 3 162 970
2653 333 3 177 1066
2802 222 2 187 1121
2880 111 1 192 1157
2946 333 1 197 1187
3176 444 3 212 1273
3405 222 1 227 1364
3627 222 4 242 1450
3704 222 1 247 1483


-- !query
SELECT c,
d-e,
CASE a+1 WHEN b THEN 111 WHEN c THEN 222
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END,
a+b*2+c*3+d*4,
e
FROM t1
WHERE d NOT BETWEEN 110 AND 150
OR c BETWEEN b-2 AND d+2
OR (e>c OR e<d)
ORDER BY 1,5,3,2,4
-- !query output
100 -3 444 1011 104
108 4 222 1079 105
112 -2 333 1118 113
117 -3 222 1165 118
129 1 111 1274 125
131 3 333 1325 130
140 -1 555 1414 143
146 1 222 1473 147
153 2 444 1526 152
159 -2 333 1570 158
163 2 444 1626 162
168 -1 222 1669 166
172 -1 222 1719 174
179 3 333 1778 175
182 -1 222 1819 184
186 4 111 1877 185
193 1 444 1925 191
198 1 555 1971 195
203 -3 333 2017 204
205 -1 111 2065 207
213 1 555 2121 211
216 -2 444 2164 219
222 -4 444 2211 224
228 4 111 2280 225
232 -3 555 2312 233
239 -3 444 2366 238
240 2 333 2422 241
247 4 222 2479 245


-- !query
SELECT a+b*2+c*3+d*4,
CAST((a+b+c+d+e)/5 AS INT),
abs(a),
e,
CASE a+1 WHEN b THEN 111 WHEN c THEN 222
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END,
d
FROM t1
WHERE b>c
AND c>d
ORDER BY 3,4,5,1,2,6
-- !query output
1118 112 110 113 333 111
1165 117 116 118 222 115
1669 167 167 166 222 165
1925 192 190 191 444 192


-- !query
SELECT a+b*2+c*3+d*4,
CASE a+1 WHEN b THEN 111 WHEN c THEN 222
WHEN d THEN 333 WHEN e THEN 444 ELSE 555 END,
(SELECT count(*) FROM t1 AS x WHERE x.c>t1.c AND x.d<t1.d),
c
FROM t1
WHERE (c<=d-2 OR c>=d+2)
ORDER BY 4,2,1,3
-- !query output
1165 222 0 117
1219 222 0 124
1274 111 0 129
1325 333 0 131
1367 222 0 139
1414 555 0 140
1473 222 0 146
1570 333 0 159
1669 222 0 168
1877 111 0 186
1971 555 0 198
2017 333 0 203
2211 444 0 222
2312 555 0 232
2366 444 0 239
2422 333 0 240
2479 222 0 247


-- !query
DROP VIEW IF EXISTS t1
-- !query output

Original file line number Diff line number Diff line change
Expand Up @@ -612,9 +612,13 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession with SQLHelper
}
}

protected def resultFileForInputFile(file: File): String = {
file.getAbsolutePath.replace(inputFilePath, goldenFilePath) + ".out"
}

protected lazy val listTestCases: Seq[TestCase] = {
listFilesRecursively(new File(inputFilePath)).flatMap { file =>
var resultFile = file.getAbsolutePath.replace(inputFilePath, goldenFilePath) + ".out"
var resultFile = resultFileForInputFile(file)
var analyzerResultFile =
file.getAbsolutePath.replace(inputFilePath, analyzerGoldenFilePath) + ".out"
// JDK-4511638 changes 'toString' result of Float/Double
Expand Down Expand Up @@ -928,14 +932,18 @@ class SQLQueryTestSuite extends QueryTest with SharedSparkSession with SQLHelper
output: String) extends QueryTestOutput {
override def toString: String = {
// We are explicitly not using multi-line string due to stripMargin removing "|" in output.
val schemaString = if (schema.nonEmpty) {
s"-- !query schema\n" + schema.get + "\n"
} else {
""
}
s"-- !query\n" +
sql + "\n" +
s"-- !query schema\n" +
schema.get + "\n" +
schemaString +
s"-- !query output\n" +
output
}
override def numSegments: Int = 3
override def numSegments: Int = if (schema.isDefined) { 3 } else { 2 }
}

/** A single SQL query's analysis results. */
Expand Down
Loading