Преглед на файлове

AMBARI-14010. Hive view doesn't show precision of types that support it. (Nitiraj Rathore via Jaimin)

Jaimin Jetly преди 9 години
родител
ревизия
85c7515577

+ 39 - 0
contrib/views/hive/src/main/resources/ui/hive-web/app/helpers/format-column-type.js

@@ -0,0 +1,39 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ used to format the precision and scale of type in database's table's columns
+**/
+
+import Ember from "ember";
+
+var columnTypeFormatter = function(column) {
+  let type = column.type;
+  let ext = type;
+  if( type === "VARCHAR" || type === "CHAR" || type == "DECIMAL"  ) {
+      ext += '(' + column.precision;
+    if (type == "DECIMAL") {
+        ext += "," + column.scale;
+    }
+    ext += ")";
+  }
+
+  return ext;
+};
+
+export default Ember.Handlebars.makeBoundHelper(columnTypeFormatter);

+ 7 - 5
contrib/views/hive/src/main/resources/ui/hive-web/app/services/database.js

@@ -69,7 +69,7 @@ export default Ember.Service.extend({
               table.get('name');
               table.get('name');
 
 
     url += '.page?searchId&count=' + this.get('pageCount');
     url += '.page?searchId&count=' + this.get('pageCount');
-    url += '&columns=3,5';
+    url += '&columns=3,5,6,8';
 
 
     if (searchTerm) {
     if (searchTerm) {
       url += '&searchId=searchColumns' + '&like=' + searchTerm;
       url += '&searchId=searchColumns' + '&like=' + searchTerm;
@@ -86,10 +86,12 @@ export default Ember.Service.extend({
         var columns;
         var columns;
 
 
         columns = data.rows.map(function (row) {
         columns = data.rows.map(function (row) {
-          return Ember.Object.create({
-            name: row[0],
-            type: row[1]
-          });
+            return Ember.Object.create({
+              name: row[0],
+              type: row[1],
+              precision : row[2],
+              scale : row[3]
+            });
         });
         });
 
 
         defer.resolve({
         defer.resolve({

+ 1 - 1
contrib/views/hive/src/main/resources/ui/hive-web/app/templates/databases-tree.hbs

@@ -28,7 +28,7 @@
                   {{#each column in table.visibleColumns}}
                   {{#each column in table.visibleColumns}}
                     <div>
                     <div>
                       <strong>{{column.name}}</strong>
                       <strong>{{column.name}}</strong>
-                      <span class="pull-right">{{column.type}}</span>
+                      <span class="pull-right">{{format-column-type column}}</span>
                     </div>
                     </div>
                   {{/each}}
                   {{/each}}
                   {{#if table.canGetNextPage}}
                   {{#if table.canGetNextPage}}