ソースを参照

HUE-589 [beeswax] Support TIMESTAMP datatype

Fix Hive/HS2 API bug
Add tests
Remove old makefile files
Romain Rigaux 13 年 前
コミット
865b35f

+ 2 - 2
apps/beeswax/src/beeswax/forms.py

@@ -318,9 +318,9 @@ class CreateByImportDelimForm(forms.Form):
 # Note, struct is not currently supported.  (Because it's recursive, for example.)
 HIVE_TYPES = \
     ( "string", "tinyint", "smallint", "int", "bigint", "boolean",
-      "float", "double", "array", "map",)
+      "float", "double", "array", "map", "timestamp")
 HIVE_PRIMITIVE_TYPES = \
-    ("string", "tinyint", "smallint", "int", "bigint", "boolean", "float", "double")
+    ("string", "tinyint", "smallint", "int", "bigint", "boolean", "float", "double", "timestamp")
 
 class PartitionTypeForm(forms.Form):
   column_name = common.HiveIdentifierField(required=True)

+ 7 - 0
apps/beeswax/src/beeswax/templates/describe_table.mako

@@ -95,6 +95,12 @@ ${layout.menubar(section='tables')}
 
                 % if sample is not None:
                     <div class="tab-pane" id="sample">
+                      % if error_message:
+                        <div class="alert alert-error">
+                          <h3>${_('Error!')}</h3>
+                          <pre>${error_message | h}</pre>
+                        </div>
+                      % else:
                         <table class="table table-striped table-condensed sampleTable">
                           <thead>
                             <tr>
@@ -113,6 +119,7 @@ ${layout.menubar(section='tables')}
                             % endfor
                           </tbody>
                         </table>
+                      % endif
                     </div>
                 % endif
             </div>

+ 9 - 3
apps/beeswax/src/beeswax/test_base.py

@@ -91,7 +91,7 @@ def get_shared_beeswax_server():
   if _SHARED_BEESWAX_SERVER is None:
     # Copy hive-default.xml.template from BEESWAX_HIVE_CONF_DIR before it is set to
     # /my/bogus/path
-    default_xml = file(beeswax.conf.BEESWAX_HIVE_CONF_DIR.get()+"/hive-default.xml.template").read()
+    default_xml = file(beeswax.conf.BEESWAX_HIVE_CONF_DIR.get() + "/hive-default.xml.template").read()
 
     finish = (
       beeswax.conf.QUERY_SERVERS['default'].SERVER_HOST.set_for_testing("localhost"),
@@ -352,8 +352,7 @@ class BeeswaxSampleProvider(object):
     cls._make_table(table_info['name'], CREATE_TABLE % table_info, data_file % 4)
 
     # Create a "myview" view.
-    make_query(cls.client, "CREATE VIEW myview (foo, bar) as SELECT * FROM test",
-               wait=True)
+    make_query(cls.client, "CREATE VIEW myview (foo, bar) as SELECT * FROM test", wait=True)
 
     _INITIALIZED = True
 
@@ -396,3 +395,10 @@ class BeeswaxSampleProvider(object):
     for x in xrange(256):
       f.write("%d\t%s\n" % (x, unichr(x).encode(encoding)))
     f.close()
+
+  @classmethod
+  def _make_custom_data_file(cls, filename, data):
+    f = cls.cluster.fs.open(filename, "w")
+    for x in data:
+      f.write("%s\n" % x)
+    f.close()

+ 21 - 0
apps/beeswax/src/beeswax/tests.py

@@ -857,6 +857,27 @@ for x in sys.stdin:
 
     assert_true('on_success_url=%2Fbeeswax%2Ftable%2Fmy_table' in resp.context['fwd_params'])
 
+  def test_create_table_timestamp(self):
+    # Check form
+    response = self.client.get('/beeswax/create/create_table')
+    assert_true('<option value="timestamp">timestamp</option>' in response.content, response.content)
+
+    # Check creation
+    filename = '/tmp/timestamp_data'
+
+    # Bad format
+    self._make_custom_data_file(filename, [0, 0, 0])
+    self._make_table('timestamp_invalid_data', 'CREATE TABLE timestamp_invalid_data (timestamp1 TIMESTAMP)', filename)
+
+    response = self.client.get("/beeswax/table/timestamp_invalid_data")
+    assert_true('Error!' in response.content, response.content)
+
+    # Good format
+    self._make_custom_data_file(filename, ['2012-01-01 10:11:30', '2012-01-01 10:11:31'])
+    self._make_table('timestamp_valid_data', 'CREATE TABLE timestamp_valid_data (timestamp1 TIMESTAMP)', filename)
+
+    response = self.client.get("/beeswax/table/timestamp_valid_data")
+    assert_true('2012-01-01 10:11:30' in response.content, response.content)
 
   def test_partitioned_create_table(self):
     """

+ 8 - 1
apps/beeswax/src/beeswax/views.py

@@ -272,9 +272,15 @@ def show_tables(request):
 
 def describe_table(request, table):
   db = dbms.get(request.user)
+  error_message = ''
+  table_data = ''
 
   table = db.get_table('default', table)
-  table_data = db.get_sample(table)
+
+  try:
+    table_data = db.get_sample(table)
+  except BeeswaxException, ex:
+    error_message, logs = expand_exception(ex, db)
 
   load_form = LoadDataForm(table)
 
@@ -282,6 +288,7 @@ def describe_table(request, table):
       'table': table,
       'sample': table_data and table_data.rows(),
       'load_form': load_form,
+      'error_message': error_message,
   })
 
 

+ 1 - 6
desktop/Makefile

@@ -155,12 +155,7 @@ install: install-source-parts $(INSTALL_BDIST_TARGETS)
 #
 SOURCE_PARTS = \
   $(wildcard *.mk) Makefile \
-  conf \
-  libs/fancyupload \
-  libs/mootools-color \
-  libs/mootools-slick \
-  libs/mootools-touch \
-  libs/protovis
+  conf
 
 .PHONY: install-source-parts
 install-source-parts: