ソースを参照

HUE-2553 [beeswax] Add test checking for NaN and infinite numbers in json

Add row numbers in sample tables to keep the row ordered
Romain Rigaux 10 年 前
コミット
fd63bc11f7

+ 20 - 1
apps/beeswax/src/beeswax/tests.py

@@ -1149,7 +1149,6 @@ for x in sys.stdin:
 
     history = QueryHistory.objects.latest('id')
 
-#response = wait_for_query_to_finish(self.client, response)
     assert_equal_mod_whitespace("""
         CREATE TABLE `default.my_table2`
         (
@@ -1422,6 +1421,26 @@ for x in sys.stdin:
     ] )
 
 
+  def test_select_invalid_data(self):
+    filename = '/tmp/test_select_invalid_data'
+    self._make_custom_data_file(filename, [1, 2, 3, 'NaN', 'INF', '-INF', 'BAD']) # Infinity not supported yet
+    self._make_table('test_select_invalid_data', 'CREATE TABLE test_select_invalid_data (timestamp1 DOUBLE)', filename)
+
+    hql = """
+      SELECT * FROM test_select_invalid_data;
+    """
+    resp = _make_query(self.client, hql)
+    resp = wait_for_query_to_finish(self.client, resp, max=30.0)
+
+    content = json.loads(resp.content)
+    history_id = content['id']
+    query_history = QueryHistory.get(id=history_id)
+
+    resp = self.client.get("/beeswax/results/%s/0?format=json" % history_id)
+    content = json.loads(resp.content)
+    assert_equal([[1.0], [2.0], [3.0], [u'NaN'], [u'NULL'], [u'NULL'], [u'NULL']], content['results'])
+
+
   def test_create_database(self):
     resp = self.client.post("/beeswax/create/database", {
       'name': 'my_db',

+ 2 - 0
apps/metastore/src/metastore/templates/describe_table.mako

@@ -123,6 +123,7 @@ ${ components.menubar() }
                 <table id="sampleTable" class="table table-striped table-condensed sampleTable">
                   <thead>
                     <tr>
+                      <th style="width: 10px"></th>
                     % for col in table.cols:
                       <th>${col.name}</th>
                     % endfor
@@ -131,6 +132,7 @@ ${ components.menubar() }
                   <tbody>
                   % for i, row in enumerate(sample):
                     <tr>
+                      <td>${ i }</td>
                     % for item in row:
                       <td>
                         % if item is None:

+ 2 - 0
apps/metastore/src/metastore/templates/sample.mako

@@ -28,6 +28,7 @@ from django.utils.translation import ugettext as _
   <table class="table table-striped table-condensed sampleTable">
     <thead>
       <tr>
+        <th style="width: 10px"></th>
         % for col in table.cols:
           <th>${ col.name }</th>
         % endfor
@@ -36,6 +37,7 @@ from django.utils.translation import ugettext as _
     <tbody>
       % for i, row in enumerate(sample):
       <tr>
+        <td>${ i }</td>
         % for item in row:
         <td>
           % if item is None: