PageRenderTime 40ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/tags/release-0.0.0-rc0/hive/external/ql/src/test/queries/clientpositive/union19.q

#
text | 26 lines | 16 code | 10 blank | 0 comment | 0 complexity | dbff4368f6b1a86866641dcf16cdf5f8 MD5 | raw file
Possible License(s): Apache-2.0, BSD-3-Clause, JSON, CPL-1.0
  1. CREATE TABLE DEST1(key STRING, value STRING) STORED AS TEXTFILE;
  2. CREATE TABLE DEST2(key STRING, val1 STRING, val2 STRING) STORED AS TEXTFILE;
  3. -- union case:map-reduce sub-queries followed by multi-table insert
  4. explain
  5. FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
  6. UNION ALL
  7. select s2.key as key, s2.value as value from src s2) unionsrc
  8. INSERT OVERWRITE TABLE DEST1 SELECT unionsrc.key, count(unionsrc.value) group by unionsrc.key
  9. INSERT OVERWRITE TABLE DEST2 SELECT unionsrc.key, unionsrc.value, unionsrc.value;
  10. FROM (select 'tst1' as key, cast(count(1) as string) as value from src s1
  11. UNION ALL
  12. select s2.key as key, s2.value as value from src s2) unionsrc
  13. INSERT OVERWRITE TABLE DEST1 SELECT unionsrc.key, count(unionsrc.value) group by unionsrc.key
  14. INSERT OVERWRITE TABLE DEST2 SELECT unionsrc.key, unionsrc.value, unionsrc.value;
  15. SELECT DEST1.* FROM DEST1 SORT BY DEST1.key, DEST1.value;
  16. SELECT DEST2.* FROM DEST2 SORT BY DEST2.key, DEST2.val1, DEST2.val2;