Browse Source

HUE-2904: [hive] Create nested type example
HUE-2905: [impala] Create nested type example
HUE-2306: [impala] Add sample tables and data to exercise all of Impala's supported types

Jenny Kim 10 years ago
parent
commit
5aeb3d41bd

BIN
apps/beeswax/data/customers.parquet


+ 90 - 0
apps/beeswax/data/designs.json

@@ -52,5 +52,95 @@
          "file_resources":[ ],
          "settings":[ ]
       }
+   },
+   {
+      "name":"Sample: Customers",
+      "desc":"Email Survey Opt-Ins, Customers for Shipping ZIP Code, Total Amount per Order",
+      "type":"0",
+      "data":{
+         "query":{
+            "query": "SELECT\r\n  c.id,\r\n  c.name,\r\n  c.email_preferences.categories.surveys\r\nFROM customers c;\n\nSELECT\r\n  customers.id,\r\n  customers.name\r\nFROM customers\r\nWHERE customers.addresses['shipping'].zip_code = '${zip_code}';\n\nSELECT\r\n  c.id AS customer_id,\r\n  c.name AS customer_name,\r\n  ords.order_id AS order_id,\r\n  SUM(order_items.price * order_items.qty) AS total_amount\r\nFROM\r\n  customers c\r\nLATERAL VIEW EXPLODE(c.orders) o AS ords\r\nLATERAL VIEW EXPLODE(ords.items) i AS order_items\r\nGROUP BY c.id, c.name, ords.order_id;",
+            "type":0,
+            "email_notify":false,
+            "is_parameterized":true,
+            "database":"default"
+         },
+         "functions":[ ],
+         "VERSION":"0.4.1",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
+   },
+   {
+      "name":"Sample: Top salary",
+      "desc":"Top salary 2007 above $100k",
+      "type":"1",
+      "data":{
+         "query":{
+            "query":"SELECT sample_07.description, sample_07.salary\r\nFROM\r\n  sample_07\r\nWHERE\r\n( sample_07.salary > 100000)\r\nORDER BY sample_07.salary DESC\r\nLIMIT 1000",
+            "type":1,
+            "email_notify":false,
+            "is_parameterized":false,
+            "database":"default"
+         },
+         "functions":[ ],
+         "VERSION":"0.4.1",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
+   },
+   {
+      "name":"Sample: Salary growth",
+      "desc":"Salary growth (sorted) from 2007-08",
+      "type":"1",
+      "data":{
+         "query":{
+            "query":"SELECT s07.description, s07.salary, s08.salary,\r\n  s08.salary - s07.salary\r\nFROM\r\n  sample_07 s07 JOIN sample_08 s08\r\nON ( s07.code = s08.code)\r\nWHERE\r\n s07.salary < s08.salary\r\nORDER BY s08.salary-s07.salary DESC\r\nLIMIT 1000",
+            "type":1,
+            "email_notify":false,
+            "is_parameterized":false,
+            "database":"default"
+         },
+         "functions":[ ],
+         "VERSION":"0.4.1",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
+   },
+   {
+      "name":"Sample: Job loss",
+      "desc":"Job loss among the top earners 2007-08",
+      "type":"1",
+      "data":{
+         "query":{
+            "query":"SELECT s07.description, s07.total_emp, s08.total_emp, s07.salary\r\nFROM\r\n  sample_07 s07 JOIN \r\n  sample_08 s08\r\nON ( s07.code = s08.code )\r\nWHERE\r\n( s07.total_emp > s08.total_emp\r\n AND s07.salary > 100000 )\r\nORDER BY s07.salary DESC\nLIMIT 1000",
+            "type":0,
+            "email_notify":false,
+            "is_parameterized":false,
+            "database":"default"
+         },
+         "functions":[ ],
+         "VERSION":"0.4.1",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
+   },
+   {
+      "name":"Sample: Customers",
+      "desc":"Email Survey Opt-Ins, Customers for Shipping ZIP Code, Total Amount per Order",
+      "type":"1",
+      "data":{
+         "query":{
+            "query": "SELECT\r\n  c.id,\r\n  c.name,\r\n  c.email_preferences.categories.surveys\r\nFROM customers c;\n\nSELECT\r\n  c.id,\r\n  c.name\r\nFROM customers c, c.addresses a\r\nWHERE a.key = 'shipping' and a.zip_code = '${zip_code}';\n\nSELECT\r\n  c.id AS customer_id,\r\n c.name AS customer_name,\r\n  o.order_id,\r\n  v.total\r\nFROM\r\n  customers c,\r\n  c.orders o,\r\n  (SELECT SUM(price * qty) total FROM o.items) v;",
+            "type":1,
+            "email_notify":false,
+            "is_parameterized":false,
+            "database":"default"
+         },
+         "functions":[ ],
+         "VERSION":"0.4.1",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
    }
 ]

+ 6 - 1
apps/beeswax/data/tables.json

@@ -8,5 +8,10 @@
     "data_file": "sample_08.csv", 
     "create_hql": "CREATE TABLE `sample_08` (\n  `code` string ,\n  `description` string ,\n  `total_emp` int ,\n  `salary` int )\nROW FORMAT DELIMITED\n  FIELDS TERMINATED BY '\t'\nSTORED AS TextFile\n", 
     "table_name": "sample_08"
+  },
+  {
+    "data_file": "customers.parquet",
+    "create_hql": "CREATE TABLE `customers` (\n `id` INT,\n `name` STRING,\n `email_preferences` STRUCT<`email_format`:STRING, `frequency`:STRING, `categories`:STRUCT<`promos`:BOOLEAN, `surveys`:BOOLEAN>>,\n `addresses` MAP<STRING, STRUCT<`street_1`:STRING, `street_2`:STRING, `city`:STRING, `state`:STRING, `zip_code`:STRING>>,\n `orders` ARRAY<STRUCT<`order_id`:STRING, `order_date`:STRING, `items`:ARRAY<STRUCT<`product_id`:INT, `sku`:STRING, `name`:STRING, `price`:DOUBLE, `qty`:INT>>>>)\nROW FORMAT SERDE 'parquet.hive.serde.ParquetHiveSerDe'\r\nSTORED AS\r\n  INPUTFORMAT 'parquet.hive.DeprecatedParquetInputFormat'\r\n  OUTPUTFORMAT 'parquet.hive.DeprecatedParquetOutputFormat'",
+    "table_name": "customers"
   }
-]
+]

+ 5 - 3
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -32,7 +32,7 @@ from desktop.models import Document
 
 import beeswax.conf
 
-from beeswax.models import SavedQuery, IMPALA
+from beeswax.models import SavedQuery, HQL, IMPALA
 from beeswax.design import hql_query
 from beeswax.server import dbms
 from beeswax.server.dbms import get_query_server_config, QueryServerException
@@ -102,9 +102,11 @@ class Command(BaseCommand):
     design_list = json.load(design_file)
     design_file.close()
 
+    # Filter design list to app-specific designs
+    app_type = HQL if app_name == 'beeswax' else IMPALA
+    design_list = filter(lambda d: int(d['type']) == app_type, design_list)
+
     for design_dict in design_list:
-      if app_name == 'impala':
-        design_dict['type'] = IMPALA
       design = SampleDesign(design_dict)
       try:
         design.install(django_user)