Pārlūkot izejas kodu

HUE-9022 [editor] Set transactional flag to customer sampletable to false

Romain 6 gadi atpakaļ
vecāks
revīzija
b7c40363a0

+ 12 - 3
apps/beeswax/data/tables_transactional.json

@@ -2,12 +2,20 @@
   {
     "data_file": "sample_07.csv",
     "create_hql": "CREATE TABLE `sample_07` (\n  `code` string ,\n  `description` string ,\n  `total_emp` int ,\n  `salary` int )\nSTORED AS parquet\nTBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only')\n",
-    "table_name": "sample_07"
+    "table_name": "sample_07",
+    "transactional": true
   },
   {
     "data_file": "sample_08.csv",
     "create_hql": "CREATE TABLE `sample_08` (\n  `code` string ,\n  `description` string ,\n  `total_emp` int ,\n  `salary` int )\nSTORED AS parquet\nTBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only')\n",
-    "table_name": "sample_08"
+    "table_name": "sample_08",
+    "transactional": true
+  },
+  {
+    "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>>>>)\nSTORED AS PARQUET\nTBLPROPERTIES ('transactional'='false')\n",
+    "table_name": "customers",
+    "transactional": false
   },
   {
     "partition_files": {
@@ -18,6 +26,7 @@
     },
     "create_hql": "CREATE TABLE `web_logs`  (  `_version_` bigint,   `app` string,   `bytes` int,   `city` string,   `client_ip` string,   `code` smallint,   `country_code` string,   `country_code3` string,   `country_name` string,   `device_family` string,   `extension` string,   `latitude` float,   `longitude` float,   `method` string,   `os_family` string,   `os_major` string,   `protocol` string,   `record` string,   `referer` string,   `region_code` string,   `request` string,   `subapp` string,   `time` string,   `url` string,   `user_agent` string,   `user_agent_family` string,   `user_agent_major` string,   `id` string)\nPARTITIONED BY (  `date` string  )\nSTORED AS parquet\nTBLPROPERTIES ('transactional'='true', 'transactional_properties'='insert_only')",
     "table_name": "web_logs",
-    "columns": [{"name": "_version_", "type": "bigint"}, {"name": "app", "type": "string"}, {"name": "bytes", "type": "int"}, {"name": "city", "type": "string"}, {"name": "client_ip", "type": "string"}, {"name": "code", "type": "smallint"}, {"name": "country_code", "type": "string"}, {"name": "country_code3", "type": "string"}, {"name": "country_name", "type": "string"}, {"name": "device_family", "type": "string"}, {"name": "extension", "type": "string"}, {"name": "latitude", "type": "float"}, {"name": "longitude", "type": "float"}, {"name": "method", "type": "string"}, {"name": "os_family", "type": "string"}, {"name": "os_major", "type": "string"}, {"name": "protocol", "type": "string"}, {"name": "record", "type": "string"}, {"name": "referer", "type": "string"}, {"name": "region_code", "type": "string"}, {"name": "request", "type": "string"}, {"name": "subapp", "type": "string"}, {"name": "time", "type": "string"}, {"name": "url", "type": "string"}, {"name": "user_agent", "type": "string"}, {"name": "user_agent_family", "type": "string"}, {"name": "user_agent_major", "type": "string"}, {"name": "id", "type": "string"}, {"name": "date", "type": "string"}]
+    "columns": [{"name": "_version_", "type": "bigint"}, {"name": "app", "type": "string"}, {"name": "bytes", "type": "int"}, {"name": "city", "type": "string"}, {"name": "client_ip", "type": "string"}, {"name": "code", "type": "smallint"}, {"name": "country_code", "type": "string"}, {"name": "country_code3", "type": "string"}, {"name": "country_name", "type": "string"}, {"name": "device_family", "type": "string"}, {"name": "extension", "type": "string"}, {"name": "latitude", "type": "float"}, {"name": "longitude", "type": "float"}, {"name": "method", "type": "string"}, {"name": "os_family", "type": "string"}, {"name": "os_major", "type": "string"}, {"name": "protocol", "type": "string"}, {"name": "record", "type": "string"}, {"name": "referer", "type": "string"}, {"name": "region_code", "type": "string"}, {"name": "request", "type": "string"}, {"name": "subapp", "type": "string"}, {"name": "time", "type": "string"}, {"name": "url", "type": "string"}, {"name": "user_agent", "type": "string"}, {"name": "user_agent_family", "type": "string"}, {"name": "user_agent_major", "type": "string"}, {"name": "id", "type": "string"}, {"name": "date", "type": "string"}],
+    "transactional": true
   }
 ]

+ 4 - 4
apps/beeswax/src/beeswax/management/commands/beeswax_install_examples.py

@@ -111,8 +111,7 @@ class Command(BaseCommand):
     design_list = [d for d in design_list if int(d['type']) == app_type]
 
     for design_dict in design_list:
-      if not has_concurrency_support() or design_dict['name'] != 'Sample: Customers':
-        design = SampleQuery(design_dict)
+      design = SampleQuery(design_dict)
       try:
         design.install(django_user)
       except Exception as ex:
@@ -135,6 +134,7 @@ class SampleTable(object):
     self.app_name = app_name
     self.db_name = db_name
     self.columns = data_dict.get('columns')
+    self.is_transactional = data_dict.get('transactional')
 
     # Sanity check
     self._data_dir = beeswax.conf.LOCAL_EXAMPLES_DATA_DIR.get()
@@ -187,7 +187,7 @@ class SampleTable(object):
         raise InstallException(msg)
 
   def load_partition(self, django_user, partition_spec, filepath, columns):
-    if has_concurrency_support():
+    if has_concurrency_support() and self.is_transactional:
       with open(filepath) as f:
         hql = \
           """
@@ -217,7 +217,7 @@ class SampleTable(object):
 
 
   def load(self, django_user):
-    if has_concurrency_support():
+    if has_concurrency_support() and self.is_transactional:
       with open(self._contents_file) as f:
         hql = \
           """