optimized_plan_as_json.slt 243 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. # Test requires stable IDs
  10. reset-server
  11. statement ok
  12. CREATE TABLE t (
  13. a int,
  14. b int
  15. )
  16. statement ok
  17. CREATE TABLE u (
  18. c int,
  19. d int
  20. )
  21. statement ok
  22. CREATE TABLE v (
  23. e int,
  24. f int
  25. )
  26. statement ok
  27. CREATE INDEX t_a_idx ON T(a);
  28. statement ok
  29. CREATE VIEW ov AS SELECT * FROM t ORDER BY b asc, a desc LIMIT 5
  30. statement ok
  31. CREATE VIEW iv AS
  32. SELECT * FROM t WHERE a IS NOT NULL
  33. statement ok
  34. CREATE DEFAULT INDEX ON iv
  35. statement ok
  36. CREATE MATERIALIZED VIEW mv AS
  37. SELECT * FROM t WHERE a IS NOT NULL
  38. mode cockroach
  39. # Test constant error.
  40. query T multiline
  41. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  42. SELECT 1 / 0
  43. ----
  44. {
  45. "plans": [
  46. {
  47. "id": "Explained Query (fast path)",
  48. "plan": {
  49. "Constant": [
  50. {
  51. "Err": "DivisionByZero"
  52. },
  53. {
  54. "column_types": [
  55. {
  56. "scalar_type": "Int32",
  57. "nullable": false
  58. }
  59. ],
  60. "keys": []
  61. }
  62. ]
  63. }
  64. }
  65. ],
  66. "sources": []
  67. }
  68. EOF
  69. # Test constant with two elements.
  70. query T multiline
  71. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  72. (SELECT 1, 2) UNION ALL (SELECT 1, 2) UNION ALL (SELECT 3, 4)
  73. ----
  74. {
  75. "plans": [
  76. {
  77. "id": "Explained Query (fast path)",
  78. "plan": {
  79. "Constant": [
  80. {
  81. "Ok": [
  82. [
  83. {
  84. "data": [
  85. 45,
  86. 1,
  87. 45,
  88. 2
  89. ]
  90. },
  91. 2
  92. ],
  93. [
  94. {
  95. "data": [
  96. 45,
  97. 3,
  98. 45,
  99. 4
  100. ]
  101. },
  102. 1
  103. ]
  104. ]
  105. },
  106. {
  107. "column_types": [
  108. {
  109. "scalar_type": "Int32",
  110. "nullable": false
  111. },
  112. {
  113. "scalar_type": "Int32",
  114. "nullable": false
  115. }
  116. ],
  117. "keys": []
  118. }
  119. ]
  120. }
  121. }
  122. ],
  123. "sources": []
  124. }
  125. EOF
  126. # Test basic linear chains (fast path).
  127. query T multiline
  128. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  129. SELECT 1, a + b as c FROM t WHERE a > 0 and b < 0 and a + b > 0
  130. ----
  131. {
  132. "plans": [
  133. {
  134. "id": "Explained Query (fast path)",
  135. "plan": {
  136. "PeekExisting": [
  137. {
  138. "User": 1
  139. },
  140. {
  141. "User": 4
  142. },
  143. null,
  144. {
  145. "mfp": {
  146. "expressions": [
  147. {
  148. "CallBinary": {
  149. "func": "AddInt32",
  150. "expr1": {
  151. "Column": [
  152. 0,
  153. "a"
  154. ]
  155. },
  156. "expr2": {
  157. "Column": [
  158. 1,
  159. "b"
  160. ]
  161. }
  162. }
  163. },
  164. {
  165. "Literal": [
  166. {
  167. "Ok": {
  168. "data": [
  169. 45,
  170. 1
  171. ]
  172. }
  173. },
  174. {
  175. "scalar_type": "Int32",
  176. "nullable": false
  177. }
  178. ]
  179. }
  180. ],
  181. "predicates": [
  182. [
  183. 1,
  184. {
  185. "CallBinary": {
  186. "func": "Gt",
  187. "expr1": {
  188. "Column": [
  189. 0,
  190. "a"
  191. ]
  192. },
  193. "expr2": {
  194. "Literal": [
  195. {
  196. "Ok": {
  197. "data": [
  198. 44
  199. ]
  200. }
  201. },
  202. {
  203. "scalar_type": "Int32",
  204. "nullable": false
  205. }
  206. ]
  207. }
  208. }
  209. }
  210. ],
  211. [
  212. 2,
  213. {
  214. "CallBinary": {
  215. "func": "Lt",
  216. "expr1": {
  217. "Column": [
  218. 1,
  219. "b"
  220. ]
  221. },
  222. "expr2": {
  223. "Literal": [
  224. {
  225. "Ok": {
  226. "data": [
  227. 44
  228. ]
  229. }
  230. },
  231. {
  232. "scalar_type": "Int32",
  233. "nullable": false
  234. }
  235. ]
  236. }
  237. }
  238. }
  239. ],
  240. [
  241. 3,
  242. {
  243. "CallBinary": {
  244. "func": "Gt",
  245. "expr1": {
  246. "Column": [
  247. 2,
  248. null
  249. ]
  250. },
  251. "expr2": {
  252. "Literal": [
  253. {
  254. "Ok": {
  255. "data": [
  256. 44
  257. ]
  258. }
  259. },
  260. {
  261. "scalar_type": "Int32",
  262. "nullable": false
  263. }
  264. ]
  265. }
  266. }
  267. }
  268. ]
  269. ],
  270. "projection": [
  271. 3,
  272. 2
  273. ],
  274. "input_arity": 2
  275. }
  276. }
  277. ]
  278. }
  279. }
  280. ],
  281. "sources": []
  282. }
  283. EOF
  284. # Test basic linear chains (slow path).
  285. query T multiline
  286. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  287. SELECT 1, a + b as c FROM mv WHERE a > 0 and b < 0 and a + b > 0
  288. ----
  289. {
  290. "plans": [
  291. {
  292. "id": "Explained Query",
  293. "plan": {
  294. "Project": {
  295. "input": {
  296. "Filter": {
  297. "input": {
  298. "Map": {
  299. "input": {
  300. "Get": {
  301. "id": {
  302. "Global": {
  303. "User": 8
  304. }
  305. },
  306. "typ": {
  307. "column_types": [
  308. {
  309. "scalar_type": "Int32",
  310. "nullable": false
  311. },
  312. {
  313. "scalar_type": "Int32",
  314. "nullable": true
  315. }
  316. ],
  317. "keys": []
  318. },
  319. "access_strategy": "Persist"
  320. }
  321. },
  322. "scalars": [
  323. {
  324. "CallBinary": {
  325. "func": "AddInt32",
  326. "expr1": {
  327. "Column": [
  328. 0,
  329. "a"
  330. ]
  331. },
  332. "expr2": {
  333. "Column": [
  334. 1,
  335. "b"
  336. ]
  337. }
  338. }
  339. },
  340. {
  341. "Literal": [
  342. {
  343. "Ok": {
  344. "data": [
  345. 45,
  346. 1
  347. ]
  348. }
  349. },
  350. {
  351. "scalar_type": "Int32",
  352. "nullable": false
  353. }
  354. ]
  355. }
  356. ]
  357. }
  358. },
  359. "predicates": [
  360. {
  361. "CallBinary": {
  362. "func": "Lt",
  363. "expr1": {
  364. "Column": [
  365. 1,
  366. "b"
  367. ]
  368. },
  369. "expr2": {
  370. "Literal": [
  371. {
  372. "Ok": {
  373. "data": [
  374. 44
  375. ]
  376. }
  377. },
  378. {
  379. "scalar_type": "Int32",
  380. "nullable": false
  381. }
  382. ]
  383. }
  384. }
  385. },
  386. {
  387. "CallBinary": {
  388. "func": "Gt",
  389. "expr1": {
  390. "Column": [
  391. 0,
  392. "a"
  393. ]
  394. },
  395. "expr2": {
  396. "Literal": [
  397. {
  398. "Ok": {
  399. "data": [
  400. 44
  401. ]
  402. }
  403. },
  404. {
  405. "scalar_type": "Int32",
  406. "nullable": false
  407. }
  408. ]
  409. }
  410. }
  411. },
  412. {
  413. "CallBinary": {
  414. "func": "Gt",
  415. "expr1": {
  416. "Column": [
  417. 2,
  418. null
  419. ]
  420. },
  421. "expr2": {
  422. "Literal": [
  423. {
  424. "Ok": {
  425. "data": [
  426. 44
  427. ]
  428. }
  429. },
  430. {
  431. "scalar_type": "Int32",
  432. "nullable": false
  433. }
  434. ]
  435. }
  436. }
  437. }
  438. ]
  439. }
  440. },
  441. "outputs": [
  442. 3,
  443. 2
  444. ]
  445. }
  446. }
  447. }
  448. ],
  449. "sources": [
  450. {
  451. "id": {
  452. "User": 8
  453. },
  454. "op": {
  455. "expressions": [],
  456. "predicates": [
  457. [
  458. 1,
  459. {
  460. "CallBinary": {
  461. "func": "Gt",
  462. "expr1": {
  463. "Column": [
  464. 0,
  465. "a"
  466. ]
  467. },
  468. "expr2": {
  469. "Literal": [
  470. {
  471. "Ok": {
  472. "data": [
  473. 44
  474. ]
  475. }
  476. },
  477. {
  478. "scalar_type": "Int32",
  479. "nullable": false
  480. }
  481. ]
  482. }
  483. }
  484. }
  485. ],
  486. [
  487. 2,
  488. {
  489. "CallBinary": {
  490. "func": "Lt",
  491. "expr1": {
  492. "Column": [
  493. 1,
  494. "b"
  495. ]
  496. },
  497. "expr2": {
  498. "Literal": [
  499. {
  500. "Ok": {
  501. "data": [
  502. 44
  503. ]
  504. }
  505. },
  506. {
  507. "scalar_type": "Int32",
  508. "nullable": false
  509. }
  510. ]
  511. }
  512. }
  513. }
  514. ],
  515. [
  516. 2,
  517. {
  518. "CallBinary": {
  519. "func": "Gt",
  520. "expr1": {
  521. "CallBinary": {
  522. "func": "AddInt32",
  523. "expr1": {
  524. "Column": [
  525. 0,
  526. "a"
  527. ]
  528. },
  529. "expr2": {
  530. "Column": [
  531. 1,
  532. "b"
  533. ]
  534. }
  535. }
  536. },
  537. "expr2": {
  538. "Literal": [
  539. {
  540. "Ok": {
  541. "data": [
  542. 44
  543. ]
  544. }
  545. },
  546. {
  547. "scalar_type": "Int32",
  548. "nullable": false
  549. }
  550. ]
  551. }
  552. }
  553. }
  554. ]
  555. ],
  556. "projection": [
  557. 0,
  558. 1
  559. ],
  560. "input_arity": 2
  561. }
  562. }
  563. ]
  564. }
  565. EOF
  566. # Test table functions in the select clause (FlatMap).
  567. query T multiline
  568. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  569. SELECT generate_series(a, b) from t
  570. ----
  571. {
  572. "plans": [
  573. {
  574. "id": "Explained Query",
  575. "plan": {
  576. "Project": {
  577. "input": {
  578. "FlatMap": {
  579. "input": {
  580. "Get": {
  581. "id": {
  582. "Global": {
  583. "User": 1
  584. }
  585. },
  586. "typ": {
  587. "column_types": [
  588. {
  589. "scalar_type": "Int32",
  590. "nullable": true
  591. },
  592. {
  593. "scalar_type": "Int32",
  594. "nullable": true
  595. }
  596. ],
  597. "keys": []
  598. },
  599. "access_strategy": {
  600. "Index": [
  601. [
  602. {
  603. "User": 4
  604. },
  605. "FullScan"
  606. ]
  607. ]
  608. }
  609. }
  610. },
  611. "func": "GenerateSeriesInt32",
  612. "exprs": [
  613. {
  614. "Column": [
  615. 0,
  616. "a"
  617. ]
  618. },
  619. {
  620. "Column": [
  621. 1,
  622. "b"
  623. ]
  624. },
  625. {
  626. "Literal": [
  627. {
  628. "Ok": {
  629. "data": [
  630. 45,
  631. 1
  632. ]
  633. }
  634. },
  635. {
  636. "scalar_type": "Int32",
  637. "nullable": false
  638. }
  639. ]
  640. }
  641. ]
  642. }
  643. },
  644. "outputs": [
  645. 2
  646. ]
  647. }
  648. }
  649. }
  650. ],
  651. "sources": []
  652. }
  653. EOF
  654. # Test Threshold, Union, Distinct, Negate.
  655. query T multiline
  656. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  657. SELECT a FROM t EXCEPT SELECT b FROM mv
  658. ----
  659. {
  660. "plans": [
  661. {
  662. "id": "Explained Query",
  663. "plan": {
  664. "Threshold": {
  665. "input": {
  666. "Union": {
  667. "base": {
  668. "Reduce": {
  669. "input": {
  670. "Project": {
  671. "input": {
  672. "Get": {
  673. "id": {
  674. "Global": {
  675. "User": 1
  676. }
  677. },
  678. "typ": {
  679. "column_types": [
  680. {
  681. "scalar_type": "Int32",
  682. "nullable": true
  683. },
  684. {
  685. "scalar_type": "Int32",
  686. "nullable": true
  687. }
  688. ],
  689. "keys": []
  690. },
  691. "access_strategy": {
  692. "Index": [
  693. [
  694. {
  695. "User": 4
  696. },
  697. "FullScan"
  698. ]
  699. ]
  700. }
  701. }
  702. },
  703. "outputs": [
  704. 0
  705. ]
  706. }
  707. },
  708. "group_key": [
  709. {
  710. "Column": [
  711. 0,
  712. null
  713. ]
  714. }
  715. ],
  716. "aggregates": [],
  717. "monotonic": false,
  718. "expected_group_size": null
  719. }
  720. },
  721. "inputs": [
  722. {
  723. "Negate": {
  724. "input": {
  725. "Reduce": {
  726. "input": {
  727. "Project": {
  728. "input": {
  729. "Get": {
  730. "id": {
  731. "Global": {
  732. "User": 8
  733. }
  734. },
  735. "typ": {
  736. "column_types": [
  737. {
  738. "scalar_type": "Int32",
  739. "nullable": false
  740. },
  741. {
  742. "scalar_type": "Int32",
  743. "nullable": true
  744. }
  745. ],
  746. "keys": []
  747. },
  748. "access_strategy": "Persist"
  749. }
  750. },
  751. "outputs": [
  752. 1
  753. ]
  754. }
  755. },
  756. "group_key": [
  757. {
  758. "Column": [
  759. 0,
  760. null
  761. ]
  762. }
  763. ],
  764. "aggregates": [],
  765. "monotonic": false,
  766. "expected_group_size": null
  767. }
  768. }
  769. }
  770. }
  771. ]
  772. }
  773. }
  774. }
  775. }
  776. }
  777. ],
  778. "sources": [
  779. {
  780. "id": {
  781. "User": 8
  782. },
  783. "op": null
  784. }
  785. ]
  786. }
  787. EOF
  788. # Test Threshold, Union, Distinct, Negate.
  789. query T multiline
  790. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  791. SELECT a FROM t EXCEPT ALL SELECT b FROM mv
  792. ----
  793. {
  794. "plans": [
  795. {
  796. "id": "Explained Query",
  797. "plan": {
  798. "Threshold": {
  799. "input": {
  800. "Union": {
  801. "base": {
  802. "Project": {
  803. "input": {
  804. "Get": {
  805. "id": {
  806. "Global": {
  807. "User": 1
  808. }
  809. },
  810. "typ": {
  811. "column_types": [
  812. {
  813. "scalar_type": "Int32",
  814. "nullable": true
  815. },
  816. {
  817. "scalar_type": "Int32",
  818. "nullable": true
  819. }
  820. ],
  821. "keys": []
  822. },
  823. "access_strategy": {
  824. "Index": [
  825. [
  826. {
  827. "User": 4
  828. },
  829. "FullScan"
  830. ]
  831. ]
  832. }
  833. }
  834. },
  835. "outputs": [
  836. 0
  837. ]
  838. }
  839. },
  840. "inputs": [
  841. {
  842. "Negate": {
  843. "input": {
  844. "Project": {
  845. "input": {
  846. "Get": {
  847. "id": {
  848. "Global": {
  849. "User": 8
  850. }
  851. },
  852. "typ": {
  853. "column_types": [
  854. {
  855. "scalar_type": "Int32",
  856. "nullable": false
  857. },
  858. {
  859. "scalar_type": "Int32",
  860. "nullable": true
  861. }
  862. ],
  863. "keys": []
  864. },
  865. "access_strategy": "Persist"
  866. }
  867. },
  868. "outputs": [
  869. 1
  870. ]
  871. }
  872. }
  873. }
  874. }
  875. ]
  876. }
  877. }
  878. }
  879. }
  880. }
  881. ],
  882. "sources": [
  883. {
  884. "id": {
  885. "User": 8
  886. },
  887. "op": null
  888. }
  889. ]
  890. }
  891. EOF
  892. # Test TopK.
  893. query T multiline
  894. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  895. SELECT * FROM ov
  896. ----
  897. {
  898. "plans": [
  899. {
  900. "id": "Explained Query",
  901. "plan": {
  902. "TopK": {
  903. "input": {
  904. "Get": {
  905. "id": {
  906. "Global": {
  907. "User": 1
  908. }
  909. },
  910. "typ": {
  911. "column_types": [
  912. {
  913. "scalar_type": "Int32",
  914. "nullable": true
  915. },
  916. {
  917. "scalar_type": "Int32",
  918. "nullable": true
  919. }
  920. ],
  921. "keys": []
  922. },
  923. "access_strategy": {
  924. "Index": [
  925. [
  926. {
  927. "User": 4
  928. },
  929. "FullScan"
  930. ]
  931. ]
  932. }
  933. }
  934. },
  935. "group_key": [],
  936. "order_key": [
  937. {
  938. "column": 1,
  939. "desc": false,
  940. "nulls_last": true
  941. },
  942. {
  943. "column": 0,
  944. "desc": true,
  945. "nulls_last": false
  946. }
  947. ],
  948. "limit": {
  949. "Literal": [
  950. {
  951. "Ok": {
  952. "data": [
  953. 50,
  954. 5
  955. ]
  956. }
  957. },
  958. {
  959. "scalar_type": "Int64",
  960. "nullable": false
  961. }
  962. ]
  963. },
  964. "offset": 0,
  965. "monotonic": false,
  966. "expected_group_size": null
  967. }
  968. }
  969. }
  970. ],
  971. "sources": []
  972. }
  973. EOF
  974. # Test Finish.
  975. query T multiline
  976. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  977. SELECT * FROM t ORDER BY b asc, a desc LIMIT 5
  978. ----
  979. {
  980. "plans": [
  981. {
  982. "id": "Explained Query (fast path)",
  983. "plan": {
  984. "PeekExisting": [
  985. {
  986. "User": 1
  987. },
  988. {
  989. "User": 4
  990. },
  991. null,
  992. {
  993. "mfp": {
  994. "expressions": [],
  995. "predicates": [],
  996. "projection": [
  997. 0,
  998. 1
  999. ],
  1000. "input_arity": 2
  1001. }
  1002. }
  1003. ]
  1004. }
  1005. }
  1006. ],
  1007. "sources": []
  1008. }
  1009. EOF
  1010. # Test Reduce (global).
  1011. query T multiline
  1012. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  1013. SELECT abs(min(a) - max(a)) FROM t
  1014. ----
  1015. {
  1016. "plans": [
  1017. {
  1018. "id": "Explained Query",
  1019. "plan": {
  1020. "Let": {
  1021. "id": 0,
  1022. "value": {
  1023. "Reduce": {
  1024. "input": {
  1025. "Project": {
  1026. "input": {
  1027. "Get": {
  1028. "id": {
  1029. "Global": {
  1030. "User": 1
  1031. }
  1032. },
  1033. "typ": {
  1034. "column_types": [
  1035. {
  1036. "scalar_type": "Int32",
  1037. "nullable": true
  1038. },
  1039. {
  1040. "scalar_type": "Int32",
  1041. "nullable": true
  1042. }
  1043. ],
  1044. "keys": []
  1045. },
  1046. "access_strategy": {
  1047. "Index": [
  1048. [
  1049. {
  1050. "User": 4
  1051. },
  1052. "FullScan"
  1053. ]
  1054. ]
  1055. }
  1056. }
  1057. },
  1058. "outputs": [
  1059. 0
  1060. ]
  1061. }
  1062. },
  1063. "group_key": [],
  1064. "aggregates": [
  1065. {
  1066. "func": "MinInt32",
  1067. "expr": {
  1068. "Column": [
  1069. 0,
  1070. "a"
  1071. ]
  1072. },
  1073. "distinct": false
  1074. },
  1075. {
  1076. "func": "MaxInt32",
  1077. "expr": {
  1078. "Column": [
  1079. 0,
  1080. "a"
  1081. ]
  1082. },
  1083. "distinct": false
  1084. }
  1085. ],
  1086. "monotonic": false,
  1087. "expected_group_size": null
  1088. }
  1089. },
  1090. "body": {
  1091. "Project": {
  1092. "input": {
  1093. "Map": {
  1094. "input": {
  1095. "Union": {
  1096. "base": {
  1097. "Get": {
  1098. "id": {
  1099. "Local": 0
  1100. },
  1101. "typ": {
  1102. "column_types": [
  1103. {
  1104. "scalar_type": "Int32",
  1105. "nullable": true
  1106. },
  1107. {
  1108. "scalar_type": "Int32",
  1109. "nullable": true
  1110. }
  1111. ],
  1112. "keys": [
  1113. []
  1114. ]
  1115. },
  1116. "access_strategy": "UnknownOrLocal"
  1117. }
  1118. },
  1119. "inputs": [
  1120. {
  1121. "Map": {
  1122. "input": {
  1123. "Union": {
  1124. "base": {
  1125. "Negate": {
  1126. "input": {
  1127. "Project": {
  1128. "input": {
  1129. "Get": {
  1130. "id": {
  1131. "Local": 0
  1132. },
  1133. "typ": {
  1134. "column_types": [
  1135. {
  1136. "scalar_type": "Int32",
  1137. "nullable": true
  1138. },
  1139. {
  1140. "scalar_type": "Int32",
  1141. "nullable": true
  1142. }
  1143. ],
  1144. "keys": [
  1145. []
  1146. ]
  1147. },
  1148. "access_strategy": "UnknownOrLocal"
  1149. }
  1150. },
  1151. "outputs": []
  1152. }
  1153. }
  1154. }
  1155. },
  1156. "inputs": [
  1157. {
  1158. "Constant": {
  1159. "rows": {
  1160. "Ok": [
  1161. [
  1162. {
  1163. "data": []
  1164. },
  1165. 1
  1166. ]
  1167. ]
  1168. },
  1169. "typ": {
  1170. "column_types": [],
  1171. "keys": []
  1172. }
  1173. }
  1174. }
  1175. ]
  1176. }
  1177. },
  1178. "scalars": [
  1179. {
  1180. "Literal": [
  1181. {
  1182. "Ok": {
  1183. "data": [
  1184. 0
  1185. ]
  1186. }
  1187. },
  1188. {
  1189. "scalar_type": "Int32",
  1190. "nullable": true
  1191. }
  1192. ]
  1193. },
  1194. {
  1195. "Literal": [
  1196. {
  1197. "Ok": {
  1198. "data": [
  1199. 0
  1200. ]
  1201. }
  1202. },
  1203. {
  1204. "scalar_type": "Int32",
  1205. "nullable": true
  1206. }
  1207. ]
  1208. }
  1209. ]
  1210. }
  1211. }
  1212. ]
  1213. }
  1214. },
  1215. "scalars": [
  1216. {
  1217. "CallUnary": {
  1218. "func": {
  1219. "AbsInt32": null
  1220. },
  1221. "expr": {
  1222. "CallBinary": {
  1223. "func": "SubInt32",
  1224. "expr1": {
  1225. "Column": [
  1226. 0,
  1227. "?column?"
  1228. ]
  1229. },
  1230. "expr2": {
  1231. "Column": [
  1232. 1,
  1233. "?column?"
  1234. ]
  1235. }
  1236. }
  1237. }
  1238. }
  1239. }
  1240. ]
  1241. }
  1242. },
  1243. "outputs": [
  1244. 2
  1245. ]
  1246. }
  1247. }
  1248. }
  1249. }
  1250. }
  1251. ],
  1252. "sources": []
  1253. }
  1254. EOF
  1255. # Test Reduce (local).
  1256. query T multiline
  1257. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  1258. SELECT abs(min(a) - max(a)) FROM t GROUP BY b
  1259. ----
  1260. {
  1261. "plans": [
  1262. {
  1263. "id": "Explained Query",
  1264. "plan": {
  1265. "Project": {
  1266. "input": {
  1267. "Map": {
  1268. "input": {
  1269. "Reduce": {
  1270. "input": {
  1271. "Get": {
  1272. "id": {
  1273. "Global": {
  1274. "User": 1
  1275. }
  1276. },
  1277. "typ": {
  1278. "column_types": [
  1279. {
  1280. "scalar_type": "Int32",
  1281. "nullable": true
  1282. },
  1283. {
  1284. "scalar_type": "Int32",
  1285. "nullable": true
  1286. }
  1287. ],
  1288. "keys": []
  1289. },
  1290. "access_strategy": {
  1291. "Index": [
  1292. [
  1293. {
  1294. "User": 4
  1295. },
  1296. "FullScan"
  1297. ]
  1298. ]
  1299. }
  1300. }
  1301. },
  1302. "group_key": [
  1303. {
  1304. "Column": [
  1305. 1,
  1306. null
  1307. ]
  1308. }
  1309. ],
  1310. "aggregates": [
  1311. {
  1312. "func": "MinInt32",
  1313. "expr": {
  1314. "Column": [
  1315. 0,
  1316. "a"
  1317. ]
  1318. },
  1319. "distinct": false
  1320. },
  1321. {
  1322. "func": "MaxInt32",
  1323. "expr": {
  1324. "Column": [
  1325. 0,
  1326. "a"
  1327. ]
  1328. },
  1329. "distinct": false
  1330. }
  1331. ],
  1332. "monotonic": false,
  1333. "expected_group_size": null
  1334. }
  1335. },
  1336. "scalars": [
  1337. {
  1338. "CallUnary": {
  1339. "func": {
  1340. "AbsInt32": null
  1341. },
  1342. "expr": {
  1343. "CallBinary": {
  1344. "func": "SubInt32",
  1345. "expr1": {
  1346. "Column": [
  1347. 1,
  1348. "?column?"
  1349. ]
  1350. },
  1351. "expr2": {
  1352. "Column": [
  1353. 2,
  1354. "?column?"
  1355. ]
  1356. }
  1357. }
  1358. }
  1359. }
  1360. }
  1361. ]
  1362. }
  1363. },
  1364. "outputs": [
  1365. 3
  1366. ]
  1367. }
  1368. }
  1369. }
  1370. ],
  1371. "sources": []
  1372. }
  1373. EOF
  1374. # Test EXISTS subqueries.
  1375. query T multiline
  1376. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  1377. SELECT * FROM t WHERE EXISTS(SELECT * FROM mv WHERE t.a < mv.a) AND EXISTS(SELECT * FROM mv WHERE t.b > mv.b)
  1378. ----
  1379. {
  1380. "plans": [
  1381. {
  1382. "id": "Explained Query",
  1383. "plan": {
  1384. "Let": {
  1385. "id": 0,
  1386. "value": {
  1387. "Project": {
  1388. "input": {
  1389. "Join": {
  1390. "inputs": [
  1391. {
  1392. "ArrangeBy": {
  1393. "input": {
  1394. "Get": {
  1395. "id": {
  1396. "Global": {
  1397. "User": 1
  1398. }
  1399. },
  1400. "typ": {
  1401. "column_types": [
  1402. {
  1403. "scalar_type": "Int32",
  1404. "nullable": true
  1405. },
  1406. {
  1407. "scalar_type": "Int32",
  1408. "nullable": true
  1409. }
  1410. ],
  1411. "keys": []
  1412. },
  1413. "access_strategy": {
  1414. "Index": [
  1415. [
  1416. {
  1417. "User": 4
  1418. },
  1419. "DifferentialJoin"
  1420. ]
  1421. ]
  1422. }
  1423. }
  1424. },
  1425. "keys": [
  1426. [
  1427. {
  1428. "Column": [
  1429. 0,
  1430. "a"
  1431. ]
  1432. }
  1433. ]
  1434. ]
  1435. }
  1436. },
  1437. {
  1438. "ArrangeBy": {
  1439. "input": {
  1440. "Reduce": {
  1441. "input": {
  1442. "Project": {
  1443. "input": {
  1444. "Filter": {
  1445. "input": {
  1446. "Join": {
  1447. "inputs": [
  1448. {
  1449. "ArrangeBy": {
  1450. "input": {
  1451. "Reduce": {
  1452. "input": {
  1453. "Project": {
  1454. "input": {
  1455. "Get": {
  1456. "id": {
  1457. "Global": {
  1458. "User": 1
  1459. }
  1460. },
  1461. "typ": {
  1462. "column_types": [
  1463. {
  1464. "scalar_type": "Int32",
  1465. "nullable": true
  1466. },
  1467. {
  1468. "scalar_type": "Int32",
  1469. "nullable": true
  1470. }
  1471. ],
  1472. "keys": []
  1473. },
  1474. "access_strategy": {
  1475. "Index": [
  1476. [
  1477. {
  1478. "User": 4
  1479. },
  1480. "FullScan"
  1481. ]
  1482. ]
  1483. }
  1484. }
  1485. },
  1486. "outputs": [
  1487. 0
  1488. ]
  1489. }
  1490. },
  1491. "group_key": [
  1492. {
  1493. "Column": [
  1494. 0,
  1495. null
  1496. ]
  1497. }
  1498. ],
  1499. "aggregates": [],
  1500. "monotonic": false,
  1501. "expected_group_size": null
  1502. }
  1503. },
  1504. "keys": [
  1505. []
  1506. ]
  1507. }
  1508. },
  1509. {
  1510. "ArrangeBy": {
  1511. "input": {
  1512. "Project": {
  1513. "input": {
  1514. "Get": {
  1515. "id": {
  1516. "Global": {
  1517. "User": 8
  1518. }
  1519. },
  1520. "typ": {
  1521. "column_types": [
  1522. {
  1523. "scalar_type": "Int32",
  1524. "nullable": false
  1525. },
  1526. {
  1527. "scalar_type": "Int32",
  1528. "nullable": true
  1529. }
  1530. ],
  1531. "keys": []
  1532. },
  1533. "access_strategy": "Persist"
  1534. }
  1535. },
  1536. "outputs": [
  1537. 0
  1538. ]
  1539. }
  1540. },
  1541. "keys": [
  1542. []
  1543. ]
  1544. }
  1545. }
  1546. ],
  1547. "equivalences": [],
  1548. "implementation": {
  1549. "Differential": [
  1550. [
  1551. 0,
  1552. [],
  1553. {
  1554. "V1": {
  1555. "unique_key": false,
  1556. "key_length": 0,
  1557. "arranged": false,
  1558. "cardinality": null,
  1559. "filters": {
  1560. "literal_equality": false,
  1561. "like": false,
  1562. "is_null": false,
  1563. "literal_inequality": 0,
  1564. "any_filter": false
  1565. },
  1566. "input": 0
  1567. }
  1568. }
  1569. ],
  1570. [
  1571. [
  1572. 1,
  1573. [],
  1574. {
  1575. "V1": {
  1576. "unique_key": false,
  1577. "key_length": 0,
  1578. "arranged": false,
  1579. "cardinality": null,
  1580. "filters": {
  1581. "literal_equality": false,
  1582. "like": false,
  1583. "is_null": false,
  1584. "literal_inequality": 0,
  1585. "any_filter": false
  1586. },
  1587. "input": 1
  1588. }
  1589. }
  1590. ]
  1591. ]
  1592. ]
  1593. }
  1594. }
  1595. },
  1596. "predicates": [
  1597. {
  1598. "CallBinary": {
  1599. "func": "Lt",
  1600. "expr1": {
  1601. "Column": [
  1602. 0,
  1603. "a"
  1604. ]
  1605. },
  1606. "expr2": {
  1607. "Column": [
  1608. 1,
  1609. "a"
  1610. ]
  1611. }
  1612. }
  1613. }
  1614. ]
  1615. }
  1616. },
  1617. "outputs": [
  1618. 0
  1619. ]
  1620. }
  1621. },
  1622. "group_key": [
  1623. {
  1624. "Column": [
  1625. 0,
  1626. null
  1627. ]
  1628. }
  1629. ],
  1630. "aggregates": [],
  1631. "monotonic": false,
  1632. "expected_group_size": null
  1633. }
  1634. },
  1635. "keys": [
  1636. [
  1637. {
  1638. "Column": [
  1639. 0,
  1640. null
  1641. ]
  1642. }
  1643. ]
  1644. ]
  1645. }
  1646. }
  1647. ],
  1648. "equivalences": [
  1649. [
  1650. {
  1651. "Column": [
  1652. 0,
  1653. null
  1654. ]
  1655. },
  1656. {
  1657. "Column": [
  1658. 2,
  1659. null
  1660. ]
  1661. }
  1662. ]
  1663. ],
  1664. "implementation": {
  1665. "Differential": [
  1666. [
  1667. 1,
  1668. [
  1669. {
  1670. "Column": [
  1671. 0,
  1672. null
  1673. ]
  1674. }
  1675. ],
  1676. {
  1677. "V1": {
  1678. "unique_key": true,
  1679. "key_length": 1,
  1680. "arranged": true,
  1681. "cardinality": null,
  1682. "filters": {
  1683. "literal_equality": false,
  1684. "like": false,
  1685. "is_null": false,
  1686. "literal_inequality": 0,
  1687. "any_filter": false
  1688. },
  1689. "input": 1
  1690. }
  1691. }
  1692. ],
  1693. [
  1694. [
  1695. 0,
  1696. [
  1697. {
  1698. "Column": [
  1699. 0,
  1700. "a"
  1701. ]
  1702. }
  1703. ],
  1704. {
  1705. "V1": {
  1706. "unique_key": false,
  1707. "key_length": 1,
  1708. "arranged": true,
  1709. "cardinality": null,
  1710. "filters": {
  1711. "literal_equality": false,
  1712. "like": false,
  1713. "is_null": false,
  1714. "literal_inequality": 0,
  1715. "any_filter": false
  1716. },
  1717. "input": 0
  1718. }
  1719. }
  1720. ]
  1721. ]
  1722. ]
  1723. }
  1724. }
  1725. },
  1726. "outputs": [
  1727. 0,
  1728. 1
  1729. ]
  1730. }
  1731. },
  1732. "body": {
  1733. "Project": {
  1734. "input": {
  1735. "Join": {
  1736. "inputs": [
  1737. {
  1738. "ArrangeBy": {
  1739. "input": {
  1740. "Get": {
  1741. "id": {
  1742. "Local": 0
  1743. },
  1744. "typ": {
  1745. "column_types": [
  1746. {
  1747. "scalar_type": "Int32",
  1748. "nullable": false
  1749. },
  1750. {
  1751. "scalar_type": "Int32",
  1752. "nullable": true
  1753. }
  1754. ],
  1755. "keys": []
  1756. },
  1757. "access_strategy": "UnknownOrLocal"
  1758. }
  1759. },
  1760. "keys": [
  1761. [
  1762. {
  1763. "Column": [
  1764. 1,
  1765. null
  1766. ]
  1767. }
  1768. ]
  1769. ]
  1770. }
  1771. },
  1772. {
  1773. "ArrangeBy": {
  1774. "input": {
  1775. "Reduce": {
  1776. "input": {
  1777. "Project": {
  1778. "input": {
  1779. "Filter": {
  1780. "input": {
  1781. "Join": {
  1782. "inputs": [
  1783. {
  1784. "ArrangeBy": {
  1785. "input": {
  1786. "Reduce": {
  1787. "input": {
  1788. "Project": {
  1789. "input": {
  1790. "Get": {
  1791. "id": {
  1792. "Local": 0
  1793. },
  1794. "typ": {
  1795. "column_types": [
  1796. {
  1797. "scalar_type": "Int32",
  1798. "nullable": false
  1799. },
  1800. {
  1801. "scalar_type": "Int32",
  1802. "nullable": true
  1803. }
  1804. ],
  1805. "keys": []
  1806. },
  1807. "access_strategy": "UnknownOrLocal"
  1808. }
  1809. },
  1810. "outputs": [
  1811. 1
  1812. ]
  1813. }
  1814. },
  1815. "group_key": [
  1816. {
  1817. "Column": [
  1818. 0,
  1819. null
  1820. ]
  1821. }
  1822. ],
  1823. "aggregates": [],
  1824. "monotonic": false,
  1825. "expected_group_size": null
  1826. }
  1827. },
  1828. "keys": [
  1829. []
  1830. ]
  1831. }
  1832. },
  1833. {
  1834. "ArrangeBy": {
  1835. "input": {
  1836. "Project": {
  1837. "input": {
  1838. "Get": {
  1839. "id": {
  1840. "Global": {
  1841. "User": 8
  1842. }
  1843. },
  1844. "typ": {
  1845. "column_types": [
  1846. {
  1847. "scalar_type": "Int32",
  1848. "nullable": false
  1849. },
  1850. {
  1851. "scalar_type": "Int32",
  1852. "nullable": true
  1853. }
  1854. ],
  1855. "keys": []
  1856. },
  1857. "access_strategy": "Persist"
  1858. }
  1859. },
  1860. "outputs": [
  1861. 1
  1862. ]
  1863. }
  1864. },
  1865. "keys": [
  1866. []
  1867. ]
  1868. }
  1869. }
  1870. ],
  1871. "equivalences": [],
  1872. "implementation": {
  1873. "Differential": [
  1874. [
  1875. 0,
  1876. [],
  1877. {
  1878. "V1": {
  1879. "unique_key": false,
  1880. "key_length": 0,
  1881. "arranged": false,
  1882. "cardinality": null,
  1883. "filters": {
  1884. "literal_equality": false,
  1885. "like": false,
  1886. "is_null": false,
  1887. "literal_inequality": 0,
  1888. "any_filter": false
  1889. },
  1890. "input": 0
  1891. }
  1892. }
  1893. ],
  1894. [
  1895. [
  1896. 1,
  1897. [],
  1898. {
  1899. "V1": {
  1900. "unique_key": false,
  1901. "key_length": 0,
  1902. "arranged": false,
  1903. "cardinality": null,
  1904. "filters": {
  1905. "literal_equality": false,
  1906. "like": false,
  1907. "is_null": false,
  1908. "literal_inequality": 0,
  1909. "any_filter": false
  1910. },
  1911. "input": 1
  1912. }
  1913. }
  1914. ]
  1915. ]
  1916. ]
  1917. }
  1918. }
  1919. },
  1920. "predicates": [
  1921. {
  1922. "CallBinary": {
  1923. "func": "Gt",
  1924. "expr1": {
  1925. "Column": [
  1926. 0,
  1927. "b"
  1928. ]
  1929. },
  1930. "expr2": {
  1931. "Column": [
  1932. 1,
  1933. "b"
  1934. ]
  1935. }
  1936. }
  1937. }
  1938. ]
  1939. }
  1940. },
  1941. "outputs": [
  1942. 0
  1943. ]
  1944. }
  1945. },
  1946. "group_key": [
  1947. {
  1948. "Column": [
  1949. 0,
  1950. null
  1951. ]
  1952. }
  1953. ],
  1954. "aggregates": [],
  1955. "monotonic": false,
  1956. "expected_group_size": null
  1957. }
  1958. },
  1959. "keys": [
  1960. [
  1961. {
  1962. "Column": [
  1963. 0,
  1964. null
  1965. ]
  1966. }
  1967. ]
  1968. ]
  1969. }
  1970. }
  1971. ],
  1972. "equivalences": [
  1973. [
  1974. {
  1975. "Column": [
  1976. 1,
  1977. null
  1978. ]
  1979. },
  1980. {
  1981. "Column": [
  1982. 2,
  1983. null
  1984. ]
  1985. }
  1986. ]
  1987. ],
  1988. "implementation": {
  1989. "Differential": [
  1990. [
  1991. 1,
  1992. [
  1993. {
  1994. "Column": [
  1995. 0,
  1996. null
  1997. ]
  1998. }
  1999. ],
  2000. {
  2001. "V1": {
  2002. "unique_key": true,
  2003. "key_length": 1,
  2004. "arranged": true,
  2005. "cardinality": null,
  2006. "filters": {
  2007. "literal_equality": false,
  2008. "like": false,
  2009. "is_null": false,
  2010. "literal_inequality": 0,
  2011. "any_filter": false
  2012. },
  2013. "input": 1
  2014. }
  2015. }
  2016. ],
  2017. [
  2018. [
  2019. 0,
  2020. [
  2021. {
  2022. "Column": [
  2023. 1,
  2024. null
  2025. ]
  2026. }
  2027. ],
  2028. {
  2029. "V1": {
  2030. "unique_key": false,
  2031. "key_length": 1,
  2032. "arranged": false,
  2033. "cardinality": null,
  2034. "filters": {
  2035. "literal_equality": false,
  2036. "like": false,
  2037. "is_null": false,
  2038. "literal_inequality": 0,
  2039. "any_filter": false
  2040. },
  2041. "input": 0
  2042. }
  2043. }
  2044. ]
  2045. ]
  2046. ]
  2047. }
  2048. }
  2049. },
  2050. "outputs": [
  2051. 0,
  2052. 1
  2053. ]
  2054. }
  2055. }
  2056. }
  2057. }
  2058. }
  2059. ],
  2060. "sources": [
  2061. {
  2062. "id": {
  2063. "User": 8
  2064. },
  2065. "op": null
  2066. }
  2067. ]
  2068. }
  2069. EOF
  2070. # Test SELECT subqueries.
  2071. query T multiline
  2072. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  2073. SELECT (SELECT iv.a FROM iv WHERE iv.b = t.b LIMIT 1), (SELECT mv.a FROM mv WHERE mv.b = t.b LIMIT 1) FROM t
  2074. ----
  2075. {
  2076. "plans": [
  2077. {
  2078. "id": "Explained Query",
  2079. "plan": {
  2080. "Let": {
  2081. "id": 0,
  2082. "value": {
  2083. "Project": {
  2084. "input": {
  2085. "Get": {
  2086. "id": {
  2087. "Global": {
  2088. "User": 1
  2089. }
  2090. },
  2091. "typ": {
  2092. "column_types": [
  2093. {
  2094. "scalar_type": "Int32",
  2095. "nullable": true
  2096. },
  2097. {
  2098. "scalar_type": "Int32",
  2099. "nullable": true
  2100. }
  2101. ],
  2102. "keys": []
  2103. },
  2104. "access_strategy": {
  2105. "Index": [
  2106. [
  2107. {
  2108. "User": 4
  2109. },
  2110. "FullScan"
  2111. ]
  2112. ]
  2113. }
  2114. }
  2115. },
  2116. "outputs": [
  2117. 1
  2118. ]
  2119. }
  2120. },
  2121. "body": {
  2122. "Let": {
  2123. "id": 1,
  2124. "value": {
  2125. "Reduce": {
  2126. "input": {
  2127. "Get": {
  2128. "id": {
  2129. "Local": 0
  2130. },
  2131. "typ": {
  2132. "column_types": [
  2133. {
  2134. "scalar_type": "Int32",
  2135. "nullable": true
  2136. }
  2137. ],
  2138. "keys": []
  2139. },
  2140. "access_strategy": "UnknownOrLocal"
  2141. }
  2142. },
  2143. "group_key": [
  2144. {
  2145. "Column": [
  2146. 0,
  2147. null
  2148. ]
  2149. }
  2150. ],
  2151. "aggregates": [],
  2152. "monotonic": false,
  2153. "expected_group_size": null
  2154. }
  2155. },
  2156. "body": {
  2157. "Let": {
  2158. "id": 2,
  2159. "value": {
  2160. "ArrangeBy": {
  2161. "input": {
  2162. "Get": {
  2163. "id": {
  2164. "Local": 1
  2165. },
  2166. "typ": {
  2167. "column_types": [
  2168. {
  2169. "scalar_type": "Int32",
  2170. "nullable": true
  2171. }
  2172. ],
  2173. "keys": [
  2174. [
  2175. 0
  2176. ]
  2177. ]
  2178. },
  2179. "access_strategy": "UnknownOrLocal"
  2180. }
  2181. },
  2182. "keys": [
  2183. [
  2184. {
  2185. "Column": [
  2186. 0,
  2187. "b"
  2188. ]
  2189. }
  2190. ]
  2191. ]
  2192. }
  2193. },
  2194. "body": {
  2195. "Let": {
  2196. "id": 3,
  2197. "value": {
  2198. "TopK": {
  2199. "input": {
  2200. "Project": {
  2201. "input": {
  2202. "Join": {
  2203. "inputs": [
  2204. {
  2205. "Get": {
  2206. "id": {
  2207. "Local": 2
  2208. },
  2209. "typ": {
  2210. "column_types": [
  2211. {
  2212. "scalar_type": "Int32",
  2213. "nullable": true
  2214. }
  2215. ],
  2216. "keys": [
  2217. [
  2218. 0
  2219. ]
  2220. ]
  2221. },
  2222. "access_strategy": "UnknownOrLocal"
  2223. }
  2224. },
  2225. {
  2226. "ArrangeBy": {
  2227. "input": {
  2228. "Filter": {
  2229. "input": {
  2230. "Get": {
  2231. "id": {
  2232. "Global": {
  2233. "User": 6
  2234. }
  2235. },
  2236. "typ": {
  2237. "column_types": [
  2238. {
  2239. "scalar_type": "Int32",
  2240. "nullable": false
  2241. },
  2242. {
  2243. "scalar_type": "Int32",
  2244. "nullable": true
  2245. }
  2246. ],
  2247. "keys": []
  2248. },
  2249. "access_strategy": {
  2250. "Index": [
  2251. [
  2252. {
  2253. "User": 7
  2254. },
  2255. "FullScan"
  2256. ]
  2257. ]
  2258. }
  2259. }
  2260. },
  2261. "predicates": [
  2262. {
  2263. "CallUnary": {
  2264. "func": {
  2265. "Not": null
  2266. },
  2267. "expr": {
  2268. "CallUnary": {
  2269. "func": {
  2270. "IsNull": null
  2271. },
  2272. "expr": {
  2273. "Column": [
  2274. 1,
  2275. "b"
  2276. ]
  2277. }
  2278. }
  2279. }
  2280. }
  2281. }
  2282. ]
  2283. }
  2284. },
  2285. "keys": [
  2286. [
  2287. {
  2288. "Column": [
  2289. 1,
  2290. "b"
  2291. ]
  2292. }
  2293. ]
  2294. ]
  2295. }
  2296. }
  2297. ],
  2298. "equivalences": [
  2299. [
  2300. {
  2301. "Column": [
  2302. 0,
  2303. "b"
  2304. ]
  2305. },
  2306. {
  2307. "Column": [
  2308. 2,
  2309. "b"
  2310. ]
  2311. }
  2312. ]
  2313. ],
  2314. "implementation": {
  2315. "Differential": [
  2316. [
  2317. 0,
  2318. [
  2319. {
  2320. "Column": [
  2321. 0,
  2322. "b"
  2323. ]
  2324. }
  2325. ],
  2326. {
  2327. "V1": {
  2328. "unique_key": true,
  2329. "key_length": 1,
  2330. "arranged": true,
  2331. "cardinality": null,
  2332. "filters": {
  2333. "literal_equality": false,
  2334. "like": false,
  2335. "is_null": false,
  2336. "literal_inequality": 0,
  2337. "any_filter": false
  2338. },
  2339. "input": 0
  2340. }
  2341. }
  2342. ],
  2343. [
  2344. [
  2345. 1,
  2346. [
  2347. {
  2348. "Column": [
  2349. 1,
  2350. "b"
  2351. ]
  2352. }
  2353. ],
  2354. {
  2355. "V1": {
  2356. "unique_key": false,
  2357. "key_length": 1,
  2358. "arranged": false,
  2359. "cardinality": null,
  2360. "filters": {
  2361. "literal_equality": false,
  2362. "like": false,
  2363. "is_null": false,
  2364. "literal_inequality": 0,
  2365. "any_filter": false
  2366. },
  2367. "input": 1
  2368. }
  2369. }
  2370. ]
  2371. ]
  2372. ]
  2373. }
  2374. }
  2375. },
  2376. "outputs": [
  2377. 0,
  2378. 1
  2379. ]
  2380. }
  2381. },
  2382. "group_key": [
  2383. 0
  2384. ],
  2385. "order_key": [],
  2386. "limit": {
  2387. "Literal": [
  2388. {
  2389. "Ok": {
  2390. "data": [
  2391. 50,
  2392. 1
  2393. ]
  2394. }
  2395. },
  2396. {
  2397. "scalar_type": "Int64",
  2398. "nullable": false
  2399. }
  2400. ]
  2401. },
  2402. "offset": 0,
  2403. "monotonic": false,
  2404. "expected_group_size": null
  2405. }
  2406. },
  2407. "body": {
  2408. "Let": {
  2409. "id": 4,
  2410. "value": {
  2411. "TopK": {
  2412. "input": {
  2413. "Project": {
  2414. "input": {
  2415. "Join": {
  2416. "inputs": [
  2417. {
  2418. "Get": {
  2419. "id": {
  2420. "Local": 2
  2421. },
  2422. "typ": {
  2423. "column_types": [
  2424. {
  2425. "scalar_type": "Int32",
  2426. "nullable": true
  2427. }
  2428. ],
  2429. "keys": [
  2430. [
  2431. 0
  2432. ]
  2433. ]
  2434. },
  2435. "access_strategy": "UnknownOrLocal"
  2436. }
  2437. },
  2438. {
  2439. "ArrangeBy": {
  2440. "input": {
  2441. "Filter": {
  2442. "input": {
  2443. "Get": {
  2444. "id": {
  2445. "Global": {
  2446. "User": 8
  2447. }
  2448. },
  2449. "typ": {
  2450. "column_types": [
  2451. {
  2452. "scalar_type": "Int32",
  2453. "nullable": false
  2454. },
  2455. {
  2456. "scalar_type": "Int32",
  2457. "nullable": true
  2458. }
  2459. ],
  2460. "keys": []
  2461. },
  2462. "access_strategy": "Persist"
  2463. }
  2464. },
  2465. "predicates": [
  2466. {
  2467. "CallUnary": {
  2468. "func": {
  2469. "Not": null
  2470. },
  2471. "expr": {
  2472. "CallUnary": {
  2473. "func": {
  2474. "IsNull": null
  2475. },
  2476. "expr": {
  2477. "Column": [
  2478. 1,
  2479. "b"
  2480. ]
  2481. }
  2482. }
  2483. }
  2484. }
  2485. }
  2486. ]
  2487. }
  2488. },
  2489. "keys": [
  2490. [
  2491. {
  2492. "Column": [
  2493. 1,
  2494. "b"
  2495. ]
  2496. }
  2497. ]
  2498. ]
  2499. }
  2500. }
  2501. ],
  2502. "equivalences": [
  2503. [
  2504. {
  2505. "Column": [
  2506. 0,
  2507. "b"
  2508. ]
  2509. },
  2510. {
  2511. "Column": [
  2512. 2,
  2513. "b"
  2514. ]
  2515. }
  2516. ]
  2517. ],
  2518. "implementation": {
  2519. "Differential": [
  2520. [
  2521. 0,
  2522. [
  2523. {
  2524. "Column": [
  2525. 0,
  2526. "b"
  2527. ]
  2528. }
  2529. ],
  2530. {
  2531. "V1": {
  2532. "unique_key": true,
  2533. "key_length": 1,
  2534. "arranged": true,
  2535. "cardinality": null,
  2536. "filters": {
  2537. "literal_equality": false,
  2538. "like": false,
  2539. "is_null": false,
  2540. "literal_inequality": 0,
  2541. "any_filter": false
  2542. },
  2543. "input": 0
  2544. }
  2545. }
  2546. ],
  2547. [
  2548. [
  2549. 1,
  2550. [
  2551. {
  2552. "Column": [
  2553. 1,
  2554. "b"
  2555. ]
  2556. }
  2557. ],
  2558. {
  2559. "V1": {
  2560. "unique_key": false,
  2561. "key_length": 1,
  2562. "arranged": false,
  2563. "cardinality": null,
  2564. "filters": {
  2565. "literal_equality": false,
  2566. "like": false,
  2567. "is_null": false,
  2568. "literal_inequality": 0,
  2569. "any_filter": false
  2570. },
  2571. "input": 1
  2572. }
  2573. }
  2574. ]
  2575. ]
  2576. ]
  2577. }
  2578. }
  2579. },
  2580. "outputs": [
  2581. 0,
  2582. 1
  2583. ]
  2584. }
  2585. },
  2586. "group_key": [
  2587. 0
  2588. ],
  2589. "order_key": [],
  2590. "limit": {
  2591. "Literal": [
  2592. {
  2593. "Ok": {
  2594. "data": [
  2595. 50,
  2596. 1
  2597. ]
  2598. }
  2599. },
  2600. {
  2601. "scalar_type": "Int64",
  2602. "nullable": false
  2603. }
  2604. ]
  2605. },
  2606. "offset": 0,
  2607. "monotonic": false,
  2608. "expected_group_size": null
  2609. }
  2610. },
  2611. "body": {
  2612. "Project": {
  2613. "input": {
  2614. "Join": {
  2615. "inputs": [
  2616. {
  2617. "ArrangeBy": {
  2618. "input": {
  2619. "Get": {
  2620. "id": {
  2621. "Local": 0
  2622. },
  2623. "typ": {
  2624. "column_types": [
  2625. {
  2626. "scalar_type": "Int32",
  2627. "nullable": true
  2628. }
  2629. ],
  2630. "keys": []
  2631. },
  2632. "access_strategy": "UnknownOrLocal"
  2633. }
  2634. },
  2635. "keys": [
  2636. [
  2637. {
  2638. "Column": [
  2639. 0,
  2640. null
  2641. ]
  2642. }
  2643. ]
  2644. ]
  2645. }
  2646. },
  2647. {
  2648. "ArrangeBy": {
  2649. "input": {
  2650. "Union": {
  2651. "base": {
  2652. "Get": {
  2653. "id": {
  2654. "Local": 3
  2655. },
  2656. "typ": {
  2657. "column_types": [
  2658. {
  2659. "scalar_type": "Int32",
  2660. "nullable": false
  2661. },
  2662. {
  2663. "scalar_type": "Int32",
  2664. "nullable": false
  2665. }
  2666. ],
  2667. "keys": [
  2668. [
  2669. 0
  2670. ]
  2671. ]
  2672. },
  2673. "access_strategy": "UnknownOrLocal"
  2674. }
  2675. },
  2676. "inputs": [
  2677. {
  2678. "Map": {
  2679. "input": {
  2680. "Union": {
  2681. "base": {
  2682. "Negate": {
  2683. "input": {
  2684. "Project": {
  2685. "input": {
  2686. "Get": {
  2687. "id": {
  2688. "Local": 3
  2689. },
  2690. "typ": {
  2691. "column_types": [
  2692. {
  2693. "scalar_type": "Int32",
  2694. "nullable": false
  2695. },
  2696. {
  2697. "scalar_type": "Int32",
  2698. "nullable": false
  2699. }
  2700. ],
  2701. "keys": [
  2702. [
  2703. 0
  2704. ]
  2705. ]
  2706. },
  2707. "access_strategy": "UnknownOrLocal"
  2708. }
  2709. },
  2710. "outputs": [
  2711. 0
  2712. ]
  2713. }
  2714. }
  2715. }
  2716. },
  2717. "inputs": [
  2718. {
  2719. "Get": {
  2720. "id": {
  2721. "Local": 1
  2722. },
  2723. "typ": {
  2724. "column_types": [
  2725. {
  2726. "scalar_type": "Int32",
  2727. "nullable": true
  2728. }
  2729. ],
  2730. "keys": [
  2731. [
  2732. 0
  2733. ]
  2734. ]
  2735. },
  2736. "access_strategy": "UnknownOrLocal"
  2737. }
  2738. }
  2739. ]
  2740. }
  2741. },
  2742. "scalars": [
  2743. {
  2744. "Literal": [
  2745. {
  2746. "Ok": {
  2747. "data": [
  2748. 0
  2749. ]
  2750. }
  2751. },
  2752. {
  2753. "scalar_type": "Int32",
  2754. "nullable": true
  2755. }
  2756. ]
  2757. }
  2758. ]
  2759. }
  2760. }
  2761. ]
  2762. }
  2763. },
  2764. "keys": [
  2765. [
  2766. {
  2767. "Column": [
  2768. 0,
  2769. null
  2770. ]
  2771. }
  2772. ]
  2773. ]
  2774. }
  2775. },
  2776. {
  2777. "ArrangeBy": {
  2778. "input": {
  2779. "Union": {
  2780. "base": {
  2781. "Get": {
  2782. "id": {
  2783. "Local": 4
  2784. },
  2785. "typ": {
  2786. "column_types": [
  2787. {
  2788. "scalar_type": "Int32",
  2789. "nullable": false
  2790. },
  2791. {
  2792. "scalar_type": "Int32",
  2793. "nullable": false
  2794. }
  2795. ],
  2796. "keys": [
  2797. [
  2798. 0
  2799. ]
  2800. ]
  2801. },
  2802. "access_strategy": "UnknownOrLocal"
  2803. }
  2804. },
  2805. "inputs": [
  2806. {
  2807. "Map": {
  2808. "input": {
  2809. "Union": {
  2810. "base": {
  2811. "Negate": {
  2812. "input": {
  2813. "Project": {
  2814. "input": {
  2815. "Get": {
  2816. "id": {
  2817. "Local": 4
  2818. },
  2819. "typ": {
  2820. "column_types": [
  2821. {
  2822. "scalar_type": "Int32",
  2823. "nullable": false
  2824. },
  2825. {
  2826. "scalar_type": "Int32",
  2827. "nullable": false
  2828. }
  2829. ],
  2830. "keys": [
  2831. [
  2832. 0
  2833. ]
  2834. ]
  2835. },
  2836. "access_strategy": "UnknownOrLocal"
  2837. }
  2838. },
  2839. "outputs": [
  2840. 0
  2841. ]
  2842. }
  2843. }
  2844. }
  2845. },
  2846. "inputs": [
  2847. {
  2848. "Get": {
  2849. "id": {
  2850. "Local": 1
  2851. },
  2852. "typ": {
  2853. "column_types": [
  2854. {
  2855. "scalar_type": "Int32",
  2856. "nullable": true
  2857. }
  2858. ],
  2859. "keys": [
  2860. [
  2861. 0
  2862. ]
  2863. ]
  2864. },
  2865. "access_strategy": "UnknownOrLocal"
  2866. }
  2867. }
  2868. ]
  2869. }
  2870. },
  2871. "scalars": [
  2872. {
  2873. "Literal": [
  2874. {
  2875. "Ok": {
  2876. "data": [
  2877. 0
  2878. ]
  2879. }
  2880. },
  2881. {
  2882. "scalar_type": "Int32",
  2883. "nullable": true
  2884. }
  2885. ]
  2886. }
  2887. ]
  2888. }
  2889. }
  2890. ]
  2891. }
  2892. },
  2893. "keys": [
  2894. [
  2895. {
  2896. "Column": [
  2897. 0,
  2898. null
  2899. ]
  2900. }
  2901. ]
  2902. ]
  2903. }
  2904. }
  2905. ],
  2906. "equivalences": [
  2907. [
  2908. {
  2909. "Column": [
  2910. 0,
  2911. null
  2912. ]
  2913. },
  2914. {
  2915. "Column": [
  2916. 1,
  2917. null
  2918. ]
  2919. },
  2920. {
  2921. "Column": [
  2922. 3,
  2923. null
  2924. ]
  2925. }
  2926. ]
  2927. ],
  2928. "implementation": {
  2929. "DeltaQuery": [
  2930. [
  2931. [
  2932. 1,
  2933. [
  2934. {
  2935. "Column": [
  2936. 0,
  2937. null
  2938. ]
  2939. }
  2940. ],
  2941. {
  2942. "V1": {
  2943. "unique_key": true,
  2944. "key_length": 1,
  2945. "arranged": false,
  2946. "cardinality": null,
  2947. "filters": {
  2948. "literal_equality": false,
  2949. "like": false,
  2950. "is_null": false,
  2951. "literal_inequality": 0,
  2952. "any_filter": false
  2953. },
  2954. "input": 1
  2955. }
  2956. }
  2957. ],
  2958. [
  2959. 2,
  2960. [
  2961. {
  2962. "Column": [
  2963. 0,
  2964. null
  2965. ]
  2966. }
  2967. ],
  2968. {
  2969. "V1": {
  2970. "unique_key": true,
  2971. "key_length": 1,
  2972. "arranged": false,
  2973. "cardinality": null,
  2974. "filters": {
  2975. "literal_equality": false,
  2976. "like": false,
  2977. "is_null": false,
  2978. "literal_inequality": 0,
  2979. "any_filter": false
  2980. },
  2981. "input": 2
  2982. }
  2983. }
  2984. ]
  2985. ],
  2986. [
  2987. [
  2988. 2,
  2989. [
  2990. {
  2991. "Column": [
  2992. 0,
  2993. null
  2994. ]
  2995. }
  2996. ],
  2997. {
  2998. "V1": {
  2999. "unique_key": true,
  3000. "key_length": 1,
  3001. "arranged": false,
  3002. "cardinality": null,
  3003. "filters": {
  3004. "literal_equality": false,
  3005. "like": false,
  3006. "is_null": false,
  3007. "literal_inequality": 0,
  3008. "any_filter": false
  3009. },
  3010. "input": 2
  3011. }
  3012. }
  3013. ],
  3014. [
  3015. 0,
  3016. [
  3017. {
  3018. "Column": [
  3019. 0,
  3020. null
  3021. ]
  3022. }
  3023. ],
  3024. {
  3025. "V1": {
  3026. "unique_key": false,
  3027. "key_length": 1,
  3028. "arranged": false,
  3029. "cardinality": null,
  3030. "filters": {
  3031. "literal_equality": false,
  3032. "like": false,
  3033. "is_null": false,
  3034. "literal_inequality": 0,
  3035. "any_filter": false
  3036. },
  3037. "input": 0
  3038. }
  3039. }
  3040. ]
  3041. ],
  3042. [
  3043. [
  3044. 1,
  3045. [
  3046. {
  3047. "Column": [
  3048. 0,
  3049. null
  3050. ]
  3051. }
  3052. ],
  3053. {
  3054. "V1": {
  3055. "unique_key": true,
  3056. "key_length": 1,
  3057. "arranged": false,
  3058. "cardinality": null,
  3059. "filters": {
  3060. "literal_equality": false,
  3061. "like": false,
  3062. "is_null": false,
  3063. "literal_inequality": 0,
  3064. "any_filter": false
  3065. },
  3066. "input": 1
  3067. }
  3068. }
  3069. ],
  3070. [
  3071. 0,
  3072. [
  3073. {
  3074. "Column": [
  3075. 0,
  3076. null
  3077. ]
  3078. }
  3079. ],
  3080. {
  3081. "V1": {
  3082. "unique_key": false,
  3083. "key_length": 1,
  3084. "arranged": false,
  3085. "cardinality": null,
  3086. "filters": {
  3087. "literal_equality": false,
  3088. "like": false,
  3089. "is_null": false,
  3090. "literal_inequality": 0,
  3091. "any_filter": false
  3092. },
  3093. "input": 0
  3094. }
  3095. }
  3096. ]
  3097. ]
  3098. ]
  3099. }
  3100. }
  3101. },
  3102. "outputs": [
  3103. 2,
  3104. 4
  3105. ]
  3106. }
  3107. }
  3108. }
  3109. }
  3110. }
  3111. }
  3112. }
  3113. }
  3114. }
  3115. }
  3116. }
  3117. }
  3118. }
  3119. ],
  3120. "sources": [
  3121. {
  3122. "id": {
  3123. "User": 8
  3124. },
  3125. "op": {
  3126. "expressions": [],
  3127. "predicates": [
  3128. [
  3129. 2,
  3130. {
  3131. "CallUnary": {
  3132. "func": {
  3133. "Not": null
  3134. },
  3135. "expr": {
  3136. "CallUnary": {
  3137. "func": {
  3138. "IsNull": null
  3139. },
  3140. "expr": {
  3141. "Column": [
  3142. 1,
  3143. "b"
  3144. ]
  3145. }
  3146. }
  3147. }
  3148. }
  3149. }
  3150. ]
  3151. ],
  3152. "projection": [
  3153. 0,
  3154. 1
  3155. ],
  3156. "input_arity": 2
  3157. }
  3158. }
  3159. ]
  3160. }
  3161. EOF
  3162. # Test outer joins (ON syntax).
  3163. query T multiline
  3164. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  3165. SELECT t1.a, t2.a
  3166. FROM t as t1
  3167. LEFT JOIN t as t2 ON t1.b = t2.b
  3168. RIGHT JOIN t as t3 ON t2.b = t3.b
  3169. ----
  3170. {
  3171. "plans": [
  3172. {
  3173. "id": "Explained Query",
  3174. "plan": {
  3175. "Let": {
  3176. "id": 0,
  3177. "value": {
  3178. "Filter": {
  3179. "input": {
  3180. "Get": {
  3181. "id": {
  3182. "Global": {
  3183. "User": 1
  3184. }
  3185. },
  3186. "typ": {
  3187. "column_types": [
  3188. {
  3189. "scalar_type": "Int32",
  3190. "nullable": true
  3191. },
  3192. {
  3193. "scalar_type": "Int32",
  3194. "nullable": true
  3195. }
  3196. ],
  3197. "keys": []
  3198. },
  3199. "access_strategy": {
  3200. "Index": [
  3201. [
  3202. {
  3203. "User": 4
  3204. },
  3205. "FullScan"
  3206. ]
  3207. ]
  3208. }
  3209. }
  3210. },
  3211. "predicates": [
  3212. {
  3213. "CallUnary": {
  3214. "func": {
  3215. "Not": null
  3216. },
  3217. "expr": {
  3218. "CallUnary": {
  3219. "func": {
  3220. "IsNull": null
  3221. },
  3222. "expr": {
  3223. "Column": [
  3224. 1,
  3225. "b"
  3226. ]
  3227. }
  3228. }
  3229. }
  3230. }
  3231. }
  3232. ]
  3233. }
  3234. },
  3235. "body": {
  3236. "Let": {
  3237. "id": 1,
  3238. "value": {
  3239. "ArrangeBy": {
  3240. "input": {
  3241. "Get": {
  3242. "id": {
  3243. "Local": 0
  3244. },
  3245. "typ": {
  3246. "column_types": [
  3247. {
  3248. "scalar_type": "Int32",
  3249. "nullable": true
  3250. },
  3251. {
  3252. "scalar_type": "Int32",
  3253. "nullable": false
  3254. }
  3255. ],
  3256. "keys": []
  3257. },
  3258. "access_strategy": "UnknownOrLocal"
  3259. }
  3260. },
  3261. "keys": [
  3262. [
  3263. {
  3264. "Column": [
  3265. 1,
  3266. "b"
  3267. ]
  3268. }
  3269. ]
  3270. ]
  3271. }
  3272. },
  3273. "body": {
  3274. "Let": {
  3275. "id": 2,
  3276. "value": {
  3277. "ArrangeBy": {
  3278. "input": {
  3279. "Project": {
  3280. "input": {
  3281. "Get": {
  3282. "id": {
  3283. "Local": 0
  3284. },
  3285. "typ": {
  3286. "column_types": [
  3287. {
  3288. "scalar_type": "Int32",
  3289. "nullable": true
  3290. },
  3291. {
  3292. "scalar_type": "Int32",
  3293. "nullable": false
  3294. }
  3295. ],
  3296. "keys": []
  3297. },
  3298. "access_strategy": "UnknownOrLocal"
  3299. }
  3300. },
  3301. "outputs": [
  3302. 1
  3303. ]
  3304. }
  3305. },
  3306. "keys": [
  3307. [
  3308. {
  3309. "Column": [
  3310. 0,
  3311. "b"
  3312. ]
  3313. }
  3314. ]
  3315. ]
  3316. }
  3317. },
  3318. "body": {
  3319. "Let": {
  3320. "id": 3,
  3321. "value": {
  3322. "Project": {
  3323. "input": {
  3324. "Join": {
  3325. "inputs": [
  3326. {
  3327. "Get": {
  3328. "id": {
  3329. "Local": 1
  3330. },
  3331. "typ": {
  3332. "column_types": [
  3333. {
  3334. "scalar_type": "Int32",
  3335. "nullable": true
  3336. },
  3337. {
  3338. "scalar_type": "Int32",
  3339. "nullable": false
  3340. }
  3341. ],
  3342. "keys": []
  3343. },
  3344. "access_strategy": "UnknownOrLocal"
  3345. }
  3346. },
  3347. {
  3348. "Get": {
  3349. "id": {
  3350. "Local": 1
  3351. },
  3352. "typ": {
  3353. "column_types": [
  3354. {
  3355. "scalar_type": "Int32",
  3356. "nullable": true
  3357. },
  3358. {
  3359. "scalar_type": "Int32",
  3360. "nullable": false
  3361. }
  3362. ],
  3363. "keys": []
  3364. },
  3365. "access_strategy": "UnknownOrLocal"
  3366. }
  3367. },
  3368. {
  3369. "Get": {
  3370. "id": {
  3371. "Local": 2
  3372. },
  3373. "typ": {
  3374. "column_types": [
  3375. {
  3376. "scalar_type": "Int32",
  3377. "nullable": false
  3378. }
  3379. ],
  3380. "keys": []
  3381. },
  3382. "access_strategy": "UnknownOrLocal"
  3383. }
  3384. }
  3385. ],
  3386. "equivalences": [
  3387. [
  3388. {
  3389. "Column": [
  3390. 1,
  3391. "b"
  3392. ]
  3393. },
  3394. {
  3395. "Column": [
  3396. 3,
  3397. "b"
  3398. ]
  3399. },
  3400. {
  3401. "Column": [
  3402. 4,
  3403. "b"
  3404. ]
  3405. }
  3406. ]
  3407. ],
  3408. "implementation": {
  3409. "DeltaQuery": [
  3410. [
  3411. [
  3412. 1,
  3413. [
  3414. {
  3415. "Column": [
  3416. 1,
  3417. "b"
  3418. ]
  3419. }
  3420. ],
  3421. {
  3422. "V1": {
  3423. "unique_key": false,
  3424. "key_length": 1,
  3425. "arranged": false,
  3426. "cardinality": null,
  3427. "filters": {
  3428. "literal_equality": false,
  3429. "like": false,
  3430. "is_null": false,
  3431. "literal_inequality": 0,
  3432. "any_filter": false
  3433. },
  3434. "input": 1
  3435. }
  3436. }
  3437. ],
  3438. [
  3439. 2,
  3440. [
  3441. {
  3442. "Column": [
  3443. 0,
  3444. "b"
  3445. ]
  3446. }
  3447. ],
  3448. {
  3449. "V1": {
  3450. "unique_key": false,
  3451. "key_length": 1,
  3452. "arranged": false,
  3453. "cardinality": null,
  3454. "filters": {
  3455. "literal_equality": false,
  3456. "like": false,
  3457. "is_null": false,
  3458. "literal_inequality": 0,
  3459. "any_filter": false
  3460. },
  3461. "input": 2
  3462. }
  3463. }
  3464. ]
  3465. ],
  3466. [
  3467. [
  3468. 0,
  3469. [
  3470. {
  3471. "Column": [
  3472. 1,
  3473. "b"
  3474. ]
  3475. }
  3476. ],
  3477. {
  3478. "V1": {
  3479. "unique_key": false,
  3480. "key_length": 1,
  3481. "arranged": false,
  3482. "cardinality": null,
  3483. "filters": {
  3484. "literal_equality": false,
  3485. "like": false,
  3486. "is_null": false,
  3487. "literal_inequality": 0,
  3488. "any_filter": false
  3489. },
  3490. "input": 0
  3491. }
  3492. }
  3493. ],
  3494. [
  3495. 2,
  3496. [
  3497. {
  3498. "Column": [
  3499. 0,
  3500. "b"
  3501. ]
  3502. }
  3503. ],
  3504. {
  3505. "V1": {
  3506. "unique_key": false,
  3507. "key_length": 1,
  3508. "arranged": false,
  3509. "cardinality": null,
  3510. "filters": {
  3511. "literal_equality": false,
  3512. "like": false,
  3513. "is_null": false,
  3514. "literal_inequality": 0,
  3515. "any_filter": false
  3516. },
  3517. "input": 2
  3518. }
  3519. }
  3520. ]
  3521. ],
  3522. [
  3523. [
  3524. 0,
  3525. [
  3526. {
  3527. "Column": [
  3528. 1,
  3529. "b"
  3530. ]
  3531. }
  3532. ],
  3533. {
  3534. "V1": {
  3535. "unique_key": false,
  3536. "key_length": 1,
  3537. "arranged": false,
  3538. "cardinality": null,
  3539. "filters": {
  3540. "literal_equality": false,
  3541. "like": false,
  3542. "is_null": false,
  3543. "literal_inequality": 0,
  3544. "any_filter": false
  3545. },
  3546. "input": 0
  3547. }
  3548. }
  3549. ],
  3550. [
  3551. 1,
  3552. [
  3553. {
  3554. "Column": [
  3555. 1,
  3556. "b"
  3557. ]
  3558. }
  3559. ],
  3560. {
  3561. "V1": {
  3562. "unique_key": false,
  3563. "key_length": 1,
  3564. "arranged": false,
  3565. "cardinality": null,
  3566. "filters": {
  3567. "literal_equality": false,
  3568. "like": false,
  3569. "is_null": false,
  3570. "literal_inequality": 0,
  3571. "any_filter": false
  3572. },
  3573. "input": 1
  3574. }
  3575. }
  3576. ]
  3577. ]
  3578. ]
  3579. }
  3580. }
  3581. },
  3582. "outputs": [
  3583. 0,
  3584. 1,
  3585. 2
  3586. ]
  3587. }
  3588. },
  3589. "body": {
  3590. "Union": {
  3591. "base": {
  3592. "Map": {
  3593. "input": {
  3594. "Union": {
  3595. "base": {
  3596. "Negate": {
  3597. "input": {
  3598. "Project": {
  3599. "input": {
  3600. "Join": {
  3601. "inputs": [
  3602. {
  3603. "Get": {
  3604. "id": {
  3605. "Local": 2
  3606. },
  3607. "typ": {
  3608. "column_types": [
  3609. {
  3610. "scalar_type": "Int32",
  3611. "nullable": false
  3612. }
  3613. ],
  3614. "keys": []
  3615. },
  3616. "access_strategy": "UnknownOrLocal"
  3617. }
  3618. },
  3619. {
  3620. "ArrangeBy": {
  3621. "input": {
  3622. "Reduce": {
  3623. "input": {
  3624. "Project": {
  3625. "input": {
  3626. "Get": {
  3627. "id": {
  3628. "Local": 3
  3629. },
  3630. "typ": {
  3631. "column_types": [
  3632. {
  3633. "scalar_type": "Int32",
  3634. "nullable": true
  3635. },
  3636. {
  3637. "scalar_type": "Int32",
  3638. "nullable": false
  3639. },
  3640. {
  3641. "scalar_type": "Int32",
  3642. "nullable": true
  3643. }
  3644. ],
  3645. "keys": []
  3646. },
  3647. "access_strategy": "UnknownOrLocal"
  3648. }
  3649. },
  3650. "outputs": [
  3651. 1
  3652. ]
  3653. }
  3654. },
  3655. "group_key": [
  3656. {
  3657. "Column": [
  3658. 0,
  3659. null
  3660. ]
  3661. }
  3662. ],
  3663. "aggregates": [],
  3664. "monotonic": false,
  3665. "expected_group_size": null
  3666. }
  3667. },
  3668. "keys": [
  3669. [
  3670. {
  3671. "Column": [
  3672. 0,
  3673. null
  3674. ]
  3675. }
  3676. ]
  3677. ]
  3678. }
  3679. }
  3680. ],
  3681. "equivalences": [
  3682. [
  3683. {
  3684. "Column": [
  3685. 0,
  3686. "b"
  3687. ]
  3688. },
  3689. {
  3690. "Column": [
  3691. 1,
  3692. null
  3693. ]
  3694. }
  3695. ]
  3696. ],
  3697. "implementation": {
  3698. "Differential": [
  3699. [
  3700. 1,
  3701. [
  3702. {
  3703. "Column": [
  3704. 0,
  3705. null
  3706. ]
  3707. }
  3708. ],
  3709. {
  3710. "V1": {
  3711. "unique_key": true,
  3712. "key_length": 1,
  3713. "arranged": true,
  3714. "cardinality": null,
  3715. "filters": {
  3716. "literal_equality": false,
  3717. "like": false,
  3718. "is_null": false,
  3719. "literal_inequality": 0,
  3720. "any_filter": false
  3721. },
  3722. "input": 1
  3723. }
  3724. }
  3725. ],
  3726. [
  3727. [
  3728. 0,
  3729. [
  3730. {
  3731. "Column": [
  3732. 0,
  3733. "b"
  3734. ]
  3735. }
  3736. ],
  3737. {
  3738. "V1": {
  3739. "unique_key": false,
  3740. "key_length": 1,
  3741. "arranged": false,
  3742. "cardinality": null,
  3743. "filters": {
  3744. "literal_equality": false,
  3745. "like": false,
  3746. "is_null": false,
  3747. "literal_inequality": 0,
  3748. "any_filter": false
  3749. },
  3750. "input": 0
  3751. }
  3752. }
  3753. ]
  3754. ]
  3755. ]
  3756. }
  3757. }
  3758. },
  3759. "outputs": []
  3760. }
  3761. }
  3762. }
  3763. },
  3764. "inputs": [
  3765. {
  3766. "Project": {
  3767. "input": {
  3768. "Get": {
  3769. "id": {
  3770. "Global": {
  3771. "User": 1
  3772. }
  3773. },
  3774. "typ": {
  3775. "column_types": [
  3776. {
  3777. "scalar_type": "Int32",
  3778. "nullable": true
  3779. },
  3780. {
  3781. "scalar_type": "Int32",
  3782. "nullable": true
  3783. }
  3784. ],
  3785. "keys": []
  3786. },
  3787. "access_strategy": {
  3788. "Index": [
  3789. [
  3790. {
  3791. "User": 4
  3792. },
  3793. "FullScan"
  3794. ]
  3795. ]
  3796. }
  3797. }
  3798. },
  3799. "outputs": []
  3800. }
  3801. }
  3802. ]
  3803. }
  3804. },
  3805. "scalars": [
  3806. {
  3807. "Literal": [
  3808. {
  3809. "Ok": {
  3810. "data": [
  3811. 0
  3812. ]
  3813. }
  3814. },
  3815. {
  3816. "scalar_type": "Int32",
  3817. "nullable": true
  3818. }
  3819. ]
  3820. },
  3821. {
  3822. "Literal": [
  3823. {
  3824. "Ok": {
  3825. "data": [
  3826. 0
  3827. ]
  3828. }
  3829. },
  3830. {
  3831. "scalar_type": "Int32",
  3832. "nullable": true
  3833. }
  3834. ]
  3835. }
  3836. ]
  3837. }
  3838. },
  3839. "inputs": [
  3840. {
  3841. "Project": {
  3842. "input": {
  3843. "Get": {
  3844. "id": {
  3845. "Local": 3
  3846. },
  3847. "typ": {
  3848. "column_types": [
  3849. {
  3850. "scalar_type": "Int32",
  3851. "nullable": true
  3852. },
  3853. {
  3854. "scalar_type": "Int32",
  3855. "nullable": false
  3856. },
  3857. {
  3858. "scalar_type": "Int32",
  3859. "nullable": true
  3860. }
  3861. ],
  3862. "keys": []
  3863. },
  3864. "access_strategy": "UnknownOrLocal"
  3865. }
  3866. },
  3867. "outputs": [
  3868. 0,
  3869. 2
  3870. ]
  3871. }
  3872. }
  3873. ]
  3874. }
  3875. }
  3876. }
  3877. }
  3878. }
  3879. }
  3880. }
  3881. }
  3882. }
  3883. }
  3884. }
  3885. ],
  3886. "sources": []
  3887. }
  3888. EOF
  3889. # Test multiple CTEs: a case where we cannot pull the let statement up through
  3890. # the join because the local l0 is correlated against the lhs of the enclosing join.
  3891. query T multiline
  3892. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  3893. SELECT
  3894. *
  3895. FROM
  3896. (
  3897. SELECT * FROM t
  3898. ) as r1
  3899. CROSS JOIN LATERAL (
  3900. WITH r2 as (
  3901. SELECT MAX(r1.a * t.a) AS m FROM t
  3902. )
  3903. SELECT * FROM r2 WHERE r2.m != r1.a
  3904. ) as r3
  3905. CROSS JOIN LATERAL (
  3906. WITH r4 as (
  3907. SELECT MAX(r1.a * t.a) AS m FROM t
  3908. )
  3909. SELECT * FROM r4 WHERE r4.m != r1.a OR (r4.m IS NOT NULL AND r1.a IS NULL)
  3910. ) as r5;
  3911. ----
  3912. {
  3913. "plans": [
  3914. {
  3915. "id": "Explained Query",
  3916. "plan": {
  3917. "Let": {
  3918. "id": 0,
  3919. "value": {
  3920. "Project": {
  3921. "input": {
  3922. "Get": {
  3923. "id": {
  3924. "Global": {
  3925. "User": 1
  3926. }
  3927. },
  3928. "typ": {
  3929. "column_types": [
  3930. {
  3931. "scalar_type": "Int32",
  3932. "nullable": true
  3933. },
  3934. {
  3935. "scalar_type": "Int32",
  3936. "nullable": true
  3937. }
  3938. ],
  3939. "keys": []
  3940. },
  3941. "access_strategy": {
  3942. "Index": [
  3943. [
  3944. {
  3945. "User": 4
  3946. },
  3947. "FullScan"
  3948. ]
  3949. ]
  3950. }
  3951. }
  3952. },
  3953. "outputs": [
  3954. 0
  3955. ]
  3956. }
  3957. },
  3958. "body": {
  3959. "Let": {
  3960. "id": 1,
  3961. "value": {
  3962. "ArrangeBy": {
  3963. "input": {
  3964. "Get": {
  3965. "id": {
  3966. "Local": 0
  3967. },
  3968. "typ": {
  3969. "column_types": [
  3970. {
  3971. "scalar_type": "Int32",
  3972. "nullable": true
  3973. }
  3974. ],
  3975. "keys": []
  3976. },
  3977. "access_strategy": "UnknownOrLocal"
  3978. }
  3979. },
  3980. "keys": [
  3981. []
  3982. ]
  3983. }
  3984. },
  3985. "body": {
  3986. "Let": {
  3987. "id": 2,
  3988. "value": {
  3989. "Project": {
  3990. "input": {
  3991. "Filter": {
  3992. "input": {
  3993. "Join": {
  3994. "inputs": [
  3995. {
  3996. "ArrangeBy": {
  3997. "input": {
  3998. "Get": {
  3999. "id": {
  4000. "Global": {
  4001. "User": 1
  4002. }
  4003. },
  4004. "typ": {
  4005. "column_types": [
  4006. {
  4007. "scalar_type": "Int32",
  4008. "nullable": true
  4009. },
  4010. {
  4011. "scalar_type": "Int32",
  4012. "nullable": true
  4013. }
  4014. ],
  4015. "keys": []
  4016. },
  4017. "access_strategy": {
  4018. "Index": [
  4019. [
  4020. {
  4021. "User": 4
  4022. },
  4023. "DifferentialJoin"
  4024. ]
  4025. ]
  4026. }
  4027. }
  4028. },
  4029. "keys": [
  4030. [
  4031. {
  4032. "Column": [
  4033. 0,
  4034. "a"
  4035. ]
  4036. }
  4037. ]
  4038. ]
  4039. }
  4040. },
  4041. {
  4042. "ArrangeBy": {
  4043. "input": {
  4044. "Reduce": {
  4045. "input": {
  4046. "Join": {
  4047. "inputs": [
  4048. {
  4049. "ArrangeBy": {
  4050. "input": {
  4051. "Reduce": {
  4052. "input": {
  4053. "Get": {
  4054. "id": {
  4055. "Local": 0
  4056. },
  4057. "typ": {
  4058. "column_types": [
  4059. {
  4060. "scalar_type": "Int32",
  4061. "nullable": true
  4062. }
  4063. ],
  4064. "keys": []
  4065. },
  4066. "access_strategy": "UnknownOrLocal"
  4067. }
  4068. },
  4069. "group_key": [
  4070. {
  4071. "Column": [
  4072. 0,
  4073. null
  4074. ]
  4075. }
  4076. ],
  4077. "aggregates": [],
  4078. "monotonic": false,
  4079. "expected_group_size": null
  4080. }
  4081. },
  4082. "keys": [
  4083. []
  4084. ]
  4085. }
  4086. },
  4087. {
  4088. "Get": {
  4089. "id": {
  4090. "Local": 1
  4091. },
  4092. "typ": {
  4093. "column_types": [
  4094. {
  4095. "scalar_type": "Int32",
  4096. "nullable": true
  4097. }
  4098. ],
  4099. "keys": []
  4100. },
  4101. "access_strategy": "UnknownOrLocal"
  4102. }
  4103. }
  4104. ],
  4105. "equivalences": [],
  4106. "implementation": {
  4107. "Differential": [
  4108. [
  4109. 0,
  4110. [],
  4111. {
  4112. "V1": {
  4113. "unique_key": false,
  4114. "key_length": 0,
  4115. "arranged": false,
  4116. "cardinality": null,
  4117. "filters": {
  4118. "literal_equality": false,
  4119. "like": false,
  4120. "is_null": false,
  4121. "literal_inequality": 0,
  4122. "any_filter": false
  4123. },
  4124. "input": 0
  4125. }
  4126. }
  4127. ],
  4128. [
  4129. [
  4130. 1,
  4131. [],
  4132. {
  4133. "V1": {
  4134. "unique_key": false,
  4135. "key_length": 0,
  4136. "arranged": false,
  4137. "cardinality": null,
  4138. "filters": {
  4139. "literal_equality": false,
  4140. "like": false,
  4141. "is_null": false,
  4142. "literal_inequality": 0,
  4143. "any_filter": false
  4144. },
  4145. "input": 1
  4146. }
  4147. }
  4148. ]
  4149. ]
  4150. ]
  4151. }
  4152. }
  4153. },
  4154. "group_key": [
  4155. {
  4156. "Column": [
  4157. 0,
  4158. null
  4159. ]
  4160. }
  4161. ],
  4162. "aggregates": [
  4163. {
  4164. "func": "MaxInt32",
  4165. "expr": {
  4166. "CallBinary": {
  4167. "func": "MulInt32",
  4168. "expr1": {
  4169. "Column": [
  4170. 0,
  4171. "a"
  4172. ]
  4173. },
  4174. "expr2": {
  4175. "Column": [
  4176. 1,
  4177. "a"
  4178. ]
  4179. }
  4180. }
  4181. },
  4182. "distinct": false
  4183. }
  4184. ],
  4185. "monotonic": false,
  4186. "expected_group_size": null
  4187. }
  4188. },
  4189. "keys": [
  4190. [
  4191. {
  4192. "Column": [
  4193. 0,
  4194. null
  4195. ]
  4196. }
  4197. ]
  4198. ]
  4199. }
  4200. }
  4201. ],
  4202. "equivalences": [
  4203. [
  4204. {
  4205. "Column": [
  4206. 0,
  4207. null
  4208. ]
  4209. },
  4210. {
  4211. "Column": [
  4212. 2,
  4213. null
  4214. ]
  4215. }
  4216. ]
  4217. ],
  4218. "implementation": {
  4219. "Differential": [
  4220. [
  4221. 1,
  4222. [
  4223. {
  4224. "Column": [
  4225. 0,
  4226. null
  4227. ]
  4228. }
  4229. ],
  4230. {
  4231. "V1": {
  4232. "unique_key": true,
  4233. "key_length": 1,
  4234. "arranged": true,
  4235. "cardinality": null,
  4236. "filters": {
  4237. "literal_equality": false,
  4238. "like": false,
  4239. "is_null": false,
  4240. "literal_inequality": 0,
  4241. "any_filter": true
  4242. },
  4243. "input": 1
  4244. }
  4245. }
  4246. ],
  4247. [
  4248. [
  4249. 0,
  4250. [
  4251. {
  4252. "Column": [
  4253. 0,
  4254. "a"
  4255. ]
  4256. }
  4257. ],
  4258. {
  4259. "V1": {
  4260. "unique_key": false,
  4261. "key_length": 1,
  4262. "arranged": true,
  4263. "cardinality": null,
  4264. "filters": {
  4265. "literal_equality": false,
  4266. "like": false,
  4267. "is_null": false,
  4268. "literal_inequality": 0,
  4269. "any_filter": true
  4270. },
  4271. "input": 0
  4272. }
  4273. }
  4274. ]
  4275. ]
  4276. ]
  4277. }
  4278. }
  4279. },
  4280. "predicates": [
  4281. {
  4282. "CallBinary": {
  4283. "func": "NotEq",
  4284. "expr1": {
  4285. "Column": [
  4286. 0,
  4287. null
  4288. ]
  4289. },
  4290. "expr2": {
  4291. "Column": [
  4292. 3,
  4293. "m"
  4294. ]
  4295. }
  4296. }
  4297. }
  4298. ]
  4299. }
  4300. },
  4301. "outputs": [
  4302. 0,
  4303. 1,
  4304. 3
  4305. ]
  4306. }
  4307. },
  4308. "body": {
  4309. "Project": {
  4310. "input": {
  4311. "Filter": {
  4312. "input": {
  4313. "Join": {
  4314. "inputs": [
  4315. {
  4316. "ArrangeBy": {
  4317. "input": {
  4318. "Get": {
  4319. "id": {
  4320. "Local": 2
  4321. },
  4322. "typ": {
  4323. "column_types": [
  4324. {
  4325. "scalar_type": "Int32",
  4326. "nullable": false
  4327. },
  4328. {
  4329. "scalar_type": "Int32",
  4330. "nullable": true
  4331. },
  4332. {
  4333. "scalar_type": "Int32",
  4334. "nullable": false
  4335. }
  4336. ],
  4337. "keys": []
  4338. },
  4339. "access_strategy": "UnknownOrLocal"
  4340. }
  4341. },
  4342. "keys": [
  4343. [
  4344. {
  4345. "Column": [
  4346. 0,
  4347. null
  4348. ]
  4349. }
  4350. ]
  4351. ]
  4352. }
  4353. },
  4354. {
  4355. "ArrangeBy": {
  4356. "input": {
  4357. "Reduce": {
  4358. "input": {
  4359. "Join": {
  4360. "inputs": [
  4361. {
  4362. "ArrangeBy": {
  4363. "input": {
  4364. "Reduce": {
  4365. "input": {
  4366. "Project": {
  4367. "input": {
  4368. "Get": {
  4369. "id": {
  4370. "Local": 2
  4371. },
  4372. "typ": {
  4373. "column_types": [
  4374. {
  4375. "scalar_type": "Int32",
  4376. "nullable": false
  4377. },
  4378. {
  4379. "scalar_type": "Int32",
  4380. "nullable": true
  4381. },
  4382. {
  4383. "scalar_type": "Int32",
  4384. "nullable": false
  4385. }
  4386. ],
  4387. "keys": []
  4388. },
  4389. "access_strategy": "UnknownOrLocal"
  4390. }
  4391. },
  4392. "outputs": [
  4393. 0
  4394. ]
  4395. }
  4396. },
  4397. "group_key": [
  4398. {
  4399. "Column": [
  4400. 0,
  4401. null
  4402. ]
  4403. }
  4404. ],
  4405. "aggregates": [],
  4406. "monotonic": false,
  4407. "expected_group_size": null
  4408. }
  4409. },
  4410. "keys": [
  4411. []
  4412. ]
  4413. }
  4414. },
  4415. {
  4416. "Get": {
  4417. "id": {
  4418. "Local": 1
  4419. },
  4420. "typ": {
  4421. "column_types": [
  4422. {
  4423. "scalar_type": "Int32",
  4424. "nullable": true
  4425. }
  4426. ],
  4427. "keys": []
  4428. },
  4429. "access_strategy": "UnknownOrLocal"
  4430. }
  4431. }
  4432. ],
  4433. "equivalences": [],
  4434. "implementation": {
  4435. "Differential": [
  4436. [
  4437. 0,
  4438. [],
  4439. {
  4440. "V1": {
  4441. "unique_key": false,
  4442. "key_length": 0,
  4443. "arranged": false,
  4444. "cardinality": null,
  4445. "filters": {
  4446. "literal_equality": false,
  4447. "like": false,
  4448. "is_null": false,
  4449. "literal_inequality": 0,
  4450. "any_filter": false
  4451. },
  4452. "input": 0
  4453. }
  4454. }
  4455. ],
  4456. [
  4457. [
  4458. 1,
  4459. [],
  4460. {
  4461. "V1": {
  4462. "unique_key": false,
  4463. "key_length": 0,
  4464. "arranged": false,
  4465. "cardinality": null,
  4466. "filters": {
  4467. "literal_equality": false,
  4468. "like": false,
  4469. "is_null": false,
  4470. "literal_inequality": 0,
  4471. "any_filter": false
  4472. },
  4473. "input": 1
  4474. }
  4475. }
  4476. ]
  4477. ]
  4478. ]
  4479. }
  4480. }
  4481. },
  4482. "group_key": [
  4483. {
  4484. "Column": [
  4485. 0,
  4486. null
  4487. ]
  4488. }
  4489. ],
  4490. "aggregates": [
  4491. {
  4492. "func": "MaxInt32",
  4493. "expr": {
  4494. "CallBinary": {
  4495. "func": "MulInt32",
  4496. "expr1": {
  4497. "Column": [
  4498. 0,
  4499. "a"
  4500. ]
  4501. },
  4502. "expr2": {
  4503. "Column": [
  4504. 1,
  4505. "a"
  4506. ]
  4507. }
  4508. }
  4509. },
  4510. "distinct": false
  4511. }
  4512. ],
  4513. "monotonic": false,
  4514. "expected_group_size": null
  4515. }
  4516. },
  4517. "keys": [
  4518. [
  4519. {
  4520. "Column": [
  4521. 0,
  4522. null
  4523. ]
  4524. }
  4525. ]
  4526. ]
  4527. }
  4528. }
  4529. ],
  4530. "equivalences": [
  4531. [
  4532. {
  4533. "Column": [
  4534. 0,
  4535. null
  4536. ]
  4537. },
  4538. {
  4539. "Column": [
  4540. 3,
  4541. null
  4542. ]
  4543. }
  4544. ]
  4545. ],
  4546. "implementation": {
  4547. "Differential": [
  4548. [
  4549. 1,
  4550. [
  4551. {
  4552. "Column": [
  4553. 0,
  4554. null
  4555. ]
  4556. }
  4557. ],
  4558. {
  4559. "V1": {
  4560. "unique_key": true,
  4561. "key_length": 1,
  4562. "arranged": true,
  4563. "cardinality": null,
  4564. "filters": {
  4565. "literal_equality": false,
  4566. "like": false,
  4567. "is_null": false,
  4568. "literal_inequality": 0,
  4569. "any_filter": true
  4570. },
  4571. "input": 1
  4572. }
  4573. }
  4574. ],
  4575. [
  4576. [
  4577. 0,
  4578. [
  4579. {
  4580. "Column": [
  4581. 0,
  4582. null
  4583. ]
  4584. }
  4585. ],
  4586. {
  4587. "V1": {
  4588. "unique_key": false,
  4589. "key_length": 1,
  4590. "arranged": false,
  4591. "cardinality": null,
  4592. "filters": {
  4593. "literal_equality": false,
  4594. "like": false,
  4595. "is_null": false,
  4596. "literal_inequality": 0,
  4597. "any_filter": true
  4598. },
  4599. "input": 0
  4600. }
  4601. }
  4602. ]
  4603. ]
  4604. ]
  4605. }
  4606. }
  4607. },
  4608. "predicates": [
  4609. {
  4610. "CallBinary": {
  4611. "func": "NotEq",
  4612. "expr1": {
  4613. "Column": [
  4614. 0,
  4615. null
  4616. ]
  4617. },
  4618. "expr2": {
  4619. "Column": [
  4620. 4,
  4621. "m"
  4622. ]
  4623. }
  4624. }
  4625. }
  4626. ]
  4627. }
  4628. },
  4629. "outputs": [
  4630. 0,
  4631. 1,
  4632. 2,
  4633. 4
  4634. ]
  4635. }
  4636. }
  4637. }
  4638. }
  4639. }
  4640. }
  4641. }
  4642. }
  4643. }
  4644. ],
  4645. "sources": []
  4646. }
  4647. EOF
  4648. # Test cross join.
  4649. query T multiline
  4650. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  4651. SELECT t1.a, t2.a FROM t as t1, t as t2
  4652. ----
  4653. {
  4654. "plans": [
  4655. {
  4656. "id": "Explained Query",
  4657. "plan": {
  4658. "Let": {
  4659. "id": 0,
  4660. "value": {
  4661. "ArrangeBy": {
  4662. "input": {
  4663. "Project": {
  4664. "input": {
  4665. "Get": {
  4666. "id": {
  4667. "Global": {
  4668. "User": 1
  4669. }
  4670. },
  4671. "typ": {
  4672. "column_types": [
  4673. {
  4674. "scalar_type": "Int32",
  4675. "nullable": true
  4676. },
  4677. {
  4678. "scalar_type": "Int32",
  4679. "nullable": true
  4680. }
  4681. ],
  4682. "keys": []
  4683. },
  4684. "access_strategy": {
  4685. "Index": [
  4686. [
  4687. {
  4688. "User": 4
  4689. },
  4690. "FullScan"
  4691. ]
  4692. ]
  4693. }
  4694. }
  4695. },
  4696. "outputs": [
  4697. 0
  4698. ]
  4699. }
  4700. },
  4701. "keys": [
  4702. []
  4703. ]
  4704. }
  4705. },
  4706. "body": {
  4707. "Join": {
  4708. "inputs": [
  4709. {
  4710. "Get": {
  4711. "id": {
  4712. "Local": 0
  4713. },
  4714. "typ": {
  4715. "column_types": [
  4716. {
  4717. "scalar_type": "Int32",
  4718. "nullable": true
  4719. }
  4720. ],
  4721. "keys": []
  4722. },
  4723. "access_strategy": "UnknownOrLocal"
  4724. }
  4725. },
  4726. {
  4727. "Get": {
  4728. "id": {
  4729. "Local": 0
  4730. },
  4731. "typ": {
  4732. "column_types": [
  4733. {
  4734. "scalar_type": "Int32",
  4735. "nullable": true
  4736. }
  4737. ],
  4738. "keys": []
  4739. },
  4740. "access_strategy": "UnknownOrLocal"
  4741. }
  4742. }
  4743. ],
  4744. "equivalences": [],
  4745. "implementation": {
  4746. "Differential": [
  4747. [
  4748. 0,
  4749. [],
  4750. {
  4751. "V1": {
  4752. "unique_key": false,
  4753. "key_length": 0,
  4754. "arranged": false,
  4755. "cardinality": null,
  4756. "filters": {
  4757. "literal_equality": false,
  4758. "like": false,
  4759. "is_null": false,
  4760. "literal_inequality": 0,
  4761. "any_filter": false
  4762. },
  4763. "input": 0
  4764. }
  4765. }
  4766. ],
  4767. [
  4768. [
  4769. 1,
  4770. [],
  4771. {
  4772. "V1": {
  4773. "unique_key": false,
  4774. "key_length": 0,
  4775. "arranged": false,
  4776. "cardinality": null,
  4777. "filters": {
  4778. "literal_equality": false,
  4779. "like": false,
  4780. "is_null": false,
  4781. "literal_inequality": 0,
  4782. "any_filter": false
  4783. },
  4784. "input": 1
  4785. }
  4786. }
  4787. ]
  4788. ]
  4789. ]
  4790. }
  4791. }
  4792. }
  4793. }
  4794. }
  4795. }
  4796. ],
  4797. "sources": []
  4798. }
  4799. EOF
  4800. # Test cyclic join.
  4801. query T multiline
  4802. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  4803. SELECT t1.a, t2.a
  4804. FROM
  4805. t as t1,
  4806. t as t2,
  4807. t as t3
  4808. WHERE t1.b = t2.b AND t2.b = t3.b
  4809. ----
  4810. {
  4811. "plans": [
  4812. {
  4813. "id": "Explained Query",
  4814. "plan": {
  4815. "Let": {
  4816. "id": 0,
  4817. "value": {
  4818. "Filter": {
  4819. "input": {
  4820. "Get": {
  4821. "id": {
  4822. "Global": {
  4823. "User": 1
  4824. }
  4825. },
  4826. "typ": {
  4827. "column_types": [
  4828. {
  4829. "scalar_type": "Int32",
  4830. "nullable": true
  4831. },
  4832. {
  4833. "scalar_type": "Int32",
  4834. "nullable": true
  4835. }
  4836. ],
  4837. "keys": []
  4838. },
  4839. "access_strategy": {
  4840. "Index": [
  4841. [
  4842. {
  4843. "User": 4
  4844. },
  4845. "FullScan"
  4846. ]
  4847. ]
  4848. }
  4849. }
  4850. },
  4851. "predicates": [
  4852. {
  4853. "CallUnary": {
  4854. "func": {
  4855. "Not": null
  4856. },
  4857. "expr": {
  4858. "CallUnary": {
  4859. "func": {
  4860. "IsNull": null
  4861. },
  4862. "expr": {
  4863. "Column": [
  4864. 1,
  4865. "b"
  4866. ]
  4867. }
  4868. }
  4869. }
  4870. }
  4871. }
  4872. ]
  4873. }
  4874. },
  4875. "body": {
  4876. "Let": {
  4877. "id": 1,
  4878. "value": {
  4879. "ArrangeBy": {
  4880. "input": {
  4881. "Get": {
  4882. "id": {
  4883. "Local": 0
  4884. },
  4885. "typ": {
  4886. "column_types": [
  4887. {
  4888. "scalar_type": "Int32",
  4889. "nullable": true
  4890. },
  4891. {
  4892. "scalar_type": "Int32",
  4893. "nullable": false
  4894. }
  4895. ],
  4896. "keys": []
  4897. },
  4898. "access_strategy": "UnknownOrLocal"
  4899. }
  4900. },
  4901. "keys": [
  4902. [
  4903. {
  4904. "Column": [
  4905. 1,
  4906. "b"
  4907. ]
  4908. }
  4909. ]
  4910. ]
  4911. }
  4912. },
  4913. "body": {
  4914. "Project": {
  4915. "input": {
  4916. "Join": {
  4917. "inputs": [
  4918. {
  4919. "Get": {
  4920. "id": {
  4921. "Local": 1
  4922. },
  4923. "typ": {
  4924. "column_types": [
  4925. {
  4926. "scalar_type": "Int32",
  4927. "nullable": true
  4928. },
  4929. {
  4930. "scalar_type": "Int32",
  4931. "nullable": false
  4932. }
  4933. ],
  4934. "keys": []
  4935. },
  4936. "access_strategy": "UnknownOrLocal"
  4937. }
  4938. },
  4939. {
  4940. "Get": {
  4941. "id": {
  4942. "Local": 1
  4943. },
  4944. "typ": {
  4945. "column_types": [
  4946. {
  4947. "scalar_type": "Int32",
  4948. "nullable": true
  4949. },
  4950. {
  4951. "scalar_type": "Int32",
  4952. "nullable": false
  4953. }
  4954. ],
  4955. "keys": []
  4956. },
  4957. "access_strategy": "UnknownOrLocal"
  4958. }
  4959. },
  4960. {
  4961. "ArrangeBy": {
  4962. "input": {
  4963. "Project": {
  4964. "input": {
  4965. "Get": {
  4966. "id": {
  4967. "Local": 0
  4968. },
  4969. "typ": {
  4970. "column_types": [
  4971. {
  4972. "scalar_type": "Int32",
  4973. "nullable": true
  4974. },
  4975. {
  4976. "scalar_type": "Int32",
  4977. "nullable": false
  4978. }
  4979. ],
  4980. "keys": []
  4981. },
  4982. "access_strategy": "UnknownOrLocal"
  4983. }
  4984. },
  4985. "outputs": [
  4986. 1
  4987. ]
  4988. }
  4989. },
  4990. "keys": [
  4991. [
  4992. {
  4993. "Column": [
  4994. 0,
  4995. "b"
  4996. ]
  4997. }
  4998. ]
  4999. ]
  5000. }
  5001. }
  5002. ],
  5003. "equivalences": [
  5004. [
  5005. {
  5006. "Column": [
  5007. 1,
  5008. "b"
  5009. ]
  5010. },
  5011. {
  5012. "Column": [
  5013. 3,
  5014. "b"
  5015. ]
  5016. },
  5017. {
  5018. "Column": [
  5019. 4,
  5020. "b"
  5021. ]
  5022. }
  5023. ]
  5024. ],
  5025. "implementation": {
  5026. "DeltaQuery": [
  5027. [
  5028. [
  5029. 1,
  5030. [
  5031. {
  5032. "Column": [
  5033. 1,
  5034. "b"
  5035. ]
  5036. }
  5037. ],
  5038. {
  5039. "V1": {
  5040. "unique_key": false,
  5041. "key_length": 1,
  5042. "arranged": false,
  5043. "cardinality": null,
  5044. "filters": {
  5045. "literal_equality": false,
  5046. "like": false,
  5047. "is_null": false,
  5048. "literal_inequality": 0,
  5049. "any_filter": false
  5050. },
  5051. "input": 1
  5052. }
  5053. }
  5054. ],
  5055. [
  5056. 2,
  5057. [
  5058. {
  5059. "Column": [
  5060. 0,
  5061. "b"
  5062. ]
  5063. }
  5064. ],
  5065. {
  5066. "V1": {
  5067. "unique_key": false,
  5068. "key_length": 1,
  5069. "arranged": false,
  5070. "cardinality": null,
  5071. "filters": {
  5072. "literal_equality": false,
  5073. "like": false,
  5074. "is_null": false,
  5075. "literal_inequality": 0,
  5076. "any_filter": false
  5077. },
  5078. "input": 2
  5079. }
  5080. }
  5081. ]
  5082. ],
  5083. [
  5084. [
  5085. 0,
  5086. [
  5087. {
  5088. "Column": [
  5089. 1,
  5090. "b"
  5091. ]
  5092. }
  5093. ],
  5094. {
  5095. "V1": {
  5096. "unique_key": false,
  5097. "key_length": 1,
  5098. "arranged": false,
  5099. "cardinality": null,
  5100. "filters": {
  5101. "literal_equality": false,
  5102. "like": false,
  5103. "is_null": false,
  5104. "literal_inequality": 0,
  5105. "any_filter": false
  5106. },
  5107. "input": 0
  5108. }
  5109. }
  5110. ],
  5111. [
  5112. 2,
  5113. [
  5114. {
  5115. "Column": [
  5116. 0,
  5117. "b"
  5118. ]
  5119. }
  5120. ],
  5121. {
  5122. "V1": {
  5123. "unique_key": false,
  5124. "key_length": 1,
  5125. "arranged": false,
  5126. "cardinality": null,
  5127. "filters": {
  5128. "literal_equality": false,
  5129. "like": false,
  5130. "is_null": false,
  5131. "literal_inequality": 0,
  5132. "any_filter": false
  5133. },
  5134. "input": 2
  5135. }
  5136. }
  5137. ]
  5138. ],
  5139. [
  5140. [
  5141. 0,
  5142. [
  5143. {
  5144. "Column": [
  5145. 1,
  5146. "b"
  5147. ]
  5148. }
  5149. ],
  5150. {
  5151. "V1": {
  5152. "unique_key": false,
  5153. "key_length": 1,
  5154. "arranged": false,
  5155. "cardinality": null,
  5156. "filters": {
  5157. "literal_equality": false,
  5158. "like": false,
  5159. "is_null": false,
  5160. "literal_inequality": 0,
  5161. "any_filter": false
  5162. },
  5163. "input": 0
  5164. }
  5165. }
  5166. ],
  5167. [
  5168. 1,
  5169. [
  5170. {
  5171. "Column": [
  5172. 1,
  5173. "b"
  5174. ]
  5175. }
  5176. ],
  5177. {
  5178. "V1": {
  5179. "unique_key": false,
  5180. "key_length": 1,
  5181. "arranged": false,
  5182. "cardinality": null,
  5183. "filters": {
  5184. "literal_equality": false,
  5185. "like": false,
  5186. "is_null": false,
  5187. "literal_inequality": 0,
  5188. "any_filter": false
  5189. },
  5190. "input": 1
  5191. }
  5192. }
  5193. ]
  5194. ]
  5195. ]
  5196. }
  5197. }
  5198. },
  5199. "outputs": [
  5200. 0,
  5201. 2
  5202. ]
  5203. }
  5204. }
  5205. }
  5206. }
  5207. }
  5208. }
  5209. }
  5210. ],
  5211. "sources": []
  5212. }
  5213. EOF
  5214. # Create indexes required for differential join tests
  5215. statement ok
  5216. CREATE INDEX u_c_idx ON U(c);
  5217. statement ok
  5218. CREATE INDEX u_d_idx ON U(d);
  5219. statement ok
  5220. CREATE INDEX v_e_idx ON V(e);
  5221. # Test a differential join.
  5222. query T multiline
  5223. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  5224. SELECT a, b, c, d, e, f
  5225. FROM t, u, v
  5226. WHERE a = c and d = e and b = f
  5227. ----
  5228. {
  5229. "plans": [
  5230. {
  5231. "id": "Explained Query",
  5232. "plan": {
  5233. "Project": {
  5234. "input": {
  5235. "Join": {
  5236. "inputs": [
  5237. {
  5238. "ArrangeBy": {
  5239. "input": {
  5240. "Filter": {
  5241. "input": {
  5242. "Get": {
  5243. "id": {
  5244. "Global": {
  5245. "User": 1
  5246. }
  5247. },
  5248. "typ": {
  5249. "column_types": [
  5250. {
  5251. "scalar_type": "Int32",
  5252. "nullable": true
  5253. },
  5254. {
  5255. "scalar_type": "Int32",
  5256. "nullable": true
  5257. }
  5258. ],
  5259. "keys": []
  5260. },
  5261. "access_strategy": {
  5262. "Index": [
  5263. [
  5264. {
  5265. "User": 4
  5266. },
  5267. "FullScan"
  5268. ]
  5269. ]
  5270. }
  5271. }
  5272. },
  5273. "predicates": [
  5274. {
  5275. "CallUnary": {
  5276. "func": {
  5277. "Not": null
  5278. },
  5279. "expr": {
  5280. "CallUnary": {
  5281. "func": {
  5282. "IsNull": null
  5283. },
  5284. "expr": {
  5285. "Column": [
  5286. 0,
  5287. "a"
  5288. ]
  5289. }
  5290. }
  5291. }
  5292. }
  5293. },
  5294. {
  5295. "CallUnary": {
  5296. "func": {
  5297. "Not": null
  5298. },
  5299. "expr": {
  5300. "CallUnary": {
  5301. "func": {
  5302. "IsNull": null
  5303. },
  5304. "expr": {
  5305. "Column": [
  5306. 1,
  5307. "b"
  5308. ]
  5309. }
  5310. }
  5311. }
  5312. }
  5313. }
  5314. ]
  5315. }
  5316. },
  5317. "keys": [
  5318. [
  5319. {
  5320. "Column": [
  5321. 0,
  5322. "a"
  5323. ]
  5324. }
  5325. ],
  5326. [
  5327. {
  5328. "Column": [
  5329. 0,
  5330. "a"
  5331. ]
  5332. },
  5333. {
  5334. "Column": [
  5335. 1,
  5336. "b"
  5337. ]
  5338. }
  5339. ]
  5340. ]
  5341. }
  5342. },
  5343. {
  5344. "ArrangeBy": {
  5345. "input": {
  5346. "Get": {
  5347. "id": {
  5348. "Global": {
  5349. "User": 2
  5350. }
  5351. },
  5352. "typ": {
  5353. "column_types": [
  5354. {
  5355. "scalar_type": "Int32",
  5356. "nullable": true
  5357. },
  5358. {
  5359. "scalar_type": "Int32",
  5360. "nullable": true
  5361. }
  5362. ],
  5363. "keys": []
  5364. },
  5365. "access_strategy": {
  5366. "Index": [
  5367. [
  5368. {
  5369. "User": 9
  5370. },
  5371. {
  5372. "DeltaJoin": "Lookup"
  5373. }
  5374. ],
  5375. [
  5376. {
  5377. "User": 10
  5378. },
  5379. {
  5380. "DeltaJoin": "Lookup"
  5381. }
  5382. ]
  5383. ]
  5384. }
  5385. }
  5386. },
  5387. "keys": [
  5388. [
  5389. {
  5390. "Column": [
  5391. 0,
  5392. "c"
  5393. ]
  5394. }
  5395. ],
  5396. [
  5397. {
  5398. "Column": [
  5399. 1,
  5400. "d"
  5401. ]
  5402. }
  5403. ]
  5404. ]
  5405. }
  5406. },
  5407. {
  5408. "ArrangeBy": {
  5409. "input": {
  5410. "Filter": {
  5411. "input": {
  5412. "Get": {
  5413. "id": {
  5414. "Global": {
  5415. "User": 3
  5416. }
  5417. },
  5418. "typ": {
  5419. "column_types": [
  5420. {
  5421. "scalar_type": "Int32",
  5422. "nullable": true
  5423. },
  5424. {
  5425. "scalar_type": "Int32",
  5426. "nullable": true
  5427. }
  5428. ],
  5429. "keys": []
  5430. },
  5431. "access_strategy": {
  5432. "Index": [
  5433. [
  5434. {
  5435. "User": 11
  5436. },
  5437. "FullScan"
  5438. ]
  5439. ]
  5440. }
  5441. }
  5442. },
  5443. "predicates": [
  5444. {
  5445. "CallUnary": {
  5446. "func": {
  5447. "Not": null
  5448. },
  5449. "expr": {
  5450. "CallUnary": {
  5451. "func": {
  5452. "IsNull": null
  5453. },
  5454. "expr": {
  5455. "Column": [
  5456. 0,
  5457. "e"
  5458. ]
  5459. }
  5460. }
  5461. }
  5462. }
  5463. },
  5464. {
  5465. "CallUnary": {
  5466. "func": {
  5467. "Not": null
  5468. },
  5469. "expr": {
  5470. "CallUnary": {
  5471. "func": {
  5472. "IsNull": null
  5473. },
  5474. "expr": {
  5475. "Column": [
  5476. 1,
  5477. "f"
  5478. ]
  5479. }
  5480. }
  5481. }
  5482. }
  5483. }
  5484. ]
  5485. }
  5486. },
  5487. "keys": [
  5488. [
  5489. {
  5490. "Column": [
  5491. 0,
  5492. "e"
  5493. ]
  5494. },
  5495. {
  5496. "Column": [
  5497. 1,
  5498. "f"
  5499. ]
  5500. }
  5501. ]
  5502. ]
  5503. }
  5504. }
  5505. ],
  5506. "equivalences": [
  5507. [
  5508. {
  5509. "Column": [
  5510. 0,
  5511. "a"
  5512. ]
  5513. },
  5514. {
  5515. "Column": [
  5516. 2,
  5517. "c"
  5518. ]
  5519. }
  5520. ],
  5521. [
  5522. {
  5523. "Column": [
  5524. 1,
  5525. "b"
  5526. ]
  5527. },
  5528. {
  5529. "Column": [
  5530. 5,
  5531. "f"
  5532. ]
  5533. }
  5534. ],
  5535. [
  5536. {
  5537. "Column": [
  5538. 3,
  5539. "d"
  5540. ]
  5541. },
  5542. {
  5543. "Column": [
  5544. 4,
  5545. "e"
  5546. ]
  5547. }
  5548. ]
  5549. ],
  5550. "implementation": {
  5551. "DeltaQuery": [
  5552. [
  5553. [
  5554. 1,
  5555. [
  5556. {
  5557. "Column": [
  5558. 0,
  5559. "c"
  5560. ]
  5561. }
  5562. ],
  5563. {
  5564. "V1": {
  5565. "unique_key": false,
  5566. "key_length": 1,
  5567. "arranged": true,
  5568. "cardinality": null,
  5569. "filters": {
  5570. "literal_equality": false,
  5571. "like": false,
  5572. "is_null": false,
  5573. "literal_inequality": 0,
  5574. "any_filter": false
  5575. },
  5576. "input": 1
  5577. }
  5578. }
  5579. ],
  5580. [
  5581. 2,
  5582. [
  5583. {
  5584. "Column": [
  5585. 0,
  5586. "e"
  5587. ]
  5588. },
  5589. {
  5590. "Column": [
  5591. 1,
  5592. "f"
  5593. ]
  5594. }
  5595. ],
  5596. {
  5597. "V1": {
  5598. "unique_key": false,
  5599. "key_length": 2,
  5600. "arranged": false,
  5601. "cardinality": null,
  5602. "filters": {
  5603. "literal_equality": false,
  5604. "like": false,
  5605. "is_null": false,
  5606. "literal_inequality": 0,
  5607. "any_filter": false
  5608. },
  5609. "input": 2
  5610. }
  5611. }
  5612. ]
  5613. ],
  5614. [
  5615. [
  5616. 0,
  5617. [
  5618. {
  5619. "Column": [
  5620. 0,
  5621. "a"
  5622. ]
  5623. }
  5624. ],
  5625. {
  5626. "V1": {
  5627. "unique_key": false,
  5628. "key_length": 1,
  5629. "arranged": true,
  5630. "cardinality": null,
  5631. "filters": {
  5632. "literal_equality": false,
  5633. "like": false,
  5634. "is_null": false,
  5635. "literal_inequality": 0,
  5636. "any_filter": false
  5637. },
  5638. "input": 0
  5639. }
  5640. }
  5641. ],
  5642. [
  5643. 2,
  5644. [
  5645. {
  5646. "Column": [
  5647. 0,
  5648. "e"
  5649. ]
  5650. },
  5651. {
  5652. "Column": [
  5653. 1,
  5654. "f"
  5655. ]
  5656. }
  5657. ],
  5658. {
  5659. "V1": {
  5660. "unique_key": false,
  5661. "key_length": 2,
  5662. "arranged": false,
  5663. "cardinality": null,
  5664. "filters": {
  5665. "literal_equality": false,
  5666. "like": false,
  5667. "is_null": false,
  5668. "literal_inequality": 0,
  5669. "any_filter": false
  5670. },
  5671. "input": 2
  5672. }
  5673. }
  5674. ]
  5675. ],
  5676. [
  5677. [
  5678. 1,
  5679. [
  5680. {
  5681. "Column": [
  5682. 1,
  5683. "d"
  5684. ]
  5685. }
  5686. ],
  5687. {
  5688. "V1": {
  5689. "unique_key": false,
  5690. "key_length": 1,
  5691. "arranged": true,
  5692. "cardinality": null,
  5693. "filters": {
  5694. "literal_equality": false,
  5695. "like": false,
  5696. "is_null": false,
  5697. "literal_inequality": 0,
  5698. "any_filter": false
  5699. },
  5700. "input": 1
  5701. }
  5702. }
  5703. ],
  5704. [
  5705. 0,
  5706. [
  5707. {
  5708. "Column": [
  5709. 0,
  5710. "a"
  5711. ]
  5712. },
  5713. {
  5714. "Column": [
  5715. 1,
  5716. "b"
  5717. ]
  5718. }
  5719. ],
  5720. {
  5721. "V1": {
  5722. "unique_key": false,
  5723. "key_length": 2,
  5724. "arranged": false,
  5725. "cardinality": null,
  5726. "filters": {
  5727. "literal_equality": false,
  5728. "like": false,
  5729. "is_null": false,
  5730. "literal_inequality": 0,
  5731. "any_filter": false
  5732. },
  5733. "input": 0
  5734. }
  5735. }
  5736. ]
  5737. ]
  5738. ]
  5739. }
  5740. }
  5741. },
  5742. "outputs": [
  5743. 0,
  5744. 1,
  5745. 0,
  5746. 3,
  5747. 3,
  5748. 1
  5749. ]
  5750. }
  5751. }
  5752. }
  5753. ],
  5754. "sources": []
  5755. }
  5756. EOF
  5757. # Create indexes required for delta join tests
  5758. statement ok
  5759. CREATE INDEX t_b_idx ON T(b);
  5760. # Test a delta join WITH.
  5761. query T multiline
  5762. EXPLAIN OPTIMIZED PLAN WITH(raw) AS JSON FOR
  5763. SELECT a, b, c, d, e, f
  5764. FROM t, u, v
  5765. WHERE b = c and d = e
  5766. ----
  5767. {
  5768. "plans": [
  5769. {
  5770. "id": "Explained Query",
  5771. "plan": {
  5772. "Project": {
  5773. "input": {
  5774. "Filter": {
  5775. "input": {
  5776. "Join": {
  5777. "inputs": [
  5778. {
  5779. "ArrangeBy": {
  5780. "input": {
  5781. "Get": {
  5782. "id": {
  5783. "Global": {
  5784. "User": 1
  5785. }
  5786. },
  5787. "typ": {
  5788. "column_types": [
  5789. {
  5790. "scalar_type": "Int32",
  5791. "nullable": true
  5792. },
  5793. {
  5794. "scalar_type": "Int32",
  5795. "nullable": true
  5796. }
  5797. ],
  5798. "keys": []
  5799. },
  5800. "access_strategy": {
  5801. "Index": [
  5802. [
  5803. {
  5804. "User": 12
  5805. },
  5806. {
  5807. "DeltaJoin": "FirstInputFullScan"
  5808. }
  5809. ]
  5810. ]
  5811. }
  5812. }
  5813. },
  5814. "keys": [
  5815. [
  5816. {
  5817. "Column": [
  5818. 1,
  5819. "b"
  5820. ]
  5821. }
  5822. ]
  5823. ]
  5824. }
  5825. },
  5826. {
  5827. "ArrangeBy": {
  5828. "input": {
  5829. "Get": {
  5830. "id": {
  5831. "Global": {
  5832. "User": 2
  5833. }
  5834. },
  5835. "typ": {
  5836. "column_types": [
  5837. {
  5838. "scalar_type": "Int32",
  5839. "nullable": true
  5840. },
  5841. {
  5842. "scalar_type": "Int32",
  5843. "nullable": true
  5844. }
  5845. ],
  5846. "keys": []
  5847. },
  5848. "access_strategy": {
  5849. "Index": [
  5850. [
  5851. {
  5852. "User": 9
  5853. },
  5854. {
  5855. "DeltaJoin": "Lookup"
  5856. }
  5857. ],
  5858. [
  5859. {
  5860. "User": 10
  5861. },
  5862. {
  5863. "DeltaJoin": "Lookup"
  5864. }
  5865. ]
  5866. ]
  5867. }
  5868. }
  5869. },
  5870. "keys": [
  5871. [
  5872. {
  5873. "Column": [
  5874. 0,
  5875. "c"
  5876. ]
  5877. }
  5878. ],
  5879. [
  5880. {
  5881. "Column": [
  5882. 1,
  5883. "d"
  5884. ]
  5885. }
  5886. ]
  5887. ]
  5888. }
  5889. },
  5890. {
  5891. "ArrangeBy": {
  5892. "input": {
  5893. "Get": {
  5894. "id": {
  5895. "Global": {
  5896. "User": 3
  5897. }
  5898. },
  5899. "typ": {
  5900. "column_types": [
  5901. {
  5902. "scalar_type": "Int32",
  5903. "nullable": true
  5904. },
  5905. {
  5906. "scalar_type": "Int32",
  5907. "nullable": true
  5908. }
  5909. ],
  5910. "keys": []
  5911. },
  5912. "access_strategy": {
  5913. "Index": [
  5914. [
  5915. {
  5916. "User": 11
  5917. },
  5918. {
  5919. "DeltaJoin": "Lookup"
  5920. }
  5921. ]
  5922. ]
  5923. }
  5924. }
  5925. },
  5926. "keys": [
  5927. [
  5928. {
  5929. "Column": [
  5930. 0,
  5931. "e"
  5932. ]
  5933. }
  5934. ]
  5935. ]
  5936. }
  5937. }
  5938. ],
  5939. "equivalences": [
  5940. [
  5941. {
  5942. "Column": [
  5943. 1,
  5944. "b"
  5945. ]
  5946. },
  5947. {
  5948. "Column": [
  5949. 2,
  5950. "c"
  5951. ]
  5952. }
  5953. ],
  5954. [
  5955. {
  5956. "Column": [
  5957. 3,
  5958. "d"
  5959. ]
  5960. },
  5961. {
  5962. "Column": [
  5963. 4,
  5964. "e"
  5965. ]
  5966. }
  5967. ]
  5968. ],
  5969. "implementation": {
  5970. "DeltaQuery": [
  5971. [
  5972. [
  5973. 1,
  5974. [
  5975. {
  5976. "Column": [
  5977. 0,
  5978. "c"
  5979. ]
  5980. }
  5981. ],
  5982. {
  5983. "V1": {
  5984. "unique_key": false,
  5985. "key_length": 1,
  5986. "arranged": true,
  5987. "cardinality": null,
  5988. "filters": {
  5989. "literal_equality": false,
  5990. "like": false,
  5991. "is_null": false,
  5992. "literal_inequality": 0,
  5993. "any_filter": false
  5994. },
  5995. "input": 1
  5996. }
  5997. }
  5998. ],
  5999. [
  6000. 2,
  6001. [
  6002. {
  6003. "Column": [
  6004. 0,
  6005. "e"
  6006. ]
  6007. }
  6008. ],
  6009. {
  6010. "V1": {
  6011. "unique_key": false,
  6012. "key_length": 1,
  6013. "arranged": true,
  6014. "cardinality": null,
  6015. "filters": {
  6016. "literal_equality": false,
  6017. "like": false,
  6018. "is_null": false,
  6019. "literal_inequality": 0,
  6020. "any_filter": false
  6021. },
  6022. "input": 2
  6023. }
  6024. }
  6025. ]
  6026. ],
  6027. [
  6028. [
  6029. 0,
  6030. [
  6031. {
  6032. "Column": [
  6033. 1,
  6034. "b"
  6035. ]
  6036. }
  6037. ],
  6038. {
  6039. "V1": {
  6040. "unique_key": false,
  6041. "key_length": 1,
  6042. "arranged": true,
  6043. "cardinality": null,
  6044. "filters": {
  6045. "literal_equality": false,
  6046. "like": false,
  6047. "is_null": false,
  6048. "literal_inequality": 0,
  6049. "any_filter": false
  6050. },
  6051. "input": 0
  6052. }
  6053. }
  6054. ],
  6055. [
  6056. 2,
  6057. [
  6058. {
  6059. "Column": [
  6060. 0,
  6061. "e"
  6062. ]
  6063. }
  6064. ],
  6065. {
  6066. "V1": {
  6067. "unique_key": false,
  6068. "key_length": 1,
  6069. "arranged": true,
  6070. "cardinality": null,
  6071. "filters": {
  6072. "literal_equality": false,
  6073. "like": false,
  6074. "is_null": false,
  6075. "literal_inequality": 0,
  6076. "any_filter": false
  6077. },
  6078. "input": 2
  6079. }
  6080. }
  6081. ]
  6082. ],
  6083. [
  6084. [
  6085. 1,
  6086. [
  6087. {
  6088. "Column": [
  6089. 1,
  6090. "d"
  6091. ]
  6092. }
  6093. ],
  6094. {
  6095. "V1": {
  6096. "unique_key": false,
  6097. "key_length": 1,
  6098. "arranged": true,
  6099. "cardinality": null,
  6100. "filters": {
  6101. "literal_equality": false,
  6102. "like": false,
  6103. "is_null": false,
  6104. "literal_inequality": 0,
  6105. "any_filter": false
  6106. },
  6107. "input": 1
  6108. }
  6109. }
  6110. ],
  6111. [
  6112. 0,
  6113. [
  6114. {
  6115. "Column": [
  6116. 1,
  6117. "b"
  6118. ]
  6119. }
  6120. ],
  6121. {
  6122. "V1": {
  6123. "unique_key": false,
  6124. "key_length": 1,
  6125. "arranged": true,
  6126. "cardinality": null,
  6127. "filters": {
  6128. "literal_equality": false,
  6129. "like": false,
  6130. "is_null": false,
  6131. "literal_inequality": 0,
  6132. "any_filter": false
  6133. },
  6134. "input": 0
  6135. }
  6136. }
  6137. ]
  6138. ]
  6139. ]
  6140. }
  6141. }
  6142. },
  6143. "predicates": [
  6144. {
  6145. "CallUnary": {
  6146. "func": {
  6147. "Not": null
  6148. },
  6149. "expr": {
  6150. "CallUnary": {
  6151. "func": {
  6152. "IsNull": null
  6153. },
  6154. "expr": {
  6155. "Column": [
  6156. 1,
  6157. "b"
  6158. ]
  6159. }
  6160. }
  6161. }
  6162. }
  6163. },
  6164. {
  6165. "CallUnary": {
  6166. "func": {
  6167. "Not": null
  6168. },
  6169. "expr": {
  6170. "CallUnary": {
  6171. "func": {
  6172. "IsNull": null
  6173. },
  6174. "expr": {
  6175. "Column": [
  6176. 3,
  6177. "d"
  6178. ]
  6179. }
  6180. }
  6181. }
  6182. }
  6183. }
  6184. ]
  6185. }
  6186. },
  6187. "outputs": [
  6188. 0,
  6189. 1,
  6190. 1,
  6191. 3,
  6192. 3,
  6193. 5
  6194. ]
  6195. }
  6196. }
  6197. }
  6198. ],
  6199. "sources": []
  6200. }
  6201. EOF
  6202. statement ok
  6203. CREATE TABLE t2(s string, like_pat string, regex_pat string);
  6204. statement ok
  6205. INSERT INTO t2 VALUES ('abc', 'a%', 'a.*'), ('ABC', 'a%', 'a.*'), ('ccc', 'a%', 'a.*');
  6206. # Our Regex wrapper struct's serde is currently not serializing the Regex itself, but all info should be visible in
  6207. # the other fields.
  6208. query T multiline
  6209. EXPLAIN OPTIMIZED PLAN AS JSON FOR
  6210. SELECT s FROM t2 WHERE s ~ 'a.*';
  6211. ----
  6212. {
  6213. "plans": [
  6214. {
  6215. "id": "Explained Query",
  6216. "plan": {
  6217. "Project": {
  6218. "input": {
  6219. "Filter": {
  6220. "input": {
  6221. "Get": {
  6222. "id": {
  6223. "Global": {
  6224. "User": 13
  6225. }
  6226. },
  6227. "typ": {
  6228. "column_types": [
  6229. {
  6230. "scalar_type": "String",
  6231. "nullable": true
  6232. },
  6233. {
  6234. "scalar_type": "String",
  6235. "nullable": true
  6236. },
  6237. {
  6238. "scalar_type": "String",
  6239. "nullable": true
  6240. }
  6241. ],
  6242. "keys": []
  6243. },
  6244. "access_strategy": "Persist"
  6245. }
  6246. },
  6247. "predicates": [
  6248. {
  6249. "CallUnary": {
  6250. "func": {
  6251. "IsRegexpMatch": {
  6252. "pattern": "a.*",
  6253. "case_insensitive": false,
  6254. "dot_matches_new_line": true
  6255. }
  6256. },
  6257. "expr": {
  6258. "Column": [
  6259. 0,
  6260. "s"
  6261. ]
  6262. }
  6263. }
  6264. }
  6265. ]
  6266. }
  6267. },
  6268. "outputs": [
  6269. 0
  6270. ]
  6271. }
  6272. }
  6273. }
  6274. ],
  6275. "sources": [
  6276. {
  6277. "id": {
  6278. "User": 13
  6279. },
  6280. "op": {
  6281. "expressions": [],
  6282. "predicates": [
  6283. [
  6284. 1,
  6285. {
  6286. "CallUnary": {
  6287. "func": {
  6288. "IsRegexpMatch": {
  6289. "pattern": "a.*",
  6290. "case_insensitive": false,
  6291. "dot_matches_new_line": true
  6292. }
  6293. },
  6294. "expr": {
  6295. "Column": [
  6296. 0,
  6297. "s"
  6298. ]
  6299. }
  6300. }
  6301. }
  6302. ]
  6303. ],
  6304. "projection": [
  6305. 0,
  6306. 1,
  6307. 2
  6308. ],
  6309. "input_arity": 3
  6310. }
  6311. }
  6312. ]
  6313. }
  6314. EOF