You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by du...@apache.org on 2022/08/24 08:46:38 UTC

[shardingsphere] branch master updated: Add default template (#20484)

This is an automated email from the ASF dual-hosted git repository.

duanzhengqiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git


The following commit(s) were added to refs/heads/master by this push:
     new 5a2a42bd477 Add default template (#20484)
5a2a42bd477 is described below

commit 5a2a42bd477a278a1749bc1aee4359dad8851648
Author: Chuxin Chen <ch...@qq.com>
AuthorDate: Wed Aug 24 16:46:29 2022 +0800

    Add default template (#20484)
---
 .../check_constraint/default/properties.ftl        |  27 ++++++
 .../component/columns/default/properties.ftl       |  51 ++++++++++
 .../default/get_constraint_cols.ftl                |  40 ++++++++
 .../component/foreign_key/default/properties.ftl   |  47 ++++++++++
 .../template/component/table/default/create.ftl    | 103 +++++++++++++++++++++
 .../table/default/get_columns_for_table.ftl        |  36 +++++++
 .../component/table/default/get_inherits.ftl       |  29 ++++++
 .../component/table/default/properties.ftl         |  84 +++++++++++++++++
 8 files changed, 417 insertions(+)

diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/check_constraint/default/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/check_constraint/default/properties.ftl
new file mode 100644
index 00000000000..fc35cd5b71f
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/check_constraint/default/properties.ftl
@@ -0,0 +1,27 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT c.oid, conname as name, relname, nspname, description as comment,
+pg_catalog.pg_get_expr(conbin, conrelid, true) as consrc, conislocal
+FROM pg_catalog.pg_constraint c
+JOIN pg_catalog.pg_class cl ON cl.oid=conrelid
+JOIN pg_catalog.pg_namespace nl ON nl.oid=relnamespace
+LEFT OUTER JOIN
+pg_catalog.pg_description des ON (des.objoid=c.oid AND
+des.classoid='pg_constraint'::regclass)
+WHERE contype = 'c'
+AND conrelid = ${ tid?c }::oid
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/columns/default/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/columns/default/properties.ftl
new file mode 100644
index 00000000000..0809fba0375
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/columns/default/properties.ftl
@@ -0,0 +1,51 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT att.attname as name, att.*, def.*, pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval,
+CASE WHEN att.attndims > 0 THEN 1 ELSE 0 END AS isarray,
+pg_catalog.format_type(ty.oid,NULL) AS typname,
+pg_catalog.format_type(ty.oid,att.atttypmod) AS displaytypname,
+CASE WHEN ty.typelem > 0 THEN ty.typelem ELSE ty.oid END as elemoid,
+tn.nspname as typnspname, et.typname as elemtypname,
+ty.typstorage AS defaultstorage, cl.relname, na.nspname,
+pg_catalog.quote_ident(na.nspname) || '.' || pg_catalog.quote_ident(cl.relname) AS parent_tbl,
+att.attstattarget, description, cs.relname AS sername,
+ns.nspname AS serschema,
+(SELECT count(1) FROM pg_catalog.pg_type t2 WHERE t2.typname=ty.typname) > 1 AS isdup,
+indkey, NULL as attoptions,
+pg_catalog.format_type(ty.oid,att.atttypmod) AS cltype,
+EXISTS(SELECT 1 FROM pg_catalog.pg_constraint WHERE conrelid=att.attrelid AND contype='f' AND att.attnum=ANY(conkey)) As is_fk,
+NULL AS seclabels,
+(CASE WHEN (att.attnum < 1) THEN true ElSE false END) AS is_sys_column
+FROM pg_catalog.pg_attribute att
+JOIN pg_catalog.pg_type ty ON ty.oid=atttypid
+JOIN pg_catalog.pg_namespace tn ON tn.oid=ty.typnamespace
+JOIN pg_catalog.pg_class cl ON cl.oid=att.attrelid
+JOIN pg_catalog.pg_namespace na ON na.oid=cl.relnamespace
+LEFT OUTER JOIN pg_catalog.pg_type et ON et.oid=ty.typelem
+LEFT OUTER JOIN pg_catalog.pg_attrdef def ON adrelid=att.attrelid AND adnum=att.attnum
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=att.attrelid AND des.objsubid=att.attnum AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN (pg_catalog.pg_depend JOIN pg_catalog.pg_class cs ON classid='pg_class'::regclass AND objid=cs.oid AND cs.relkind='S') ON refobjid=att.attrelid AND refobjsubid=att.attnum
+LEFT OUTER JOIN pg_catalog.pg_namespace ns ON ns.oid=cs.relnamespace
+LEFT OUTER JOIN pg_catalog.pg_index pi ON pi.indrelid=att.attrelid AND indisprimary
+WHERE att.attrelid = ${tid?c}::oid
+<#if clid?? >
+AND att.attnum = ${clid?c}::int
+</#if>
+AND att.attnum > 0
+AND att.attisdropped IS FALSE
+ORDER BY att.attnum;
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/exclusion_constraint/default/get_constraint_cols.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/exclusion_constraint/default/get_constraint_cols.ftl
new file mode 100644
index 00000000000..eaeb7e104be
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/exclusion_constraint/default/get_constraint_cols.ftl
@@ -0,0 +1,40 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<#list (0..colcnt) as n >
+<#if n?counter != 1 >
+UNION
+</#if>
+SELECT
+i.indoption[${n?index}] AS options,
+pg_catalog.pg_get_indexdef(i.indexrelid, ${n?counter}, true) AS coldef,
+op.oprname,
+CASE WHEN (o.opcdefault = FALSE) THEN o.opcname ELSE null END AS opcname
+,
+coll.collname,
+nspc.nspname as collnspname,
+pg_catalog.format_type(ty.oid,NULL) AS datatype,
+CASE WHEN pg_catalog.pg_get_indexdef(i.indexrelid, ${n?counter}, true) = a.attname THEN FALSE ELSE TRUE END AS is_exp
+FROM pg_catalog.pg_index i
+JOIN pg_catalog.pg_attribute a ON (a.attrelid = i.indexrelid AND attnum = ${n?counter})
+JOIN pg_catalog.pg_type ty ON ty.oid=a.atttypid
+LEFT OUTER JOIN pg_catalog.pg_opclass o ON (o.oid = i.indclass[${n?index}])
+LEFT OUTER JOIN pg_catalog.pg_constraint c ON (c.conindid = i.indexrelid) LEFT OUTER JOIN pg_catalog.pg_operator op ON (op.oid = c.conexclop[${n?counter}])
+LEFT OUTER JOIN pg_catalog.pg_collation coll ON a.attcollation=coll.oid
+LEFT OUTER JOIN pg_catalog.pg_namespace nspc ON coll.collnamespace=nspc.oid
+WHERE i.indexrelid = ${cid}::oid
+</#list>
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/foreign_key/default/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/foreign_key/default/properties.ftl
new file mode 100644
index 00000000000..63270ede055
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/foreign_key/default/properties.ftl
@@ -0,0 +1,47 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT
+convalidated,
+ct.oid,
+conname as name,
+condeferrable,
+condeferred,
+confupdtype,
+confdeltype,
+CASE confmatchtype
+WHEN 's' THEN FALSE
+WHEN 'f' THEN TRUE
+END AS confmatchtype,
+conkey,
+confkey,
+confrelid,
+nl.nspname as fknsp,
+cl.relname as fktab,
+nr.nspname as refnsp,
+cr.relname as reftab,
+description as comment,
+conislocal
+FROM pg_catalog.pg_constraint ct
+JOIN pg_catalog.pg_class cl ON cl.oid=conrelid
+JOIN pg_catalog.pg_namespace nl ON nl.oid=cl.relnamespace
+JOIN pg_catalog.pg_class cr ON cr.oid=confrelid
+JOIN pg_catalog.pg_namespace nr ON nr.oid=cr.relnamespace
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=ct.oid AND des.classoid='pg_constraint'::regclass)
+WHERE contype='f' AND
+conrelid = ${tid?c}::oid
+ORDER BY conname
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/create.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/create.ftl
new file mode 100644
index 00000000000..279a104145f
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/create.ftl
@@ -0,0 +1,103 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<#import "../../../macro/constraints.ftl" as CONSTRAINTS>
+CREATE <#if relpersistence!false >UNLOGGED </#if>TABLE IF NOT EXISTS ${schema}.${name}
+<#if typname?? >
+OF ${typname }
+</#if>
+<#if like_relation?? || coll_inherits?size gt 0 || columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 || exclude_constraint?size gt 0 >
+(
+</#if>
+<#if like_relation?? >
+LIKE ${like_relation }<#if like_default_value!false >
+INCLUDING DEFAULTS</#if><#if like_constraints!false >
+INCLUDING CONSTRAINTS</#if><#if like_indexes!false >
+INCLUDING INDEXES</#if><#if like_storage!false >
+INCLUDING STORAGE</#if><#if  like_comments!false >
+INCLUDING COMMENTS</#if><#if  columns?size gt 0 >,
+</#if>
+</#if>
+<#if columns?? && columns?size gt 0 >
+<#list columns as c >
+<#if c.name?? && c.cltype?? >
+<#if c.inheritedfromtable?? >-- Inherited from table ${c.inheritedfromtable}: <#elseif c.inheritedfromtype?? >-- Inherited from type ${c.inheritedfromtype}: </#if>${c.name} ${c.displaytypname}<#if c.collspcname?? && c.collspcname?length gt 0 > COLLATE ${c.collspcname}</#if><#if c.attnotnull!false > NOT NULL</#if><#if c.defval?? && c.defval != ''> DEFAULT ${c.defval}</#if>
+<#if c.colconstype?? && c.colconstype == 'i' && c.attidentity?? && c.attidentity != '' >
+<#if c.attidentity?? &&  c.attidentity == 'a' > GENERATED ALWAYS AS IDENTITY<#elseif c.attidentity?? && c.attidentity == 'd' > GENERATED BY DEFAULT AS IDENTITY</#if>
+<#if c.seqincrement?? || c.seqcycle!false || c.seqincrement?? || c.seqstart?? || c.seqmin?? || c.seqmax?? || c.seqcache?? > ( </#if>
+<#if c.seqcycle!false >
+CYCLE </#if><#if c.seqincrement?? && c.seqincrement?number gt -1 >
+INCREMENT ${c.seqincrement} </#if><#if c.seqstart?? && c.seqstart?number gt -1>
+START ${c.seqstart} </#if><#if c.seqmin?? && c.seqmin?number gt -1>
+MINVALUE ${c.seqmin} </#if><#if c.seqmax?? && c.seqmax?number gt -1>
+MAXVALUE ${c.seqmax} </#if><#if c.seqcache?? && c.seqcache?number gt -1>
+CACHE ${c.seqcache} </#if>
+<#if c.seqincrement?? || c.seqcycle!false || c.seqincrement?? || c.seqstart?? || c.seqmin?? || c.seqmax?? || c.seqcache?? >)</#if>
+</#if>
+<#if c?counter lt columns?size>,
+</#if>
+</#if>
+</#list>
+</#if>
+<#if primary_key?size gt 0 ><#if columns?size gt 0 >,</#if>
+<@CONSTRAINTS.PRIMARY_KEY data=primary_key[0] /></#if><#if unique_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 >,</#if>
+<@CONSTRAINTS.UNIQUE unique_data=unique_constraint /></#if><#if foreign_key?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 >,</#if>
+<@CONSTRAINTS.FOREIGN_KEY foreign_key_data=foreign_key /></#if><#if check_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 >,</#if>
+<@CONSTRAINTS.CHECK check_data=check_constraint/></#if><#if exclude_constraint?size gt 0 ><#if columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 >,</#if>
+<@CONSTRAINTS.EXCLUDE exclude_data=exclude_constraint/></#if>
+<#if like_relation?? || coll_inherits?size gt 0 || columns?size gt 0 || primary_key?size gt 0 || unique_constraint?size gt 0 || foreign_key?size gt 0 || check_constraint?size gt 0 || exclude_constraint?size gt 0 >
+)</#if><#if relkind?? && relkind == 'p' > PARTITION BY ${ partition_scheme }</#if>
+<#if coll_inherits?? && coll_inherits?size gt 0>
+INHERITS (<#list coll_inherits as val ><#if val?counter != 1 >, </#if>${val}</#list>)
+</#if>
+WITH (
+OIDS = <#if relhasoids!false >TRUE<#else>FALSE</#if><#if fillfactor?? >,
+FILLFACTOR = ${ fillfactor }</#if><#if parallel_workers?? && parallel_workers != '' >,
+autovacuum_enabled = <#if autovacuum_enabled == 't' >TRUE<#else >FALSE</#if></#if><#if toast_autovacuum_enabled?? && (toast_autovacuum_enabled == 't' || toast_autovacuum_enabled == 'f')  >,
+toast.autovacuum_enabled = <#if toast_autovacuum_enabled == 't' >TRUE<#else >FALSE</#if>
+</#if><#if autovacuum_custom!false && vacuum_table?size gt 0 >
+<#list vacuum_table as opt ><#if opt.name?? && opt.value?? >
+,
+${opt.name} = ${opt.value}</#if>
+</#list></#if><#if toast_autovacuum!false && vacuum_toast?size gt 0 >
+<#list vacuum_toast as opt ><#if opt.name?? && opt.value?? >
+,
+toast.${opt.name} = ${opt.value}</#if>
+</#list></#if>
+<#if spcname?? >
+)
+TABLESPACE ${spcname };
+<#else>
+);
+</#if>
+<#if description?? >
+COMMENT ON TABLE ${schema}.${name}
+IS '${description}';
+</#if>
+<#if columns?? && columns?size gt 0 >
+<#list columns as c >
+<#if c.description?? >
+COMMENT ON COLUMN ${schema}.${name}.${c.name}
+IS '${c.description}';
+</#if>
+</#list>
+</#if>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=primary_key/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=unique_constraint/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=foreign_key/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=check_constraint/>
+<@CONSTRAINTS.CONSTRAINT_COMMENTS schema=schema table=name data=exclude_constraint/>
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/get_columns_for_table.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/get_columns_for_table.ftl
new file mode 100644
index 00000000000..95e1b1802d3
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/get_columns_for_table.ftl
@@ -0,0 +1,36 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT
+    a.attname AS name, pg_catalog.format_type(a.atttypid, NULL) AS cltype,
+    pg_catalog.pg_get_expr(def.adbin, def.adrelid) AS defval,
+    pg_catalog.quote_ident(n.nspname)||'.'||pg_catalog.quote_ident(c.relname) as inheritedfrom,
+    c.oid as inheritedid
+FROM
+    pg_catalog.pg_class c
+JOIN
+    pg_catalog.pg_namespace n ON c.relnamespace=n.oid
+JOIN
+    pg_catalog.pg_attribute a ON a.attrelid = c.oid AND NOT a.attisdropped AND a.attnum > 0
+LEFT OUTER JOIN
+    pg_catalog.pg_attrdef def ON adrelid=a.attrelid AND adnum=a.attnum
+WHERE
+<#if tid?? >
+    c.oid = ${tid?c}::OID
+<#else >
+    c.relname = '${tname}'
+</#if>
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/get_inherits.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/get_inherits.ftl
new file mode 100644
index 00000000000..bb4e839411b
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/get_inherits.ftl
@@ -0,0 +1,29 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<#import "../../../macro/db_catalogs.ftl" as CATALOG>
+SELECT c.oid, c.relname , nspname,
+CASE WHEN nspname NOT LIKE 'pg\_%' THEN
+pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname)
+ELSE pg_catalog.quote_ident(c.relname)
+END AS inherits
+FROM pg_catalog.pg_class c
+JOIN pg_catalog.pg_namespace n
+ON n.oid=c.relnamespace
+WHERE relkind='r'
+<@CATALOG.VALID_CATALOGS server_type />
+ORDER BY relnamespace, c.relname
diff --git a/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/properties.ftl b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/properties.ftl
new file mode 100644
index 00000000000..38af8b822e0
--- /dev/null
+++ b/shardingsphere-kernel/shardingsphere-data-pipeline/shardingsphere-data-pipeline-dialect/shardingsphere-data-pipeline-postgresql/src/main/resources/template/component/table/default/properties.ftl
@@ -0,0 +1,84 @@
+<#--
+  ~ Licensed to the Apache Software Foundation (ASF) under one or more
+  ~ contributor license agreements.  See the NOTICE file distributed with
+  ~ this work for additional information regarding copyright ownership.
+  ~ The ASF licenses this file to You under the Apache License, Version 2.0
+  ~ (the "License"); you may not use this file except in compliance with
+  ~ the License.  You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+SELECT *,
+(CASE when pre_coll_inherits is NULL then ARRAY[]::varchar[] else pre_coll_inherits END) as coll_inherits
+FROM (
+SELECT rel.oid, rel.relname AS name, rel.reltablespace AS spcoid,rel.relacl AS relacl_str,
+(CASE WHEN length(spc.spcname::text) > 0 THEN spc.spcname ELSE
+(SELECT sp.spcname FROM pg_catalog.pg_database dtb
+JOIN pg_catalog.pg_tablespace sp ON dtb.dattablespace=sp.oid
+WHERE dtb.oid = ${ did?c }::oid)
+END) as spcname,
+(select nspname FROM pg_catalog.pg_namespace WHERE oid = ${scid?c}::oid ) as schema,
+pg_catalog.pg_get_userbyid(rel.relowner) AS relowner, rel.relhasoids,
+rel.relhassubclass, rel.reltuples::bigint, des.description, con.conname, con.conkey,
+EXISTS(select 1 FROM pg_catalog.pg_trigger
+JOIN pg_catalog.pg_proc pt ON pt.oid=tgfoid AND pt.proname='logtrigger'
+JOIN pg_catalog.pg_proc pc ON pc.pronamespace=pt.pronamespace AND pc.proname='slonyversion'
+WHERE tgrelid=rel.oid) AS isrepl,
+(SELECT count(*) FROM pg_catalog.pg_trigger WHERE tgrelid=rel.oid) AS triggercount,
+(SELECT ARRAY(SELECT CASE WHEN (nspname NOT LIKE 'pg\_%') THEN
+pg_catalog.quote_ident(nspname)||'.'||pg_catalog.quote_ident(c.relname)
+ELSE pg_catalog.quote_ident(c.relname) END AS inherited_tables
+FROM pg_catalog.pg_inherits i
+JOIN pg_catalog.pg_class c ON c.oid = i.inhparent
+JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+WHERE i.inhrelid = rel.oid ORDER BY inhseqno)) AS pre_coll_inherits,
+(SELECT count(*)
+FROM pg_catalog.pg_inherits i
+JOIN pg_catalog.pg_class c ON c.oid = i.inhparent
+JOIN pg_catalog.pg_namespace n ON n.oid=c.relnamespace
+WHERE i.inhrelid = rel.oid) AS inherited_tables_cnt,
+false AS relpersistence,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'fillfactor=([0-9]*)') AS fillfactor,
+(substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS autovacuum_enabled,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS autovacuum_vacuum_threshold,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_vacuum_scale_factor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS autovacuum_analyze_threshold,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS autovacuum_analyze_scale_factor,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS autovacuum_vacuum_cost_delay,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS autovacuum_vacuum_cost_limit,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS autovacuum_freeze_min_age,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS autovacuum_freeze_max_age,
+substring(pg_catalog.array_to_string(rel.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS autovacuum_freeze_table_age,
+(substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_enabled=([a-z|0-9]*)'))::BOOL AS toast_autovacuum_enabled,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_threshold=([0-9]*)') AS toast_autovacuum_vacuum_threshold,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_vacuum_scale_factor,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_threshold=([0-9]*)') AS toast_autovacuum_analyze_threshold,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_analyze_scale_factor=([0-9]*[.]?[0-9]*)') AS toast_autovacuum_analyze_scale_factor,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_delay=([0-9]*)') AS toast_autovacuum_vacuum_cost_delay,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_vacuum_cost_limit=([0-9]*)') AS toast_autovacuum_vacuum_cost_limit,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_min_age=([0-9]*)') AS toast_autovacuum_freeze_min_age,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_max_age=([0-9]*)') AS toast_autovacuum_freeze_max_age,
+substring(pg_catalog.array_to_string(tst.reloptions, ',') FROM 'autovacuum_freeze_table_age=([0-9]*)') AS toast_autovacuum_freeze_table_age,
+rel.reloptions AS reloptions, tst.reloptions AS toast_reloptions, NULL AS reloftype, NULL AS typname,
+typ.typrelid AS typoid, rel.relrowsecurity as rlspolicy, rel.relforcerowsecurity as forcerlspolicy,
+(CASE WHEN rel.reltoastrelid = 0 THEN false ELSE true END) AS hastoasttable,
+ARRAY[]::varchar[] AS seclabels,
+(CASE WHEN rel.oid <= ${ datlastsysoid?c}::oid THEN true ElSE false END) AS is_sys_table
+
+FROM pg_catalog.pg_class rel
+LEFT OUTER JOIN pg_catalog.pg_tablespace spc on spc.oid=rel.reltablespace
+LEFT OUTER JOIN pg_catalog.pg_description des ON (des.objoid=rel.oid AND des.objsubid=0 AND des.classoid='pg_class'::regclass)
+LEFT OUTER JOIN pg_catalog.pg_constraint con ON con.conrelid=rel.oid AND con.contype='p'
+LEFT OUTER JOIN pg_catalog.pg_class tst ON tst.oid = rel.reltoastrelid
+
+WHERE rel.relkind IN ('r','s','t') AND rel.relnamespace = ${ scid?c }
+<#if tid?? >  AND rel.oid = ${ tid?c }::oid </#if>
+) AS TableInformation
+ORDER BY name