瀏覽代碼

HUE-5988 [importer] Add partition values logic into the indexer front end

Romain Rigaux 8 年之前
父節點
當前提交
6049961670

+ 2 - 0
desktop/libs/indexer/src/indexer/api3.py

@@ -324,6 +324,8 @@ def _create_table_from_a_file(request, source, destination):
 
   if table_format in ('text', 'json', 'csv', 'regexp') and not external and load_data:
     sql += "\n\nLOAD DATA INPATH '%s' INTO TABLE `%s`.`%s`;" % (source_path, database, table_name)
+    # TODO partition_columns
+    # cf metastore load_data
 
   if load_data and table_format in ('parquet', 'kudu'):
     file_format = table_format

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

@@ -66,6 +66,7 @@ class Field(object):
       'length': 100,
       'keyType': 'string',
       'isPartition': False,
+      'partitionValue': '',
       'comment': ''
     }
 

+ 13 - 3
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -802,6 +802,12 @@ ${ assist.assistPanel() }
       <input type="number" class="input-small" placeholder="${ _('Length') }" data-bind="value: length, visible: type() == 'varchar' || type() == 'char'">
     </label>
 
+    <!-- ko if: $root.createWizard.source.inputFormat() != 'manual' && typeof isPartition !== 'undefined' && isPartition() -->
+      <label class="margin-left-5">${ _('Value') }&nbsp;
+        <input type="text" class="input-medium margin-left-5" placeholder="${ _('Partition value') }" data-bind="value: partitionValue">
+      </label>
+    <!-- /ko -->
+
     <span data-bind="visible: level() == 0 || ($parent.type() != 'array' && $parent.type() != 'map')">
       <a href="javascript:void(0)" title="${ _('Show field properties') }" data-bind="css: {'inactive-action': !showProperties()}, click: function() {showProperties(!showProperties()) }"><i class="fa fa-sliders"></i></a>
 
@@ -1509,9 +1515,13 @@ ${ assist.assistPanel() }
       self.readyToIndex = ko.computed(function () {
         var validFields = self.destination.columns().length || self.destination.outputFormat() == 'database';
         var validDestination = self.destination.name().length > 0 && (['table', 'database'].indexOf(self.destination.outputFormat()) == -1 || /^([a-zA-Z0-9_]+\.)?[a-zA-Z0-9_]+$/.test(self.destination.name()));
-        var validTableColumns = self.destination.outputFormat() != 'table' || $.grep(self.destination.columns(), function(column) {
-          return column.name().length == 0;
-        }).length == 0;
+        var validTableColumns = self.destination.outputFormat() != 'table' || ($.grep(self.destination.columns(), function(column) {
+            return column.name().length == 0;
+          }).length == 0
+          && $.grep(self.destination.partitionColumns(), function(column) {
+            return column.name().length == 0 || (self.source.inputFormat() != 'manual' && column.partitionValue().length == 0);
+          }).length == 0
+        );
         var isTargetAlreadyExisting = ! self.destination.isTargetExisting() || self.destination.outputFormat() == 'index';
         var isValidTable = self.destination.outputFormat() != 'table' || (
           self.destination.tableFormat() != 'kudu' || (self.destination.kuduPartitionColumns().length > 0 &&