spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From marmb...@apache.org
Subject [01/13] spark git commit: [SPARK-1442] [SQL] Window Function Support for Spark SQL
Date Wed, 06 May 2015 17:43:53 GMT
Repository: spark
Updated Branches:
  refs/heads/branch-1.4 7212897dc -> b521a3b03


http://git-wip-us.apache.org/repos/asf/spark/blob/b521a3b0/sql/hive/src/test/resources/golden/windowing_windowspec.q (deterministic)-8-45a1d7c2aba45d761e19ff4dfdf5463e
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/resources/golden/windowing_windowspec.q (deterministic)-8-45a1d7c2aba45d761e19ff4dfdf5463e b/sql/hive/src/test/resources/golden/windowing_windowspec.q (deterministic)-8-45a1d7c2aba45d761e19ff4dfdf5463e
new file mode 100644
index 0000000..84b934f
--- /dev/null
+++ b/sql/hive/src/test/resources/golden/windowing_windowspec.q (deterministic)-8-45a1d7c2aba45d761e19ff4dfdf5463e	
@@ -0,0 +1,1049 @@
+	65560	20.0
+	65718	20.0
+	65740	20.0
+alice allen	65662	20.0
+alice allen	65720	20.0
+alice allen	65758	20.0
+alice brown	65696	20.0
+alice carson	65559	20.0
+alice davidson	65547	20.0
+alice falkner	65669	20.0
+alice garcia	65613	20.0
+alice hernandez	65737	20.0
+alice hernandez	65784	20.0
+alice johnson	65739	20.0
+alice king	65660	20.0
+alice king	65734	20.0
+alice king	65738	20.0
+alice laertes	65669	20.0
+alice laertes	65671	20.0
+alice miller	65590	20.0
+alice nixon	65586	20.0
+alice nixon	65595	20.0
+alice nixon	65604	20.0
+alice ovid	65737	20.0
+alice polk	65548	20.0
+alice quirinius	65636	20.0
+alice quirinius	65728	20.0
+alice robinson	65606	20.0
+alice robinson	65789	20.0
+alice steinbeck	65578	20.0
+alice steinbeck	65673	20.0
+alice steinbeck	65786	20.0
+alice underhill	65750	20.0
+alice van buren	65562	20.0
+alice xylophone	65578	20.0
+alice xylophone	65585	20.0
+alice xylophone	65599	20.0
+alice zipper	65553	20.0
+alice zipper	65662	20.0
+alice zipper	65766	20.0
+bob brown	65584	20.0
+bob brown	65777	20.0
+bob brown	65783	20.0
+bob carson	65713	20.0
+bob davidson	65664	20.0
+bob davidson	65693	20.0
+bob davidson	65768	20.0
+bob ellison	65591	20.0
+bob ellison	65624	20.0
+bob ellison	65721	20.0
+bob ellison	65760	20.0
+bob falkner	65789	20.0
+bob garcia	65585	20.0
+bob garcia	65598	20.0
+bob garcia	65673	20.0
+bob garcia	65754	20.0
+bob garcia	65782	20.0
+bob hernandez	65557	20.0
+bob ichabod	65549	20.0
+bob king	65715	20.0
+bob king	65757	20.0
+bob king	65783	20.0
+bob laertes	65602	20.0
+bob laertes	65663	20.0
+bob miller	65608	20.0
+bob ovid	65564	20.0
+bob ovid	65619	20.0
+bob ovid	65686	20.0
+bob ovid	65726	20.0
+bob polk	65594	20.0
+bob quirinius	65700	20.0
+bob steinbeck	65637	20.0
+bob van buren	65778	20.0
+bob white	65543	20.0
+bob white	65605	20.0
+bob xylophone	65574	20.0
+bob xylophone	65666	20.0
+bob young	65556	20.0
+bob zipper	65559	20.0
+bob zipper	65633	20.0
+bob zipper	65739	20.0
+calvin allen	65669	20.0
+calvin brown	65537	20.0
+calvin brown	65580	20.0
+calvin brown	65677	20.0
+calvin carson	65637	20.0
+calvin davidson	65541	20.0
+calvin davidson	65564	20.0
+calvin ellison	65667	20.0
+calvin falkner	65573	20.0
+calvin falkner	65596	20.0
+calvin falkner	65738	20.0
+calvin falkner	65762	20.0
+calvin falkner	65778	20.0
+calvin falkner	65784	20.0
+calvin garcia	65664	20.0
+calvin hernandez	65578	20.0
+calvin johnson	65731	20.0
+calvin laertes	65570	20.0
+calvin laertes	65684	20.0
+calvin nixon	65654	20.0
+calvin nixon	65724	20.0
+calvin nixon	65749	20.0
+calvin ovid	65554	20.0
+calvin ovid	65643	20.0
+calvin ovid	65663	20.0
+calvin ovid	65715	20.0
+calvin polk	65731	20.0
+calvin quirinius	65741	20.0
+calvin quirinius	65769	20.0
+calvin robinson	65581	20.0
+calvin steinbeck	65680	20.0
+calvin steinbeck	65762	20.0
+calvin steinbeck	65779	20.0
+calvin thompson	65560	20.0
+calvin thompson	65640	20.0
+calvin underhill	65732	20.0
+calvin van buren	65552	20.0
+calvin van buren	65771	20.0
+calvin white	65553	20.0
+calvin white	65561	20.0
+calvin xylophone	65575	20.0
+calvin xylophone	65596	20.0
+calvin xylophone	65713	20.0
+calvin young	65574	20.0
+calvin young	65746	20.0
+calvin zipper	65669	20.0
+calvin zipper	65739	20.0
+david allen	65588	20.0
+david allen	65617	20.0
+david brown	65637	20.0
+david brown	65760	20.0
+david davidson	65559	20.0
+david davidson	65756	20.0
+david davidson	65778	20.0
+david davidson	65779	20.0
+david ellison	65634	20.0
+david ellison	65724	20.0
+david ellison	65724	20.0
+david hernandez	65763	20.0
+david ichabod	65699	20.0
+david ichabod	65715	20.0
+david laertes	65762	20.0
+david nixon	65536	20.0
+david ovid	65623	20.0
+david ovid	65628	20.0
+david quirinius	65697	20.0
+david quirinius	65759	20.0
+david quirinius	65779	20.0
+david robinson	65762	20.0
+david robinson	65775	20.0
+david thompson	65550	20.0
+david underhill	65602	20.0
+david underhill	65662	20.0
+david underhill	65751	20.0
+david van buren	65625	20.0
+david van buren	65634	20.0
+david white	65678	20.0
+david xylophone	65537	20.0
+david xylophone	65670	20.0
+david xylophone	65764	20.0
+david young	65551	20.0
+david young	65694	20.0
+ethan allen	65747	20.0
+ethan brown	65539	20.0
+ethan brown	65617	20.0
+ethan brown	65685	20.0
+ethan brown	65685	20.0
+ethan brown	65722	20.0
+ethan brown	65733	20.0
+ethan carson	65742	20.0
+ethan ellison	65714	20.0
+ethan ellison	65732	20.0
+ethan falkner	65577	20.0
+ethan falkner	65614	20.0
+ethan garcia	65736	20.0
+ethan hernandez	65618	20.0
+ethan johnson	65536	20.0
+ethan king	65614	20.0
+ethan laertes	65562	20.0
+ethan laertes	65597	20.0
+ethan laertes	65628	20.0
+ethan laertes	65643	20.0
+ethan laertes	65680	20.0
+ethan laertes	65745	20.0
+ethan laertes	65760	20.0
+ethan miller	65712	20.0
+ethan nixon	65766	20.0
+ethan ovid	65697	20.0
+ethan polk	65589	20.0
+ethan polk	65615	20.0
+ethan polk	65622	20.0
+ethan polk	65622	20.0
+ethan quirinius	65542	20.0
+ethan quirinius	65591	20.0
+ethan quirinius	65706	20.0
+ethan robinson	65547	20.0
+ethan robinson	65659	20.0
+ethan underhill	65570	20.0
+ethan van buren	65572	20.0
+ethan white	65677	20.0
+ethan white	65788	20.0
+ethan xylophone	65595	20.0
+ethan zipper	65593	20.0
+ethan zipper	65680	20.0
+fred davidson	65552	20.0
+fred davidson	65595	20.0
+fred davidson	65721	20.0
+fred ellison	65548	20.0
+fred ellison	65691	20.0
+fred ellison	65771	20.0
+fred falkner	65637	20.0
+fred falkner	65648	20.0
+fred falkner	65783	20.0
+fred hernandez	65541	20.0
+fred ichabod	65572	20.0
+fred ichabod	65789	20.0
+fred johnson	65758	20.0
+fred king	65694	20.0
+fred king	65745	20.0
+fred laertes	65769	20.0
+fred miller	65536	20.0
+fred nixon	65560	20.0
+fred nixon	65612	20.0
+fred nixon	65703	20.0
+fred nixon	65705	20.0
+fred polk	65603	20.0
+fred polk	65656	20.0
+fred polk	65701	20.0
+fred polk	65706	20.0
+fred quirinius	65697	20.0
+fred quirinius	65782	20.0
+fred robinson	65623	20.0
+fred steinbeck	65544	20.0
+fred steinbeck	65651	20.0
+fred steinbeck	65755	20.0
+fred underhill	65629	20.0
+fred van buren	65537	20.0
+fred van buren	65561	20.0
+fred van buren	65745	20.0
+fred van buren	65789	20.0
+fred white	65589	20.0
+fred young	65594	20.0
+fred young	65773	20.0
+fred zipper	65553	20.0
+gabriella allen	65646	20.0
+gabriella allen	65677	20.0
+gabriella brown	65704	20.0
+gabriella brown	65753	20.0
+gabriella carson	65586	20.0
+gabriella davidson	65565	20.0
+gabriella ellison	65706	20.0
+gabriella ellison	65716	20.0
+gabriella falkner	65623	20.0
+gabriella falkner	65711	20.0
+gabriella falkner	65767	20.0
+gabriella garcia	65571	20.0
+gabriella hernandez	65587	20.0
+gabriella hernandez	65717	20.0
+gabriella ichabod	65559	20.0
+gabriella ichabod	65633	20.0
+gabriella ichabod	65702	20.0
+gabriella ichabod	65712	20.0
+gabriella ichabod	65717	20.0
+gabriella king	65651	20.0
+gabriella king	65657	20.0
+gabriella laertes	65781	20.0
+gabriella miller	65646	20.0
+gabriella ovid	65556	20.0
+gabriella ovid	65583	20.0
+gabriella polk	65701	20.0
+gabriella polk	65790	20.0
+gabriella steinbeck	65582	20.0
+gabriella steinbeck	65653	20.0
+gabriella thompson	65682	20.0
+gabriella thompson	65755	20.0
+gabriella thompson	65766	20.0
+gabriella van buren	65581	20.0
+gabriella van buren	65644	20.0
+gabriella white	65638	20.0
+gabriella young	65699	20.0
+gabriella young	65774	20.0
+gabriella zipper	65540	20.0
+gabriella zipper	65754	20.0
+holly allen	65596	20.0
+holly brown	65599	20.0
+holly brown	65619	20.0
+holly falkner	65720	20.0
+holly hernandez	65602	20.0
+holly hernandez	65686	20.0
+holly hernandez	65750	20.0
+holly hernandez	65788	20.0
+holly ichabod	65711	20.0
+holly ichabod	65749	20.0
+holly ichabod	65752	20.0
+holly johnson	65655	20.0
+holly johnson	65662	20.0
+holly johnson	65755	20.0
+holly king	65549	20.0
+holly king	65648	20.0
+holly laertes	65664	20.0
+holly miller	65653	20.0
+holly nixon	65539	20.0
+holly nixon	65658	20.0
+holly polk	65743	20.0
+holly polk	65751	20.0
+holly robinson	65564	20.0
+holly thompson	65538	20.0
+holly thompson	65578	20.0
+holly thompson	65713	20.0
+holly underhill	65634	20.0
+holly underhill	65654	20.0
+holly underhill	65721	20.0
+holly underhill	65759	20.0
+holly van buren	65727	20.0
+holly white	65536	20.0
+holly white	65602	20.0
+holly xylophone	65544	20.0
+holly young	65606	20.0
+holly young	65765	20.0
+holly zipper	65607	20.0
+holly zipper	65755	20.0
+irene allen	65556	20.0
+irene brown	65633	20.0
+irene brown	65650	20.0
+irene brown	65765	20.0
+irene carson	65590	20.0
+irene ellison	65659	20.0
+irene ellison	65696	20.0
+irene falkner	65620	20.0
+irene falkner	65661	20.0
+irene garcia	65660	20.0
+irene garcia	65711	20.0
+irene garcia	65787	20.0
+irene ichabod	65645	20.0
+irene ichabod	65722	20.0
+irene johnson	65583	20.0
+irene laertes	65664	20.0
+irene laertes	65710	20.0
+irene laertes	65722	20.0
+irene miller	65730	20.0
+irene nixon	65631	20.0
+irene nixon	65643	20.0
+irene nixon	65653	20.0
+irene ovid	65691	20.0
+irene ovid	65734	20.0
+irene ovid	65753	20.0
+irene polk	65551	20.0
+irene polk	65575	20.0
+irene polk	65579	20.0
+irene polk	65595	20.0
+irene polk	65610	20.0
+irene quirinius	65724	20.0
+irene quirinius	65769	20.0
+irene quirinius	65773	20.0
+irene robinson	65554	20.0
+irene steinbeck	65683	20.0
+irene thompson	65688	20.0
+irene underhill	65591	20.0
+irene underhill	65787	20.0
+irene van buren	65579	20.0
+irene van buren	65589	20.0
+irene xylophone	65775	20.0
+jessica brown	65588	20.0
+jessica carson	65553	20.0
+jessica carson	65672	20.0
+jessica carson	65747	20.0
+jessica davidson	65549	20.0
+jessica davidson	65606	20.0
+jessica davidson	65675	20.0
+jessica davidson	65727	20.0
+jessica ellison	65567	20.0
+jessica ellison	65663	20.0
+jessica falkner	65584	20.0
+jessica garcia	65676	20.0
+jessica garcia	65789	20.0
+jessica ichabod	65704	20.0
+jessica johnson	65607	20.0
+jessica johnson	65720	20.0
+jessica miller	65733	20.0
+jessica nixon	65590	20.0
+jessica nixon	65774	20.0
+jessica ovid	65582	20.0
+jessica ovid	65751	20.0
+jessica polk	65637	20.0
+jessica quirinius	65562	20.0
+jessica quirinius	65608	20.0
+jessica quirinius	65712	20.0
+jessica quirinius	65716	20.0
+jessica robinson	65576	20.0
+jessica thompson	65581	20.0
+jessica thompson	65675	20.0
+jessica underhill	65656	20.0
+jessica underhill	65702	20.0
+jessica underhill	65783	20.0
+jessica van buren	65615	20.0
+jessica white	65544	20.0
+jessica white	65570	20.0
+jessica white	65594	20.0
+jessica white	65673	20.0
+jessica white	65779	20.0
+jessica xylophone	65562	20.0
+jessica young	65623	20.0
+jessica young	65711	20.0
+jessica zipper	65600	20.0
+jessica zipper	65657	20.0
+jessica zipper	65778	20.0
+katie allen	65542	20.0
+katie brown	65590	20.0
+katie davidson	65619	20.0
+katie ellison	65675	20.0
+katie ellison	65699	20.0
+katie falkner	65728	20.0
+katie garcia	65625	20.0
+katie garcia	65747	20.0
+katie hernandez	65550	20.0
+katie ichabod	65658	20.0
+katie ichabod	65726	20.0
+katie ichabod	65757	20.0
+katie king	65629	20.0
+katie king	65647	20.0
+katie king	65776	20.0
+katie miller	65541	20.0
+katie miller	65661	20.0
+katie nixon	65669	20.0
+katie ovid	65681	20.0
+katie polk	65746	20.0
+katie polk	65784	20.0
+katie robinson	65697	20.0
+katie van buren	65643	20.0
+katie van buren	65730	20.0
+katie white	65620	20.0
+katie white	65719	20.0
+katie xylophone	65585	20.0
+katie young	65644	20.0
+katie young	65746	20.0
+katie young	65764	20.0
+katie zipper	65568	20.0
+katie zipper	65733	20.0
+luke allen	65547	20.0
+luke allen	65552	20.0
+luke allen	65576	20.0
+luke allen	65681	20.0
+luke allen	65776	20.0
+luke brown	65719	20.0
+luke davidson	65656	20.0
+luke davidson	65791	20.0
+luke ellison	65582	20.0
+luke ellison	65664	20.0
+luke ellison	65779	20.0
+luke falkner	65589	20.0
+luke falkner	65618	20.0
+luke garcia	65687	20.0
+luke garcia	65778	20.0
+luke ichabod	65629	20.0
+luke ichabod	65654	20.0
+luke johnson	65545	20.0
+luke johnson	65716	20.0
+luke johnson	65718	20.0
+luke laertes	65608	20.0
+luke laertes	65657	20.0
+luke laertes	65685	20.0
+luke laertes	65730	20.0
+luke laertes	65756	20.0
+luke miller	65752	20.0
+luke ovid	65569	20.0
+luke ovid	65693	20.0
+luke polk	65645	20.0
+luke polk	65658	20.0
+luke quirinius	65655	20.0
+luke robinson	65634	20.0
+luke robinson	65772	20.0
+luke thompson	65626	20.0
+luke underhill	65553	20.0
+luke underhill	65571	20.0
+luke underhill	65651	20.0
+luke van buren	65678	20.0
+luke white	65693	20.0
+luke xylophone	65597	20.0
+luke zipper	65641	20.0
+mike allen	65706	20.0
+mike brown	65654	20.0
+mike carson	65698	20.0
+mike carson	65700	20.0
+mike carson	65751	20.0
+mike davidson	65658	20.0
+mike davidson	65759	20.0
+mike ellison	65598	20.0
+mike ellison	65606	20.0
+mike ellison	65718	20.0
+mike ellison	65738	20.0
+mike ellison	65760	20.0
+mike falkner	65609	20.0
+mike garcia	65571	20.0
+mike garcia	65600	20.0
+mike garcia	65770	20.0
+mike hernandez	65548	20.0
+mike hernandez	65672	20.0
+mike ichabod	65621	20.0
+mike king	65563	20.0
+mike king	65586	20.0
+mike king	65591	20.0
+mike king	65642	20.0
+mike king	65769	20.0
+mike king	65776	20.0
+mike miller	65549	20.0
+mike nixon	65619	20.0
+mike nixon	65704	20.0
+mike polk	65619	20.0
+mike polk	65658	20.0
+mike polk	65704	20.0
+mike quirinius	65717	20.0
+mike steinbeck	65550	20.0
+mike steinbeck	65564	20.0
+mike steinbeck	65573	20.0
+mike steinbeck	65749	20.0
+mike van buren	65620	20.0
+mike van buren	65770	20.0
+mike white	65648	20.0
+mike white	65685	20.0
+mike white	65769	20.0
+mike white	65778	20.0
+mike young	65545	20.0
+mike young	65581	20.0
+mike young	65736	20.0
+mike zipper	65552	20.0
+mike zipper	65695	20.0
+mike zipper	65779	20.0
+nick allen	65641	20.0
+nick allen	65786	20.0
+nick brown	65724	20.0
+nick davidson	65601	20.0
+nick ellison	65691	20.0
+nick ellison	65745	20.0
+nick falkner	65583	20.0
+nick falkner	65676	20.0
+nick garcia	65695	20.0
+nick garcia	65712	20.0
+nick garcia	65720	20.0
+nick ichabod	65572	20.0
+nick ichabod	65681	20.0
+nick ichabod	65737	20.0
+nick johnson	65585	20.0
+nick johnson	65784	20.0
+nick laertes	65624	20.0
+nick miller	65757	20.0
+nick nixon	65650	20.0
+nick ovid	65719	20.0
+nick polk	65716	20.0
+nick quirinius	65588	20.0
+nick quirinius	65723	20.0
+nick robinson	65547	20.0
+nick robinson	65675	20.0
+nick steinbeck	65689	20.0
+nick thompson	65610	20.0
+nick underhill	65619	20.0
+nick van buren	65603	20.0
+nick xylophone	65644	20.0
+nick young	65654	20.0
+nick young	65660	20.0
+nick zipper	65757	20.0
+nick zipper	65765	20.0
+oscar allen	65644	20.0
+oscar brown	65614	20.0
+oscar carson	65537	20.0
+oscar carson	65548	20.0
+oscar carson	65549	20.0
+oscar carson	65624	20.0
+oscar carson	65697	20.0
+oscar davidson	65556	20.0
+oscar ellison	65630	20.0
+oscar ellison	65630	20.0
+oscar falkner	65692	20.0
+oscar garcia	65751	20.0
+oscar hernandez	65683	20.0
+oscar hernandez	65707	20.0
+oscar ichabod	65536	20.0
+oscar ichabod	65562	20.0
+oscar ichabod	65637	20.0
+oscar ichabod	65763	20.0
+oscar johnson	65645	20.0
+oscar johnson	65778	20.0
+oscar king	65541	20.0
+oscar king	65550	20.0
+oscar king	65787	20.0
+oscar laertes	65625	20.0
+oscar laertes	65690	20.0
+oscar laertes	65756	20.0
+oscar laertes	65790	20.0
+oscar nixon	65596	20.0
+oscar ovid	65536	20.0
+oscar ovid	65615	20.0
+oscar ovid	65659	20.0
+oscar polk	65541	20.0
+oscar polk	65643	20.0
+oscar quirinius	65541	20.0
+oscar quirinius	65560	20.0
+oscar quirinius	65689	20.0
+oscar quirinius	65720	20.0
+oscar robinson	65537	20.0
+oscar robinson	65658	20.0
+oscar robinson	65687	20.0
+oscar robinson	65782	20.0
+oscar steinbeck	65709	20.0
+oscar thompson	65542	20.0
+oscar thompson	65698	20.0
+oscar thompson	65727	20.0
+oscar thompson	65738	20.0
+oscar underhill	65626	20.0
+oscar van buren	65581	20.0
+oscar van buren	65635	20.0
+oscar van buren	65705	20.0
+oscar white	65552	20.0
+oscar white	65564	20.0
+oscar white	65671	20.0
+oscar white	65735	20.0
+oscar xylophone	65773	20.0
+oscar xylophone	65773	20.0
+oscar xylophone	65775	20.0
+oscar zipper	65568	20.0
+oscar zipper	65740	20.0
+oscar zipper	65777	20.0
+priscilla brown	65670	20.0
+priscilla brown	65690	20.0
+priscilla brown	65749	20.0
+priscilla carson	65658	20.0
+priscilla carson	65687	20.0
+priscilla carson	65755	20.0
+priscilla ichabod	65627	20.0
+priscilla ichabod	65759	20.0
+priscilla johnson	65543	20.0
+priscilla johnson	65633	20.0
+priscilla johnson	65668	20.0
+priscilla johnson	65681	20.0
+priscilla johnson	65755	20.0
+priscilla king	65646	20.0
+priscilla nixon	65564	20.0
+priscilla nixon	65600	20.0
+priscilla ovid	65541	20.0
+priscilla ovid	65790	20.0
+priscilla polk	65747	20.0
+priscilla quirinius	65672	20.0
+priscilla thompson	65654	20.0
+priscilla underhill	65715	20.0
+priscilla underhill	65729	20.0
+priscilla van buren	65607	20.0
+priscilla van buren	65685	20.0
+priscilla van buren	65749	20.0
+priscilla white	65652	20.0
+priscilla xylophone	65538	20.0
+priscilla xylophone	65763	20.0
+priscilla xylophone	65774	20.0
+priscilla young	65585	20.0
+priscilla young	65658	20.0
+priscilla zipper	65622	20.0
+priscilla zipper	65726	20.0
+quinn allen	65657	20.0
+quinn allen	65708	20.0
+quinn brown	65691	20.0
+quinn brown	65700	20.0
+quinn brown	65733	20.0
+quinn davidson	65549	20.0
+quinn davidson	65714	20.0
+quinn davidson	65776	20.0
+quinn davidson	65779	20.0
+quinn ellison	65705	20.0
+quinn ellison	65778	20.0
+quinn garcia	65568	20.0
+quinn garcia	65604	20.0
+quinn garcia	65610	20.0
+quinn garcia	65773	20.0
+quinn ichabod	65564	20.0
+quinn king	65558	20.0
+quinn king	65649	20.0
+quinn laertes	65542	20.0
+quinn laertes	65560	20.0
+quinn laertes	65627	20.0
+quinn nixon	65659	20.0
+quinn ovid	65699	20.0
+quinn quirinius	65747	20.0
+quinn robinson	65627	20.0
+quinn steinbeck	65578	20.0
+quinn steinbeck	65763	20.0
+quinn thompson	65643	20.0
+quinn thompson	65774	20.0
+quinn underhill	65549	20.0
+quinn underhill	65694	20.0
+quinn underhill	65767	20.0
+quinn van buren	65725	20.0
+quinn young	65647	20.0
+quinn zipper	65579	20.0
+quinn zipper	65693	20.0
+rachel allen	65661	20.0
+rachel allen	65709	20.0
+rachel brown	65586	20.0
+rachel brown	65587	20.0
+rachel brown	65587	20.0
+rachel brown	65610	20.0
+rachel brown	65693	20.0
+rachel carson	65677	20.0
+rachel carson	65682	20.0
+rachel davidson	65755	20.0
+rachel ellison	65761	20.0
+rachel falkner	65616	20.0
+rachel falkner	65681	20.0
+rachel falkner	65693	20.0
+rachel falkner	65764	20.0
+rachel johnson	65658	20.0
+rachel king	65604	20.0
+rachel king	65643	20.0
+rachel laertes	65562	20.0
+rachel laertes	65624	20.0
+rachel ovid	65721	20.0
+rachel ovid	65736	20.0
+rachel polk	65686	20.0
+rachel quirinius	65787	20.0
+rachel robinson	65544	20.0
+rachel robinson	65717	20.0
+rachel robinson	65724	20.0
+rachel thompson	65648	20.0
+rachel thompson	65662	20.0
+rachel thompson	65733	20.0
+rachel underhill	65667	20.0
+rachel white	65615	20.0
+rachel white	65717	20.0
+rachel young	65727	20.0
+rachel zipper	65757	20.0
+rachel zipper	65785	20.0
+sarah carson	65679	20.0
+sarah carson	65693	20.0
+sarah carson	65694	20.0
+sarah ellison	65611	20.0
+sarah falkner	65606	20.0
+sarah falkner	65680	20.0
+sarah garcia	65563	20.0
+sarah garcia	65638	20.0
+sarah garcia	65661	20.0
+sarah ichabod	65667	20.0
+sarah ichabod	65671	20.0
+sarah johnson	65659	20.0
+sarah johnson	65716	20.0
+sarah johnson	65731	20.0
+sarah johnson	65751	20.0
+sarah king	65650	20.0
+sarah king	65699	20.0
+sarah miller	65557	20.0
+sarah ovid	65550	20.0
+sarah robinson	65677	20.0
+sarah robinson	65763	20.0
+sarah steinbeck	65721	20.0
+sarah white	65622	20.0
+sarah white	65747	20.0
+sarah xylophone	65678	20.0
+sarah young	65595	20.0
+sarah zipper	65550	20.0
+tom brown	65593	20.0
+tom brown	65675	20.0
+tom carson	65539	20.0
+tom carson	65624	20.0
+tom carson	65780	20.0
+tom davidson	65780	20.0
+tom ellison	65578	20.0
+tom ellison	65670	20.0
+tom ellison	65756	20.0
+tom falkner	65574	20.0
+tom falkner	65583	20.0
+tom hernandez	65575	20.0
+tom hernandez	65632	20.0
+tom ichabod	65588	20.0
+tom johnson	65536	20.0
+tom johnson	65789	20.0
+tom king	65576	20.0
+tom laertes	65617	20.0
+tom laertes	65701	20.0
+tom miller	65594	20.0
+tom miller	65603	20.0
+tom miller	65704	20.0
+tom nixon	65672	20.0
+tom ovid	65628	20.0
+tom polk	65652	20.0
+tom polk	65742	20.0
+tom quirinius	65563	20.0
+tom quirinius	65783	20.0
+tom robinson	65626	20.0
+tom robinson	65632	20.0
+tom robinson	65691	20.0
+tom robinson	65758	20.0
+tom steinbeck	65666	20.0
+tom van buren	65621	20.0
+tom van buren	65652	20.0
+tom van buren	65669	20.0
+tom white	65548	20.0
+tom young	65544	20.0
+tom young	65546	20.0
+tom zipper	65789	20.0
+ulysses brown	65735	20.0
+ulysses carson	65602	20.0
+ulysses carson	65643	20.0
+ulysses carson	65703	20.0
+ulysses carson	65716	20.0
+ulysses davidson	65750	20.0
+ulysses ellison	65575	20.0
+ulysses garcia	65666	20.0
+ulysses hernandez	65651	20.0
+ulysses hernandez	65702	20.0
+ulysses hernandez	65786	20.0
+ulysses ichabod	65551	20.0
+ulysses ichabod	65566	20.0
+ulysses johnson	65776	20.0
+ulysses king	65649	20.0
+ulysses laertes	65691	20.0
+ulysses laertes	65711	20.0
+ulysses laertes	65781	20.0
+ulysses miller	65610	20.0
+ulysses miller	65637	20.0
+ulysses nixon	65603	20.0
+ulysses ovid	65656	20.0
+ulysses polk	65563	20.0
+ulysses polk	65580	20.0
+ulysses polk	65612	20.0
+ulysses polk	65777	20.0
+ulysses quirinius	65786	20.0
+ulysses robinson	65744	20.0
+ulysses steinbeck	65611	20.0
+ulysses steinbeck	65680	20.0
+ulysses thompson	65788	20.0
+ulysses underhill	65570	20.0
+ulysses underhill	65616	20.0
+ulysses underhill	65620	20.0
+ulysses underhill	65623	20.0
+ulysses underhill	65641	20.0
+ulysses underhill	65713	20.0
+ulysses underhill	65785	20.0
+ulysses van buren	65684	20.0
+ulysses white	65654	20.0
+ulysses white	65675	20.0
+ulysses xylophone	65623	20.0
+ulysses xylophone	65636	20.0
+ulysses xylophone	65781	20.0
+ulysses young	65675	20.0
+ulysses young	65736	20.0
+ulysses young	65748	20.0
+victor allen	65684	20.0
+victor allen	65707	20.0
+victor brown	65550	20.0
+victor brown	65555	20.0
+victor brown	65622	20.0
+victor brown	65673	20.0
+victor davidson	65579	20.0
+victor davidson	65628	20.0
+victor davidson	65783	20.0
+victor ellison	65641	20.0
+victor ellison	65782	20.0
+victor hernandez	65571	20.0
+victor hernandez	65659	20.0
+victor hernandez	65708	20.0
+victor hernandez	65735	20.0
+victor hernandez	65775	20.0
+victor johnson	65606	20.0
+victor johnson	65607	20.0
+victor johnson	65607	20.0
+victor king	65721	20.0
+victor king	65743	20.0
+victor laertes	65638	20.0
+victor laertes	65644	20.0
+victor miller	65570	20.0
+victor nixon	65709	20.0
+victor nixon	65791	20.0
+victor ovid	65649	20.0
+victor polk	65625	20.0
+victor quirinius	65620	20.0
+victor quirinius	65651	20.0
+victor robinson	65596	20.0
+victor robinson	65673	20.0
+victor steinbeck	65618	20.0
+victor steinbeck	65661	20.0
+victor steinbeck	65686	20.0
+victor thompson	65548	20.0
+victor van buren	65664	20.0
+victor van buren	65774	20.0
+victor white	65548	20.0
+victor white	65601	20.0
+victor xylophone	65549	20.0
+victor xylophone	65618	20.0
+victor xylophone	65644	20.0
+victor xylophone	65677	20.0
+victor xylophone	65755	20.0
+victor young	65628	20.0
+victor zipper	65743	20.0
+wendy allen	65628	20.0
+wendy allen	65711	20.0
+wendy allen	65782	20.0
+wendy brown	65580	20.0
+wendy brown	65657	20.0
+wendy ellison	65545	20.0
+wendy ellison	65603	20.0
+wendy falkner	65595	20.0
+wendy falkner	65604	20.0
+wendy falkner	65635	20.0
+wendy garcia	65659	20.0
+wendy garcia	65746	20.0
+wendy garcia	65747	20.0
+wendy garcia	65777	20.0
+wendy hernandez	65650	20.0
+wendy ichabod	65730	20.0
+wendy king	65586	20.0
+wendy king	65664	20.0
+wendy king	65670	20.0
+wendy laertes	65566	20.0
+wendy laertes	65683	20.0
+wendy laertes	65727	20.0
+wendy miller	65582	20.0
+wendy miller	65626	20.0
+wendy nixon	65611	20.0
+wendy nixon	65746	20.0
+wendy ovid	65589	20.0
+wendy ovid	65643	20.0
+wendy polk	65656	20.0
+wendy polk	65692	20.0
+wendy quirinius	65766	20.0
+wendy quirinius	65767	20.0
+wendy robinson	65622	20.0
+wendy robinson	65715	20.0
+wendy robinson	65774	20.0
+wendy steinbeck	65612	20.0
+wendy thompson	65650	20.0
+wendy thompson	65737	20.0
+wendy underhill	65662	20.0
+wendy underhill	65758	20.0
+wendy underhill	65775	20.0
+wendy van buren	65680	20.0
+wendy van buren	65699	20.0
+wendy white	65705	20.0
+wendy xylophone	65687	20.0
+wendy xylophone	65773	20.0
+wendy young	65674	20.0
+wendy young	65685	20.0
+xavier allen	65611	20.0
+xavier allen	65618	20.0
+xavier allen	65771	20.0
+xavier brown	65600	20.0
+xavier brown	65704	20.0
+xavier brown	65723	20.0
+xavier carson	65731	20.0
+xavier carson	65758	20.0
+xavier davidson	65644	20.0
+xavier davidson	65664	20.0
+xavier davidson	65755	20.0
+xavier ellison	65541	20.0
+xavier ellison	65654	20.0
+xavier garcia	65672	20.0
+xavier hernandez	65541	20.0
+xavier hernandez	65544	20.0
+xavier hernandez	65766	20.0
+xavier ichabod	65597	20.0
+xavier ichabod	65663	20.0
+xavier johnson	65654	20.0
+xavier johnson	65744	20.0
+xavier king	65590	20.0
+xavier king	65601	20.0
+xavier laertes	65743	20.0
+xavier ovid	65788	20.0
+xavier polk	65587	20.0
+xavier polk	65653	20.0
+xavier polk	65675	20.0
+xavier polk	65696	20.0
+xavier quirinius	65599	20.0
+xavier quirinius	65650	20.0
+xavier quirinius	65656	20.0
+xavier quirinius	65737	20.0
+xavier thompson	65608	20.0
+xavier underhill	65710	20.0
+xavier white	65703	20.0
+xavier white	65732	20.0
+xavier xylophone	65572	20.0
+xavier zipper	65561	20.0
+yuri allen	65565	20.0
+yuri allen	65682	20.0
+yuri brown	65538	20.0
+yuri brown	65688	20.0
+yuri carson	65670	20.0
+yuri carson	65769	20.0
+yuri ellison	65570	20.0
+yuri ellison	65581	20.0
+yuri falkner	65658	20.0
+yuri falkner	65681	20.0
+yuri garcia	65639	20.0
+yuri hernandez	65706	20.0
+yuri johnson	65587	20.0
+yuri johnson	65697	20.0
+yuri johnson	65712	20.0
+yuri king	65721	20.0
+yuri laertes	65637	20.0
+yuri laertes	65773	20.0
+yuri nixon	65635	20.0
+yuri nixon	65740	20.0
+yuri polk	65607	20.0
+yuri polk	65713	20.0
+yuri polk	65742	20.0
+yuri quirinius	65544	20.0
+yuri quirinius	65617	20.0
+yuri quirinius	65695	20.0
+yuri steinbeck	65592	20.0
+yuri steinbeck	65679	20.0
+yuri thompson	65676	20.0
+yuri underhill	65718	20.0
+yuri underhill	65750	20.0
+yuri white	65659	20.0
+yuri xylophone	65714	20.0
+zach allen	65667	20.0
+zach brown	65559	20.0
+zach brown	65588	20.0
+zach brown	65691	20.0
+zach brown	65759	20.0
+zach brown	65762	20.0
+zach carson	65572	20.0
+zach ellison	65748	20.0
+zach falkner	65620	20.0
+zach falkner	65627	20.0
+zach garcia	65544	20.0
+zach garcia	65623	20.0
+zach garcia	65629	20.0
+zach garcia	65786	20.0
+zach ichabod	65599	20.0
+zach ichabod	65612	20.0
+zach king	65556	20.0
+zach king	65702	20.0
+zach king	65773	20.0
+zach miller	65584	20.0
+zach miller	65665	20.0
+zach miller	65719	20.0
+zach ovid	65578	20.0
+zach ovid	65703	20.0
+zach ovid	65750	20.0
+zach ovid	65784	20.0
+zach quirinius	65691	20.0
+zach robinson	65599	20.0
+zach steinbeck	65602	20.0
+zach steinbeck	65695	20.0
+zach thompson	65636	20.0
+zach thompson	65696	20.0
+zach underhill	65573	20.0
+zach white	65733	20.0
+zach xylophone	65542	20.0
+zach xylophone	65780	20.0
+zach young	65576	20.0
+zach zipper	65579	20.0
+zach zipper	65649	20.0
+zach zipper	65676	20.0

http://git-wip-us.apache.org/repos/asf/spark/blob/b521a3b0/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
index 027056d..5ead5f3 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveComparisonTest.scala
@@ -300,7 +300,7 @@ abstract class HiveComparisonTest
 
             val hiveQueries = queryList.map(new TestHive.HiveQLQueryExecution(_))
             // Make sure we can at least parse everything before attempting hive execution.
-            hiveQueries.foreach(_.analyzed)
+            hiveQueries.foreach(_.logical)
             val computedResults = (queryList.zipWithIndex, hiveQueries, hiveCacheFiles).zipped.map {
               case ((queryString, i), hiveQuery, cachedAnswerFile)=>
                 try {

http://git-wip-us.apache.org/repos/asf/spark/blob/b521a3b0/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveWindowFunctionQuerySuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveWindowFunctionQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveWindowFunctionQuerySuite.scala
new file mode 100644
index 0000000..934452f
--- /dev/null
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveWindowFunctionQuerySuite.scala
@@ -0,0 +1,845 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.spark.sql.hive.execution
+
+import java.io.File
+import java.util.{Locale, TimeZone}
+
+import org.scalatest.BeforeAndAfter
+
+import org.apache.spark.sql.hive.test.TestHive
+import org.apache.spark.sql.hive.test.TestHive._
+import org.apache.spark.util.Utils
+
+/**
+ * The test suite for window functions. To actually compare results with Hive,
+ * every test should be created by `createQueryTest`. Because we are reusing tables
+ * for different tests and there are a few properties needed to let Hive generate golden
+ * files, every `createQueryTest` calls should explicitly set `reset` to `false`.
+ */
+abstract class HiveWindowFunctionQueryBaseSuite extends HiveComparisonTest with BeforeAndAfter {
+  private val originalTimeZone = TimeZone.getDefault
+  private val originalLocale = Locale.getDefault
+  private val testTempDir = Utils.createTempDir()
+
+  override def beforeAll() {
+    TestHive.cacheTables = true
+    // Timezone is fixed to America/Los_Angeles for those timezone sensitive tests (timestamp_*)
+    TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"))
+    // Add Locale setting
+    Locale.setDefault(Locale.US)
+
+    // Create the table used in windowing.q
+    sql("DROP TABLE IF EXISTS part")
+    sql(
+      """
+        |CREATE TABLE part(
+        |  p_partkey INT,
+        |  p_name STRING,
+        |  p_mfgr STRING,
+        |  p_brand STRING,
+        |  p_type STRING,
+        |  p_size INT,
+        |  p_container STRING,
+        |  p_retailprice DOUBLE,
+        |  p_comment STRING)
+      """.stripMargin)
+    val testData1 = TestHive.getHiveFile("data/files/part_tiny.txt").getCanonicalPath
+    sql(
+      s"""
+        |LOAD DATA LOCAL INPATH '$testData1' overwrite into table part
+      """.stripMargin)
+
+    sql("DROP TABLE IF EXISTS over1k")
+    sql(
+      """
+        |create table over1k(
+        |  t tinyint,
+        |  si smallint,
+        |  i int,
+        |  b bigint,
+        |  f float,
+        |  d double,
+        |  bo boolean,
+        |  s string,
+        |  ts timestamp,
+        |  dec decimal(4,2),
+        |  bin binary)
+        |row format delimited
+        |fields terminated by '|'
+      """.stripMargin)
+    val testData2 = TestHive.getHiveFile("data/files/over1k").getCanonicalPath
+    sql(
+      s"""
+        |LOAD DATA LOCAL INPATH '$testData2' overwrite into table over1k
+      """.stripMargin)
+
+    // The following settings are used for generating golden files with Hive.
+    // We have to use kryo to correctly let Hive serialize plans with window functions.
+    // This is used to generate golden files.
+    sql("set hive.plan.serialization.format=kryo")
+    // Explicitly set fs to local fs.
+    sql(s"set fs.default.name=file://$testTempDir/")
+    // Ask Hive to run jobs in-process as a single map and reduce task.
+    sql("set mapred.job.tracker=local")
+  }
+
+  override def afterAll() {
+    TestHive.cacheTables = false
+    TimeZone.setDefault(originalTimeZone)
+    Locale.setDefault(originalLocale)
+    TestHive.reset()
+  }
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests based on windowing_multipartitioning.q
+  // Results of the original query file are not deterministic.
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing_multipartitioning.q (deterministic) 1",
+    s"""
+      |select s,
+      |rank() over (partition by s order by si) r,
+      |sum(b) over (partition by s order by si) sum
+      |from over1k
+      |order by s, r, sum;
+    """.stripMargin, reset = false)
+
+  /* timestamp comparison issue with Hive?
+  createQueryTest("windowing_multipartitioning.q (deterministic) 2",
+    s"""
+      |select s,
+      |rank() over (partition by s order by dec desc) r,
+      |sum(b) over (partition by s order by ts desc) as sum
+      |from over1k
+      |where s = 'tom allen' or s = 'bob steinbeck'
+      |order by s, r, sum;
+     """.stripMargin, reset = false)
+  */
+
+  createQueryTest("windowing_multipartitioning.q (deterministic) 3",
+    s"""
+      |select s, sum(i) over (partition by s), sum(f) over (partition by si)
+      |from over1k where s = 'tom allen' or s = 'bob steinbeck';
+     """.stripMargin, reset = false)
+
+  createQueryTest("windowing_multipartitioning.q (deterministic) 4",
+    s"""
+      |select s, rank() over (partition by s order by bo),
+      |rank() over (partition by si order by bin desc) from over1k
+      |where s = 'tom allen' or s = 'bob steinbeck';
+     """.stripMargin, reset = false)
+
+  createQueryTest("windowing_multipartitioning.q (deterministic) 5",
+    s"""
+      |select s, sum(f) over (partition by i), row_number() over (order by f)
+      |from over1k where s = 'tom allen' or s = 'bob steinbeck';
+     """.stripMargin, reset = false)
+
+  createQueryTest("windowing_multipartitioning.q (deterministic) 6",
+    s"""
+      |select s, rank() over w1,
+      |rank() over w2
+      |from over1k
+      |where s = 'tom allen' or s = 'bob steinbeck'
+      |window
+      |w1 as (partition by s order by dec),
+      |w2 as (partition by si order by f) ;
+     """.stripMargin, reset = false)
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests based on windowing_navfn.q
+  // Results of the original query file are not deterministic.
+  // Also, the original query of
+  // select i, lead(s) over (partition by bin order by d,i desc) from over1k ;
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing_navfn.q (deterministic)",
+    s"""
+      |select s, row_number() over (partition by d order by dec) rn from over1k
+      |order by s, rn desc;
+      |select i, lead(s) over (partition by cast(bin as string) order by d,i desc) as l
+      |from over1k
+      |order by i desc, l;
+      |select i, lag(dec) over (partition by i order by s,i,dec) l from over1k
+      |order by i, l;
+      |select s, last_value(t) over (partition by d order by f) l from over1k
+      |order by s, l;
+      |select s, first_value(s) over (partition by bo order by s) f from over1k
+      |order by s, f;
+      |select t, s, i, last_value(i) over (partition by t order by s)
+      |from over1k where (s = 'oscar allen' or s = 'oscar carson') and t = 10;
+     """.stripMargin, reset = false)
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests based on windowing_ntile.q
+  // Results of the original query file are not deterministic.
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing_ntile.q (deterministic)",
+    s"""
+      |select i, ntile(10) over (partition by s order by i) n from over1k
+      |order by i, n;
+      |select s, ntile(100) over (partition by i order by s) n from over1k
+      |order by s, n;
+      |select f, ntile(4) over (partition by d order by f) n from over1k
+      |order by f, n;
+      |select d, ntile(1000) over (partition by dec order by d) n from over1k
+      |order by d, n;
+     """.stripMargin, reset = false)
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests based on windowing_udaf.q
+  // Results of the original query file are not deterministic.
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing_udaf.q (deterministic)",
+    s"""
+      |select s, min(i) over (partition by s) m from over1k
+      |order by s, m;
+      |select s, avg(f) over (partition by si order by s) a from over1k
+      |order by s, a;
+      |select s, avg(i) over (partition by t, b order by s) a from over1k
+      |order by s, a;
+      |select max(i) over w m from over1k
+      |order by m window w as (partition by f) ;
+      |select s, avg(d) over (partition by t order by f) a from over1k
+      |order by s, a;
+     """.stripMargin, reset = false)
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests based on windowing_windowspec.q
+  // Results of the original query file are not deterministic.
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing_windowspec.q (deterministic)",
+    s"""
+      |select s, sum(b) over (partition by i order by s,b rows unbounded preceding) as sum
+      |from over1k order by s, sum;
+      |select s, sum(f) over (partition by d order by s,f rows unbounded preceding) as sum
+      |from over1k order by s, sum;
+      |select s, sum(f) over
+      |(partition by ts order by f range between current row and unbounded following) as sum
+      |from over1k order by s, sum;
+      |select s, avg(f)
+      |over (partition by ts order by s,f rows between current row and 5 following) avg
+      |from over1k order by s, avg;
+      |select s, avg(d) over
+      |(partition by t order by s,d desc rows between 5 preceding and 5 following) avg
+      |from over1k order by s, avg;
+      |select s, sum(i) over(partition by ts order by s) sum from over1k
+      |order by s, sum;
+      |select f, sum(f) over
+      |(partition by ts order by f range between unbounded preceding and current row) sum
+      |from over1k order by f, sum;
+      |select s, i, round(avg(d) over (partition by s order by i) / 10.0 , 2) avg
+      |from over1k order by s, i, avg;
+      |select s, i, round((avg(d) over  w1 + 10.0) - (avg(d) over w1 - 10.0),2) avg
+      |from over1k
+      |order by s, i, avg window w1 as (partition by s order by i);
+     """.stripMargin, reset = false)
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests based on windowing_rank.q
+  // Results of the original query file are not deterministic.
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing_rank.q (deterministic) 1",
+    s"""
+      |select s, rank() over (partition by f order by t) r from over1k order by s, r;
+      |select s, dense_rank() over (partition by ts order by i,s desc) as r from over1k
+      |order by s desc, r desc;
+      |select s, cume_dist() over (partition by bo order by b,s) cd from over1k
+      |order by s, cd;
+      |select s, percent_rank() over (partition by dec order by f) r from over1k
+      |order by s desc, r desc;
+     """.stripMargin, reset = false)
+
+  createQueryTest("windowing_rank.q (deterministic) 2",
+    s"""
+      |select ts, dec, rnk
+      |from
+      |  (select ts, dec,
+      |          rank() over (partition by ts order by dec)  as rnk
+      |          from
+      |            (select other.ts, other.dec
+      |             from over1k other
+      |             join over1k on (other.b = over1k.b)
+      |            ) joined
+      |  ) ranked
+      |where rnk =  1
+      |order by ts, dec, rnk;
+     """.stripMargin, reset = false)
+
+  createQueryTest("windowing_rank.q (deterministic) 3",
+    s"""
+      |select ts, dec, rnk
+      |from
+      |  (select ts, dec,
+      |          rank() over (partition by ts order by dec)  as rnk
+      |          from
+      |            (select other.ts, other.dec
+      |             from over1k other
+      |             join over1k on (other.b = over1k.b)
+      |            ) joined
+      |  ) ranked
+      |where dec = 89.5
+      |order by ts, dec, rnk;
+     """.stripMargin, reset = false)
+
+  createQueryTest("windowing_rank.q (deterministic) 4",
+    s"""
+      |select ts, dec, rnk
+      |from
+      |  (select ts, dec,
+      |          rank() over (partition by ts order by dec)  as rnk
+      |          from
+      |            (select other.ts, other.dec
+      |             from over1k other
+      |             join over1k on (other.b = over1k.b)
+      |             where other.t < 10
+      |            ) joined
+      |  ) ranked
+      |where rnk = 1
+      |order by ts, dec, rnk;
+     """.stripMargin, reset = false)
+
+  /////////////////////////////////////////////////////////////////////////////
+  // Tests from windowing.q
+  // We port tests in windowing.q to here because this query file contains too
+  // many tests and the syntax of test "-- 7. testJoinWithWindowingAndPTF"
+  // is not supported right now.
+  /////////////////////////////////////////////////////////////////////////////
+  createQueryTest("windowing.q -- 1. testWindowing",
+    s"""
+      |select p_mfgr, p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |sum(p_retailprice) over
+      |(distribute by p_mfgr sort by p_name rows between unbounded preceding and current row) as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 2. testGroupByWithPartitioning",
+    s"""
+      |select p_mfgr, p_name, p_size,
+      |min(p_retailprice),
+      |rank() over(distribute by p_mfgr sort by p_name)as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz
+      |from part
+      |group by p_mfgr, p_name, p_size
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 3. testGroupByHavingWithSWQ",
+    s"""
+      |select p_mfgr, p_name, p_size, min(p_retailprice),
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz
+      |from part
+      |group by p_mfgr, p_name, p_size
+      |having p_size > 0
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 4. testCount",
+    s"""
+      |select p_mfgr, p_name,
+      |count(p_size) over(distribute by p_mfgr sort by p_name) as cd
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 5. testCountWithWindowingUDAF",
+    s"""
+      |select p_mfgr, p_name,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |count(p_size) over(distribute by p_mfgr sort by p_name) as cd,
+      |p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name
+      |                                  rows between unbounded preceding and current row) as s1,
+      |p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 6. testCountInSubQ",
+    s"""
+      |select sub1.r, sub1.dr, sub1.cd, sub1.s1, sub1.deltaSz
+      |from (select p_mfgr, p_name,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |count(p_size) over(distribute by p_mfgr sort by p_name) as cd,
+      |p_retailprice, sum(p_retailprice) over (distribute by p_mfgr sort by p_name
+      |                                  rows between unbounded preceding and current row) as s1,
+      |p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz
+      |from part
+      |) sub1
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 8. testMixedCaseAlias",
+    s"""
+      |select p_mfgr, p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name, p_size desc) as R
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 9. testHavingWithWindowingNoGBY",
+    s"""
+      |select p_mfgr, p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |sum(p_retailprice) over (distribute by p_mfgr sort by p_name
+      |                        rows between unbounded preceding and current row)  as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 10. testHavingWithWindowingCondRankNoGBY",
+    s"""
+      |select p_mfgr, p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |sum(p_retailprice) over (distribute by p_mfgr sort by p_name
+      |                        rows between unbounded preceding and current row) as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 11. testFirstLast",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |sum(p_size) over (distribute by p_mfgr sort by p_name
+      |rows between current row and current row) as s2,
+      |first_value(p_size) over w1  as f,
+      |last_value(p_size, false) over w1  as l
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 12. testFirstLastWithWhere",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |sum(p_size) over (distribute by p_mfgr sort by p_name
+      |rows between current row and current row) as s2,
+      |first_value(p_size) over w1 as f,
+      |last_value(p_size, false) over w1 as l
+      |from part
+      |where p_mfgr = 'Manufacturer#3'
+      |window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 13. testSumWindow",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |sum(p_size) over w1 as s1,
+      |sum(p_size) over (distribute by p_mfgr  sort by p_name
+      |rows between current row and current row)  as s2
+      |from part
+      |window w1 as (distribute by p_mfgr  sort by p_name rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 14. testNoSortClause",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 15. testExpressions",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |cume_dist() over(distribute by p_mfgr sort by p_name) as cud,
+      |percent_rank() over(distribute by p_mfgr sort by p_name) as pr,
+      |ntile(3) over(distribute by p_mfgr sort by p_name) as nt,
+      |count(p_size) over(distribute by p_mfgr sort by p_name) as ca,
+      |avg(p_size) over(distribute by p_mfgr sort by p_name) as avg,
+      |stddev(p_size) over(distribute by p_mfgr sort by p_name) as st,
+      |first_value(p_size % 5) over(distribute by p_mfgr sort by p_name) as fv,
+      |last_value(p_size) over(distribute by p_mfgr sort by p_name) as lv,
+      |first_value(p_size) over w1  as fvW1
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 16. testMultipleWindows",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |cume_dist() over(distribute by p_mfgr sort by p_name) as cud,
+      |sum(p_size) over (distribute by p_mfgr sort by p_name
+      |range between unbounded preceding and current row) as s1,
+      |sum(p_size) over (distribute by p_mfgr sort by p_size
+      |range between 5 preceding and current row) as s2,
+      |first_value(p_size) over w1  as fv1
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+
+  createQueryTest("windowing.q -- 17. testCountStar",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |count(*) over(distribute by p_mfgr sort by p_name ) as c,
+      |count(p_size) over(distribute by p_mfgr sort by p_name) as ca,
+      |first_value(p_size) over w1  as fvW1
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 18. testUDAFs",
+    s"""
+      |select  p_mfgr,p_name, p_size,
+      |sum(p_retailprice) over w1 as s,
+      |min(p_retailprice) over w1 as mi,
+      |max(p_retailprice) over w1 as ma,
+      |avg(p_retailprice) over w1 as ag
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 19. testUDAFsWithGBY",
+    """
+      |select  p_mfgr,p_name, p_size, p_retailprice,
+      |sum(p_retailprice) over w1 as s,
+      |min(p_retailprice) as mi ,
+      |max(p_retailprice) as ma ,
+      |avg(p_retailprice) over w1 as ag
+      |from part
+      |group by p_mfgr,p_name, p_size, p_retailprice
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following);
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 20. testSTATs",
+    """
+      |select  p_mfgr,p_name, p_size,
+      |stddev(p_retailprice) over w1 as sdev,
+      |stddev_pop(p_retailprice) over w1 as sdev_pop,
+      |collect_set(p_size) over w1 as uniq_size,
+      |variance(p_retailprice) over w1 as var,
+      |corr(p_size, p_retailprice) over w1 as cor,
+      |covar_pop(p_size, p_retailprice) over w1 as covarp
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 21. testDISTs",
+    """
+      |select  p_mfgr,p_name, p_size,
+      |histogram_numeric(p_retailprice, 5) over w1 as hist,
+      |percentile(p_partkey, 0.5) over w1 as per,
+      |row_number() over(distribute by p_mfgr sort by p_name) as rn
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_mfgr, p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 24. testLateralViews",
+    """
+      |select p_mfgr, p_name,
+      |lv_col, p_size, sum(p_size) over w1   as s
+      |from (select p_mfgr, p_name, p_size, array(1,2,3) arr from part) p
+      |lateral view explode(arr) part_lv as lv_col
+      |window w1 as (distribute by p_mfgr sort by p_size, lv_col
+      |             rows between 2 preceding and current row)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 26. testGroupByHavingWithSWQAndAlias",
+    """
+      |select p_mfgr, p_name, p_size, min(p_retailprice) as mi,
+      |rank() over(distribute by p_mfgr sort by p_name) as r,
+      |dense_rank() over(distribute by p_mfgr sort by p_name) as dr,
+      |p_size, p_size - lag(p_size,1,p_size) over(distribute by p_mfgr sort by p_name) as deltaSz
+      |from part
+      |group by p_mfgr, p_name, p_size
+      |having p_size > 0
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 27. testMultipleRangeWindows",
+    """
+      |select  p_mfgr,p_name, p_size,
+      |sum(p_size) over (distribute by p_mfgr sort by p_size
+      |range between 10 preceding and current row) as s2,
+      |sum(p_size) over (distribute by p_mfgr sort by p_size
+      |range between current row and 10 following )  as s1
+      |from part
+      |window w1 as (rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 28. testPartOrderInUDAFInvoke",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over (partition by p_mfgr  order by p_name
+      |rows between 2 preceding and 2 following) as s
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 29. testPartOrderInWdwDef",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s
+      |from part
+      |window w1 as (partition by p_mfgr  order by p_name
+      |             rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 30. testDefaultPartitioningSpecRules",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s,
+      |sum(p_size) over w2 as s2
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following),
+      |       w2 as (partition by p_mfgr order by p_name)
+    """.stripMargin, reset = false)
+
+  /* p_name is not a numeric column. What is Hive's semantic?
+  createQueryTest("windowing.q -- 31. testWindowCrossReference",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s1,
+      |sum(p_size) over w2 as s2
+      |from part
+      |window w1 as (partition by p_mfgr order by p_name
+      |             range between 2 preceding and 2 following),
+      |       w2 as w1
+    """.stripMargin, reset = false)
+  */
+  /*
+  createQueryTest("windowing.q -- 32. testWindowInheritance",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s1,
+      |sum(p_size) over w2 as s2
+      |from part
+      |window w1 as (partition by p_mfgr order by p_name
+      |             range between 2 preceding and 2 following),
+      |       w2 as (w1 rows between unbounded preceding and current row)
+    """.stripMargin, reset = false)
+  */
+
+  /* p_name is not a numeric column. What is Hive's semantic?
+  createQueryTest("windowing.q -- 33. testWindowForwardReference",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s1,
+      |sum(p_size) over w2 as s2,
+      |sum(p_size) over w3 as s3
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_name
+      |             range between 2 preceding and 2 following),
+      |       w2 as w3,
+      |       w3 as (distribute by p_mfgr sort by p_name
+      |             range between unbounded preceding and current row)
+    """.stripMargin, reset = false)
+  */
+  /*
+  createQueryTest("windowing.q -- 34. testWindowDefinitionPropagation",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s1,
+      |sum(p_size) over w2 as s2,
+      |sum(p_size) over (w3 rows between 2 preceding and 2 following)  as s3
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_name
+      |             range between 2 preceding and 2 following),
+      |       w2 as w3,
+      |       w3 as (distribute by p_mfgr sort by p_name
+      |             range between unbounded preceding and current row)
+    """.stripMargin, reset = false)
+  */
+
+  /* Seems Hive evaluate SELECT DISTINCT before window functions?
+  createQueryTest("windowing.q -- 35. testDistinctWithWindowing",
+    """
+      |select DISTINCT p_mfgr, p_name, p_size,
+      |sum(p_size) over w1 as s
+      |from part
+      |window w1 as (distribute by p_mfgr sort by p_name rows between 2 preceding and 2 following)
+    """.stripMargin, reset = false)
+  */
+
+  createQueryTest("windowing.q -- 36. testRankWithPartitioning",
+    """
+      |select p_mfgr, p_name, p_size,
+      |rank() over (partition by p_mfgr order by p_name )  as r
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 37. testPartitioningVariousForms",
+    """
+      |select p_mfgr,
+      |round(sum(p_retailprice) over (partition by p_mfgr order by p_mfgr),2) as s1,
+      |min(p_retailprice) over (partition by p_mfgr) as s2,
+      |max(p_retailprice) over (distribute by p_mfgr sort by p_mfgr) as s3,
+      |round(avg(p_retailprice) over (distribute by p_mfgr),2) as s4,
+      |count(p_retailprice) over (cluster by p_mfgr ) as s5
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 38. testPartitioningVariousForms2",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_retailprice) over (partition by p_mfgr, p_name order by p_mfgr, p_name
+      |rows between unbounded preceding and current row) as s1,
+      |min(p_retailprice) over (distribute by p_mfgr, p_name sort by p_mfgr, p_name
+      |rows between unbounded preceding and current row) as s2,
+      |max(p_retailprice) over (partition by p_mfgr, p_name order by p_name) as s3
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 39. testUDFOnOrderCols",
+    """
+      |select p_mfgr, p_type, substr(p_type, 2) as short_ptype,
+      |rank() over (partition by p_mfgr order by substr(p_type, 2))  as r
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 40. testNoBetweenForRows",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_retailprice) over (distribute by p_mfgr sort by p_name rows unbounded preceding) as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 41. testNoBetweenForRange",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_retailprice) over (distribute by p_mfgr sort by p_size range unbounded preceding) as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 42. testUnboundedFollowingForRows",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_retailprice) over (distribute by p_mfgr sort by p_name
+      |rows between current row and unbounded following) as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 43. testUnboundedFollowingForRange",
+    """
+      |select p_mfgr, p_name, p_size,
+      |sum(p_retailprice) over (distribute by p_mfgr sort by p_size
+      |range between current row and unbounded following) as s1
+      |from part
+    """.stripMargin, reset = false)
+
+  createQueryTest("windowing.q -- 44. testOverNoPartitionSingleAggregate",
+    """
+      |select p_name, p_retailprice,
+      |round(avg(p_retailprice) over(),2)
+      |from part
+      |order by p_name
+    """.stripMargin, reset = false)
+}
+
+class HiveWindowFunctionQueryWithoutCodeGenSuite extends HiveWindowFunctionQueryBaseSuite {
+  var originalCodegenEnabled: Boolean = _
+  override def beforeAll(): Unit = {
+    super.beforeAll()
+    originalCodegenEnabled = conf.codegenEnabled
+    sql("set spark.sql.codegen=false")
+  }
+
+  override def afterAll(): Unit = {
+    sql(s"set spark.sql.codegen=$originalCodegenEnabled")
+    super.afterAll()
+  }
+}
+
+abstract class HiveWindowFunctionQueryFileBaseSuite
+  extends HiveCompatibilitySuite with BeforeAndAfter {
+  private val originalTimeZone = TimeZone.getDefault
+  private val originalLocale = Locale.getDefault
+  private val testTempDir = Utils.createTempDir()
+
+  override def beforeAll() {
+    TestHive.cacheTables = true
+    // Timezone is fixed to America/Los_Angeles for those timezone sensitive tests (timestamp_*)
+    TimeZone.setDefault(TimeZone.getTimeZone("America/Los_Angeles"))
+    // Add Locale setting
+    Locale.setDefault(Locale.US)
+
+    // The following settings are used for generating golden files with Hive.
+    // We have to use kryo to correctly let Hive serialize plans with window functions.
+    // This is used to generate golden files.
+    sql("set hive.plan.serialization.format=kryo")
+    // Explicitly set fs to local fs.
+    sql(s"set fs.default.name=file://$testTempDir/")
+    // Ask Hive to run jobs in-process as a single map and reduce task.
+    sql("set mapred.job.tracker=local")
+  }
+
+  override def afterAll() {
+    TestHive.cacheTables = false
+    TimeZone.setDefault(originalTimeZone)
+    Locale.setDefault(originalLocale)
+    TestHive.reset()
+  }
+
+  override def blackList: Seq[String] = Seq(
+    // Partitioned table functions are not supported.
+    "ptf*",
+    // tests of windowing.q are in HiveWindowFunctionQueryBaseSuite
+    "windowing.q",
+
+    // This one failed on the expression of
+    // sum(lag(p_retailprice,1,0.0)) over w1
+    // lag(p_retailprice,1,0.0) is a GenericUDF and the argument inspector of
+    // p_retailprice created by HiveInspectors is
+    // PrimitiveObjectInspectorFactory.javaDoubleObjectInspector.
+    // However, seems Hive assumes it is
+    // PrimitiveObjectInspectorFactory.writableDoubleObjectInspector, which introduces an error.
+    "windowing_expressions",
+
+    // Hive's results are not deterministic
+    "windowing_multipartitioning",
+    "windowing_navfn",
+    "windowing_ntile",
+    "windowing_udaf",
+    "windowing_windowspec",
+    "windowing_rank"
+  )
+
+  override def whiteList: Seq[String] = Seq(
+    "windowing_udaf2",
+    "windowing_columnPruning",
+    "windowing_adjust_rowcontainer_sz"
+  )
+
+  override def testCases: Seq[(String, File)] = super.testCases.filter {
+    case (name, _) => realWhiteList.contains(name)
+  }
+}
+
+class HiveWindowFunctionQueryFileWithoutCodeGenSuite extends HiveWindowFunctionQueryFileBaseSuite {
+  var originalCodegenEnabled: Boolean = _
+  override def beforeAll(): Unit = {
+    super.beforeAll()
+    originalCodegenEnabled = conf.codegenEnabled
+    sql("set spark.sql.codegen=false")
+  }
+
+  override def afterAll(): Unit = {
+    sql(s"set spark.sql.codegen=$originalCodegenEnabled")
+    super.afterAll()
+  }
+}

http://git-wip-us.apache.org/repos/asf/spark/blob/b521a3b0/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
----------------------------------------------------------------------
diff --git a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
index 630dec8..616352d 100644
--- a/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
+++ b/sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala
@@ -48,6 +48,10 @@ case class Order(
     state: String,
     month: Int)
 
+case class WindowData(
+    month: Int,
+    area: String,
+    product: Int)
 /** A SQL Dialect for testing purpose, and it can not be nested type */
 class MyDialect extends DefaultDialect
 
@@ -604,4 +608,147 @@ class SQLQuerySuite extends QueryTest {
       sql("SELECT TRANSFORM (d1, d2, d3) USING 'cat' AS (a,b,c) FROM script_trans")
       .queryExecution.toRdd.count())
   }
+
+  test("window function: udaf with aggregate expressin") {
+    val data = Seq(
+      WindowData(1, "a", 5),
+      WindowData(2, "a", 6),
+      WindowData(3, "b", 7),
+      WindowData(4, "b", 8),
+      WindowData(5, "c", 9),
+      WindowData(6, "c", 10)
+    )
+    sparkContext.parallelize(data).toDF().registerTempTable("windowData")
+
+    checkAnswer(
+      sql(
+        """
+          |select area, sum(product), sum(sum(product)) over (partition by area)
+          |from windowData group by month, area
+        """.stripMargin),
+      Seq(
+        ("a", 5, 11),
+        ("a", 6, 11),
+        ("b", 7, 15),
+        ("b", 8, 15),
+        ("c", 9, 19),
+        ("c", 10, 19)
+      ).map(i => Row(i._1, i._2, i._3)))
+
+    checkAnswer(
+      sql(
+        """
+          |select area, sum(product) - 1, sum(sum(product)) over (partition by area)
+          |from windowData group by month, area
+        """.stripMargin),
+      Seq(
+        ("a", 4, 11),
+        ("a", 5, 11),
+        ("b", 6, 15),
+        ("b", 7, 15),
+        ("c", 8, 19),
+        ("c", 9, 19)
+      ).map(i => Row(i._1, i._2, i._3)))
+
+    checkAnswer(
+      sql(
+        """
+          |select area, sum(product), sum(product) / sum(sum(product)) over (partition by area)
+          |from windowData group by month, area
+        """.stripMargin),
+      Seq(
+        ("a", 5, 5d/11),
+        ("a", 6, 6d/11),
+        ("b", 7, 7d/15),
+        ("b", 8, 8d/15),
+        ("c", 10, 10d/19),
+        ("c", 9, 9d/19)
+      ).map(i => Row(i._1, i._2, i._3)))
+
+    checkAnswer(
+      sql(
+        """
+          |select area, sum(product), sum(product) / sum(sum(product) - 1) over (partition by area)
+          |from windowData group by month, area
+        """.stripMargin),
+      Seq(
+        ("a", 5, 5d/9),
+        ("a", 6, 6d/9),
+        ("b", 7, 7d/13),
+        ("b", 8, 8d/13),
+        ("c", 10, 10d/17),
+        ("c", 9, 9d/17)
+      ).map(i => Row(i._1, i._2, i._3)))
+  }
+
+  test("window function: partition and order expressions") {
+    val data = Seq(
+      WindowData(1, "a", 5),
+      WindowData(2, "a", 6),
+      WindowData(3, "b", 7),
+      WindowData(4, "b", 8),
+      WindowData(5, "c", 9),
+      WindowData(6, "c", 10)
+    )
+    sparkContext.parallelize(data).toDF().registerTempTable("windowData")
+
+    checkAnswer(
+      sql(
+        """
+          |select month, area, product, sum(product + 1) over (partition by 1 order by 2)
+          |from windowData
+        """.stripMargin),
+      Seq(
+        (1, "a", 5, 51),
+        (2, "a", 6, 51),
+        (3, "b", 7, 51),
+        (4, "b", 8, 51),
+        (5, "c", 9, 51),
+        (6, "c", 10, 51)
+      ).map(i => Row(i._1, i._2, i._3, i._4)))
+
+    checkAnswer(
+      sql(
+        """
+          |select month, area, product, sum(product)
+          |over (partition by month % 2 order by 10 - product)
+          |from windowData
+        """.stripMargin),
+      Seq(
+        (1, "a", 5, 21),
+        (2, "a", 6, 24),
+        (3, "b", 7, 16),
+        (4, "b", 8, 18),
+        (5, "c", 9, 9),
+        (6, "c", 10, 10)
+      ).map(i => Row(i._1, i._2, i._3, i._4)))
+  }
+
+  test("window function: expressions in arguments of a window functions") {
+    val data = Seq(
+      WindowData(1, "a", 5),
+      WindowData(2, "a", 6),
+      WindowData(3, "b", 7),
+      WindowData(4, "b", 8),
+      WindowData(5, "c", 9),
+      WindowData(6, "c", 10)
+    )
+    sparkContext.parallelize(data).toDF().registerTempTable("windowData")
+
+    checkAnswer(
+      sql(
+        """
+          |select month, area, month % 2,
+          |lag(product, 1 + 1, product) over (partition by month % 2 order by area)
+          |from windowData
+        """.stripMargin),
+      Seq(
+        (1, "a", 1, 5),
+        (2, "a", 0, 6),
+        (3, "b", 1, 7),
+        (4, "b", 0, 8),
+        (5, "c", 1, 5),
+        (6, "c", 0, 6)
+      ).map(i => Row(i._1, i._2, i._3, i._4)))
+  }
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@spark.apache.org
For additional commands, e-mail: commits-help@spark.apache.org


Mime
View raw message