You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hawq.apache.org by hu...@apache.org on 2016/09/20 08:35:04 UTC

incubator-hawq git commit: HAWQ-1035. Add ddl of partition table for hawq register.

Repository: incubator-hawq
Updated Branches:
  refs/heads/master 50c1aa9ea -> f676c58e4


HAWQ-1035. Add ddl of partition table for 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/f676c58e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-hawq/tree/f676c58e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-hawq/diff/f676c58e

Branch: refs/heads/master
Commit: f676c58e4d9f007b13e0e21942134c936c6cb94d
Parents: 50c1aa9
Author: hzhang2 <zh...@163.com>
Authored: Tue Sep 20 12:58:14 2016 +0800
Committer: hzhang2 <zh...@163.com>
Committed: Tue Sep 20 16:34:39 2016 +0800

----------------------------------------------------------------------
 tools/bin/hawqregister | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-hawq/blob/f676c58e/tools/bin/hawqregister
----------------------------------------------------------------------
diff --git a/tools/bin/hawqregister b/tools/bin/hawqregister
index bdd6947..89e9f4b 100755
--- a/tools/bin/hawqregister
+++ b/tools/bin/hawqregister
@@ -133,17 +133,31 @@ class GpRegisterAccessor(object):
         qry = """select count(*) from pg_class where relname = '%s';""" % tablename.split('.')[-1].lower()
         return self.exec_query(qry)[0]['count'] == 1
 
-    def do_create_table(self, tablename, schema_info, fmt, distrbution_policy, file_locations, bucket_number):
+    def do_create_table(self, tablename, schema_info, fmt, distrbution_policy, file_locations, bucket_number, partitionby, partitions_constraint, partitions_name):
         if self.get_table_existed(tablename):
             return False
         schema = ','.join([k['name'] + ' ' + k['type'] for k in schema_info])
+        partlist = ""
+        for index in range(len(partitions_constraint)):
+          if index > 0:
+              partlist += ", "
+          partlist = partlist + "partition " + partitions_name[index] + " " + partitions_constraint[index]
+          
         fmt = 'ROW' if fmt == 'AO' else fmt
         if fmt == 'ROW':
-            query = ('create table %s(%s) with (appendonly=true, orientation=%s, compresstype=%s, compresslevel=%s, checksum=%s, bucketnum=%s) %s;'
-                     % (tablename, schema, fmt, file_locations['CompressionType'], file_locations['CompressionLevel'], file_locations['Checksum'], bucket_number, distrbution_policy))
+            if partitionby is None:
+                query = ('create table %s(%s) with (appendonly=true, orientation=%s, compresstype=%s, compresslevel=%s, checksum=%s, bucketnum=%s) %s;'
+                         % (tablename, schema, fmt, file_locations['CompressionType'], file_locations['CompressionLevel'], file_locations['Checksum'], bucket_number, distrbution_policy))
+            else:
+                query = ('create table %s(%s) with (appendonly=true, orientation=%s, compresstype=%s, compresslevel=%s, checksum=%s, bucketnum=%s) %s %s (%s);'
+                         % (tablename, schema,fmt, file_locations['CompressionType'], file_locations['CompressionLevel'], file_locations['Checksum'], bucket_number, distrbution_policy, partitionby, partlist))
         else: # Parquet
-            query = ('create table %s(%s) with (appendonly=true, orientation=%s, compresstype=%s, compresslevel=%s, pagesize=%s, rowgroupsize=%s, bucketnum=%s) %s;'
-                     % (tablename, schema, fmt, file_locations['CompressionType'], file_locations['CompressionLevel'], file_locations['PageSize'], file_locations['RowGroupSize'], bucket_number, distrbution_policy))
+            if partitionby is None:
+                query = ('create table %s(%s) with (appendonly=true, orientation=%s, compresstype=%s, compresslevel=%s, pagesize=%s, rowgroupsize=%s, bucketnum=%s) %s;'
+                         % (tablename, schema, fmt, file_locations['CompressionType'], file_locations['CompressionLevel'], file_locations['PageSize'], file_locations['RowGroupSize'], bucket_number, distrbution_policy))
+            else:
+                query = ('create table %s(%s) with (appendonly=true, orientation=%s, compresstype=%s, compresslevel=%s, pagesize=%s, rowgroupsize=%s, bucketnum=%s) %s %s (%s);'
+                         % (tablename, schema, fmt, file_locations['CompressionType'], file_locations['CompressionLevel'], file_locations['PageSize'], file_locations['RowGroupSize'], bucket_number, distrbution_policy, partitionby, partlist))
         self.conn.query(query)
         return True
 
@@ -266,7 +280,8 @@ class HawqRegister(object):
                 sys.exit(1)
 
         def create_table():
-            return self.accessor.do_create_table(self.tablename, self.schema, self.file_format, self.distribution_policy, self.file_locations, self.bucket_number)
+            return self.accessor.do_create_table(self.tablename, self.schema, self.file_format, self.distribution_policy, self.file_locations, self.bucket_number,
+                                                 self.partitionby, self.partitions_constraint, self.partitions_name)
 
         def get_seg_name():
             return self.utility_accessor.get_seg_name(self.tablename, self.database, self.file_format)