Repository: incubator-hawq
Updated Branches:
  refs/heads/master 107b79dfe -> dc12e94b4


HAWQ-1061. Bugfix for --force mode of hawq register.


Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/25e082aa
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/25e082aa
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/25e082aa

Branch: refs/heads/master
Commit: 25e082aaf24df7a8b54fae930d633cb20c0373d5
Parents: 107b79d
Author: xunzhang <xunzhang...@gmail.com>
Authored: Thu Sep 22 14:38:48 2016 +0800
Committer: xunzhang <xunzhang...@gmail.com>
Committed: Thu Sep 22 14:38:48 2016 +0800

----------------------------------------------------------------------
 tools/bin/hawqregister | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/25e082aa/tools/bin/hawqregister
----------------------------------------------------------------------
diff --git a/tools/bin/hawqregister b/tools/bin/hawqregister
index bef1460..1a6b5d3 100755
--- a/tools/bin/hawqregister
+++ b/tools/bin/hawqregister
@@ -301,9 +301,9 @@ class HawqRegister(object):
                     sys.exit(1)
                 return 'repair'
             else:
-                return 'second_normal'
+                return 'usage2_table_not_exist'
         else:
-            return 'first'
+            return 'usage1'
 
     def _init(self):
         def check_hash_type():
@@ -463,7 +463,7 @@ class HawqRegister(object):
             check_database_encoding()
             if self.mode != 'force' and self.mode != 'repair':
                 if not create_table():
-                    self.mode = 'second_exist'
+                    self.mode = 'usage2_table_exist'
             check_bucket_number()
             check_distribution_policy()
             check_policy_consistency()
@@ -471,7 +471,7 @@ class HawqRegister(object):
             self.file_format = 'Parquet'
             check_hash_type() # Usage1 only support randomly distributed table
         if not self.filepath:
-            if self.mode == 'first':
+            if self.mode == 'usage1':
                 logger.info('Please specify filepath with -f option.')
             else:
                 logger.info('Hawq Register Succeed.')
@@ -496,7 +496,7 @@ class HawqRegister(object):
                     logger.error('Can not register in repair mode since giving 
larger file size: %s' % self.sizes[k])
                     sys.exit(1)
 
-        if self.mode == 'second_exist':
+        if self.mode == 'usage2_table_exist':
             if self.tabledir.strip('/') == self.filepath.strip('/'):
                 logger.error('Files to be registered should not be the same 
with table path.')
                 sys.exit(1)
@@ -511,6 +511,9 @@ class HawqRegister(object):
                 else:
                     self.do_not_move, self.files_update, self.sizes_update = 
True, self.files, self.sizes
                     self.files, self.sizes = [], []
+            elif len(self.files) < len(existed_files):
+                logger.error('In force mode, you should include existing table 
files in yaml configuration file. Otherwise you should drop the previous table 
before register --force.')
+                sys.exit(1)
             else:
                 files_old, sizes_old = [f for f in self.files], [sz for sz in 
self.sizes]
                 for k, f in enumerate(files_old):
@@ -519,6 +522,10 @@ class HawqRegister(object):
                         self.sizes_update.append(sizes_old[k])
                         self.files.remove(files_old[k])
                         self.sizes.remove(sizes_old[k])
+                if sorted(self.files_update) != sorted(existed_files):
+                    logger.error('In force mode, you should include existing 
table files in yaml configuration file. Otherwise you should drop the previous 
table before register --force.')
+                    sys.exit(1)
+
         elif self.mode == 'repair':
             self.do_not_move = True
             self.files_update, self.sizes_update = [fn for fn in self.files], 
[sz for sz in self.sizes]

Reply via email to