Browse Source

HUE-5939 [metastore] Add decimal to the list of available types

Adrian Yavorskyy 8 years ago
parent
commit
c9952aa

File diff suppressed because it is too large
+ 0 - 0
desktop/libs/indexer/src/indexer/create_table_tests.py


+ 3 - 1
desktop/libs/indexer/src/indexer/fields.py

@@ -67,7 +67,9 @@ class Field(object):
       'keyType': 'string',
       'keyType': 'string',
       'isPartition': False,
       'isPartition': False,
       'partitionValue': '',
       'partitionValue': '',
-      'comment': ''
+      'comment': '',
+      'scale': 0,
+      'precision': 10
     }
     }
 
 
 FIELD_TYPES = [
 FIELD_TYPES = [

+ 2 - 0
desktop/libs/indexer/src/indexer/templates/gen/create_table_statement.mako

@@ -26,6 +26,8 @@ def col_type(col):
     return "char(%s)" % col["length"]
     return "char(%s)" % col["length"]
   elif col["type"] == "varchar":
   elif col["type"] == "varchar":
     return "varchar(%s)" % col["length"]
     return "varchar(%s)" % col["length"]
+  elif col["type"] == "decimal":
+    return "decimal(%s, %s)" % (col["precision"], col["scale"])
   return col["type"]
   return col["type"]
 
 
 %>
 %>

+ 4 - 0
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -797,6 +797,10 @@ ${ assist.assistPanel() }
     <!-- /ko -->
     <!-- /ko -->
 
 
       <input type="number" class="input-small" placeholder="${ _('Length') }" data-bind="value: length, visible: type() == 'varchar' || type() == 'char'">
       <input type="number" class="input-small" placeholder="${ _('Length') }" data-bind="value: length, visible: type() == 'varchar' || type() == 'char'">
+      <!-- ko if: $parent.type() == 'decimal' -->
+        <input type="number" class="input-small" placeholder="${ _('Precision') }" data-bind="value: precision">
+        <input type="number" class="input-small" placeholder="${ _('Scale') }" data-bind="value: scale">
+      <!-- /ko -->
     </label>
     </label>
 
 
     <!-- ko if: $root.createWizard.source.inputFormat() != 'manual' && typeof isPartition !== 'undefined' && isPartition() -->
     <!-- ko if: $root.createWizard.source.inputFormat() != 'manual' && typeof isPartition !== 'undefined' && isPartition() -->

+ 1 - 1
desktop/libs/indexer/src/indexer/views.py

@@ -79,7 +79,7 @@ def indexer(request):
 
 
 HIVE_PRIMITIVE_TYPES = \
 HIVE_PRIMITIVE_TYPES = \
     ("string", "tinyint", "smallint", "int", "bigint", "boolean",
     ("string", "tinyint", "smallint", "int", "bigint", "boolean",
-      "float", "double", "timestamp", "date", "char", "varchar")
+      "float", "double", "decimal", "timestamp", "date", "char", "varchar")
 HIVE_TYPES = HIVE_PRIMITIVE_TYPES + ("array", "map", "struct")
 HIVE_TYPES = HIVE_PRIMITIVE_TYPES + ("array", "map", "struct")
 
 
 
 

Some files were not shown because too many files changed in this diff