Ver Fonte

[editor] Swapping file names of create table data files

Romain Rigaux há 5 anos atrás
pai
commit
3b6a5fda34

+ 15 - 22
apps/beeswax/data/tables.json

@@ -1,27 +1,20 @@
 [
   {
-    "data_file": "sample_07.csv",
-    "create_sql": "CREATE TABLE `sample_07` (\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_07"
-  },
-  {
-    "data_file": "sample_08.csv",
-    "create_sql": "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_sql": "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",
-    "table_name": "customers"
-  },
+    "data_file": "employe_sample.csv",
+    "create_sql": "CREATE TABLE employe_sample (\n  code text ,\n  description text ,\n  total_emp int ,\n  salary int )\n",
+    "insert_sql": "INSERT INTO employe_sample (code, description, total_emp, salary)\nVALUES %(values)s",
+    "table_name": "employe_sample",
+    "dialects": ["mysql", "postgresql", "presto"],
+    "transactional": true
+  }
+  ,
   {
-    "partition_files": {
-      "`date`='2015-11-18'": "web_logs_1.csv",
-      "`date`='2015-11-19'": "web_logs_2.csv",
-      "`date`='2015-11-20'": "web_logs_3.csv",
-      "`date`='2015-11-21'": "web_logs_4.csv"
-    },
-    "create_sql": "CREATE TABLE `web_logs`  (  `_version_` bigint,   `app` string,   `bytes` smallint,   `city` string,   `client_ip` string,   `code` tinyint,   `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` bigint,   `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  )\nROW FORMAT DELIMITED \n FIELDS TERMINATED BY ','",
-    "table_name": "web_logs"
+    "data_file": "./tables/us_population.csv",
+    "create_sql": "CREATE TABLE IF NOT EXISTS us_population (\n  state CHAR(2) NOT NULL,\n  city VARCHAR NOT NULL,\n  population BIGINT\n  CONSTRAINT my_pk PRIMARY KEY (state, city)\n)\n",
+    "insert_sql": "UPSERT INTO us_population VALUES %(values)s",
+    "table_name": "us_population",
+    "dialects": ["phoenix"],
+    "transactional": true,
+    "is_multi_inserts": true
   }
 ]

+ 22 - 15
apps/beeswax/data/tables_standard.json

@@ -1,20 +1,27 @@
 [
   {
-    "data_file": "employe_sample.csv",
-    "create_sql": "CREATE TABLE employe_sample (\n  code text ,\n  description text ,\n  total_emp int ,\n  salary int )\n",
-    "insert_sql": "INSERT INTO employe_sample (code, description, total_emp, salary)\nVALUES %(values)s",
-    "table_name": "employe_sample",
-    "dialects": ["mysql", "postgresql", "presto"],
-    "transactional": true
-  }
-  ,
+    "data_file": "sample_07.csv",
+    "create_sql": "CREATE TABLE `sample_07` (\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_07"
+  },
+  {
+    "data_file": "sample_08.csv",
+    "create_sql": "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_sql": "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",
+    "table_name": "customers"
+  },
   {
-    "data_file": "./tables/us_population.csv",
-    "create_sql": "CREATE TABLE IF NOT EXISTS us_population (\n  state CHAR(2) NOT NULL,\n  city VARCHAR NOT NULL,\n  population BIGINT\n  CONSTRAINT my_pk PRIMARY KEY (state, city)\n)\n",
-    "insert_sql": "UPSERT INTO us_population VALUES %(values)s",
-    "table_name": "us_population",
-    "dialects": ["phoenix"],
-    "transactional": true,
-    "is_multi_inserts": true
+    "partition_files": {
+      "`date`='2015-11-18'": "web_logs_1.csv",
+      "`date`='2015-11-19'": "web_logs_2.csv",
+      "`date`='2015-11-20'": "web_logs_3.csv",
+      "`date`='2015-11-21'": "web_logs_4.csv"
+    },
+    "create_sql": "CREATE TABLE `web_logs`  (  `_version_` bigint,   `app` string,   `bytes` smallint,   `city` string,   `client_ip` string,   `code` tinyint,   `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` bigint,   `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  )\nROW FORMAT DELIMITED \n FIELDS TERMINATED BY ','",
+    "table_name": "web_logs"
   }
 ]

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

@@ -67,9 +67,9 @@ class Command(BaseCommand):
       self.queries = options.get('queries')
       self.tables = options.get('tables')
 
-    tables = 'tables_standard.json' if dialect not in ('hive', 'impala') else (
+    tables = 'tables.json' if dialect not in ('hive', 'impala') else (
         'tables_transactional.json' if has_concurrency_support() else
-        'tables.json'
+        'tables_standard.json'
     )
     exception = None