Repository: incubator-hawq Updated Branches: refs/heads/master 5a152dcdd -> 21b867a10
HAWQ-1061. Ensure filepath is not regex-like. Project: http://git-wip-us.apache.org/repos/asf/incubator-hawq/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-hawq/commit/21b867a1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/21b867a1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/21b867a1 Branch: refs/heads/master Commit: 21b867a10322c75e3a8b18a5f502a9e16c2e58d4 Parents: 06412f3 Author: xunzhang <[email protected]> Authored: Thu Sep 22 22:13:34 2016 +0800 Committer: Lili Ma <[email protected]> Committed: Fri Sep 23 10:36:39 2016 +0800 ---------------------------------------------------------------------- tools/bin/hawqregister | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/21b867a1/tools/bin/hawqregister ---------------------------------------------------------------------- diff --git a/tools/bin/hawqregister b/tools/bin/hawqregister index 65a5e44..08041b4 100755 --- a/tools/bin/hawqregister +++ b/tools/bin/hawqregister @@ -316,7 +316,11 @@ class HawqRegister(object): else: return 'usage2_table_not_exist' else: - return 'usage1' + if not table_existed(): + logger.error('You should create table before registering the data.') + sys.exit(1) + else: + return 'usage1' def _init(self): def check_hash_type(): @@ -480,6 +484,18 @@ class HawqRegister(object): logger.error('File size(%s) in yaml configuration file should not exceed actual length(%s) of file %s.' % (self.sizes[k], out.strip().split()[0], fn)) sys.exit(1) + def check_no_regex_filepath(files): + for fn in files: + tmp_lst = fn.split('/') + for v in tmp_lst: + if v == '.': + logger.error('Hawq register does not support file path with regex: %s.' % fn) + sys.exit(1) + for ch in ['..', '*']: + if fn.find(ch) != -1: + logger.error('Hawq register does not support file path with regex: %s.' % fn) + sys.exit(1) + if self.yml: option_parser_yml(options.yml_config) self.filepath = self.files[0][:self.files[0].rfind('/')] if self.files else '' @@ -491,6 +507,7 @@ class HawqRegister(object): check_bucket_number() check_distribution_policy() check_policy_consistency() + check_no_regex_filepath(self.files) else: self.file_format = 'Parquet' check_hash_type() # Usage1 only support randomly distributed table @@ -562,6 +579,7 @@ class HawqRegister(object): self._check_files_and_table_in_same_hdfs_cluster(self.filepath, self.tabledir) if not self.yml: + check_no_regex_filepath([self.filepath]) self.files, self.sizes = self._get_files_in_hdfs(self.filepath) print 'New file(s) to be registered: ', self.files if self.files_update:
