瀏覽代碼

HUE-414. Running beeswax examples produces "unsaved" queries

bc Wong 15 年之前
父節點
當前提交
4757c68385
共有 2 個文件被更改,包括 59 次插入19 次删除
  1. 56 18
      apps/beeswax/data/designs.json
  2. 3 1
      apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

+ 56 - 18
apps/beeswax/data/designs.json

@@ -1,20 +1,58 @@
 [
-  {
-    "data": "{\"query\": {\"query\": \"SELECT sample_07.description, sample_07.salary\\nFROM\\n  sample_07\\nWHERE\\n( sample_07.salary > 100000)\\nSORT BY sample_07.salary DESC\", \"type\": null}, \"functions\": [], \"VERSION\": \"0.4.0\", \"file_resources\": [], \"settings\": []}",
-    "type": "0", 
-    "name": "Sample: Top salary", 
-    "desc": "Top salary 2007 above $100k"
-  },
-  {
-    "data": "{\"query\": {\"query\": \"SELECT s07.description, s07.salary, s08.salary,\\n  s08.salary - s07.salary\\nFROM\\n  sample_07 s07 JOIN sample_08 s08\\nON ( s07.code = s08.code)\\nWHERE\\n s07.salary < s08.salary\\nSORT BY s08.salary-s07.salary DESC\", \"type\": null}, \"functions\": [], \"VERSION\": \"0.4.0\", \"file_resources\": [], \"settings\": [{\"value\": \"1\", \"key\": \"hive.merge.mapredfiles\"}]}",
-    "type": "0", 
-    "name": "Sample: Salary growth", 
-    "desc": "Salary growth (sorted) from 2007-08"
-  },
-  {
-    "data": "{\"query\": {\"query\": \"SELECT s07.description, s07.total_emp, s08.total_emp, s07.salary\\nFROM\\n  sample_07 s07 JOIN \\n  sample_08 s08\\nON ( s07.code = s08.code )\\nWHERE\\n( s07.total_emp > s08.total_emp\\n AND s07.salary > 100000 )\\nSORT BY s07.salary DESC\", \"type\": null}, \"functions\": [], \"VERSION\": \"0.4.0\", \"file_resources\": [], \"settings\": []}",
-    "type": "0", 
-    "name": "Sample: Job loss", 
-    "desc": "Job loss among the top earners 2007-08"
-  }
+   {
+      "name":"Sample: Top salary",
+      "desc":"Top salary 2007 above $100k",
+      "type":"0",
+      "data":{
+         "query":{
+            "query":"SELECT sample_07.description, sample_07.salary\nFROM\n  sample_07\nWHERE\n( sample_07.salary > 100000)\nSORT BY sample_07.salary DESC",
+            "type":null,
+            "email_notify":null,
+            "is_parameterized":null
+         },
+         "functions":[ ],
+         "VERSION":"0.4.0",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
+   },
+   {
+      "name":"Sample: Salary growth",
+      "desc":"Salary growth (sorted) from 2007-08",
+      "type":"0",
+      "data":{
+         "query":{
+            "query":"SELECT s07.description, s07.salary, s08.salary,\n  s08.salary - s07.salary\nFROM\n  sample_07 s07 JOIN sample_08 s08\nON ( s07.code = s08.code)\nWHERE\n s07.salary < s08.salary\nSORT BY s08.salary-s07.salary DESC",
+            "type":null,
+            "email_notify":null,
+            "is_parameterized":null
+         },
+         "functions":[ ],
+         "VERSION":"0.4.0",
+         "file_resources":[ ],
+         "settings":[
+            {
+               "value":"1",
+               "key":"hive.merge.mapredfiles"
+            }
+         ]
+      }
+   },
+   {
+      "name":"Sample: Job loss",
+      "desc":"Job loss among the top earners 2007-08",
+      "type":"0",
+      "data":{
+         "query":{
+            "query":"SELECT s07.description, s07.total_emp, s08.total_emp, s07.salary\nFROM\n  sample_07 s07 JOIN \n  sample_08 s08\nON ( s07.code = s08.code )\nWHERE\n( s07.total_emp > s08.total_emp\n AND s07.salary > 100000 )\nSORT BY s07.salary DESC",
+            "type":null,
+            "email_notify":null,
+            "is_parameterized":null
+         },
+         "functions":[ ],
+         "VERSION":"0.4.0",
+         "file_resources":[ ],
+         "settings":[ ]
+      }
+   }
 ]

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

@@ -228,7 +228,9 @@ class SampleDesign(object):
     except models.SavedQuery.DoesNotExist:
       model = models.SavedQuery(owner=django_user, name=self.name)
       model.type = self.type
-      model.data = self.data
+      # The data field needs to be a string. The sample file writes it
+      # as json (without encoding into a string) for readability.
+      model.data = simplejson.dumps(self.data)
       model.desc = self.desc
       model.save()
       LOG.info('Successfully installed sample design: %s' % (self.name,))