1#include "catch.hpp"
2#include "duckdb/common/file_system.hpp"
3#include "dbgen.hpp"
4#include "test_helpers.hpp"
5
6using namespace duckdb;
7using namespace std;
8
9TEST_CASE("Spinque test: many nested views", "[monetdb][.]") {
10 unique_ptr<QueryResult> result;
11 DuckDB db(nullptr);
12 Connection con(db);
13
14 return;
15
16 REQUIRE_NO_FAIL(con.Query("START TRANSACTION;"));
17 REQUIRE_NO_FAIL(con.Query("CREATE TABLE params_str (paramname VARCHAR, value VARCHAR, prob DOUBLE);"));
18 REQUIRE_NO_FAIL(con.Query("CREATE TABLE params_int (paramname VARCHAR, value BIGINT, prob DOUBLE);"));
19 REQUIRE_NO_FAIL(con.Query(
20 "CREATE TABLE bm_0_obj_dict (id INTEGER NOT NULL, idstr VARCHAR NOT NULL, prob DOUBLE NOT NULL, CONSTRAINT "
21 "bm_0_obj_dict_id_pkey PRIMARY KEY (id), CONSTRAINT bm_0_obj_dict_idstr_unique UNIQUE (idstr));"));
22 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_6 (a1 INTEGER, prob DOUBLE);"));
23 REQUIRE_NO_FAIL(
24 con.Query("CREATE TABLE _cachedrel_21 (a1 VARCHAR, a2 VARCHAR, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
25 REQUIRE_NO_FAIL(
26 con.Query("CREATE TABLE _cachedrel_27 (a1 VARCHAR, a2 VARCHAR, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
27 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_31 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
28 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_40 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
29 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_41 (a1 INTEGER, prob DOUBLE);"));
30 REQUIRE_NO_FAIL(
31 con.Query("CREATE TABLE _cachedrel_42 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
32 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_44 (a1 CHAR(1), prob DECIMAL);"));
33 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_49 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
34 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_52 (a1 INTEGER, a2 INTEGER, a3 INTEGER, prob DOUBLE);"));
35 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_60 (a1 INTEGER, prob DOUBLE);"));
36 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_64 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
37 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_68 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
38 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_77 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
39 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_78 (a1 INTEGER, prob DOUBLE);"));
40 REQUIRE_NO_FAIL(
41 con.Query("CREATE TABLE _cachedrel_81 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
42 REQUIRE_NO_FAIL(
43 con.Query("CREATE TABLE _cachedrel_82 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
44 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_90 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
45 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_99 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
46 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_100 (a1 INTEGER, prob DOUBLE);"));
47 REQUIRE_NO_FAIL(
48 con.Query("CREATE TABLE _cachedrel_101 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
49 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_102 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
50 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_106 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
51 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_115 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
52 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_116 (a1 INTEGER, prob DOUBLE);"));
53 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_118 (a1 CHAR(1), prob DOUBLE);"));
54 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_120 (a1 CHAR(1), prob DOUBLE);"));
55 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_146 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
56 REQUIRE_NO_FAIL(con.Query("create view _cachedrel_147 as select a2 as a1, a1 as a2, prob from _cachedrel_146;"));
57 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_150 (a1 INTEGER, a2 INTEGER, a3 BIGINT, prob DOUBLE);"));
58 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_152 (a1 CHAR(1), prob DOUBLE);"));
59 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_158 (a1 INTEGER, prob DOUBLE);"));
60 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_160 (a1 CHAR(1), prob DOUBLE);"));
61 REQUIRE_NO_FAIL(
62 con.Query("CREATE TABLE _cachedrel_163 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
63 REQUIRE_NO_FAIL(con.Query("create view _cachedrel_1 as select idstr as a1, id as a2, prob from bm_0_obj_dict;"));
64 REQUIRE_NO_FAIL(con.Query("create view _cachedrel_2 as select a2 as a1, prob from _cachedrel_1;"));
65 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x0 AS SELECT 0 AS a1, a2, prob FROM (SELECT paramName AS a1, value AS a2, "
66 "prob FROM params_str WHERE paramName = 's0_keyword') AS t__x0;"));
67 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x1 AS SELECT a1, a2, prob FROM _x0;"));
68 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x2 AS SELECT a2 AS a1, prob FROM _x1;"));
69 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x3 AS SELECT a1, prob FROM (SELECT _x2.a1 AS a1, _x2.prob / t__x3.prob AS "
70 "prob FROM _x2,(SELECT max(prob) AS prob FROM _x2) AS t__x3) AS t__x4;"));
71 REQUIRE_NO_FAIL(con.Query(
72 "CREATE VIEW _x4 AS SELECT a1||a2 AS a1, prob FROM (SELECT t__x5_1.a1 AS a1, t__x5_2.a1 AS a2, t__x5_1.prob * "
73 "t__x5_2.prob AS prob FROM _x3 AS t__x5_1,_x3 AS t__x5_2 WHERE t__x5_1.a1 <> t__x5_2.a1) AS t__x6;"));
74 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x5 AS SELECT a1, prob FROM _x3 UNION ALL SELECT a1, prob FROM _x4;"));
75 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x6 AS SELECT lower(a1) AS a1, prob FROM _x5;"));
76 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x7 AS SELECT upper(a1) AS a1, prob FROM _x6;"));
77 REQUIRE_NO_FAIL(con.Query(
78 "CREATE VIEW _x8 AS SELECT a2 AS a1, a4 AS a2, max(prob) AS prob FROM (SELECT _cachedrel_21.a1 AS a1, "
79 "_cachedrel_21.a2 AS a2, _cachedrel_21.a3 AS a3, _cachedrel_21.a4 AS a4, _x7.a1 AS a5, _cachedrel_21.prob * "
80 "_x7.prob AS prob FROM _cachedrel_21,_x7 WHERE _cachedrel_21.a1 = _x7.a1) AS t__x8 GROUP BY a2, a4;"));
81 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x9 AS SELECT a1, max(prob) AS prob FROM (SELECT a2 AS a1, prob FROM _x8 "
82 "UNION ALL SELECT a1, prob FROM _x5) AS t__x9 GROUP BY a1;"));
83 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x10 AS SELECT upper(a1) AS a1, prob FROM _x6;"));
84 REQUIRE_NO_FAIL(con.Query(
85 "CREATE VIEW _x11 AS SELECT a2 AS a1, a4 AS a2, max(prob) AS prob FROM (SELECT _cachedrel_27.a1 AS a1, "
86 "_cachedrel_27.a2 AS a2, _cachedrel_27.a3 AS a3, _cachedrel_27.a4 AS a4, _x10.a1 AS a5, _cachedrel_27.prob * "
87 "_x10.prob AS prob FROM _cachedrel_27,_x10 WHERE _cachedrel_27.a1 = _x10.a1) AS t__x11 GROUP BY a2, a4;"));
88 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x12 AS SELECT a1, max(prob) AS prob FROM (SELECT a2 AS a1, prob FROM _x11 "
89 "UNION ALL SELECT a1, prob FROM _x5) AS t__x12 GROUP BY a1;"));
90 REQUIRE_NO_FAIL(
91 con.Query("CREATE VIEW _x13 AS SELECT a1, prob FROM (SELECT _x9.a1 AS a1, t__x14.a1 AS a2, _x9.prob * "
92 "t__x14.prob AS prob FROM _x9,(SELECT '1',1.0) AS t__x14(a1,prob)) AS t__x15;"));
93 REQUIRE_NO_FAIL(
94 con.Query("CREATE VIEW _x14 AS SELECT a1, prob FROM (SELECT _x12.a1 AS a1, t__x17.a1 AS a2, _x12.prob * "
95 "t__x17.prob AS prob FROM _x12,(SELECT '2',1.0) AS t__x17(a1,prob)) AS t__x18;"));
96 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x15 AS SELECT a1, prob FROM _x13 UNION ALL SELECT a1, prob FROM _x14;"));
97 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x16 AS SELECT a1, max(prob) AS prob FROM _x15 GROUP BY a1;"));
98 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x17 AS SELECT a1, prob FROM (SELECT _x16.a1 AS a1, t__x20.a1 AS a2, "
99 "_x16.prob * t__x20.prob AS prob FROM _x16,(SELECT '3',1.0) AS t__x20(a1,prob) WHERE "
100 "length(_x16.a1) >= CAST(t__x20.a1 AS INT)) AS t__x21;"));
101 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x18 AS SELECT a1, prob FROM _x17;"));
102 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x19 AS SELECT 0 AS a1, a1 AS a2, prob FROM _x18;"));
103 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x20 AS SELECT a1, a2, prob FROM _x19;"));
104 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x21 AS SELECT a1, upper(a2) AS a2, prob FROM _x20;"));
105 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x22 AS SELECT a1, lower(a2) AS a2, prob FROM _x21;"));
106 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x23 AS SELECT a1, a3 AS a2, prob FROM (SELECT _x22.a1 AS a1, _x22.a2 AS "
107 "a2, _cachedrel_31.a1 AS a3, _cachedrel_31.a2 AS a4, _x22.prob * _cachedrel_31.prob AS "
108 "prob FROM _x22,_cachedrel_31 WHERE _x22.a2 = _cachedrel_31.a2) AS t__x24;"));
109 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x24 AS SELECT a1, a2, sum(prob) AS prob FROM _x23 GROUP BY a1, a2;"));
110 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x25 AS SELECT a1, a2, 1 AS prob FROM _x24;"));
111 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x26 AS SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM "
112 "_x24 GROUP BY a2) AS t__x25;"));
113 REQUIRE_NO_FAIL(
114 con.Query("CREATE VIEW _x27 AS SELECT a1, a2, prob FROM (SELECT _x25.a1 AS a1, _x25.a2 AS a2, _x26.a1 AS a3, "
115 "_x25.prob * _x26.prob AS prob FROM _x25,_x26 WHERE _x25.a2 = _x26.a1) AS t__x27;"));
116 REQUIRE_NO_FAIL(
117 con.Query("CREATE VIEW _x28 AS SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_40.a1 AS a1, "
118 "_cachedrel_40.a2 AS a2, _x27.a1 AS a3, _x27.a2 AS a4, _cachedrel_40.prob * _x27.prob AS prob FROM "
119 "_cachedrel_40,_x27 WHERE _cachedrel_40.a2 = _x27.a2) AS t__x29 GROUP BY a1, a3;"));
120 REQUIRE_NO_FAIL(
121 con.Query("CREATE VIEW _x29 AS SELECT a1, prob FROM (SELECT t__x30.a1 AS a1, t__x30.a2 AS a2, _cachedrel_41.a1 "
122 "AS a3, t__x30.prob * _cachedrel_41.prob AS prob FROM (SELECT a1, a2, prob FROM _x28 WHERE a2 = 0) "
123 "AS t__x30,_cachedrel_41 WHERE t__x30.a1 = _cachedrel_41.a1) AS t__x31;"));
124 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x30 AS SELECT a1, prob FROM (SELECT _x29.a1 AS a1, _x29.prob / t__x33.prob "
125 "AS prob FROM _x29,(SELECT max(prob) AS prob FROM _x29) AS t__x33) AS t__x34;"));
126 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x31 AS SELECT lower(a1) AS a1, prob FROM _x16;"));
127 REQUIRE_NO_FAIL(
128 con.Query("CREATE VIEW _x32 AS SELECT a1, prob FROM (SELECT _cachedrel_42.a1 AS a1, _cachedrel_42.a2 AS a2, "
129 "_cachedrel_42.a3 AS a3, _cachedrel_42.a4 AS a4, _x31.a1 AS a5, _cachedrel_42.prob * _x31.prob AS "
130 "prob FROM _cachedrel_42,_x31 WHERE _cachedrel_42.a3 =_x31.a1) AS t__x36;"));
131 REQUIRE_NO_FAIL(con.Query(
132 "CREATE VIEW _x33 AS SELECT a1, prob FROM (SELECT _cachedrel_6.a1 AS a1, _x32.a1 AS a2, _cachedrel_6.prob * "
133 "_x32.prob AS prob FROM _cachedrel_6,_x32 WHERE _cachedrel_6.a1 = _x32.a1) AS t__x38;"));
134 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x34 AS SELECT a1, prob FROM (SELECT _x30.a1 AS a1, _x30.prob / t__x40.prob "
135 "AS prob FROM _x30,(SELECT max(prob) AS prob FROM _x30) AS t__x40) AS t__x41;"));
136 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x35 AS SELECT a1, prob FROM (SELECT _x33.a1 AS a1, _x33.prob / t__x43.prob "
137 "AS prob FROM _x33,(SELECT max(prob) AS prob FROM _x33) AS t__x43) AS t__x44;"));
138 REQUIRE_NO_FAIL(con.Query(
139 "CREATE VIEW _x36 AS SELECT a1, prob FROM (SELECT _x34.a1 AS a1, t__x46.a1 AS a2, _x34.prob * t__x46.prob AS "
140 "prob FROM _x34,(SELECT a1, prob FROM _cachedrel_44 WHERE a1 = '1') AS t__x46) AS t__x47;"));
141 REQUIRE_NO_FAIL(con.Query(
142 "CREATE VIEW _x37 AS SELECT a1, prob FROM (SELECT _x35.a1 AS a1, t__x49.a1 AS a2, _x35.prob * t__x49.prob AS "
143 "prob FROM _x35,(SELECT a1, prob FROM _cachedrel_44 WHERE a1 = '2') AS t__x49) AS t__x50;"));
144 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x38 AS SELECT a1, prob FROM _x36 UNION ALL SELECT a1, prob FROM _x37;"));
145 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x39 AS SELECT a1, sum(prob) AS prob FROM _x38 GROUP BY a1;"));
146 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x40 AS SELECT a1, a2, prob FROM (SELECT _cachedrel_49.a1 AS a1, "
147 "_cachedrel_49.a2 AS a2, _x39.a1 AS a3, _cachedrel_49.prob * _x39.prob AS prob FROM "
148 "_cachedrel_49,_x39 WHERE _cachedrel_49.a1 = _x39.a1) AS t__x52;"));
149 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x41 AS SELECT a2 AS a1, sum(prob) AS prob FROM _x40 GROUP BY a2;"));
150 REQUIRE_NO_FAIL(
151 con.Query("CREATE VIEW _x42 AS SELECT a1, a3 AS a2, prob FROM (SELECT _x41.a1 AS a1, t__x55.a1 AS a2, "
152 "t__x55.a2 AS a3, _x41.prob * t__x55.prob AS prob FROM _x41,(SELECT a1, a2, max(prob) AS prob FROM "
153 "(SELECT a1, a3 AS a2, prob FROM _cachedrel_52 UNION ALL SELECT a3 AS a1, a1 AS a2, prob FROM "
154 "_cachedrel_52) AS t__x54 GROUP BY a1, a2) AS t__x55 WHERE _x41.a1 = t__x55.a1) AS t__x56;"));
155 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x43 AS SELECT a2 AS a1, max(prob) AS prob FROM _x42 GROUP BY a2;"));
156 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x44 AS SELECT 0 AS a1, a1 AS a2, prob FROM _x16;"));
157 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x45 AS SELECT a1, a2, prob FROM _x44;"));
158 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x46 AS SELECT a1, upper(a2) AS a2, prob FROM _x45;"));
159 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x47 AS SELECT a1, lower(a2) AS a2, prob FROM _x46;"));
160 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x48 AS SELECT a1, a3 AS a2, prob FROM (SELECT _x47.a1 AS a1, _x47.a2 AS "
161 "a2, _cachedrel_68.a1 AS a3, _cachedrel_68.a2 AS a4, _x47.prob * _cachedrel_68.prob AS "
162 "prob FROM _x47,_cachedrel_68 WHERE _x47.a2 = _cachedrel_68.a2) AS t__x59;"));
163 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x49 AS SELECT a1, a2, sum(prob) AS prob FROM _x48 GROUP BY a1, a2;"));
164 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x50 AS SELECT a1, a2, 1 AS prob FROM _x49;"));
165 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x51 AS SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM "
166 "_x49 GROUP BY a2) AS t__x60;"));
167 REQUIRE_NO_FAIL(
168 con.Query("CREATE VIEW _x52 AS SELECT a1, a2, prob FROM (SELECT _x50.a1 AS a1, _x50.a2 AS a2, _x51.a1 AS a3, "
169 "_x50.prob * _x51.prob AS prob FROM _x50,_x51 WHERE _x50.a2 = _x51.a1) AS t__x62;"));
170 REQUIRE_NO_FAIL(
171 con.Query("CREATE VIEW _x53 AS SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_77.a1 AS a1, "
172 "_cachedrel_77.a2 AS a2, _x52.a1 AS a3, _x52.a2 AS a4, _cachedrel_77.prob * _x52.prob AS prob FROM "
173 "_cachedrel_77,_x52 WHERE _cachedrel_77.a2 = _x52.a2) AS t__x64 GROUP BY a1, a3;"));
174 REQUIRE_NO_FAIL(
175 con.Query("CREATE VIEW _x54 AS SELECT a1, prob FROM (SELECT t__x65.a1 AS a1, t__x65.a2 AS a2, _cachedrel_78.a1 "
176 "AS a3, t__x65.prob * _cachedrel_78.prob AS prob FROM (SELECT a1, a2, prob FROM _x53 WHERE a2 = 0) "
177 "AS t__x65,_cachedrel_78 WHERE t__x65.a1 = _cachedrel_78.a1) AS t__x66;"));
178 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x55 AS SELECT a1, prob FROM (SELECT _x54.a1 AS a1, _x54.prob / t__x68.prob "
179 "AS prob FROM _x54,(SELECT max(prob) AS prob FROM _x54) AS t__x68) AS t__x69;"));
180 REQUIRE_NO_FAIL(
181 con.Query("CREATE VIEW _x56 AS SELECT a1, prob FROM (SELECT _cachedrel_82.a1 AS a1, _cachedrel_82.a2 AS a2, "
182 "_cachedrel_82.a3 AS a3, _cachedrel_82.a4 AS a4, _x31.a1 AS a5, _cachedrel_82.prob * _x31.prob AS "
183 "prob FROM _cachedrel_82,_x31 WHERE _cachedrel_82.a3 = _x31.a1) AS t__x71;"));
184 REQUIRE_NO_FAIL(con.Query(
185 "CREATE VIEW _x57 AS SELECT a1, prob FROM (SELECT _cachedrel_60.a1 AS a1, _x56.a1 AS a2, _cachedrel_60.prob * "
186 "_x56.prob AS prob FROM _cachedrel_60,_x56 WHERE _cachedrel_60.a1 = _x56.a1) AS t__x73;"));
187 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x58 AS SELECT a1, a3 AS a2, prob FROM (SELECT _x47.a1 AS a1, _x47.a2 AS "
188 "a2, _cachedrel_90.a1 AS a3, _cachedrel_90.a2 AS a4, _x47.prob * _cachedrel_90.prob AS "
189 "prob FROM _x47,_cachedrel_90 WHERE _x47.a2 = _cachedrel_90.a2) AS t__x74;"));
190 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x59 AS SELECT a1, a2, sum(prob) AS prob FROM _x58 GROUP BY a1, a2;"));
191 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x60 AS SELECT a1, a2, 1 AS prob FROM _x59;"));
192 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x61 AS SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM "
193 "_x59 GROUP BY a2) AS t__x75;"));
194 REQUIRE_NO_FAIL(
195 con.Query("CREATE VIEW _x62 AS SELECT a1, a2, prob FROM (SELECT _x60.a1 AS a1, _x60.a2 AS a2, _x61.a1 AS a3, "
196 "_x60.prob * _x61.prob AS prob FROM _x60,_x61 WHERE _x60.a2 = _x61.a1) AS t__x77;"));
197 REQUIRE_NO_FAIL(
198 con.Query("CREATE VIEW _x63 AS SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_99.a1 AS a1, "
199 "_cachedrel_99.a2 AS a2, _x62.a1 AS a3, _x62.a2 AS a4, _cachedrel_99.prob * _x62.prob AS prob FROM "
200 "_cachedrel_99,_x62 WHERE _cachedrel_99.a2 = _x62.a2) AS t__x79 GROUP BY a1, a3;"));
201 REQUIRE_NO_FAIL(
202 con.Query("CREATE VIEW _x64 AS SELECT a1, prob FROM (SELECT t__x80.a1 AS a1, t__x80.a2 AS a2, "
203 "_cachedrel_100.a1 AS a3, t__x80.prob * _cachedrel_100.prob AS prob FROM (SELECT a1, a2, prob FROM "
204 "_x63 WHERE a2 = 0) AS t__x80,_cachedrel_100 WHERE t__x80.a1 = _cachedrel_100.a1) AS t__x81;"));
205 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x65 AS SELECT a1, prob FROM (SELECT _x64.a1 AS a1, _x64.prob / t__x83.prob "
206 "AS prob FROM _x64,(SELECT max(prob) AS prob FROM _x64) AS t__x83) AS t__x84;"));
207 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x66 AS SELECT lower(a1) AS a1, prob FROM _x18;"));
208 REQUIRE_NO_FAIL(
209 con.Query("CREATE VIEW _x67 AS SELECT a1, prob FROM (SELECT _cachedrel_101.a1 AS a1, _cachedrel_101.a2 AS a2, "
210 "_cachedrel_101.a3 AS a3, _cachedrel_101.a4 AS a4, _x66.a1 AS a5, _cachedrel_101.prob * _x66.prob AS "
211 "prob FROM _cachedrel_101,_x66 WHERE _cachedrel_101.a3 =_x66.a1) AS t__x86;"));
212 REQUIRE_NO_FAIL(con.Query(
213 "CREATE VIEW _x68 AS SELECT a1, prob FROM (SELECT _cachedrel_60.a1 AS a1, _x67.a1 AS a2, _cachedrel_60.prob * "
214 "_x67.prob AS prob FROM _cachedrel_60,_x67 WHERE _cachedrel_60.a1 = _x67.a1) AS t__x87;"));
215 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x69 AS SELECT a1, a3 AS a2, prob FROM (SELECT _x47.a1 AS a1, _x47.a2 AS "
216 "a2, _cachedrel_106.a1 AS a3, _cachedrel_106.a2 AS a4, _x47.prob * _cachedrel_106.prob "
217 "AS prob FROM _x47,_cachedrel_106 WHERE _x47.a2 = _cachedrel_106.a2) AS t__x88;"));
218 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x70 AS SELECT a1, a2, sum(prob) AS prob FROM _x69 GROUP BY a1, a2;"));
219 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x71 AS SELECT a1, a2, 1 AS prob FROM _x70;"));
220 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x72 AS SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM "
221 "_x70 GROUP BY a2) AS t__x89;"));
222 REQUIRE_NO_FAIL(
223 con.Query("CREATE VIEW _x73 AS SELECT a1, a2, prob FROM (SELECT _x71.a1 AS a1, _x71.a2 AS a2, _x72.a1 AS a3, "
224 "_x71.prob * _x72.prob AS prob FROM _x71,_x72 WHERE _x71.a2 = _x72.a1) AS t__x91;"));
225 REQUIRE_NO_FAIL(
226 con.Query("CREATE VIEW _x74 AS SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_115.a1 AS a1, "
227 "_cachedrel_115.a2 AS a2, _x73.a1 AS a3, _x73.a2 AS a4, _cachedrel_115.prob * _x73.prob AS prob FROM "
228 "_cachedrel_115,_x73 WHERE _cachedrel_115.a2 = _x73.a2) AS t__x93 GROUP BY a1, a3;"));
229 REQUIRE_NO_FAIL(
230 con.Query("CREATE VIEW _x75 AS SELECT a1, prob FROM (SELECT t__x94.a1 AS a1, t__x94.a2 AS a2, "
231 "_cachedrel_116.a1 AS a3, t__x94.prob * _cachedrel_116.prob AS prob FROM (SELECT a1, a2, prob FROM "
232 "_x74 WHERE a2 = 0) AS t__x94,_cachedrel_116 WHERE t__x94.a1 = _cachedrel_116.a1) AS t__x95;"));
233 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x76 AS SELECT a1, prob FROM (SELECT _x75.a1 AS a1, _x75.prob / t__x97.prob "
234 "AS prob FROM _x75,(SELECT max(prob) AS prob FROM _x75) AS t__x97) AS t__x98;"));
235 REQUIRE_NO_FAIL(
236 con.Query("CREATE VIEW _x77 AS SELECT _cachedrel_64.a1 AS a1, _cachedrel_64.a2 AS a2, _x16.a1 AS a3, "
237 "_cachedrel_64.prob * _x16.prob AS prob FROM _cachedrel_64,_x16 WHERE _cachedrel_64.a2 =_x16.a1;"));
238 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x78 AS SELECT a1, a2, max(prob) AS prob FROM _x77 GROUP BY a1, a2;"));
239 REQUIRE_NO_FAIL(con.Query(
240 "CREATE VIEW _x79 AS SELECT _cachedrel_102.a1 AS a1, _cachedrel_102.a2 AS a2, _x16.a1 AS a3, "
241 "_cachedrel_102.prob * _x16.prob AS prob FROM _cachedrel_102,_x16 WHERE _cachedrel_102.a2 = _x16.a1;"));
242 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x80 AS SELECT a1, a2, max(prob) AS prob FROM _x79 GROUP BY a1, a2;"));
243 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x81 AS SELECT a1, a2, prob FROM (SELECT _x78.a1 AS a1, _x78.a2 AS a2, "
244 "t__x102.a1 AS a3, _x78.prob * t__x102.prob AS prob FROM _x78,(SELECT a1, prob FROM "
245 "_cachedrel_118 WHERE a1 = '1') AS t__x102) AS t__x103;"));
246 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x82 AS SELECT a1, a2, prob FROM (SELECT _x80.a1 AS a1, _x80.a2 AS a2, "
247 "t__x105.a1 AS a3, _x80.prob * t__x105.prob AS prob FROM _x80,(SELECT a1, prob FROM "
248 "_cachedrel_118 WHERE a1 = '2') AS t__x105) AS t__x106;"));
249 REQUIRE_NO_FAIL(
250 con.Query("CREATE VIEW _x83 AS SELECT a1, a2, prob FROM _x81 UNION ALL SELECT a1, a2, prob FROM _x82;"));
251 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x84 AS SELECT a1, a2, sum(prob) AS prob FROM _x83 GROUP BY a1, a2;"));
252 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x85 AS SELECT a1, prob FROM (SELECT a1, prob FROM _x84) AS t__x107;"));
253 REQUIRE_NO_FAIL(
254 con.Query("CREATE VIEW _x86 AS SELECT a1, prob FROM (SELECT _x43.a1 AS a1, _x43.prob / t__x109.prob AS prob "
255 "FROM _x43,(SELECT max(prob) AS prob FROM _x43) AS t__x109) AS t__x110;"));
256 REQUIRE_NO_FAIL(
257 con.Query("CREATE VIEW _x87 AS SELECT a1, prob FROM (SELECT _x55.a1 AS a1, _x55.prob / t__x112.prob AS prob "
258 "FROM _x55,(SELECT max(prob) AS prob FROM _x55) AS t__x112) AS t__x113;"));
259 REQUIRE_NO_FAIL(
260 con.Query("CREATE VIEW _x88 AS SELECT a1, prob FROM (SELECT _x57.a1 AS a1, _x57.prob / t__x115.prob AS prob "
261 "FROM _x57,(SELECT max(prob) AS prob FROM _x57) AS t__x115) AS t__x116;"));
262 REQUIRE_NO_FAIL(
263 con.Query("CREATE VIEW _x89 AS SELECT a1, prob FROM (SELECT _x65.a1 AS a1, _x65.prob / t__x118.prob AS prob "
264 "FROM _x65,(SELECT max(prob) AS prob FROM _x65) AS t__x118) AS t__x119;"));
265 REQUIRE_NO_FAIL(
266 con.Query("CREATE VIEW _x90 AS SELECT a1, prob FROM (SELECT _x68.a1 AS a1, _x68.prob / t__x121.prob AS prob "
267 "FROM _x68,(SELECT max(prob) AS prob FROM _x68) AS t__x121) AS t__x122;"));
268 REQUIRE_NO_FAIL(
269 con.Query("CREATE VIEW _x91 AS SELECT a1, prob FROM (SELECT _x76.a1 AS a1, _x76.prob / t__x124.prob AS prob "
270 "FROM _x76,(SELECT max(prob) AS prob FROM _x76) AS t__x124) AS t__x125;"));
271 REQUIRE_NO_FAIL(
272 con.Query("CREATE VIEW _x92 AS SELECT a1, prob FROM (SELECT _x85.a1 AS a1, _x85.prob / t__x127.prob AS prob "
273 "FROM _x85,(SELECT max(prob) AS prob FROM _x85) AS t__x127) AS t__x128;"));
274 REQUIRE_NO_FAIL(con.Query(
275 "CREATE VIEW _x93 AS SELECT a1, prob FROM (SELECT _x86.a1 AS a1, t__x130.a1 AS a2, _x86.prob * t__x130.prob AS "
276 "prob FROM _x86,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '1') AS t__x130) AS t__x131;"));
277 REQUIRE_NO_FAIL(con.Query(
278 "CREATE VIEW _x94 AS SELECT a1, prob FROM (SELECT _x87.a1 AS a1, t__x133.a1 AS a2, _x87.prob * t__x133.prob AS "
279 "prob FROM _x87,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '2') AS t__x133) AS t__x134;"));
280 REQUIRE_NO_FAIL(con.Query(
281 "CREATE VIEW _x95 AS SELECT a1, prob FROM (SELECT _x88.a1 AS a1, t__x136.a1 AS a2, _x88.prob * t__x136.prob AS "
282 "prob FROM _x88,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '3') AS t__x136) AS t__x137;"));
283 REQUIRE_NO_FAIL(con.Query(
284 "CREATE VIEW _x96 AS SELECT a1, prob FROM (SELECT _x89.a1 AS a1, t__x139.a1 AS a2, _x89.prob * t__x139.prob AS "
285 "prob FROM _x89,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '4') AS t__x139) AS t__x140;"));
286 REQUIRE_NO_FAIL(con.Query(
287 "CREATE VIEW _x97 AS SELECT a1, prob FROM (SELECT _x90.a1 AS a1, t__x142.a1 AS a2, _x90.prob * t__x142.prob AS "
288 "prob FROM _x90,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '5') AS t__x142) AS t__x143;"));
289 REQUIRE_NO_FAIL(con.Query(
290 "CREATE VIEW _x98 AS SELECT a1, prob FROM (SELECT _x91.a1 AS a1, t__x145.a1 AS a2, _x91.prob * t__x145.prob AS "
291 "prob FROM _x91,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '6') AS t__x145) AS t__x146;"));
292 REQUIRE_NO_FAIL(con.Query(
293 "CREATE VIEW _x99 AS SELECT a1, prob FROM (SELECT _x92.a1 AS a1, t__x148.a1 AS a2, _x92.prob * t__x148.prob AS "
294 "prob FROM _x92,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '7') AS t__x148) AS t__x149;"));
295 REQUIRE_NO_FAIL(
296 con.Query("CREATE VIEW _x100 AS SELECT a1, prob FROM _x93 UNION ALL (SELECT a1, prob FROM _x94 UNION ALL "
297 "(SELECT a1, prob FROM _x95 UNION ALL (SELECT a1, prob FROM _x96 UNION ALL (SELECT a1, prob FROM "
298 "_x97 UNION ALL (SELECT a1, prob FROM _x98 UNION ALL SELECT a1, prob FROM _x99)))));"));
299 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x101 AS SELECT a1, sum(prob) AS prob FROM _x100 GROUP BY a1;"));
300 REQUIRE_NO_FAIL(con.Query(
301 "CREATE VIEW _x102 AS SELECT a1, prob FROM (SELECT _cachedrel_150.a1 AS a1, _cachedrel_150.a2 AS a2, "
302 "_cachedrel_150.a3 AS a3, t__x152.a1 AS a4, _cachedrel_150.prob * t__x152.prob AS prob FROM "
303 "_cachedrel_150,(SELECT a2 AS a1, prob FROM (SELECT paramName AS a1, value AS a2, prob FROM params_int WHERE "
304 "paramName = 's0_userid') AS t__x151) AS t__x152 WHERE _cachedrel_150.a3 = t__x152.a1) AS t__x153;"));
305 REQUIRE_NO_FAIL(con.Query(
306 "CREATE VIEW _x103 AS SELECT a1, prob FROM (SELECT _cachedrel_2.a1 AS a1, _x102.a1 AS a2, _cachedrel_2.prob * "
307 "_x102.prob AS prob FROM _cachedrel_2,_x102 WHERE _cachedrel_2.a1 = _x102.a1) AS t__x155;"));
308 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x104 AS SELECT a1, prob FROM (SELECT _cachedrel_147.a1 AS a1, "
309 "_cachedrel_147.a2 AS a2, _x103.a1 AS a3, _cachedrel_147.prob * _x103.prob AS prob FROM "
310 "_cachedrel_147,_x103 WHERE _cachedrel_147.a2 = _x103.a1) AS t__x157;"));
311 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x105 AS SELECT a1, 1 AS prob FROM _x104;"));
312 REQUIRE_NO_FAIL(
313 con.Query("CREATE VIEW _x106 AS SELECT a1, a4 AS a2, prob FROM (SELECT _x105.a1 AS a1, _cachedrel_52.a1 AS a2, "
314 "_cachedrel_52.a2 AS a3, _cachedrel_52.a3 AS a4, _x105.prob * _cachedrel_52.prob AS prob FROM "
315 "_x105,_cachedrel_52 WHERE _x105.a1 = _cachedrel_52.a1) AS t__x159;"));
316 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x107 AS SELECT a2 AS a1, max(prob) AS prob FROM _x106 GROUP BY a2;"));
317 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x108 AS SELECT a1, a2, max(prob) AS prob FROM _x106 GROUP BY a1, a2;"));
318 REQUIRE_NO_FAIL(
319 con.Query("CREATE VIEW _x109 AS SELECT a1, a4 AS a2, prob FROM (SELECT _x107.a1 AS a1, t__x161.a1 AS a2, "
320 "t__x161.a2 AS a3, t__x161.a3 AS a4, _x107.prob * t__x161.prob AS prob FROM _x107,(SELECT a3 AS a1, "
321 "a2, a1 AS a3, prob FROM _cachedrel_52) AS t__x161 WHERE _x107.a1 = t__x161.a1) AS t__x162;"));
322 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x110 AS SELECT a2 AS a1, prob FROM _x109;"));
323 REQUIRE_NO_FAIL(con.Query(
324 "CREATE VIEW _x111 AS SELECT a1, a3 AS a2, max(prob) AS prob FROM (SELECT _cachedrel_81.a1 AS a1, "
325 "_cachedrel_81.a2 AS a2, _cachedrel_81.a3 AS a3, _cachedrel_81.a4 AS a4, _x110.a1 AS a5, _cachedrel_81.prob * "
326 "_x110.prob AS prob FROM _cachedrel_81,_x110 WHERE _cachedrel_81.a1 = _x110.a1) AS t__x164 GROUP BY a1, a3;"));
327 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x112 AS SELECT a2 AS a1, a1 AS a2, prob FROM _x108;"));
328 REQUIRE_NO_FAIL(con.Query(
329 "CREATE VIEW _x113 AS SELECT a1, a3 AS a2, prob FROM (SELECT _cachedrel_81.a1 AS a1, _cachedrel_81.a2 AS a2, "
330 "_cachedrel_81.a3 AS a3, _cachedrel_81.a4 AS a4, _x104.a1 AS a5, _cachedrel_81.prob * _x104.prob AS prob FROM "
331 "_cachedrel_81,_x104 WHERE _cachedrel_81.a1 = _x104.a1) AS t__x165;"));
332 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x114 AS SELECT a1, a4 AS a2, sum(prob) AS prob FROM (SELECT _x112.a1 AS "
333 "a1, _x112.a2 AS a2, _x113.a1 AS a3, _x113.a2 AS a4, _x112.prob * _x113.prob AS prob "
334 "FROM _x112,_x113 WHERE _x112.a2 = _x113.a1) AS t__x167 GROUP BY a1, a4;"));
335 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x115 AS SELECT _x111.a1 AS a1, _x111.a2 AS a2, _x114.a1 AS a3, _x114.a2 AS "
336 "a4, _x111.prob * _x114.prob AS prob FROM _x111,_x114 WHERE _x111.a2 = _x114.a2;"));
337 REQUIRE_NO_FAIL(
338 con.Query("CREATE VIEW _x116 AS SELECT a1, a3 AS a2, max(prob) AS prob FROM _x115 GROUP BY a1, a3;"));
339 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x117 AS SELECT a1, prob FROM (SELECT a1, prob FROM _x116) AS t__x169;"));
340 REQUIRE_NO_FAIL(
341 con.Query("CREATE VIEW _x118 AS SELECT a1, prob FROM (SELECT _x104.a1 AS a1, _x104.prob / t__x171.prob AS prob "
342 "FROM _x104,(SELECT max(prob) AS prob FROM _x104) AS t__x171) AS t__x172;"));
343 REQUIRE_NO_FAIL(
344 con.Query("CREATE VIEW _x119 AS SELECT a1, prob FROM (SELECT _x117.a1 AS a1, _x117.prob / t__x174.prob AS prob "
345 "FROM _x117,(SELECT max(prob) AS prob FROM _x117) AS t__x174) AS t__x175;"));
346 REQUIRE_NO_FAIL(con.Query(
347 "CREATE VIEW _x120 AS SELECT a1, prob FROM (SELECT _x118.a1 AS a1, t__x177.a1 AS a2, _x118.prob * t__x177.prob "
348 "AS prob FROM _x118,(SELECT a1, prob FROM _cachedrel_152 WHERE a1 = '1') AS t__x177) AS t__x178;"));
349 REQUIRE_NO_FAIL(con.Query(
350 "CREATE VIEW _x121 AS SELECT a1, prob FROM (SELECT _x119.a1 AS a1, t__x180.a1 AS a2, _x119.prob * t__x180.prob "
351 "AS prob FROM _x119,(SELECT a1, prob FROM _cachedrel_152 WHERE a1 = '2') AS t__x180) AS t__x181;"));
352 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x122 AS SELECT a1, prob FROM _x120 UNION ALL SELECT a1, prob FROM _x121;"));
353 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x123 AS SELECT a1, sum(prob) AS prob FROM _x122 GROUP BY a1;"));
354 REQUIRE_NO_FAIL(con.Query(
355 "CREATE VIEW _x124 AS SELECT a1, sum(prob) AS prob FROM (SELECT _x101.a1 AS a1, _x123.a1 AS a2, _x101.prob * "
356 "_x123.prob AS prob FROM _x101,_x123 WHERE _x101.a1 = _x123.a1) AS t__x183 GROUP BY a1;"));
357 REQUIRE_NO_FAIL(con.Query(
358 "CREATE VIEW _x125 AS SELECT a1, prob FROM (SELECT _x101.a1 AS a1, _cachedrel_158.a1 AS a2, _x101.prob * "
359 "_cachedrel_158.prob AS prob FROM _x101,_cachedrel_158 WHERE _x101.a1 = _cachedrel_158.a1) AS t__x184;"));
360 REQUIRE_NO_FAIL(
361 con.Query("CREATE VIEW _x126 AS SELECT a1, prob FROM (SELECT _x101.a1 AS a1, _x101.prob / t__x185.prob AS prob "
362 "FROM _x101,(SELECT max(prob) AS prob FROM _x101) AS t__x185) AS t__x186;"));
363 REQUIRE_NO_FAIL(
364 con.Query("CREATE VIEW _x127 AS SELECT a1, prob FROM (SELECT _x124.a1 AS a1, _x124.prob / t__x188.prob AS prob "
365 "FROM _x124,(SELECT max(prob) AS prob FROM _x124) AS t__x188) AS t__x189;"));
366 REQUIRE_NO_FAIL(
367 con.Query("CREATE VIEW _x128 AS SELECT a1, prob FROM (SELECT _x125.a1 AS a1, _x125.prob / t__x191.prob AS prob "
368 "FROM _x125,(SELECT max(prob) AS prob FROM _x125) AS t__x191) AS t__x192;"));
369 REQUIRE_NO_FAIL(con.Query(
370 "CREATE VIEW _x129 AS SELECT a1, prob FROM (SELECT _x126.a1 AS a1, t__x194.a1 AS a2, _x126.prob * t__x194.prob "
371 "AS prob FROM _x126,(SELECT a1, prob FROM _cachedrel_160 WHERE a1 = '1') AS t__x194) AS t__x195;"));
372 REQUIRE_NO_FAIL(con.Query(
373 "CREATE VIEW _x130 AS SELECT a1, prob FROM (SELECT _x127.a1 AS a1, t__x197.a1 AS a2, _x127.prob * t__x197.prob "
374 "AS prob FROM _x127,(SELECT a1, prob FROM _cachedrel_160 WHERE a1 = '2') AS t__x197) AS t__x198;"));
375 REQUIRE_NO_FAIL(con.Query(
376 "CREATE VIEW _x131 AS SELECT a1, prob FROM (SELECT _x128.a1 AS a1, t__x200.a1 AS a2, _x128.prob * t__x200.prob "
377 "AS prob FROM _x128,(SELECT a1, prob FROM _cachedrel_160 WHERE a1 = '3') AS t__x200) AS t__x201;"));
378 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x132 AS SELECT a1, prob FROM _x129 UNION ALL (SELECT a1, prob FROM _x130 "
379 "UNION ALL SELECT a1, prob FROM _x131);"));
380 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x133 AS SELECT a1, sum(prob) AS prob FROM _x132 GROUP BY a1;"));
381 REQUIRE_NO_FAIL(
382 con.Query("CREATE VIEW _x134 AS SELECT a1, prob FROM (SELECT _cachedrel_163.a1 AS a1, _cachedrel_163.a2 AS a2, "
383 "_cachedrel_163.a3 AS a3, _cachedrel_163.a4 AS a4, _x31.a1 AS a5, _cachedrel_163.prob * _x31.prob AS "
384 "prob FROM _cachedrel_163,_x31 WHERE _cachedrel_163.a3 = _x31.a1) AS t__x203;"));
385 REQUIRE_NO_FAIL(con.Query(
386 "CREATE VIEW _x135 AS SELECT a1, prob FROM (SELECT _cachedrel_60.a1 AS a1, _x134.a1 AS a2, _cachedrel_60.prob "
387 "* _x134.prob AS prob FROM _cachedrel_60,_x134 WHERE _cachedrel_60.a1 = _x134.a1) AS t__x204;"));
388 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x136 AS SELECT CAST(count(prob) AS DOUBLE) AS prob FROM _x135;"));
389 REQUIRE_NO_FAIL(
390 con.Query("CREATE VIEW _x137 AS SELECT a1, prob FROM (SELECT _x135.a1 AS a1, _x135.prob * t__x207.prob AS prob "
391 "FROM _x135,(SELECT prob FROM (SELECT CASE WHEN prob > CAST(0 AS DOUBLE) THEN CAST(1 AS DOUBLE) ELSE "
392 "CAST(0 AS DOUBLE) END AS prob FROM _x136) AS t__x206 WHERE prob > 0.0) AS t__x207 UNION ALL SELECT "
393 "_x133.a1 AS a1, _x133.prob * t__x210.prob AS prob FROM _x133,(SELECT prob FROM (SELECT CASE WHEN "
394 "prob > CAST(0 AS DOUBLE) THEN CAST(0 AS DOUBLE) ELSE CAST(1 AS DOUBLE) END AS prob FROM _x136) AS "
395 "t__x209 WHERE prob > 0.0) AS t__x210) AS t__x211;"));
396 REQUIRE_NO_FAIL(con.Query("CREATE VIEW _x138 AS SELECT a1, sum(prob) AS prob FROM (SELECT _x137.a1 AS a1, "
397 "_cachedrel_60.a1 AS a2, _x137.prob * _cachedrel_60.prob AS prob FROM "
398 "_x137,_cachedrel_60 WHERE _x137.a1 = _cachedrel_60.a1) AS t__x213 GROUP BY a1;"));
399 REQUIRE_NO_FAIL(con.Query("CREATE VIEW s0_RESULTVIEW_result AS SELECT a1, prob FROM _x138;"));
400
401 result = con.Query("SELECT * FROM s0_RESULTVIEW_result;");
402 result->Print();
403 REQUIRE_NO_FAIL(con.Query("ROLLBACK;"));
404}
405
406TEST_CASE("Spinque test: many CTEs", "[monetdb][.]") {
407 unique_ptr<QueryResult> result;
408 DuckDB db(nullptr);
409 Connection con(db);
410
411 return;
412
413 REQUIRE_NO_FAIL(con.Query("START TRANSACTION;"));
414 REQUIRE_NO_FAIL(con.Query("CREATE TABLE params_str (paramname VARCHAR, value VARCHAR, prob DOUBLE);"));
415 REQUIRE_NO_FAIL(con.Query("CREATE TABLE params_int (paramname VARCHAR, value BIGINT, prob DOUBLE);"));
416 REQUIRE_NO_FAIL(con.Query(
417 "CREATE TABLE bm_0_obj_dict (id INTEGER NOT NULL, idstr VARCHAR NOT NULL, prob DOUBLE NOT NULL, CONSTRAINT "
418 "bm_0_obj_dict_id_pkey PRIMARY KEY (id), CONSTRAINT bm_0_obj_dict_idstr_unique UNIQUE (idstr));"));
419 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_6 (a1 INTEGER, prob DOUBLE);"));
420 REQUIRE_NO_FAIL(
421 con.Query("CREATE TABLE _cachedrel_21 (a1 VARCHAR, a2 VARCHAR, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
422 REQUIRE_NO_FAIL(
423 con.Query("CREATE TABLE _cachedrel_27 (a1 VARCHAR, a2 VARCHAR, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
424 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_31 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
425 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_40 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
426 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_41 (a1 INTEGER, prob DOUBLE);"));
427 REQUIRE_NO_FAIL(
428 con.Query("CREATE TABLE _cachedrel_42 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
429 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_44 (a1 CHAR(1), prob DECIMAL);"));
430 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_49 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
431 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_52 (a1 INTEGER, a2 INTEGER, a3 INTEGER, prob DOUBLE);"));
432 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_60 (a1 INTEGER, prob DOUBLE);"));
433 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_64 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
434 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_68 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
435 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_77 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
436 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_78 (a1 INTEGER, prob DOUBLE);"));
437 REQUIRE_NO_FAIL(
438 con.Query("CREATE TABLE _cachedrel_81 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
439 REQUIRE_NO_FAIL(
440 con.Query("CREATE TABLE _cachedrel_82 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
441 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_90 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
442 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_99 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
443 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_100 (a1 INTEGER, prob DOUBLE);"));
444 REQUIRE_NO_FAIL(
445 con.Query("CREATE TABLE _cachedrel_101 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
446 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_102 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
447 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_106 (a1 INTEGER, a2 VARCHAR, prob DOUBLE);"));
448 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_115 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
449 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_116 (a1 INTEGER, prob DOUBLE);"));
450 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_118 (a1 CHAR(1), prob DOUBLE);"));
451 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_120 (a1 CHAR(1), prob DOUBLE);"));
452 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_146 (a1 INTEGER, a2 INTEGER, prob DOUBLE);"));
453 REQUIRE_NO_FAIL(con.Query("create view _cachedrel_147 as select a2 as a1, a1 as a2, prob from _cachedrel_146;"));
454 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_150 (a1 INTEGER, a2 INTEGER, a3 BIGINT, prob DOUBLE);"));
455 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_152 (a1 CHAR(1), prob DOUBLE);"));
456 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_158 (a1 INTEGER, prob DOUBLE);"));
457 REQUIRE_NO_FAIL(con.Query("CREATE TABLE _cachedrel_160 (a1 CHAR(1), prob DOUBLE);"));
458 REQUIRE_NO_FAIL(
459 con.Query("CREATE TABLE _cachedrel_163 (a1 INTEGER, a2 INTEGER, a3 VARCHAR, a4 VARCHAR, prob DOUBLE);"));
460 REQUIRE_NO_FAIL(con.Query("create view _cachedrel_1 as select idstr as a1, id as a2, prob from bm_0_obj_dict;"));
461 REQUIRE_NO_FAIL(con.Query("create view _cachedrel_2 as select a2 as a1, prob from _cachedrel_1;"));
462
463 result = con.Query(
464 "WITH _x0 AS (SELECT 0 AS a1, a2, prob FROM (SELECT paramName AS a1, value AS a2, prob FROM params_str WHERE "
465 "paramName = 's0_keyword') AS t__x0),"
466 " _x1 AS (SELECT a1, a2, prob FROM _x0),"
467 " _x2 AS (SELECT a2 AS a1, prob FROM _x1),"
468 " _x3 AS (SELECT a1, prob FROM (SELECT _x2.a1 AS a1, _x2.prob / t__x3.prob AS prob FROM _x2,(SELECT "
469 "max(prob) AS prob FROM _x2) AS t__x3) AS t__x4),"
470 " _x4 AS (SELECT a1||a2 AS a1, prob FROM (SELECT t__x5_1.a1 AS a1, t__x5_2.a1 AS a2, t__x5_1.prob * "
471 "t__x5_2.prob AS prob FROM _x3 AS t__x5_1,_x3 AS t__x5_2 WHERE t__x5_1.a1 <> t__x5_2.a1) AS t__x6),"
472 " _x5 AS (SELECT a1, prob FROM _x3 UNION ALL SELECT a1, prob FROM _x4),"
473 " _x6 AS (SELECT lower(a1) AS a1, prob FROM _x5),"
474 " _x7 AS (SELECT upper(a1) AS a1, prob FROM _x6),"
475 " _x8 AS (SELECT a2 AS a1, a4 AS a2, max(prob) AS prob FROM (SELECT _cachedrel_21.a1 AS a1, _cachedrel_21.a2 "
476 "AS a2, _cachedrel_21.a3 AS a3, _cachedrel_21.a4 AS a4, _x7.a1 AS a5, _cachedrel_21.prob * _x7.prob AS prob "
477 "FROM _cachedrel_21,_x7 WHERE _cachedrel_21.a1 = _x7.a1) AS t__x8 GROUP BY a2, a4),"
478 " _x9 AS (SELECT a1, max(prob) AS prob FROM (SELECT a2 AS a1, prob FROM _x8 UNION ALL SELECT a1, prob FROM "
479 "_x5) AS t__x9 GROUP BY a1),"
480 " _x10 AS (SELECT upper(a1) AS a1, prob FROM _x6),"
481 " _x11 AS (SELECT a2 AS a1, a4 AS a2, max(prob) AS prob FROM (SELECT _cachedrel_27.a1 AS a1, "
482 "_cachedrel_27.a2 AS a2, _cachedrel_27.a3 AS a3, _cachedrel_27.a4 AS a4, _x10.a1 AS a5, _cachedrel_27.prob * "
483 "_x10.prob AS prob FROM _cachedrel_27,_x10 WHERE _cachedrel_27.a1 = _x10.a1) AS t__x11 GROUP BY a2, a4),"
484 " _x12 AS (SELECT a1, max(prob) AS prob FROM (SELECT a2 AS a1, prob FROM _x11 UNION ALL SELECT a1, prob FROM "
485 "_x5) AS t__x12 GROUP BY a1),"
486 " _x13 AS (SELECT a1, prob FROM (SELECT _x9.a1 AS a1, t__x14.a1 AS a2, _x9.prob * t__x14.prob AS prob FROM "
487 "_x9,(SELECT '1',1.0) AS t__x14(a1,prob)) AS t__x15),"
488 " _x14 AS (SELECT a1, prob FROM (SELECT _x12.a1 AS a1, t__x17.a1 AS a2, _x12.prob * t__x17.prob AS prob FROM "
489 "_x12,(SELECT '2',1.0) AS t__x17(a1,prob)) AS t__x18),"
490 " _x15 AS (SELECT a1, prob FROM _x13 UNION ALL SELECT a1, prob FROM _x14),"
491 " _x16 AS (SELECT a1, max(prob) AS prob FROM _x15 GROUP BY a1),"
492 " _x17 AS (SELECT a1, prob FROM (SELECT _x16.a1 AS a1, t__x20.a1 AS a2, _x16.prob * t__x20.prob AS prob FROM "
493 "_x16,(SELECT '3',1.0) AS t__x20(a1,prob) WHERE length(_x16.a1) >= CAST(t__x20.a1 AS INT)) AS t__x21),"
494 " _x18 AS (SELECT a1, prob FROM _x17),"
495 " _x19 AS (SELECT 0 AS a1, a1 AS a2, prob FROM _x18),"
496 " _x20 AS (SELECT a1, a2, prob FROM _x19),"
497 " _x21 AS (SELECT a1, upper(a2) AS a2, prob FROM _x20),"
498 " _x22 AS (SELECT a1, lower(a2) AS a2, prob FROM _x21),"
499 " _x23 AS (SELECT a1, a3 AS a2, prob FROM (SELECT _x22.a1 AS a1, _x22.a2 AS a2, _cachedrel_31.a1 AS a3, "
500 "_cachedrel_31.a2 AS a4, _x22.prob * _cachedrel_31.prob AS prob FROM _x22,_cachedrel_31 WHERE _x22.a2 = "
501 "_cachedrel_31.a2) AS t__x24),"
502 " _x24 AS (SELECT a1, a2, sum(prob) AS prob FROM _x23 GROUP BY a1, a2),"
503 " _x25 AS (SELECT a1, a2, 1 AS prob FROM _x24),"
504 " _x26 AS (SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM _x24 GROUP BY a2) AS t__x25),"
505 " _x27 AS (SELECT a1, a2, prob FROM (SELECT _x25.a1 AS a1, _x25.a2 AS a2, _x26.a1 AS a3, _x25.prob * "
506 "_x26.prob AS prob FROM _x25,_x26 WHERE _x25.a2 = _x26.a1) AS t__x27),"
507 " _x28 AS (SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_40.a1 AS a1, _cachedrel_40.a2 AS "
508 "a2, _x27.a1 AS a3, _x27.a2 AS a4, _cachedrel_40.prob * _x27.prob AS prob FROM _cachedrel_40,_x27 WHERE "
509 "_cachedrel_40.a2 = _x27.a2) AS t__x29 GROUP BY a1, a3),"
510 " _x29 AS (SELECT a1, prob FROM (SELECT t__x30.a1 AS a1, t__x30.a2 AS a2, _cachedrel_41.a1 AS a3, "
511 "t__x30.prob * _cachedrel_41.prob AS prob FROM (SELECT a1, a2, prob FROM _x28 WHERE a2 = 0) AS "
512 "t__x30,_cachedrel_41 WHERE t__x30.a1 = _cachedrel_41.a1) AS t__x31),"
513 " _x30 AS (SELECT a1, prob FROM (SELECT _x29.a1 AS a1, _x29.prob / t__x33.prob AS prob FROM _x29,(SELECT "
514 "max(prob) AS prob FROM _x29) AS t__x33) AS t__x34),"
515 " _x31 AS (SELECT lower(a1) AS a1, prob FROM _x16),"
516 " _x32 AS (SELECT a1, prob FROM (SELECT _cachedrel_42.a1 AS a1, _cachedrel_42.a2 AS a2, _cachedrel_42.a3 AS "
517 "a3, _cachedrel_42.a4 AS a4, _x31.a1 AS a5, _cachedrel_42.prob * _x31.prob AS prob FROM _cachedrel_42,_x31 "
518 "WHERE _cachedrel_42.a3 =_x31.a1) AS t__x36),"
519 " _x33 AS (SELECT a1, prob FROM (SELECT _cachedrel_6.a1 AS a1, _x32.a1 AS a2, _cachedrel_6.prob * _x32.prob "
520 "AS prob FROM _cachedrel_6,_x32 WHERE _cachedrel_6.a1 = _x32.a1) AS t__x38),"
521 " _x34 AS (SELECT a1, prob FROM (SELECT _x30.a1 AS a1, _x30.prob / t__x40.prob AS prob FROM _x30,(SELECT "
522 "max(prob) AS prob FROM _x30) AS t__x40) AS t__x41),"
523 " _x35 AS (SELECT a1, prob FROM (SELECT _x33.a1 AS a1, _x33.prob / t__x43.prob AS prob FROM _x33,(SELECT "
524 "max(prob) AS prob FROM _x33) AS t__x43) AS t__x44),"
525 " _x36 AS (SELECT a1, prob FROM (SELECT _x34.a1 AS a1, t__x46.a1 AS a2, _x34.prob * t__x46.prob AS prob FROM "
526 "_x34,(SELECT a1, prob FROM _cachedrel_44 WHERE a1 = '1') AS t__x46) AS t__x47),"
527 " _x37 AS (SELECT a1, prob FROM (SELECT _x35.a1 AS a1, t__x49.a1 AS a2, _x35.prob * t__x49.prob AS prob FROM "
528 "_x35,(SELECT a1, prob FROM _cachedrel_44 WHERE a1 = '2') AS t__x49) AS t__x50),"
529 " _x38 AS (SELECT a1, prob FROM _x36 UNION ALL SELECT a1, prob FROM _x37),"
530 " _x39 AS (SELECT a1, sum(prob) AS prob FROM _x38 GROUP BY a1),"
531 " _x40 AS (SELECT a1, a2, prob FROM (SELECT _cachedrel_49.a1 AS a1, _cachedrel_49.a2 AS a2, _x39.a1 AS a3, "
532 "_cachedrel_49.prob * _x39.prob AS prob FROM _cachedrel_49,_x39 WHERE _cachedrel_49.a1 = _x39.a1) AS t__x52),"
533 " _x41 AS (SELECT a2 AS a1, sum(prob) AS prob FROM _x40 GROUP BY a2),"
534 " _x42 AS (SELECT a1, a3 AS a2, prob FROM (SELECT _x41.a1 AS a1, t__x55.a1 AS a2, t__x55.a2 AS a3, _x41.prob "
535 "* t__x55.prob AS prob FROM _x41,(SELECT a1, a2, max(prob) AS prob FROM (SELECT a1, a3 AS a2, prob FROM "
536 "_cachedrel_52 UNION ALL SELECT a3 AS a1, a1 AS a2, prob FROM _cachedrel_52) AS t__x54 GROUP BY a1, a2) AS "
537 "t__x55 WHERE _x41.a1 = t__x55.a1) AS t__x56),"
538 " _x43 AS (SELECT a2 AS a1, max(prob) AS prob FROM _x42 GROUP BY a2),"
539 " _x44 AS (SELECT 0 AS a1, a1 AS a2, prob FROM _x16),"
540 " _x45 AS (SELECT a1, a2, prob FROM _x44),"
541 " _x46 AS (SELECT a1, upper(a2) AS a2, prob FROM _x45),"
542 " _x47 AS (SELECT a1, lower(a2) AS a2, prob FROM _x46),"
543 " _x48 AS (SELECT a1, a3 AS a2, prob FROM (SELECT _x47.a1 AS a1, _x47.a2 AS a2, _cachedrel_68.a1 AS a3, "
544 "_cachedrel_68.a2 AS a4, _x47.prob * _cachedrel_68.prob AS prob FROM _x47,_cachedrel_68 WHERE _x47.a2 = "
545 "_cachedrel_68.a2) AS t__x59),"
546 " _x49 AS (SELECT a1, a2, sum(prob) AS prob FROM _x48 GROUP BY a1, a2),"
547 " _x50 AS (SELECT a1, a2, 1 AS prob FROM _x49),"
548 " _x51 AS (SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM _x49 GROUP BY a2) AS t__x60),"
549 " _x52 AS (SELECT a1, a2, prob FROM (SELECT _x50.a1 AS a1, _x50.a2 AS a2, _x51.a1 AS a3, _x50.prob * "
550 "_x51.prob AS prob FROM _x50,_x51 WHERE _x50.a2 = _x51.a1) AS t__x62),"
551 " _x53 AS (SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_77.a1 AS a1, _cachedrel_77.a2 AS "
552 "a2, _x52.a1 AS a3, _x52.a2 AS a4, _cachedrel_77.prob * _x52.prob AS prob FROM _cachedrel_77,_x52 WHERE "
553 "_cachedrel_77.a2 = _x52.a2) AS t__x64 GROUP BY a1, a3),"
554 " _x54 AS (SELECT a1, prob FROM (SELECT t__x65.a1 AS a1, t__x65.a2 AS a2, _cachedrel_78.a1 AS a3, "
555 "t__x65.prob * _cachedrel_78.prob AS prob FROM (SELECT a1, a2, prob FROM _x53 WHERE a2 = 0) AS "
556 "t__x65,_cachedrel_78 WHERE t__x65.a1 = _cachedrel_78.a1) AS t__x66),"
557 " _x55 AS (SELECT a1, prob FROM (SELECT _x54.a1 AS a1, _x54.prob / t__x68.prob AS prob FROM _x54,(SELECT "
558 "max(prob) AS prob FROM _x54) AS t__x68) AS t__x69),"
559 " _x56 AS (SELECT a1, prob FROM (SELECT _cachedrel_82.a1 AS a1, _cachedrel_82.a2 AS a2, _cachedrel_82.a3 AS "
560 "a3, _cachedrel_82.a4 AS a4, _x31.a1 AS a5, _cachedrel_82.prob * _x31.prob AS prob FROM _cachedrel_82,_x31 "
561 "WHERE _cachedrel_82.a3 = _x31.a1) AS t__x71),"
562 " _x57 AS (SELECT a1, prob FROM (SELECT _cachedrel_60.a1 AS a1, _x56.a1 AS a2, _cachedrel_60.prob * "
563 "_x56.prob AS prob FROM _cachedrel_60,_x56 WHERE _cachedrel_60.a1 = _x56.a1) AS t__x73),"
564 " _x58 AS (SELECT a1, a3 AS a2, prob FROM (SELECT _x47.a1 AS a1, _x47.a2 AS a2, _cachedrel_90.a1 AS a3, "
565 "_cachedrel_90.a2 AS a4, _x47.prob * _cachedrel_90.prob AS prob FROM _x47,_cachedrel_90 WHERE _x47.a2 = "
566 "_cachedrel_90.a2) AS t__x74),"
567 " _x59 AS (SELECT a1, a2, sum(prob) AS prob FROM _x58 GROUP BY a1, a2),"
568 " _x60 AS (SELECT a1, a2, 1 AS prob FROM _x59),"
569 " _x61 AS (SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM _x59 GROUP BY a2) AS t__x75),"
570 " _x62 AS (SELECT a1, a2, prob FROM (SELECT _x60.a1 AS a1, _x60.a2 AS a2, _x61.a1 AS a3, _x60.prob * "
571 "_x61.prob AS prob FROM _x60,_x61 WHERE _x60.a2 = _x61.a1) AS t__x77),"
572 " _x63 AS (SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_99.a1 AS a1, _cachedrel_99.a2 AS "
573 "a2, _x62.a1 AS a3, _x62.a2 AS a4, _cachedrel_99.prob * _x62.prob AS prob FROM _cachedrel_99,_x62 WHERE "
574 "_cachedrel_99.a2 = _x62.a2) AS t__x79 GROUP BY a1, a3),"
575 " _x64 AS (SELECT a1, prob FROM (SELECT t__x80.a1 AS a1, t__x80.a2 AS a2, _cachedrel_100.a1 AS a3, "
576 "t__x80.prob * _cachedrel_100.prob AS prob FROM (SELECT a1, a2, prob FROM _x63 WHERE a2 = 0) AS "
577 "t__x80,_cachedrel_100 WHERE t__x80.a1 = _cachedrel_100.a1) AS t__x81),"
578 " _x65 AS (SELECT a1, prob FROM (SELECT _x64.a1 AS a1, _x64.prob / t__x83.prob AS prob FROM _x64,(SELECT "
579 "max(prob) AS prob FROM _x64) AS t__x83) AS t__x84),"
580 " _x66 AS (SELECT lower(a1) AS a1, prob FROM _x18),"
581 " _x67 AS (SELECT a1, prob FROM (SELECT _cachedrel_101.a1 AS a1, _cachedrel_101.a2 AS a2, _cachedrel_101.a3 "
582 "AS a3, _cachedrel_101.a4 AS a4, _x66.a1 AS a5, _cachedrel_101.prob * _x66.prob AS prob FROM "
583 "_cachedrel_101,_x66 WHERE _cachedrel_101.a3 =_x66.a1) AS t__x86),"
584 " _x68 AS (SELECT a1, prob FROM (SELECT _cachedrel_60.a1 AS a1, _x67.a1 AS a2, _cachedrel_60.prob * "
585 "_x67.prob AS prob FROM _cachedrel_60,_x67 WHERE _cachedrel_60.a1 = _x67.a1) AS t__x87),"
586 " _x69 AS (SELECT a1, a3 AS a2, prob FROM (SELECT _x47.a1 AS a1, _x47.a2 AS a2, _cachedrel_106.a1 AS a3, "
587 "_cachedrel_106.a2 AS a4, _x47.prob * _cachedrel_106.prob AS prob FROM _x47,_cachedrel_106 WHERE _x47.a2 = "
588 "_cachedrel_106.a2) AS t__x88),"
589 " _x70 AS (SELECT a1, a2, sum(prob) AS prob FROM _x69 GROUP BY a1, a2),"
590 " _x71 AS (SELECT a1, a2, 1 AS prob FROM _x70),"
591 " _x72 AS (SELECT a1, 1 AS prob FROM (SELECT a2 AS a1, max(prob) AS prob FROM _x70 GROUP BY a2) AS t__x89),"
592 " _x73 AS (SELECT a1, a2, prob FROM (SELECT _x71.a1 AS a1, _x71.a2 AS a2, _x72.a1 AS a3, _x71.prob * "
593 "_x72.prob AS prob FROM _x71,_x72 WHERE _x71.a2 = _x72.a1) AS t__x91),"
594 " _x74 AS (SELECT a1, a3 AS a2, sum(prob) AS prob FROM (SELECT _cachedrel_115.a1 AS a1, _cachedrel_115.a2 AS "
595 "a2, _x73.a1 AS a3, _x73.a2 AS a4, _cachedrel_115.prob * _x73.prob AS prob FROM _cachedrel_115,_x73 WHERE "
596 "_cachedrel_115.a2 = _x73.a2) AS t__x93 GROUP BY a1, a3),"
597 " _x75 AS (SELECT a1, prob FROM (SELECT t__x94.a1 AS a1, t__x94.a2 AS a2, _cachedrel_116.a1 AS a3, "
598 "t__x94.prob * _cachedrel_116.prob AS prob FROM (SELECT a1, a2, prob FROM _x74 WHERE a2 = 0) AS "
599 "t__x94,_cachedrel_116 WHERE t__x94.a1 = _cachedrel_116.a1) AS t__x95),"
600 " _x76 AS (SELECT a1, prob FROM (SELECT _x75.a1 AS a1, _x75.prob / t__x97.prob AS prob FROM _x75,(SELECT "
601 "max(prob) AS prob FROM _x75) AS t__x97) AS t__x98),"
602 " _x77 AS (SELECT _cachedrel_64.a1 AS a1, _cachedrel_64.a2 AS a2, _x16.a1 AS a3, _cachedrel_64.prob * "
603 "_x16.prob AS prob FROM _cachedrel_64,_x16 WHERE _cachedrel_64.a2 =_x16.a1),"
604 " _x78 AS (SELECT a1, a2, max(prob) AS prob FROM _x77 GROUP BY a1, a2),"
605 " _x79 AS (SELECT _cachedrel_102.a1 AS a1, _cachedrel_102.a2 AS a2, _x16.a1 AS a3, _cachedrel_102.prob * "
606 "_x16.prob AS prob FROM _cachedrel_102,_x16 WHERE _cachedrel_102.a2 = _x16.a1),"
607 " _x80 AS (SELECT a1, a2, max(prob) AS prob FROM _x79 GROUP BY a1, a2),"
608 " _x81 AS (SELECT a1, a2, prob FROM (SELECT _x78.a1 AS a1, _x78.a2 AS a2, t__x102.a1 AS a3, _x78.prob * "
609 "t__x102.prob AS prob FROM _x78,(SELECT a1, prob FROM _cachedrel_118 WHERE a1 = '1') AS t__x102) AS t__x103),"
610 " _x82 AS (SELECT a1, a2, prob FROM (SELECT _x80.a1 AS a1, _x80.a2 AS a2, t__x105.a1 AS a3, _x80.prob * "
611 "t__x105.prob AS prob FROM _x80,(SELECT a1, prob FROM _cachedrel_118 WHERE a1 = '2') AS t__x105) AS t__x106),"
612 " _x83 AS (SELECT a1, a2, prob FROM _x81 UNION ALL SELECT a1, a2, prob FROM _x82),"
613 " _x84 AS (SELECT a1, a2, sum(prob) AS prob FROM _x83 GROUP BY a1, a2),"
614 " _x85 AS (SELECT a1, prob FROM (SELECT a1, prob FROM _x84) AS t__x107),"
615 " _x86 AS (SELECT a1, prob FROM (SELECT _x43.a1 AS a1, _x43.prob / t__x109.prob AS prob FROM _x43,(SELECT "
616 "max(prob) AS prob FROM _x43) AS t__x109) AS t__x110),"
617 " _x87 AS (SELECT a1, prob FROM (SELECT _x55.a1 AS a1, _x55.prob / t__x112.prob AS prob FROM _x55,(SELECT "
618 "max(prob) AS prob FROM _x55) AS t__x112) AS t__x113),"
619 " _x88 AS (SELECT a1, prob FROM (SELECT _x57.a1 AS a1, _x57.prob / t__x115.prob AS prob FROM _x57,(SELECT "
620 "max(prob) AS prob FROM _x57) AS t__x115) AS t__x116),"
621 " _x89 AS (SELECT a1, prob FROM (SELECT _x65.a1 AS a1, _x65.prob / t__x118.prob AS prob FROM _x65,(SELECT "
622 "max(prob) AS prob FROM _x65) AS t__x118) AS t__x119),"
623 " _x90 AS (SELECT a1, prob FROM (SELECT _x68.a1 AS a1, _x68.prob / t__x121.prob AS prob FROM _x68,(SELECT "
624 "max(prob) AS prob FROM _x68) AS t__x121) AS t__x122),"
625 " _x91 AS (SELECT a1, prob FROM (SELECT _x76.a1 AS a1, _x76.prob / t__x124.prob AS prob FROM _x76,(SELECT "
626 "max(prob) AS prob FROM _x76) AS t__x124) AS t__x125),"
627 " _x92 AS (SELECT a1, prob FROM (SELECT _x85.a1 AS a1, _x85.prob / t__x127.prob AS prob FROM _x85,(SELECT "
628 "max(prob) AS prob FROM _x85) AS t__x127) AS t__x128),"
629 " _x93 AS (SELECT a1, prob FROM (SELECT _x86.a1 AS a1, t__x130.a1 AS a2, _x86.prob * t__x130.prob AS prob "
630 "FROM _x86,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '1') AS t__x130) AS t__x131),"
631 " _x94 AS (SELECT a1, prob FROM (SELECT _x87.a1 AS a1, t__x133.a1 AS a2, _x87.prob * t__x133.prob AS prob "
632 "FROM _x87,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '2') AS t__x133) AS t__x134),"
633 " _x95 AS (SELECT a1, prob FROM (SELECT _x88.a1 AS a1, t__x136.a1 AS a2, _x88.prob * t__x136.prob AS prob "
634 "FROM _x88,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '3') AS t__x136) AS t__x137),"
635 " _x96 AS (SELECT a1, prob FROM (SELECT _x89.a1 AS a1, t__x139.a1 AS a2, _x89.prob * t__x139.prob AS prob "
636 "FROM _x89,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '4') AS t__x139) AS t__x140),"
637 " _x97 AS (SELECT a1, prob FROM (SELECT _x90.a1 AS a1, t__x142.a1 AS a2, _x90.prob * t__x142.prob AS prob "
638 "FROM _x90,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '5') AS t__x142) AS t__x143),"
639 " _x98 AS (SELECT a1, prob FROM (SELECT _x91.a1 AS a1, t__x145.a1 AS a2, _x91.prob * t__x145.prob AS prob "
640 "FROM _x91,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '6') AS t__x145) AS t__x146),"
641 " _x99 AS (SELECT a1, prob FROM (SELECT _x92.a1 AS a1, t__x148.a1 AS a2, _x92.prob * t__x148.prob AS prob "
642 "FROM _x92,(SELECT a1, prob FROM _cachedrel_120 WHERE a1 = '7') AS t__x148) AS t__x149),"
643 " _x100 AS (SELECT a1, prob FROM _x93 UNION ALL (SELECT a1, prob FROM _x94 UNION ALL (SELECT a1, prob FROM "
644 "_x95 UNION ALL (SELECT a1, prob FROM _x96 UNION ALL (SELECT a1, prob FROM _x97 UNION ALL (SELECT a1, prob "
645 "FROM _x98 UNION ALL SELECT a1, prob FROM _x99)))))),"
646 " _x101 AS (SELECT a1, sum(prob) AS prob FROM _x100 GROUP BY a1),"
647 " _x102 AS (SELECT a1, prob FROM (SELECT _cachedrel_150.a1 AS a1, _cachedrel_150.a2 AS a2, _cachedrel_150.a3 "
648 "AS a3, t__x152.a1 AS a4, _cachedrel_150.prob * t__x152.prob AS prob FROM _cachedrel_150,(SELECT a2 AS a1, "
649 "prob FROM (SELECT paramName AS a1, value AS a2, prob FROM params_int WHERE paramName = 's0_userid') AS "
650 "t__x151) AS t__x152 WHERE _cachedrel_150.a3 = t__x152.a1) AS t__x153),"
651 " _x103 AS (SELECT a1, prob FROM (SELECT _cachedrel_2.a1 AS a1, _x102.a1 AS a2, _cachedrel_2.prob * "
652 "_x102.prob AS prob FROM _cachedrel_2,_x102 WHERE _cachedrel_2.a1 = _x102.a1) AS t__x155),"
653 " _x104 AS (SELECT a1, prob FROM (SELECT _cachedrel_147.a1 AS a1, _cachedrel_147.a2 AS a2, _x103.a1 AS a3, "
654 "_cachedrel_147.prob * _x103.prob AS prob FROM _cachedrel_147,_x103 WHERE _cachedrel_147.a2 = _x103.a1) AS "
655 "t__x157),"
656 " _x105 AS (SELECT a1, 1 AS prob FROM _x104),"
657 " _x106 AS (SELECT a1, a4 AS a2, prob FROM (SELECT _x105.a1 AS a1, _cachedrel_52.a1 AS a2, _cachedrel_52.a2 "
658 "AS a3, _cachedrel_52.a3 AS a4, _x105.prob * _cachedrel_52.prob AS prob FROM _x105,_cachedrel_52 WHERE "
659 "_x105.a1 = _cachedrel_52.a1) AS t__x159),"
660 " _x107 AS (SELECT a2 AS a1, max(prob) AS prob FROM _x106 GROUP BY a2),"
661 " _x108 AS (SELECT a1, a2, max(prob) AS prob FROM _x106 GROUP BY a1, a2),"
662 " _x109 AS (SELECT a1, a4 AS a2, prob FROM (SELECT _x107.a1 AS a1, t__x161.a1 AS a2, t__x161.a2 AS a3, "
663 "t__x161.a3 AS a4, _x107.prob * t__x161.prob AS prob FROM _x107,(SELECT a3 AS a1, a2, a1 AS a3, prob FROM "
664 "_cachedrel_52) AS t__x161 WHERE _x107.a1 = t__x161.a1) AS t__x162),"
665 " _x110 AS (SELECT a2 AS a1, prob FROM _x109),"
666 " _x111 AS (SELECT a1, a3 AS a2, max(prob) AS prob FROM (SELECT _cachedrel_81.a1 AS a1, _cachedrel_81.a2 AS "
667 "a2, _cachedrel_81.a3 AS a3, _cachedrel_81.a4 AS a4, _x110.a1 AS a5, _cachedrel_81.prob * _x110.prob AS prob "
668 "FROM _cachedrel_81,_x110 WHERE _cachedrel_81.a1 = _x110.a1) AS t__x164 GROUP BY a1, a3),"
669 " _x112 AS (SELECT a2 AS a1, a1 AS a2, prob FROM _x108),"
670 " _x113 AS (SELECT a1, a3 AS a2, prob FROM (SELECT _cachedrel_81.a1 AS a1, _cachedrel_81.a2 AS a2, "
671 "_cachedrel_81.a3 AS a3, _cachedrel_81.a4 AS a4, _x104.a1 AS a5, _cachedrel_81.prob * _x104.prob AS prob FROM "
672 "_cachedrel_81,_x104 WHERE _cachedrel_81.a1 = _x104.a1) AS t__x165),"
673 " _x114 AS (SELECT a1, a4 AS a2, sum(prob) AS prob FROM (SELECT _x112.a1 AS a1, _x112.a2 AS a2, _x113.a1 AS "
674 "a3, _x113.a2 AS a4, _x112.prob * _x113.prob AS prob FROM _x112,_x113 WHERE _x112.a2 = _x113.a1) AS t__x167 "
675 "GROUP BY a1, a4),"
676 " _x115 AS (SELECT _x111.a1 AS a1, _x111.a2 AS a2, _x114.a1 AS a3, _x114.a2 AS a4, _x111.prob * _x114.prob "
677 "AS prob FROM _x111,_x114 WHERE _x111.a2 = _x114.a2),"
678 " _x116 AS (SELECT a1, a3 AS a2, max(prob) AS prob FROM _x115 GROUP BY a1, a3),"
679 " _x117 AS (SELECT a1, prob FROM (SELECT a1, prob FROM _x116) AS t__x169),"
680 " _x118 AS (SELECT a1, prob FROM (SELECT _x104.a1 AS a1, _x104.prob / t__x171.prob AS prob FROM "
681 "_x104,(SELECT max(prob) AS prob FROM _x104) AS t__x171) AS t__x172),"
682 " _x119 AS (SELECT a1, prob FROM (SELECT _x117.a1 AS a1, _x117.prob / t__x174.prob AS prob FROM "
683 "_x117,(SELECT max(prob) AS prob FROM _x117) AS t__x174) AS t__x175),"
684 " _x120 AS (SELECT a1, prob FROM (SELECT _x118.a1 AS a1, t__x177.a1 AS a2, _x118.prob * t__x177.prob AS prob "
685 "FROM _x118,(SELECT a1, prob FROM _cachedrel_152 WHERE a1 = '1') AS t__x177) AS t__x178),"
686 " _x121 AS (SELECT a1, prob FROM (SELECT _x119.a1 AS a1, t__x180.a1 AS a2, _x119.prob * t__x180.prob AS prob "
687 "FROM _x119,(SELECT a1, prob FROM _cachedrel_152 WHERE a1 = '2') AS t__x180) AS t__x181),"
688 " _x122 AS (SELECT a1, prob FROM _x120 UNION ALL SELECT a1, prob FROM _x121),"
689 " _x123 AS (SELECT a1, sum(prob) AS prob FROM _x122 GROUP BY a1),"
690 " _x124 AS (SELECT a1, sum(prob) AS prob FROM (SELECT _x101.a1 AS a1, _x123.a1 AS a2, _x101.prob * "
691 "_x123.prob AS prob FROM _x101,_x123 WHERE _x101.a1 = _x123.a1) AS t__x183 GROUP BY a1),"
692 " _x125 AS (SELECT a1, prob FROM (SELECT _x101.a1 AS a1, _cachedrel_158.a1 AS a2, _x101.prob * "
693 "_cachedrel_158.prob AS prob FROM _x101,_cachedrel_158 WHERE _x101.a1 = _cachedrel_158.a1) AS t__x184),"
694 " _x126 AS (SELECT a1, prob FROM (SELECT _x101.a1 AS a1, _x101.prob / t__x185.prob AS prob FROM "
695 "_x101,(SELECT max(prob) AS prob FROM _x101) AS t__x185) AS t__x186),"
696 " _x127 AS (SELECT a1, prob FROM (SELECT _x124.a1 AS a1, _x124.prob / t__x188.prob AS prob FROM "
697 "_x124,(SELECT max(prob) AS prob FROM _x124) AS t__x188) AS t__x189),"
698 " _x128 AS (SELECT a1, prob FROM (SELECT _x125.a1 AS a1, _x125.prob / t__x191.prob AS prob FROM "
699 "_x125,(SELECT max(prob) AS prob FROM _x125) AS t__x191) AS t__x192),"
700 " _x129 AS (SELECT a1, prob FROM (SELECT _x126.a1 AS a1, t__x194.a1 AS a2, _x126.prob * t__x194.prob AS prob "
701 "FROM _x126,(SELECT a1, prob FROM _cachedrel_160 WHERE a1 = '1') AS t__x194) AS t__x195),"
702 " _x130 AS (SELECT a1, prob FROM (SELECT _x127.a1 AS a1, t__x197.a1 AS a2, _x127.prob * t__x197.prob AS prob "
703 "FROM _x127,(SELECT a1, prob FROM _cachedrel_160 WHERE a1 = '2') AS t__x197) AS t__x198),"
704 " _x131 AS (SELECT a1, prob FROM (SELECT _x128.a1 AS a1, t__x200.a1 AS a2, _x128.prob * t__x200.prob AS prob "
705 "FROM _x128,(SELECT a1, prob FROM _cachedrel_160 WHERE a1 = '3') AS t__x200) AS t__x201),"
706 " _x132 AS (SELECT a1, prob FROM _x129 UNION ALL (SELECT a1, prob FROM _x130 UNION ALL SELECT a1, prob FROM "
707 "_x131)),"
708 " _x133 AS (SELECT a1, sum(prob) AS prob FROM _x132 GROUP BY a1),"
709 " _x134 AS (SELECT a1, prob FROM (SELECT _cachedrel_163.a1 AS a1, _cachedrel_163.a2 AS a2, _cachedrel_163.a3 "
710 "AS a3, _cachedrel_163.a4 AS a4, _x31.a1 AS a5, _cachedrel_163.prob * _x31.prob AS prob FROM "
711 "_cachedrel_163,_x31 WHERE _cachedrel_163.a3 = _x31.a1) AS t__x203),"
712 " _x135 AS (SELECT a1, prob FROM (SELECT _cachedrel_60.a1 AS a1, _x134.a1 AS a2, _cachedrel_60.prob * "
713 "_x134.prob AS prob FROM _cachedrel_60,_x134 WHERE _cachedrel_60.a1 = _x134.a1) AS t__x204),"
714 " _x136 AS (SELECT CAST(count(prob) AS DECIMAL) AS prob FROM _x135),"
715 " _x137 AS (SELECT a1, prob FROM (SELECT _x135.a1 AS a1, _x135.prob * t__x207.prob AS prob FROM "
716 "_x135,(SELECT prob FROM (SELECT CASE WHEN prob > CAST(0 AS DECIMAL) THEN CAST(1 AS DECIMAL) ELSE CAST(0 AS "
717 "DECIMAL) END AS prob FROM _x136) AS t__x206 WHERE prob > 0.0) AS t__x207 UNION ALL SELECT _x133.a1 AS a1, "
718 "_x133.prob * t__x210.prob AS prob FROM _x133,(SELECT prob FROM (SELECT CASE WHEN prob > CAST(0 AS DECIMAL) "
719 "THEN CAST(0 AS DECIMAL) ELSE CAST(1 AS DECIMAL) END AS prob FROM _x136) AS t__x209 WHERE prob > 0.0) AS "
720 "t__x210) AS t__x211),"
721 " _x138 AS (SELECT a1, sum(prob) AS prob FROM (SELECT _x137.a1 AS a1, _cachedrel_60.a1 AS a2, _x137.prob * "
722 "_cachedrel_60.prob AS prob FROM _x137,_cachedrel_60 WHERE _x137.a1 = _cachedrel_60.a1) AS t__x213 GROUP BY a1)"
723 " SELECT a1, prob FROM _x138;");
724
725 REQUIRE_NO_FAIL(con.Query("ROLLBACK;"));
726}
727