subselect.err 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054
  1. Registering pre-existing tables
  2. onek
  3. int4_tbl
  4. INT4_TBL
  5. tenk1
  6. text_tbl
  7. road
  8. TEXT_TBL
  9. int8_tbl
  10. <sql-statement>
  11. --
  12. -- SUBSELECT
  13. --
  14. SELECT 1 AS one WHERE 1 IN (SELECT 1);
  15. </sql-statement>
  16. <sql-statement>
  17. SELECT 1 AS zero WHERE 1 NOT IN (SELECT 1);
  18. </sql-statement>
  19. <sql-statement>
  20. SELECT 1 AS zero WHERE 1 IN (SELECT 2);
  21. </sql-statement>
  22. <sql-statement>
  23. -- Check grammar's handling of extra parens in assorted contexts
  24. SELECT * FROM (SELECT 1 AS x) ss;
  25. </sql-statement>
  26. <sql-statement>
  27. SELECT * FROM ((SELECT 1 AS x)) ss;
  28. </sql-statement>
  29. <sql-statement>
  30. (SELECT 2) UNION SELECT 2;
  31. </sql-statement>
  32. <sql-statement>
  33. ((SELECT 2)) UNION SELECT 2;
  34. </sql-statement>
  35. <sql-statement>
  36. SELECT ((SELECT 2) UNION SELECT 2);
  37. </sql-statement>
  38. <sql-statement>
  39. SELECT (((SELECT 2)) UNION SELECT 2);
  40. </sql-statement>
  41. <sql-statement>
  42. SELECT (SELECT ARRAY[1,2,3])[1];
  43. </sql-statement>
  44. -stdin-:<main>: Error: Parse Sql
  45. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
  46. SELECT (SELECT ARRAY[1,2,3])[1];
  47. ^
  48. <sql-statement>
  49. SELECT ((SELECT ARRAY[1,2,3]))[2];
  50. </sql-statement>
  51. -stdin-:<main>: Error: Parse Sql
  52. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
  53. SELECT ((SELECT ARRAY[1,2,3]))[2];
  54. ^
  55. <sql-statement>
  56. SELECT (((SELECT ARRAY[1,2,3])))[3];
  57. </sql-statement>
  58. -stdin-:<main>: Error: Parse Sql
  59. -stdin-:<main>:1:1: Error: alternative is not implemented yet : 360
  60. SELECT (((SELECT ARRAY[1,2,3])))[3];
  61. ^
  62. <sql-statement>
  63. -- Set up some simple test tables
  64. CREATE TABLE SUBSELECT_TBL (
  65. f1 integer,
  66. f2 integer,
  67. f3 float
  68. );
  69. </sql-statement>
  70. <sql-statement>
  71. INSERT INTO SUBSELECT_TBL VALUES (1, 2, 3);
  72. </sql-statement>
  73. <sql-statement>
  74. INSERT INTO SUBSELECT_TBL VALUES (2, 3, 4);
  75. </sql-statement>
  76. <sql-statement>
  77. INSERT INTO SUBSELECT_TBL VALUES (3, 4, 5);
  78. </sql-statement>
  79. <sql-statement>
  80. INSERT INTO SUBSELECT_TBL VALUES (1, 1, 1);
  81. </sql-statement>
  82. <sql-statement>
  83. INSERT INTO SUBSELECT_TBL VALUES (2, 2, 2);
  84. </sql-statement>
  85. <sql-statement>
  86. INSERT INTO SUBSELECT_TBL VALUES (3, 3, 3);
  87. </sql-statement>
  88. <sql-statement>
  89. INSERT INTO SUBSELECT_TBL VALUES (6, 7, 8);
  90. </sql-statement>
  91. <sql-statement>
  92. INSERT INTO SUBSELECT_TBL VALUES (8, 9, NULL);
  93. </sql-statement>
  94. <sql-statement>
  95. SELECT * FROM SUBSELECT_TBL;
  96. </sql-statement>
  97. <sql-statement>
  98. -- Uncorrelated subselects
  99. SELECT f1 AS "Constant Select" FROM SUBSELECT_TBL
  100. WHERE f1 IN (SELECT 1);
  101. </sql-statement>
  102. <sql-statement>
  103. SELECT f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL
  104. WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL);
  105. </sql-statement>
  106. <sql-statement>
  107. SELECT f1 AS "Uncorrelated Field" FROM SUBSELECT_TBL
  108. WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE
  109. f2 IN (SELECT f1 FROM SUBSELECT_TBL));
  110. </sql-statement>
  111. <sql-statement>
  112. SELECT f1, f2
  113. FROM SUBSELECT_TBL
  114. WHERE (f1, f2) NOT IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL
  115. WHERE f3 IS NOT NULL);
  116. </sql-statement>
  117. -stdin-:<main>: Error: Parse Sql
  118. -stdin-:<main>:3:18: Error: alternative is not implemented yet : 138
  119. WHERE (f1, f2) NOT IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL
  120. ^
  121. <sql-statement>
  122. -- Correlated subselects
  123. SELECT f1 AS "Correlated Field", f2 AS "Second Field"
  124. FROM SUBSELECT_TBL upper
  125. WHERE f1 IN (SELECT f2 FROM SUBSELECT_TBL WHERE f1 = upper.f1);
  126. </sql-statement>
  127. <sql-statement>
  128. SELECT f1 AS "Correlated Field", f3 AS "Second Field"
  129. FROM SUBSELECT_TBL upper
  130. WHERE f1 IN
  131. (SELECT f2 FROM SUBSELECT_TBL WHERE CAST(upper.f2 AS float) = f3);
  132. </sql-statement>
  133. -stdin-:<main>: Error: Type annotation
  134. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedFilter, At function: OrderedMap, At function: EquiJoin
  135. SELECT f1 AS "Correlated Field", f3 AS "Second Field"
  136. ^
  137. -stdin-:<main>:3:12: Error: At function: Aggregate
  138. WHERE f1 IN
  139. ^
  140. -stdin-:/lib/yql/aggregate.yql:644:18: Error: At function: AggregationTraits
  141. ^
  142. -stdin-:/lib/yql/aggregate.yql:678:111: Error: At function: SafeCast
  143. ^
  144. -stdin-:<main>:3:12: Error: At function: FromPg, At function: PgResolvedOp
  145. WHERE f1 IN
  146. ^
  147. -stdin-:<main>:3:9: Error: At function: Member
  148. WHERE f1 IN
  149. ^
  150. -stdin-:<main>:3:9: Error: Member not found: _yql_join_sublink_0__alias_upper.f1. Did you mean _yql_join_sublink_0__alias_upper.f2?
  151. WHERE f1 IN
  152. ^
  153. <sql-statement>
  154. SELECT f1 AS "Correlated Field", f3 AS "Second Field"
  155. FROM SUBSELECT_TBL upper
  156. WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL
  157. WHERE f2 = CAST(f3 AS integer));
  158. </sql-statement>
  159. -stdin-:<main>: Error: Type annotation
  160. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: OrderedFilter, At function: OrderedMap, At function: EquiJoin
  161. SELECT f1 AS "Correlated Field", f3 AS "Second Field"
  162. ^
  163. -stdin-:<main>:3:12: Error: At function: Aggregate
  164. WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL
  165. ^
  166. -stdin-:/lib/yql/aggregate.yql:644:18: Error: At function: AggregationTraits
  167. ^
  168. -stdin-:/lib/yql/aggregate.yql:678:111: Error: At function: SafeCast
  169. ^
  170. -stdin-:<main>:3:12: Error: At function: FromPg, At function: PgResolvedOp
  171. WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL
  172. ^
  173. -stdin-:<main>:3:9: Error: At function: Member
  174. WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL
  175. ^
  176. -stdin-:<main>:3:9: Error: Member not found: _yql_join_sublink_0__alias_upper.f3. Did you mean _yql_join_sublink_0__alias_upper.f1?
  177. WHERE f3 IN (SELECT upper.f1 + f2 FROM SUBSELECT_TBL
  178. ^
  179. <sql-statement>
  180. SELECT f1 AS "Correlated Field"
  181. FROM SUBSELECT_TBL
  182. WHERE (f1, f2) IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL
  183. WHERE f3 IS NOT NULL);
  184. </sql-statement>
  185. -stdin-:<main>: Error: Parse Sql
  186. -stdin-:<main>:3:18: Error: alternative is not implemented yet : 138
  187. WHERE (f1, f2) IN (SELECT f2, CAST(f3 AS int4) FROM SUBSELECT_TBL
  188. ^
  189. <sql-statement>
  190. --
  191. -- Use some existing tables in the regression test
  192. --
  193. SELECT ss.f1 AS "Correlated Field", ss.f3 AS "Second Field"
  194. FROM SUBSELECT_TBL ss
  195. WHERE f1 NOT IN (SELECT f1+1 FROM INT4_TBL
  196. WHERE f1 != ss.f1 AND f1 < 2147483647);
  197. </sql-statement>
  198. <sql-statement>
  199. select q1, float8(count(*)) / (select count(*) from int8_tbl)
  200. from int8_tbl group by q1 order by q1;
  201. </sql-statement>
  202. -stdin-:<main>: Fatal: Optimization
  203. -stdin-:<main>:1:1: Fatal: ydb/library/yql/core/common_opt/yql_co_pgselect.cpp:3637 ExpandPgSelectImpl(): requirement order failed
  204. select q1, float8(count(*)) / (select count(*) from int8_tbl)
  205. ^
  206. -stdin-:<main>: Fatal: ydb/library/yql/core/common_opt/yql_co_pgselect.cpp:727 RewriteSubLinksPartial(): requirement status.Level != IGraphTransformer::TStatus::Error failed
  207. <sql-statement>
  208. -- Unspecified-type literals in output columns should resolve as text
  209. SELECT *, pg_typeof(f1) FROM
  210. (SELECT 'foo' AS f1 FROM generate_series(1,3)) ss ORDER BY 1;
  211. </sql-statement>
  212. -stdin-:<main>: Error: Type annotation
  213. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  214. -- Unspecified-type literals in output columns should resolve as text
  215. ^
  216. -stdin-:<main>:2:21: Error: Star is incompatible to column reference
  217. SELECT *, pg_typeof(f1) FROM
  218. ^
  219. <sql-statement>
  220. -- ... unless there's context to suggest differently
  221. explain (verbose, costs off) select '42' union all select '43';
  222. </sql-statement>
  223. -stdin-:<main>: Error: Parse Sql
  224. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  225. -- ... unless there's context to suggest differently
  226. ^
  227. <sql-statement>
  228. explain (verbose, costs off) select '42' union all select 43;
  229. </sql-statement>
  230. -stdin-:<main>: Error: Parse Sql
  231. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  232. explain (verbose, costs off) select '42' union all select 43;
  233. ^
  234. <sql-statement>
  235. -- check materialization of an initplan reference (bug #14524)
  236. explain (verbose, costs off)
  237. select 1 = all (select (select 1));
  238. </sql-statement>
  239. -stdin-:<main>: Error: Parse Sql
  240. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  241. -- check materialization of an initplan reference (bug #14524)
  242. ^
  243. <sql-statement>
  244. select 1 = all (select (select 1));
  245. </sql-statement>
  246. <sql-statement>
  247. --
  248. -- Check EXISTS simplification with LIMIT
  249. --
  250. explain (costs off)
  251. select * from int4_tbl o where exists
  252. (select 1 from int4_tbl i where i.f1=o.f1 limit null);
  253. </sql-statement>
  254. -stdin-:<main>: Error: Parse Sql
  255. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  256. --
  257. ^
  258. <sql-statement>
  259. explain (costs off)
  260. select * from int4_tbl o where not exists
  261. (select 1 from int4_tbl i where i.f1=o.f1 limit 1);
  262. </sql-statement>
  263. -stdin-:<main>: Error: Parse Sql
  264. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  265. explain (costs off)
  266. ^
  267. <sql-statement>
  268. explain (costs off)
  269. select * from int4_tbl o where exists
  270. (select 1 from int4_tbl i where i.f1=o.f1 limit 0);
  271. </sql-statement>
  272. -stdin-:<main>: Error: Parse Sql
  273. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  274. explain (costs off)
  275. ^
  276. <sql-statement>
  277. --
  278. -- Test cases to catch unpleasant interactions between IN-join processing
  279. -- and subquery pullup.
  280. --
  281. select count(*) from
  282. (select 1 from tenk1 a
  283. where unique1 IN (select hundred from tenk1 b)) ss;
  284. </sql-statement>
  285. <sql-statement>
  286. select count(distinct ss.ten) from
  287. (select ten from tenk1 a
  288. where unique1 IN (select hundred from tenk1 b)) ss;
  289. </sql-statement>
  290. <sql-statement>
  291. select count(*) from
  292. (select 1 from tenk1 a
  293. where unique1 IN (select distinct hundred from tenk1 b)) ss;
  294. </sql-statement>
  295. <sql-statement>
  296. select count(distinct ss.ten) from
  297. (select ten from tenk1 a
  298. where unique1 IN (select distinct hundred from tenk1 b)) ss;
  299. </sql-statement>
  300. <sql-statement>
  301. --
  302. -- Test cases to check for overenthusiastic optimization of
  303. -- "IN (SELECT DISTINCT ...)" and related cases. Per example from
  304. -- Luca Pireddu and Michael Fuhr.
  305. --
  306. CREATE TEMP TABLE foo (id integer);
  307. </sql-statement>
  308. <sql-statement>
  309. CREATE TEMP TABLE bar (id1 integer, id2 integer);
  310. </sql-statement>
  311. <sql-statement>
  312. INSERT INTO foo VALUES (1);
  313. </sql-statement>
  314. <sql-statement>
  315. INSERT INTO bar VALUES (1, 1);
  316. </sql-statement>
  317. <sql-statement>
  318. INSERT INTO bar VALUES (2, 2);
  319. </sql-statement>
  320. <sql-statement>
  321. INSERT INTO bar VALUES (3, 1);
  322. </sql-statement>
  323. <sql-statement>
  324. -- These cases require an extra level of distinct-ing above subquery s
  325. SELECT * FROM foo WHERE id IN
  326. (SELECT id2 FROM (SELECT DISTINCT id1, id2 FROM bar) AS s);
  327. </sql-statement>
  328. <sql-statement>
  329. SELECT * FROM foo WHERE id IN
  330. (SELECT id2 FROM (SELECT id1,id2 FROM bar GROUP BY id1,id2) AS s);
  331. </sql-statement>
  332. <sql-statement>
  333. SELECT * FROM foo WHERE id IN
  334. (SELECT id2 FROM (SELECT id1, id2 FROM bar UNION
  335. SELECT id1, id2 FROM bar) AS s);
  336. </sql-statement>
  337. <sql-statement>
  338. -- These cases do not
  339. SELECT * FROM foo WHERE id IN
  340. (SELECT id2 FROM (SELECT DISTINCT ON (id2) id1, id2 FROM bar) AS s);
  341. </sql-statement>
  342. <sql-statement>
  343. SELECT * FROM foo WHERE id IN
  344. (SELECT id2 FROM (SELECT id2 FROM bar GROUP BY id2) AS s);
  345. </sql-statement>
  346. <sql-statement>
  347. SELECT * FROM foo WHERE id IN
  348. (SELECT id2 FROM (SELECT id2 FROM bar UNION
  349. SELECT id2 FROM bar) AS s);
  350. </sql-statement>
  351. <sql-statement>
  352. --
  353. -- Test case to catch problems with multiply nested sub-SELECTs not getting
  354. -- recalculated properly. Per bug report from Didier Moens.
  355. --
  356. CREATE TABLE orderstest (
  357. approver_ref integer,
  358. po_ref integer,
  359. ordercanceled boolean
  360. );
  361. </sql-statement>
  362. <sql-statement>
  363. INSERT INTO orderstest VALUES (1, 1, false);
  364. </sql-statement>
  365. <sql-statement>
  366. INSERT INTO orderstest VALUES (66, 5, false);
  367. </sql-statement>
  368. <sql-statement>
  369. INSERT INTO orderstest VALUES (66, 6, false);
  370. </sql-statement>
  371. <sql-statement>
  372. INSERT INTO orderstest VALUES (66, 7, false);
  373. </sql-statement>
  374. <sql-statement>
  375. INSERT INTO orderstest VALUES (66, 1, true);
  376. </sql-statement>
  377. <sql-statement>
  378. INSERT INTO orderstest VALUES (66, 8, false);
  379. </sql-statement>
  380. <sql-statement>
  381. INSERT INTO orderstest VALUES (66, 1, false);
  382. </sql-statement>
  383. <sql-statement>
  384. INSERT INTO orderstest VALUES (77, 1, false);
  385. </sql-statement>
  386. <sql-statement>
  387. INSERT INTO orderstest VALUES (1, 1, false);
  388. </sql-statement>
  389. <sql-statement>
  390. INSERT INTO orderstest VALUES (66, 1, false);
  391. </sql-statement>
  392. <sql-statement>
  393. INSERT INTO orderstest VALUES (1, 1, false);
  394. </sql-statement>
  395. <sql-statement>
  396. CREATE VIEW orders_view AS
  397. SELECT *,
  398. (SELECT CASE
  399. WHEN ord.approver_ref=1 THEN '---' ELSE 'Approved'
  400. END) AS "Approved",
  401. (SELECT CASE
  402. WHEN ord.ordercanceled
  403. THEN 'Canceled'
  404. ELSE
  405. (SELECT CASE
  406. WHEN ord.po_ref=1
  407. THEN
  408. (SELECT CASE
  409. WHEN ord.approver_ref=1
  410. THEN '---'
  411. ELSE 'Approved'
  412. END)
  413. ELSE 'PO'
  414. END)
  415. END) AS "Status",
  416. (CASE
  417. WHEN ord.ordercanceled
  418. THEN 'Canceled'
  419. ELSE
  420. (CASE
  421. WHEN ord.po_ref=1
  422. THEN
  423. (CASE
  424. WHEN ord.approver_ref=1
  425. THEN '---'
  426. ELSE 'Approved'
  427. END)
  428. ELSE 'PO'
  429. END)
  430. END) AS "Status_OK"
  431. FROM orderstest ord;
  432. </sql-statement>
  433. -stdin-:<main>: Error: Parse Sql
  434. -stdin-:<main>:1:1: Error: expected at least one target column
  435. CREATE VIEW orders_view AS
  436. ^
  437. <sql-statement>
  438. SELECT * FROM orders_view;
  439. </sql-statement>
  440. -stdin-:<main>: Fatal: Table metadata loading
  441. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.orders_view
  442. <sql-statement>
  443. DROP TABLE orderstest cascade;
  444. </sql-statement>
  445. -stdin-:<main>: Error: Parse Sql
  446. -stdin-:<main>:1:1: Error: CASCADE is not implemented
  447. DROP TABLE orderstest cascade;
  448. ^
  449. <sql-statement>
  450. --
  451. -- Test cases to catch situations where rule rewriter fails to propagate
  452. -- hasSubLinks flag correctly. Per example from Kyle Bateman.
  453. --
  454. create temp table parts (
  455. partnum text,
  456. cost float8
  457. );
  458. </sql-statement>
  459. <sql-statement>
  460. create temp table shipped (
  461. ttype char(2),
  462. ordnum int4,
  463. partnum text,
  464. value float8
  465. );
  466. </sql-statement>
  467. <sql-statement>
  468. create temp view shipped_view as
  469. select * from shipped where ttype = 'wt';
  470. </sql-statement>
  471. -stdin-:<main>: Error: Parse Sql
  472. -stdin-:<main>:1:1: Error: expected at least one target column
  473. create temp view shipped_view as
  474. ^
  475. <sql-statement>
  476. create rule shipped_view_insert as on insert to shipped_view do instead
  477. insert into shipped values('wt', new.ordnum, new.partnum, new.value);
  478. </sql-statement>
  479. -stdin-:<main>: Error: Parse Sql
  480. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 265
  481. create rule shipped_view_insert as on insert to shipped_view do instead
  482. ^
  483. <sql-statement>
  484. insert into parts (partnum, cost) values (1, 1234.56);
  485. </sql-statement>
  486. <sql-statement>
  487. insert into shipped_view (ordnum, partnum, value)
  488. values (0, 1, (select cost from parts where partnum = '1'));
  489. </sql-statement>
  490. -stdin-:<main>: Error: Parse Sql
  491. -stdin-:<main>:2:19: Error: SubLinks are not allowed in: VALUES
  492. values (0, 1, (select cost from parts where partnum = '1'));
  493. ^
  494. <sql-statement>
  495. select * from shipped_view;
  496. </sql-statement>
  497. -stdin-:<main>: Fatal: Table metadata loading
  498. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.shipped_view
  499. <sql-statement>
  500. create rule shipped_view_update as on update to shipped_view do instead
  501. update shipped set partnum = new.partnum, value = new.value
  502. where ttype = new.ttype and ordnum = new.ordnum;
  503. </sql-statement>
  504. -stdin-:<main>: Error: Parse Sql
  505. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 265
  506. create rule shipped_view_update as on update to shipped_view do instead
  507. ^
  508. <sql-statement>
  509. update shipped_view set value = 11
  510. from int4_tbl a join int4_tbl b
  511. on (a.f1 = (select f1 from int4_tbl c where c.f1=b.f1))
  512. where ordnum = a.f1;
  513. </sql-statement>
  514. -stdin-:<main>: Error: Parse Sql
  515. -stdin-:<main>:3:18: Error: SubLinks are not allowed in: JOIN ON
  516. on (a.f1 = (select f1 from int4_tbl c where c.f1=b.f1))
  517. ^
  518. <sql-statement>
  519. select * from shipped_view;
  520. </sql-statement>
  521. -stdin-:<main>: Fatal: Table metadata loading
  522. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.shipped_view
  523. <sql-statement>
  524. select f1, ss1 as relabel from
  525. (select *, (select sum(f1) from int4_tbl b where f1 >= a.f1) as ss1
  526. from int4_tbl a) ss;
  527. </sql-statement>
  528. <sql-statement>
  529. --
  530. -- Test cases involving PARAM_EXEC parameters and min/max index optimizations.
  531. -- Per bug report from David Sanchez i Gregori.
  532. --
  533. select * from (
  534. select max(unique1) from tenk1 as a
  535. where exists (select 1 from tenk1 as b where b.thousand = a.unique2)
  536. ) ss;
  537. </sql-statement>
  538. <sql-statement>
  539. select * from (
  540. select min(unique1) from tenk1 as a
  541. where not exists (select 1 from tenk1 as b where b.unique2 = 10000)
  542. ) ss;
  543. </sql-statement>
  544. <sql-statement>
  545. --
  546. -- Test that an IN implemented using a UniquePath does unique-ification
  547. -- with the right semantics, as per bug #4113. (Unfortunately we have
  548. -- no simple way to ensure that this test case actually chooses that type
  549. -- of plan, but it does in releases 7.4-8.3. Note that an ordering difference
  550. -- here might mean that some other plan type is being used, rendering the test
  551. -- pointless.)
  552. --
  553. create temp table numeric_table (num_col numeric);
  554. </sql-statement>
  555. <sql-statement>
  556. insert into numeric_table values (1), (1.000000000000000000001), (2), (3);
  557. </sql-statement>
  558. <sql-statement>
  559. create temp table float_table (float_col float8);
  560. </sql-statement>
  561. <sql-statement>
  562. insert into float_table values (1), (2), (3);
  563. </sql-statement>
  564. <sql-statement>
  565. select * from float_table
  566. where float_col in (select num_col from numeric_table);
  567. </sql-statement>
  568. <sql-statement>
  569. select * from numeric_table
  570. where num_col in (select float_col from float_table);
  571. </sql-statement>
  572. <sql-statement>
  573. --
  574. -- Test case for bug #4290: bogus calculation of subplan param sets
  575. --
  576. create temp table ta (id int primary key, val int);
  577. </sql-statement>
  578. <sql-statement>
  579. insert into ta values(1,1);
  580. </sql-statement>
  581. <sql-statement>
  582. insert into ta values(2,2);
  583. </sql-statement>
  584. <sql-statement>
  585. create temp table tb (id int primary key, aval int);
  586. </sql-statement>
  587. <sql-statement>
  588. insert into tb values(1,1);
  589. </sql-statement>
  590. <sql-statement>
  591. insert into tb values(2,1);
  592. </sql-statement>
  593. <sql-statement>
  594. insert into tb values(3,2);
  595. </sql-statement>
  596. <sql-statement>
  597. insert into tb values(4,2);
  598. </sql-statement>
  599. <sql-statement>
  600. create temp table tc (id int primary key, aid int);
  601. </sql-statement>
  602. <sql-statement>
  603. insert into tc values(1,1);
  604. </sql-statement>
  605. <sql-statement>
  606. insert into tc values(2,2);
  607. </sql-statement>
  608. <sql-statement>
  609. select
  610. ( select min(tb.id) from tb
  611. where tb.aval = (select ta.val from ta where ta.id = tc.aid) ) as min_tb_id
  612. from tc;
  613. </sql-statement>
  614. -stdin-:<main>: Error: Type annotation
  615. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  616. select
  617. ^
  618. -stdin-:<main>:2:3: Error: At function: PgSubLink, At function: PgSelect
  619. ( select min(tb.id) from tb
  620. ^
  621. -stdin-:<main>: Error: At function: PgSetItem
  622. -stdin-:<main>:2:3: Error: At function: PgWhere
  623. ( select min(tb.id) from tb
  624. ^
  625. -stdin-:<main>:3:19: Error: At function: PgOp
  626. where tb.aval = (select ta.val from ta where ta.id = tc.aid) ) as min_tb_id
  627. ^
  628. -stdin-:<main>:3:21: Error: At function: PgSubLink, At function: PgSelect, At function: PgSetItem
  629. where tb.aval = (select ta.val from ta where ta.id = tc.aid) ) as min_tb_id
  630. ^
  631. -stdin-:<main>:3:58: Error: No such column: aid
  632. where tb.aval = (select ta.val from ta where ta.id = tc.aid) ) as min_tb_id
  633. ^
  634. <sql-statement>
  635. --
  636. -- Test case for 8.3 "failed to locate grouping columns" bug
  637. --
  638. create temp table t1 (f1 numeric(14,0), f2 varchar(30));
  639. </sql-statement>
  640. <sql-statement>
  641. select * from
  642. (select distinct f1, f2, (select f2 from t1 x where x.f1 = up.f1) as fs
  643. from t1 up) ss
  644. group by f1,f2,fs;
  645. </sql-statement>
  646. <sql-statement>
  647. --
  648. -- Test case for bug #5514 (mishandling of whole-row Vars in subselects)
  649. --
  650. create temp table table_a(id integer);
  651. </sql-statement>
  652. <sql-statement>
  653. insert into table_a values (42);
  654. </sql-statement>
  655. <sql-statement>
  656. create temp view view_a as select * from table_a;
  657. </sql-statement>
  658. -stdin-:<main>: Error: Parse Sql
  659. -stdin-:<main>:1:1: Error: expected at least one target column
  660. create temp view view_a as select * from table_a;
  661. ^
  662. <sql-statement>
  663. select view_a from view_a;
  664. </sql-statement>
  665. -stdin-:<main>: Fatal: Table metadata loading
  666. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.view_a
  667. <sql-statement>
  668. select (select view_a) from view_a;
  669. </sql-statement>
  670. -stdin-:<main>: Fatal: Table metadata loading
  671. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.view_a
  672. <sql-statement>
  673. select (select (select view_a)) from view_a;
  674. </sql-statement>
  675. -stdin-:<main>: Fatal: Table metadata loading
  676. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.view_a
  677. <sql-statement>
  678. select (select (a.*)::text) from view_a a;
  679. </sql-statement>
  680. -stdin-:<main>: Fatal: Table metadata loading
  681. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.view_a
  682. <sql-statement>
  683. --
  684. -- Check that whole-row Vars reading the result of a subselect don't include
  685. -- any junk columns therein
  686. --
  687. select q from (select max(f1) from int4_tbl group by f1 order by f1) q;
  688. </sql-statement>
  689. -stdin-:<main>: Fatal: Execution
  690. -stdin-:<main>:1:1: Fatal: Execution of node: Pull
  691. --
  692. ^
  693. -stdin-:<main>:1:1: Fatal: ERROR: input of anonymous composite types is not implemented
  694. --
  695. ^
  696. <sql-statement>
  697. with q as (select max(f1) from int4_tbl group by f1 order by f1)
  698. select q from q;
  699. </sql-statement>
  700. -stdin-:<main>: Fatal: Execution
  701. -stdin-:<main>:1:1: Fatal: Execution of node: Pull
  702. with q as (select max(f1) from int4_tbl group by f1 order by f1)
  703. ^
  704. -stdin-:<main>:1:1: Fatal: ERROR: input of anonymous composite types is not implemented
  705. with q as (select max(f1) from int4_tbl group by f1 order by f1)
  706. ^
  707. <sql-statement>
  708. --
  709. -- Test case for sublinks pulled up into joinaliasvars lists in an
  710. -- inherited update/delete query
  711. --
  712. begin; -- this shouldn't delete anything, but be safe
  713. </sql-statement>
  714. <sql-statement>
  715. delete from road
  716. where exists (
  717. select 1
  718. from
  719. int4_tbl cross join
  720. ( select f1, array(select q1 from int8_tbl) as arr
  721. from text_tbl ) ss
  722. where road.name = ss.f1 );
  723. </sql-statement>
  724. -stdin-:<main>: Fatal: Pre type annotation
  725. -stdin-:<main>: Fatal: tools/enum_parser/enum_serialization_runtime/enum_runtime.cpp:70: Key 'pg_delete' not found in enum NYql::EYtSettingType. Valid options are: 'initial', 'infer_scheme', 'force_infer_schema', 'do_not_fail_on_invalid_schema', 'direct_read', 'view', 'mode', 'scheme', 'weak_concat', 'anonymous', 'with_qb', 'inline', 'sample', 'joinLabel', 'ignore_non_existing', 'warn_non_existing', 'xlock', 'unordered', 'nonUnique', 'userschema', 'usercolumns', 'statcolumns', 'syscolumns', 'ignoretypev3', 'memUsage', 'itemsCount', 'rowFactor', 'ordered', 'keyFilter', 'keyFilter2', 'take', 'skip', 'limit', 'sortLimitBy', 'sortBy', 'reduceBy', 'reduceFilterBy', 'forceTransform', 'weakFields', 'sharded', 'combineChunks', 'jobCount', 'joinReduce', 'firstAsPrimary', 'flow', 'keepSorted', 'keySwitch', 'uniqueBy', 'opHash', 'mapOutputType', 'reduceInputType', 'noDq', 'split', 'compression_codec', 'erasure_codec', 'expiration', 'replication_factor', 'user_attrs', 'media', 'primary_medium', 'keep_meta', 'monotonic_keys', 'mutationid'.
  726. <sql-statement>
  727. rollback;
  728. </sql-statement>
  729. <sql-statement>
  730. --
  731. -- Test case for sublinks pushed down into subselects via join alias expansion
  732. --
  733. select
  734. (select sq1) as qq1
  735. from
  736. (select exists(select 1 from int4_tbl where f1 = q2) as sq1, 42 as dummy
  737. from int8_tbl) sq0
  738. join
  739. int4_tbl i4 on dummy = i4.f1;
  740. </sql-statement>
  741. -stdin-:<main>: Error: Type annotation
  742. -stdin-:<main>:1:1: Error: At function: OrderedFlatMap, At function: EquiJoin, At function: OrderedFlatMap, At function: EquiJoin, At function: OrderedFlatMap, At function: EquiJoin
  743. --
  744. ^
  745. -stdin-:<main>:7:11: Error: At function: Aggregate, At function: OrderedMap, At function: EquiJoin
  746. (select exists(select 1 from int4_tbl where f1 = q2) as sq1, 42 as dummy
  747. ^
  748. -stdin-:<main>:7:11: Error: Cannot compare key columns (a._alias_int4_tbl.f1 has type: pgint4, b._alias_int8_tbl.q2 has type: pgint8)
  749. (select exists(select 1 from int4_tbl where f1 = q2) as sq1, 42 as dummy
  750. ^
  751. <sql-statement>
  752. --
  753. -- Test case for subselect within UPDATE of INSERT...ON CONFLICT DO UPDATE
  754. --
  755. create temp table upsert(key int4 primary key, val text);
  756. </sql-statement>
  757. <sql-statement>
  758. insert into upsert values(1, 'val') on conflict (key) do update set val = 'not seen';
  759. </sql-statement>
  760. -stdin-:<main>: Error: Parse Sql
  761. -stdin-:<main>:1:1: Error: InsertStmt: not supported onConflictClause
  762. insert into upsert values(1, 'val') on conflict (key) do update set val = 'not seen';
  763. ^
  764. <sql-statement>
  765. insert into upsert values(1, 'val') on conflict (key) do update set val = 'seen with subselect ' || (select f1 from int4_tbl where f1 != 0 limit 1)::text;
  766. </sql-statement>
  767. -stdin-:<main>: Error: Parse Sql
  768. -stdin-:<main>:1:1: Error: InsertStmt: not supported onConflictClause
  769. insert into upsert values(1, 'val') on conflict (key) do update set val = 'seen with subselect ' || (select f1 from int4_tbl where f1 != 0 limit 1)::text;
  770. ^
  771. <sql-statement>
  772. select * from upsert;
  773. </sql-statement>
  774. <sql-statement>
  775. with aa as (select 'int4_tbl' u from int4_tbl limit 1)
  776. insert into upsert values (1, 'x'), (999, 'y')
  777. on conflict (key) do update set val = (select u from aa)
  778. returning *;
  779. </sql-statement>
  780. -stdin-:<main>: Error: Parse Sql
  781. -stdin-:<main>:1:1: Error: InsertStmt: not supported onConflictClause
  782. with aa as (select 'int4_tbl' u from int4_tbl limit 1)
  783. ^
  784. <sql-statement>
  785. --
  786. -- Test case for cross-type partial matching in hashed subplan (bug #7597)
  787. --
  788. create temp table outer_7597 (f1 int4, f2 int4);
  789. </sql-statement>
  790. <sql-statement>
  791. insert into outer_7597 values (0, 0);
  792. </sql-statement>
  793. <sql-statement>
  794. insert into outer_7597 values (1, 0);
  795. </sql-statement>
  796. <sql-statement>
  797. insert into outer_7597 values (0, null);
  798. </sql-statement>
  799. <sql-statement>
  800. insert into outer_7597 values (1, null);
  801. </sql-statement>
  802. <sql-statement>
  803. create temp table inner_7597(c1 int8, c2 int8);
  804. </sql-statement>
  805. <sql-statement>
  806. insert into inner_7597 values(0, null);
  807. </sql-statement>
  808. <sql-statement>
  809. select * from outer_7597 where (f1, f2) not in (select * from inner_7597);
  810. </sql-statement>
  811. -stdin-:<main>: Error: Parse Sql
  812. -stdin-:<main>:1:41: Error: alternative is not implemented yet : 138
  813. select * from outer_7597 where (f1, f2) not in (select * from inner_7597);
  814. ^
  815. <sql-statement>
  816. --
  817. -- Similar test case using text that verifies that collation
  818. -- information is passed through by execTuplesEqual() in nodeSubplan.c
  819. -- (otherwise it would error in texteq())
  820. --
  821. create temp table outer_text (f1 text, f2 text);
  822. </sql-statement>
  823. <sql-statement>
  824. insert into outer_text values ('a', 'a');
  825. </sql-statement>
  826. <sql-statement>
  827. insert into outer_text values ('b', 'a');
  828. </sql-statement>
  829. <sql-statement>
  830. insert into outer_text values ('a', null);
  831. </sql-statement>
  832. <sql-statement>
  833. insert into outer_text values ('b', null);
  834. </sql-statement>
  835. <sql-statement>
  836. create temp table inner_text (c1 text, c2 text);
  837. </sql-statement>
  838. <sql-statement>
  839. insert into inner_text values ('a', null);
  840. </sql-statement>
  841. <sql-statement>
  842. insert into inner_text values ('123', '456');
  843. </sql-statement>
  844. <sql-statement>
  845. select * from outer_text where (f1, f2) not in (select * from inner_text);
  846. </sql-statement>
  847. -stdin-:<main>: Error: Parse Sql
  848. -stdin-:<main>:1:41: Error: alternative is not implemented yet : 138
  849. select * from outer_text where (f1, f2) not in (select * from inner_text);
  850. ^
  851. <sql-statement>
  852. --
  853. -- Another test case for cross-type hashed subplans: comparison of
  854. -- inner-side values must be done with appropriate operator
  855. --
  856. explain (verbose, costs off)
  857. select 'foo'::text in (select 'bar'::name union all select 'bar'::name);
  858. </sql-statement>
  859. -stdin-:<main>: Error: Parse Sql
  860. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  861. --
  862. ^
  863. <sql-statement>
  864. select 'foo'::text in (select 'bar'::name union all select 'bar'::name);
  865. </sql-statement>
  866. -stdin-:<main>: Error: Type annotation
  867. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: AsStruct
  868. select 'foo'::text in (select 'bar'::name union all select 'bar'::name);
  869. ^
  870. -stdin-:<main>:1:20: Error: At function: ToPg, At function: SqlIn
  871. select 'foo'::text in (select 'bar'::name union all select 'bar'::name);
  872. ^
  873. -stdin-:<main>:1:20: Error: Can't lookup pgtext in collection of pgname: types pgtext and pgname are not comparable
  874. select 'foo'::text in (select 'bar'::name union all select 'bar'::name);
  875. ^
  876. <sql-statement>
  877. --
  878. -- Test that we don't try to hash nested records (bug #17363)
  879. -- (Hashing could be supported, but for now we don't)
  880. --
  881. explain (verbose, costs off)
  882. select row(row(row(1))) = any (select row(row(1)));
  883. </sql-statement>
  884. -stdin-:<main>: Error: Parse Sql
  885. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  886. --
  887. ^
  888. <sql-statement>
  889. select row(row(row(1))) = any (select row(row(1)));
  890. </sql-statement>
  891. -stdin-:<main>: Error: Parse Sql
  892. -stdin-:<main>:1:25: Error: alternative is not implemented yet : 138
  893. select row(row(row(1))) = any (select row(row(1)));
  894. ^
  895. <sql-statement>
  896. --
  897. -- Test case for premature memory release during hashing of subplan output
  898. --
  899. select '1'::text in (select '1'::name union all select '1'::name);
  900. </sql-statement>
  901. -stdin-:<main>: Error: Type annotation
  902. -stdin-:<main>:1:1: Error: At function: AssumeColumnOrder, At function: PgReplaceUnknown, At function: OrderedMap, At function: AsStruct
  903. --
  904. ^
  905. -stdin-:<main>:4:18: Error: At function: ToPg, At function: SqlIn
  906. select '1'::text in (select '1'::name union all select '1'::name);
  907. ^
  908. -stdin-:<main>:4:18: Error: Can't lookup pgtext in collection of pgname: types pgtext and pgname are not comparable
  909. select '1'::text in (select '1'::name union all select '1'::name);
  910. ^
  911. <sql-statement>
  912. --
  913. -- Test that we don't try to use a hashed subplan if the simplified
  914. -- testexpr isn't of the right shape
  915. --
  916. -- this fails by default, of course
  917. select * from int8_tbl where q1 in (select c1 from inner_text);
  918. </sql-statement>
  919. -stdin-:<main>: Error: Type annotation
  920. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  921. --
  922. ^
  923. -stdin-:<main>: Error: At function: PgSetItem
  924. -stdin-:<main>:1:1: Error: At function: PgWhere
  925. --
  926. ^
  927. -stdin-:<main>:6:33: Error: At function: PgSubLink, At function: PgOp
  928. select * from int8_tbl where q1 in (select c1 from inner_text);
  929. ^
  930. -stdin-:<main>:6:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text)
  931. select * from int8_tbl where q1 in (select c1 from inner_text);
  932. ^
  933. <sql-statement>
  934. begin;
  935. </sql-statement>
  936. <sql-statement>
  937. -- make an operator to allow it to succeed
  938. create function bogus_int8_text_eq(int8, text) returns boolean
  939. language sql as 'select $1::text = $2';
  940. </sql-statement>
  941. -stdin-:<main>: Error: Parse Sql
  942. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  943. -- make an operator to allow it to succeed
  944. ^
  945. <sql-statement>
  946. create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
  947. </sql-statement>
  948. -stdin-:<main>: Error: Parse Sql
  949. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 255
  950. create operator = (procedure=bogus_int8_text_eq, leftarg=int8, rightarg=text);
  951. ^
  952. <sql-statement>
  953. explain (costs off)
  954. select * from int8_tbl where q1 in (select c1 from inner_text);
  955. </sql-statement>
  956. -stdin-:<main>: Error: Parse Sql
  957. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  958. explain (costs off)
  959. ^
  960. <sql-statement>
  961. select * from int8_tbl where q1 in (select c1 from inner_text);
  962. </sql-statement>
  963. -stdin-:<main>: Error: Type annotation
  964. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  965. select * from int8_tbl where q1 in (select c1 from inner_text);
  966. ^
  967. -stdin-:<main>: Error: At function: PgSetItem
  968. -stdin-:<main>:1:1: Error: At function: PgWhere
  969. select * from int8_tbl where q1 in (select c1 from inner_text);
  970. ^
  971. -stdin-:<main>:1:33: Error: At function: PgSubLink, At function: PgOp
  972. select * from int8_tbl where q1 in (select c1 from inner_text);
  973. ^
  974. -stdin-:<main>:1:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text)
  975. select * from int8_tbl where q1 in (select c1 from inner_text);
  976. ^
  977. <sql-statement>
  978. -- inlining of this function results in unusual number of hash clauses,
  979. -- which we can still cope with
  980. create or replace function bogus_int8_text_eq(int8, text) returns boolean
  981. language sql as 'select $1::text = $2 and $1::text = $2';
  982. </sql-statement>
  983. -stdin-:<main>: Error: Parse Sql
  984. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  985. -- inlining of this function results in unusual number of hash clauses,
  986. ^
  987. <sql-statement>
  988. explain (costs off)
  989. select * from int8_tbl where q1 in (select c1 from inner_text);
  990. </sql-statement>
  991. -stdin-:<main>: Error: Parse Sql
  992. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  993. explain (costs off)
  994. ^
  995. <sql-statement>
  996. select * from int8_tbl where q1 in (select c1 from inner_text);
  997. </sql-statement>
  998. -stdin-:<main>: Error: Type annotation
  999. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1000. select * from int8_tbl where q1 in (select c1 from inner_text);
  1001. ^
  1002. -stdin-:<main>: Error: At function: PgSetItem
  1003. -stdin-:<main>:1:1: Error: At function: PgWhere
  1004. select * from int8_tbl where q1 in (select c1 from inner_text);
  1005. ^
  1006. -stdin-:<main>:1:33: Error: At function: PgSubLink, At function: PgOp
  1007. select * from int8_tbl where q1 in (select c1 from inner_text);
  1008. ^
  1009. -stdin-:<main>:1:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text)
  1010. select * from int8_tbl where q1 in (select c1 from inner_text);
  1011. ^
  1012. <sql-statement>
  1013. -- inlining of this function causes LHS and RHS to be switched,
  1014. -- which we can't cope with, so hashing should be abandoned
  1015. create or replace function bogus_int8_text_eq(int8, text) returns boolean
  1016. language sql as 'select $2 = $1::text';
  1017. </sql-statement>
  1018. -stdin-:<main>: Error: Parse Sql
  1019. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  1020. -- inlining of this function causes LHS and RHS to be switched,
  1021. ^
  1022. <sql-statement>
  1023. explain (costs off)
  1024. select * from int8_tbl where q1 in (select c1 from inner_text);
  1025. </sql-statement>
  1026. -stdin-:<main>: Error: Parse Sql
  1027. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1028. explain (costs off)
  1029. ^
  1030. <sql-statement>
  1031. select * from int8_tbl where q1 in (select c1 from inner_text);
  1032. </sql-statement>
  1033. -stdin-:<main>: Error: Type annotation
  1034. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1035. select * from int8_tbl where q1 in (select c1 from inner_text);
  1036. ^
  1037. -stdin-:<main>: Error: At function: PgSetItem
  1038. -stdin-:<main>:1:1: Error: At function: PgWhere
  1039. select * from int8_tbl where q1 in (select c1 from inner_text);
  1040. ^
  1041. -stdin-:<main>:1:33: Error: At function: PgSubLink, At function: PgOp
  1042. select * from int8_tbl where q1 in (select c1 from inner_text);
  1043. ^
  1044. -stdin-:<main>:1:33: Error: Unable to find an overload for operator = with given argument type(s): (int8,text)
  1045. select * from int8_tbl where q1 in (select c1 from inner_text);
  1046. ^
  1047. <sql-statement>
  1048. rollback; -- to get rid of the bogus operator
  1049. </sql-statement>
  1050. <sql-statement>
  1051. --
  1052. -- Test resolution of hashed vs non-hashed implementation of EXISTS subplan
  1053. --
  1054. explain (costs off)
  1055. select count(*) from tenk1 t
  1056. where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0);
  1057. </sql-statement>
  1058. -stdin-:<main>: Error: Parse Sql
  1059. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1060. --
  1061. ^
  1062. <sql-statement>
  1063. select count(*) from tenk1 t
  1064. where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0);
  1065. </sql-statement>
  1066. <sql-statement>
  1067. explain (costs off)
  1068. select count(*) from tenk1 t
  1069. where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0)
  1070. and thousand = 1;
  1071. </sql-statement>
  1072. -stdin-:<main>: Error: Parse Sql
  1073. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1074. explain (costs off)
  1075. ^
  1076. <sql-statement>
  1077. select count(*) from tenk1 t
  1078. where (exists(select 1 from tenk1 k where k.unique1 = t.unique2) or ten < 0)
  1079. and thousand = 1;
  1080. </sql-statement>
  1081. <sql-statement>
  1082. -- It's possible for the same EXISTS to get resolved both ways
  1083. create temp table exists_tbl (c1 int, c2 int, c3 int) partition by list (c1);
  1084. </sql-statement>
  1085. -stdin-:<main>: Error: Parse Sql
  1086. -stdin-:<main>:1:1: Error: PARTITION BY clause not supported
  1087. -- It's possible for the same EXISTS to get resolved both ways
  1088. ^
  1089. <sql-statement>
  1090. create temp table exists_tbl_null partition of exists_tbl for values in (null);
  1091. </sql-statement>
  1092. -stdin-:<main>: Error: Parse Sql
  1093. -stdin-:<main>:1:1: Error: table inheritance not supported
  1094. create temp table exists_tbl_null partition of exists_tbl for values in (null);
  1095. ^
  1096. <sql-statement>
  1097. create temp table exists_tbl_def partition of exists_tbl default;
  1098. </sql-statement>
  1099. -stdin-:<main>: Error: Parse Sql
  1100. -stdin-:<main>:1:1: Error: table inheritance not supported
  1101. create temp table exists_tbl_def partition of exists_tbl default;
  1102. ^
  1103. <sql-statement>
  1104. insert into exists_tbl select x, x/2, x+1 from generate_series(0,10) x;
  1105. </sql-statement>
  1106. -stdin-:<main>: Fatal: Table metadata loading
  1107. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.exists_tbl
  1108. <sql-statement>
  1109. analyze exists_tbl;
  1110. </sql-statement>
  1111. -stdin-:<main>: Error: Parse Sql
  1112. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 275
  1113. analyze exists_tbl;
  1114. ^
  1115. <sql-statement>
  1116. explain (costs off)
  1117. select * from exists_tbl t1
  1118. where (exists(select 1 from exists_tbl t2 where t1.c1 = t2.c2) or c3 < 0);
  1119. </sql-statement>
  1120. -stdin-:<main>: Error: Parse Sql
  1121. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1122. explain (costs off)
  1123. ^
  1124. <sql-statement>
  1125. select * from exists_tbl t1
  1126. where (exists(select 1 from exists_tbl t2 where t1.c1 = t2.c2) or c3 < 0);
  1127. </sql-statement>
  1128. -stdin-:<main>: Fatal: Table metadata loading
  1129. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.exists_tbl
  1130. <sql-statement>
  1131. --
  1132. -- Test case for planner bug with nested EXISTS handling
  1133. --
  1134. select a.thousand from tenk1 a, tenk1 b
  1135. where a.thousand = b.thousand
  1136. and exists ( select 1 from tenk1 c where b.hundred = c.hundred
  1137. and not exists ( select 1 from tenk1 d
  1138. where a.thousand = d.thousand ) );
  1139. </sql-statement>
  1140. -stdin-:<main>: Error: Type annotation
  1141. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1142. --
  1143. ^
  1144. -stdin-:<main>: Error: At function: PgSetItem
  1145. -stdin-:<main>:1:1: Error: At function: PgWhere
  1146. --
  1147. ^
  1148. -stdin-:<main>:6:3: Error: At function: PgAnd
  1149. and exists ( select 1 from tenk1 c where b.hundred = c.hundred
  1150. ^
  1151. -stdin-:<main>:6:7: Error: At function: PgSubLink, At function: PgSelect
  1152. and exists ( select 1 from tenk1 c where b.hundred = c.hundred
  1153. ^
  1154. -stdin-:<main>: Error: At function: PgSetItem
  1155. -stdin-:<main>:6:7: Error: At function: PgWhere
  1156. and exists ( select 1 from tenk1 c where b.hundred = c.hundred
  1157. ^
  1158. -stdin-:<main>:7:20: Error: At function: PgAnd
  1159. and not exists ( select 1 from tenk1 d
  1160. ^
  1161. -stdin-:<main>:7:24: Error: At function: PgNot
  1162. and not exists ( select 1 from tenk1 d
  1163. ^
  1164. -stdin-:<main>:7:28: Error: At function: PgSubLink, At function: PgSelect, At function: PgSetItem
  1165. and not exists ( select 1 from tenk1 d
  1166. ^
  1167. -stdin-:<main>:8:43: Error: No such column: thousand
  1168. where a.thousand = d.thousand ) );
  1169. ^
  1170. <sql-statement>
  1171. --
  1172. -- Check that nested sub-selects are not pulled up if they contain volatiles
  1173. --
  1174. explain (verbose, costs off)
  1175. select x, x from
  1176. (select (select now()) as x from (values(1),(2)) v(y)) ss;
  1177. </sql-statement>
  1178. -stdin-:<main>: Error: Parse Sql
  1179. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1180. --
  1181. ^
  1182. <sql-statement>
  1183. explain (verbose, costs off)
  1184. select x, x from
  1185. (select (select random()) as x from (values(1),(2)) v(y)) ss;
  1186. </sql-statement>
  1187. -stdin-:<main>: Error: Parse Sql
  1188. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1189. explain (verbose, costs off)
  1190. ^
  1191. <sql-statement>
  1192. explain (verbose, costs off)
  1193. select x, x from
  1194. (select (select now() where y=y) as x from (values(1),(2)) v(y)) ss;
  1195. </sql-statement>
  1196. -stdin-:<main>: Error: Parse Sql
  1197. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1198. explain (verbose, costs off)
  1199. ^
  1200. <sql-statement>
  1201. explain (verbose, costs off)
  1202. select x, x from
  1203. (select (select random() where y=y) as x from (values(1),(2)) v(y)) ss;
  1204. </sql-statement>
  1205. -stdin-:<main>: Error: Parse Sql
  1206. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1207. explain (verbose, costs off)
  1208. ^
  1209. <sql-statement>
  1210. --
  1211. -- Test rescan of a hashed subplan (the use of random() is to prevent the
  1212. -- sub-select from being pulled up, which would result in not hashing)
  1213. --
  1214. explain (verbose, costs off)
  1215. select sum(ss.tst::int) from
  1216. onek o cross join lateral (
  1217. select i.ten in (select f1 from int4_tbl where f1 <= o.hundred) as tst,
  1218. random() as r
  1219. from onek i where i.unique1 = o.unique1 ) ss
  1220. where o.ten = 0;
  1221. </sql-statement>
  1222. -stdin-:<main>: Error: Parse Sql
  1223. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1224. --
  1225. ^
  1226. <sql-statement>
  1227. select sum(ss.tst::int) from
  1228. onek o cross join lateral (
  1229. select i.ten in (select f1 from int4_tbl where f1 <= o.hundred) as tst,
  1230. random() as r
  1231. from onek i where i.unique1 = o.unique1 ) ss
  1232. where o.ten = 0;
  1233. </sql-statement>
  1234. -stdin-:<main>: Error: Parse Sql
  1235. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  1236. select sum(ss.tst::int) from
  1237. ^
  1238. <sql-statement>
  1239. --
  1240. -- Test rescan of a SetOp node
  1241. --
  1242. explain (costs off)
  1243. select count(*) from
  1244. onek o cross join lateral (
  1245. select * from onek i1 where i1.unique1 = o.unique1
  1246. except
  1247. select * from onek i2 where i2.unique1 = o.unique2
  1248. ) ss
  1249. where o.ten = 1;
  1250. </sql-statement>
  1251. -stdin-:<main>: Error: Parse Sql
  1252. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1253. --
  1254. ^
  1255. <sql-statement>
  1256. select count(*) from
  1257. onek o cross join lateral (
  1258. select * from onek i1 where i1.unique1 = o.unique1
  1259. except
  1260. select * from onek i2 where i2.unique1 = o.unique2
  1261. ) ss
  1262. where o.ten = 1;
  1263. </sql-statement>
  1264. -stdin-:<main>: Error: Parse Sql
  1265. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  1266. select count(*) from
  1267. ^
  1268. <sql-statement>
  1269. --
  1270. -- Test rescan of a RecursiveUnion node
  1271. --
  1272. explain (costs off)
  1273. select sum(o.four), sum(ss.a) from
  1274. onek o cross join lateral (
  1275. with recursive x(a) as
  1276. (select o.four as a
  1277. union
  1278. select a + 1 from x
  1279. where a < 10)
  1280. select * from x
  1281. ) ss
  1282. where o.ten = 1;
  1283. </sql-statement>
  1284. -stdin-:<main>: Error: Parse Sql
  1285. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1286. --
  1287. ^
  1288. <sql-statement>
  1289. select sum(o.four), sum(ss.a) from
  1290. onek o cross join lateral (
  1291. with recursive x(a) as
  1292. (select o.four as a
  1293. union
  1294. select a + 1 from x
  1295. where a < 10)
  1296. select * from x
  1297. ) ss
  1298. where o.ten = 1;
  1299. </sql-statement>
  1300. -stdin-:<main>: Error: Parse Sql
  1301. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  1302. select sum(o.four), sum(ss.a) from
  1303. ^
  1304. <sql-statement>
  1305. --
  1306. -- Check we don't misoptimize a NOT IN where the subquery returns no rows.
  1307. --
  1308. create temp table notinouter (a int);
  1309. </sql-statement>
  1310. <sql-statement>
  1311. create temp table notininner (b int not null);
  1312. </sql-statement>
  1313. <sql-statement>
  1314. insert into notinouter values (null), (1);
  1315. </sql-statement>
  1316. <sql-statement>
  1317. select * from notinouter where a not in (select b from notininner);
  1318. </sql-statement>
  1319. <sql-statement>
  1320. --
  1321. -- Check we behave sanely in corner case of empty SELECT list (bug #8648)
  1322. --
  1323. create temp table nocolumns();
  1324. </sql-statement>
  1325. <sql-statement>
  1326. select exists(select * from nocolumns);
  1327. </sql-statement>
  1328. <sql-statement>
  1329. --
  1330. -- Check behavior with a SubPlan in VALUES (bug #14924)
  1331. --
  1332. select val.x
  1333. from generate_series(1,10) as s(i),
  1334. lateral (
  1335. values ((select s.i + 1)), (s.i + 101)
  1336. ) as val(x)
  1337. where s.i < 10 and (select val.x) < 110;
  1338. </sql-statement>
  1339. -stdin-:<main>: Error: Parse Sql
  1340. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  1341. --
  1342. ^
  1343. <sql-statement>
  1344. -- another variant of that (bug #16213)
  1345. explain (verbose, costs off)
  1346. select * from
  1347. (values
  1348. (3 not in (select * from (values (1), (2)) ss1)),
  1349. (false)
  1350. ) ss;
  1351. </sql-statement>
  1352. -stdin-:<main>: Error: Parse Sql
  1353. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1354. -- another variant of that (bug #16213)
  1355. ^
  1356. <sql-statement>
  1357. select * from
  1358. (values
  1359. (3 not in (select * from (values (1), (2)) ss1)),
  1360. (false)
  1361. ) ss;
  1362. </sql-statement>
  1363. -stdin-:<main>: Error: Parse Sql
  1364. -stdin-:<main>:3:6: Error: SubLinks are not allowed in: VALUES
  1365. (3 not in (select * from (values (1), (2)) ss1)),
  1366. ^
  1367. -stdin-:<main>: Error: Type annotation
  1368. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1369. select * from
  1370. ^
  1371. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  1372. select * from
  1373. ^
  1374. <sql-statement>
  1375. --
  1376. -- Check sane behavior with nested IN SubLinks
  1377. --
  1378. explain (verbose, costs off)
  1379. select * from int4_tbl where
  1380. (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in
  1381. (select ten from tenk1 b);
  1382. </sql-statement>
  1383. -stdin-:<main>: Error: Parse Sql
  1384. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1385. --
  1386. ^
  1387. <sql-statement>
  1388. select * from int4_tbl where
  1389. (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in
  1390. (select ten from tenk1 b);
  1391. </sql-statement>
  1392. -stdin-:<main>: Error: Type annotation
  1393. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1394. select * from int4_tbl where
  1395. ^
  1396. -stdin-:<main>: Error: At function: PgSetItem
  1397. -stdin-:<main>:1:1: Error: At function: PgWhere
  1398. select * from int4_tbl where
  1399. ^
  1400. -stdin-:<main>:2:73: Error: At function: PgSubLink, At function: PgOp
  1401. (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in
  1402. ^
  1403. -stdin-:<main>:2:4: Error: At function: If, At function: Coalesce, At function: FromPg
  1404. (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in
  1405. ^
  1406. -stdin-:<main>:2:17: Error: Expected computable data, but got: Unit
  1407. (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in
  1408. ^
  1409. -stdin-:<main>:2:17: Error: Computable required. Atom, key, world, datasink, datasource, type, lambda are not computable
  1410. (case when f1 in (select unique1 from tenk1 a) then f1 else null end) in
  1411. ^
  1412. <sql-statement>
  1413. --
  1414. -- Check for incorrect optimization when IN subquery contains a SRF
  1415. --
  1416. explain (verbose, costs off)
  1417. select * from int4_tbl o where (f1, f1) in
  1418. (select f1, generate_series(1,50) / 10 g from int4_tbl i group by f1);
  1419. </sql-statement>
  1420. -stdin-:<main>: Error: Parse Sql
  1421. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1422. --
  1423. ^
  1424. <sql-statement>
  1425. select * from int4_tbl o where (f1, f1) in
  1426. (select f1, generate_series(1,50) / 10 g from int4_tbl i group by f1);
  1427. </sql-statement>
  1428. -stdin-:<main>: Error: Parse Sql
  1429. -stdin-:<main>:1:41: Error: alternative is not implemented yet : 138
  1430. select * from int4_tbl o where (f1, f1) in
  1431. ^
  1432. <sql-statement>
  1433. --
  1434. -- check for over-optimization of whole-row Var referencing an Append plan
  1435. --
  1436. select (select q from
  1437. (select 1,2,3 where f1 > 0
  1438. union all
  1439. select 4,5,6.0 where f1 <= 0
  1440. ) q )
  1441. from int4_tbl;
  1442. </sql-statement>
  1443. -stdin-:<main>: Error: Type annotation
  1444. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem, At function: PgResultItem
  1445. --
  1446. ^
  1447. -stdin-:<main>:4:8: Error: At function: PgSubLink, At function: PgSelect, At function: PgSetItem, At function: PgSelect
  1448. select (select q from
  1449. ^
  1450. -stdin-:<main>:4:8: Error: At function: PgSetItem
  1451. select (select q from
  1452. ^
  1453. -stdin-:<main>:5:30: Error: Column reference can't be used without FROM
  1454. (select 1,2,3 where f1 > 0
  1455. ^
  1456. -stdin-:<main>:4:8: Error: At function: PgSetItem
  1457. select (select q from
  1458. ^
  1459. -stdin-:<main>:7:32: Error: Column reference can't be used without FROM
  1460. select 4,5,6.0 where f1 <= 0
  1461. ^
  1462. <sql-statement>
  1463. --
  1464. -- Check for sane handling of a lateral reference in a subquery's quals
  1465. -- (most of the complication here is to prevent the test case from being
  1466. -- flattened too much)
  1467. --
  1468. explain (verbose, costs off)
  1469. select * from
  1470. int4_tbl i4,
  1471. lateral (
  1472. select i4.f1 > 1 as b, 1 as id
  1473. from (select random() order by 1) as t1
  1474. union all
  1475. select true as b, 2 as id
  1476. ) as t2
  1477. where b and f1 >= 0;
  1478. </sql-statement>
  1479. -stdin-:<main>: Error: Parse Sql
  1480. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1481. --
  1482. ^
  1483. <sql-statement>
  1484. select * from
  1485. int4_tbl i4,
  1486. lateral (
  1487. select i4.f1 > 1 as b, 1 as id
  1488. from (select random() order by 1) as t1
  1489. union all
  1490. select true as b, 2 as id
  1491. ) as t2
  1492. where b and f1 >= 0;
  1493. </sql-statement>
  1494. -stdin-:<main>: Error: Parse Sql
  1495. -stdin-:<main>:1:1: Error: RangeSubselect: unsupported lateral
  1496. select * from
  1497. ^
  1498. <sql-statement>
  1499. --
  1500. -- Check that volatile quals aren't pushed down past a DISTINCT:
  1501. -- nextval() should not be called more than the nominal number of times
  1502. --
  1503. create temp sequence ts1;
  1504. </sql-statement>
  1505. -stdin-:<main>: Error: Pre type annotation
  1506. -stdin-:<main>:1:1: Error: Unexpected tag: pgObject
  1507. --
  1508. ^
  1509. <sql-statement>
  1510. select * from
  1511. (select distinct ten from tenk1) ss
  1512. where ten < 10 + nextval('ts1')
  1513. order by 1;
  1514. </sql-statement>
  1515. -stdin-:<main>: Fatal: Execution
  1516. -stdin-:<main>:1:1: Fatal: Execution of node: YtMapReduce!
  1517. select * from
  1518. ^
  1519. -stdin-:<main>:1:1: Fatal: ERROR: relation "ts1" does not exist
  1520. select * from
  1521. ^
  1522. <sql-statement>
  1523. select nextval('ts1');
  1524. </sql-statement>
  1525. -stdin-:<main>: Fatal: Execution
  1526. -stdin-:<main>:1:1: Fatal: Execution of node: Result
  1527. select nextval('ts1');
  1528. ^
  1529. -stdin-:<main>:1:1: Fatal: ERROR: relation "ts1" does not exist
  1530. select nextval('ts1');
  1531. ^
  1532. <sql-statement>
  1533. --
  1534. -- Check that volatile quals aren't pushed down past a set-returning function;
  1535. -- while a nonvolatile qual can be, if it doesn't reference the SRF.
  1536. --
  1537. create function tattle(x int, y int) returns bool
  1538. volatile language plpgsql as $$
  1539. begin
  1540. raise notice 'x = %, y = %', x, y;
  1541. return x > y;
  1542. end$$;
  1543. </sql-statement>
  1544. -stdin-:<main>: Error: Parse Sql
  1545. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  1546. --
  1547. ^
  1548. <sql-statement>
  1549. explain (verbose, costs off)
  1550. select * from
  1551. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1552. where tattle(x, 8);
  1553. </sql-statement>
  1554. -stdin-:<main>: Error: Parse Sql
  1555. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1556. explain (verbose, costs off)
  1557. ^
  1558. <sql-statement>
  1559. select * from
  1560. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1561. where tattle(x, 8);
  1562. </sql-statement>
  1563. -stdin-:<main>: Error: Parse Sql
  1564. -stdin-:<main>:2:19: Error: Generator functions are not allowed in: SELECT
  1565. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1566. ^
  1567. -stdin-:<main>: Error: Type annotation
  1568. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1569. select * from
  1570. ^
  1571. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  1572. select * from
  1573. ^
  1574. <sql-statement>
  1575. -- if we pretend it's stable, we get different results:
  1576. alter function tattle(x int, y int) stable;
  1577. </sql-statement>
  1578. -stdin-:<main>: Error: Parse Sql
  1579. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 262
  1580. -- if we pretend it's stable, we get different results:
  1581. ^
  1582. <sql-statement>
  1583. explain (verbose, costs off)
  1584. select * from
  1585. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1586. where tattle(x, 8);
  1587. </sql-statement>
  1588. -stdin-:<main>: Error: Parse Sql
  1589. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1590. explain (verbose, costs off)
  1591. ^
  1592. <sql-statement>
  1593. select * from
  1594. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1595. where tattle(x, 8);
  1596. </sql-statement>
  1597. -stdin-:<main>: Error: Parse Sql
  1598. -stdin-:<main>:2:19: Error: Generator functions are not allowed in: SELECT
  1599. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1600. ^
  1601. -stdin-:<main>: Error: Type annotation
  1602. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1603. select * from
  1604. ^
  1605. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  1606. select * from
  1607. ^
  1608. <sql-statement>
  1609. -- although even a stable qual should not be pushed down if it references SRF
  1610. explain (verbose, costs off)
  1611. select * from
  1612. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1613. where tattle(x, u);
  1614. </sql-statement>
  1615. -stdin-:<main>: Error: Parse Sql
  1616. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1617. -- although even a stable qual should not be pushed down if it references SRF
  1618. ^
  1619. <sql-statement>
  1620. select * from
  1621. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1622. where tattle(x, u);
  1623. </sql-statement>
  1624. -stdin-:<main>: Error: Parse Sql
  1625. -stdin-:<main>:2:19: Error: Generator functions are not allowed in: SELECT
  1626. (select 9 as x, unnest(array[1,2,3,11,12,13]) as u) ss
  1627. ^
  1628. -stdin-:<main>: Error: Type annotation
  1629. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect
  1630. select * from
  1631. ^
  1632. -stdin-:<main>:1:1: Error: Recursive query does not have the form non-recursive-term UNION [ALL] recursive-term
  1633. select * from
  1634. ^
  1635. <sql-statement>
  1636. drop function tattle(x int, y int);
  1637. </sql-statement>
  1638. -stdin-:<main>: Error: Parse Sql
  1639. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
  1640. drop function tattle(x int, y int);
  1641. ^
  1642. <sql-statement>
  1643. --
  1644. -- Test that LIMIT can be pushed to SORT through a subquery that just projects
  1645. -- columns. We check for that having happened by looking to see if EXPLAIN
  1646. -- ANALYZE shows that a top-N sort was used. We must suppress or filter away
  1647. -- all the non-invariant parts of the EXPLAIN ANALYZE output.
  1648. --
  1649. create table sq_limit (pk int primary key, c1 int, c2 int);
  1650. </sql-statement>
  1651. <sql-statement>
  1652. insert into sq_limit values
  1653. (1, 1, 1),
  1654. (2, 2, 2),
  1655. (3, 3, 3),
  1656. (4, 4, 4),
  1657. (5, 1, 1),
  1658. (6, 2, 2),
  1659. (7, 3, 3),
  1660. (8, 4, 4);
  1661. </sql-statement>
  1662. <sql-statement>
  1663. create function explain_sq_limit() returns setof text language plpgsql as
  1664. $$
  1665. declare ln text;
  1666. begin
  1667. for ln in
  1668. explain (analyze, summary off, timing off, costs off)
  1669. select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3
  1670. loop
  1671. ln := regexp_replace(ln, 'Memory: \S*', 'Memory: xxx');
  1672. return next ln;
  1673. end loop;
  1674. end;
  1675. $$;
  1676. </sql-statement>
  1677. -stdin-:<main>: Error: Parse Sql
  1678. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 261
  1679. create function explain_sq_limit() returns setof text language plpgsql as
  1680. ^
  1681. <sql-statement>
  1682. select * from explain_sq_limit();
  1683. </sql-statement>
  1684. -stdin-:<main>: Error: Type annotation
  1685. -stdin-:<main>:1:1: Error: At function: RemovePrefixMembers, At function: PgSelect, At function: PgSetItem
  1686. select * from explain_sq_limit();
  1687. ^
  1688. -stdin-:<main>:1:15: Error: At function: PgCall
  1689. select * from explain_sq_limit();
  1690. ^
  1691. -stdin-:<main>:1:15: Error: No such proc: explain_sq_limit
  1692. select * from explain_sq_limit();
  1693. ^
  1694. <sql-statement>
  1695. select * from (select pk,c2 from sq_limit order by c1,pk) as x limit 3;
  1696. </sql-statement>
  1697. <sql-statement>
  1698. drop function explain_sq_limit();
  1699. </sql-statement>
  1700. -stdin-:<main>: Error: Parse Sql
  1701. -stdin-:<main>:1:1: Error: DropStmt: alternative is not implemented yet : 386
  1702. drop function explain_sq_limit();
  1703. ^
  1704. <sql-statement>
  1705. drop table sq_limit;
  1706. </sql-statement>
  1707. <sql-statement>
  1708. --
  1709. -- Ensure that backward scan direction isn't propagated into
  1710. -- expression subqueries (bug #15336)
  1711. --
  1712. begin;
  1713. </sql-statement>
  1714. <sql-statement>
  1715. declare c1 scroll cursor for
  1716. select * from generate_series(1,4) i
  1717. where i <> all (values (2),(3));
  1718. </sql-statement>
  1719. -stdin-:<main>: Error: Parse Sql
  1720. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 304
  1721. declare c1 scroll cursor for
  1722. ^
  1723. <sql-statement>
  1724. move forward all in c1;
  1725. </sql-statement>
  1726. -stdin-:<main>: Error: Parse Sql
  1727. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 259
  1728. move forward all in c1;
  1729. ^
  1730. <sql-statement>
  1731. fetch backward all in c1;
  1732. </sql-statement>
  1733. -stdin-:<main>: Error: Parse Sql
  1734. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 259
  1735. fetch backward all in c1;
  1736. ^
  1737. <sql-statement>
  1738. commit;
  1739. </sql-statement>
  1740. <sql-statement>
  1741. --
  1742. -- Tests for CTE inlining behavior
  1743. --
  1744. -- Basic subquery that can be inlined
  1745. explain (verbose, costs off)
  1746. with x as (select * from (select f1 from subselect_tbl) ss)
  1747. select * from x where f1 = 1;
  1748. </sql-statement>
  1749. -stdin-:<main>: Error: Parse Sql
  1750. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1751. --
  1752. ^
  1753. <sql-statement>
  1754. -- Explicitly request materialization
  1755. explain (verbose, costs off)
  1756. with x as materialized (select * from (select f1 from subselect_tbl) ss)
  1757. select * from x where f1 = 1;
  1758. </sql-statement>
  1759. -stdin-:<main>: Error: Parse Sql
  1760. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1761. -- Explicitly request materialization
  1762. ^
  1763. <sql-statement>
  1764. -- Stable functions are safe to inline
  1765. explain (verbose, costs off)
  1766. with x as (select * from (select f1, now() from subselect_tbl) ss)
  1767. select * from x where f1 = 1;
  1768. </sql-statement>
  1769. -stdin-:<main>: Error: Parse Sql
  1770. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1771. -- Stable functions are safe to inline
  1772. ^
  1773. <sql-statement>
  1774. -- Volatile functions prevent inlining
  1775. explain (verbose, costs off)
  1776. with x as (select * from (select f1, random() from subselect_tbl) ss)
  1777. select * from x where f1 = 1;
  1778. </sql-statement>
  1779. -stdin-:<main>: Error: Parse Sql
  1780. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1781. -- Volatile functions prevent inlining
  1782. ^
  1783. <sql-statement>
  1784. -- SELECT FOR UPDATE cannot be inlined
  1785. explain (verbose, costs off)
  1786. with x as (select * from (select f1 from subselect_tbl for update) ss)
  1787. select * from x where f1 = 1;
  1788. </sql-statement>
  1789. -stdin-:<main>: Error: Parse Sql
  1790. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1791. -- SELECT FOR UPDATE cannot be inlined
  1792. ^
  1793. <sql-statement>
  1794. -- Multiply-referenced CTEs are inlined only when requested
  1795. explain (verbose, costs off)
  1796. with x as (select * from (select f1, now() as n from subselect_tbl) ss)
  1797. select * from x, x x2 where x.n = x2.n;
  1798. </sql-statement>
  1799. -stdin-:<main>: Error: Parse Sql
  1800. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1801. -- Multiply-referenced CTEs are inlined only when requested
  1802. ^
  1803. <sql-statement>
  1804. explain (verbose, costs off)
  1805. with x as not materialized (select * from (select f1, now() as n from subselect_tbl) ss)
  1806. select * from x, x x2 where x.n = x2.n;
  1807. </sql-statement>
  1808. -stdin-:<main>: Error: Parse Sql
  1809. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1810. explain (verbose, costs off)
  1811. ^
  1812. <sql-statement>
  1813. -- Multiply-referenced CTEs can't be inlined if they contain outer self-refs
  1814. explain (verbose, costs off)
  1815. with recursive x(a) as
  1816. ((values ('a'), ('b'))
  1817. union all
  1818. (with z as not materialized (select * from x)
  1819. select z.a || z1.a as a from z cross join z as z1
  1820. where length(z.a || z1.a) < 5))
  1821. select * from x;
  1822. </sql-statement>
  1823. -stdin-:<main>: Error: Parse Sql
  1824. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1825. -- Multiply-referenced CTEs can't be inlined if they contain outer self-refs
  1826. ^
  1827. <sql-statement>
  1828. with recursive x(a) as
  1829. ((values ('a'), ('b'))
  1830. union all
  1831. (with z as not materialized (select * from x)
  1832. select z.a || z1.a as a from z cross join z as z1
  1833. where length(z.a || z1.a) < 5))
  1834. select * from x;
  1835. </sql-statement>
  1836. -stdin-:<main>: Fatal: Table metadata loading
  1837. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.z
  1838. <sql-statement>
  1839. explain (verbose, costs off)
  1840. with recursive x(a) as
  1841. ((values ('a'), ('b'))
  1842. union all
  1843. (with z as not materialized (select * from x)
  1844. select z.a || z.a as a from z
  1845. where length(z.a || z.a) < 5))
  1846. select * from x;
  1847. </sql-statement>
  1848. -stdin-:<main>: Error: Parse Sql
  1849. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1850. explain (verbose, costs off)
  1851. ^
  1852. <sql-statement>
  1853. with recursive x(a) as
  1854. ((values ('a'), ('b'))
  1855. union all
  1856. (with z as not materialized (select * from x)
  1857. select z.a || z.a as a from z
  1858. where length(z.a || z.a) < 5))
  1859. select * from x;
  1860. </sql-statement>
  1861. -stdin-:<main>: Fatal: Table metadata loading
  1862. -stdin-:<main>: Fatal: ydb/library/yql/providers/yt/gateway/file/yql_yt_file_services.cpp:44: Table not found: plato.z
  1863. <sql-statement>
  1864. -- Check handling of outer references
  1865. explain (verbose, costs off)
  1866. with x as (select * from int4_tbl)
  1867. select * from (with y as (select * from x) select * from y) ss;
  1868. </sql-statement>
  1869. -stdin-:<main>: Error: Parse Sql
  1870. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1871. -- Check handling of outer references
  1872. ^
  1873. <sql-statement>
  1874. explain (verbose, costs off)
  1875. with x as materialized (select * from int4_tbl)
  1876. select * from (with y as (select * from x) select * from y) ss;
  1877. </sql-statement>
  1878. -stdin-:<main>: Error: Parse Sql
  1879. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1880. explain (verbose, costs off)
  1881. ^
  1882. <sql-statement>
  1883. -- Ensure that we inline the currect CTE when there are
  1884. -- multiple CTEs with the same name
  1885. explain (verbose, costs off)
  1886. with x as (select 1 as y)
  1887. select * from (with x as (select 2 as y) select * from x) ss;
  1888. </sql-statement>
  1889. -stdin-:<main>: Error: Parse Sql
  1890. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1891. -- Ensure that we inline the currect CTE when there are
  1892. ^
  1893. <sql-statement>
  1894. -- Row marks are not pushed into CTEs
  1895. explain (verbose, costs off)
  1896. with x as (select * from subselect_tbl)
  1897. select * from x for update;
  1898. </sql-statement>
  1899. -stdin-:<main>: Error: Parse Sql
  1900. -stdin-:<main>:1:1: Error: RawStmt: alternative is not implemented yet : 276
  1901. -- Row marks are not pushed into CTEs
  1902. ^