Skip to content

Commit

Permalink
[Bug] [connector-jdbc] PostgresCatalog's SELECT_COLUMNS_SQL_TEMPLATE …
Browse files Browse the repository at this point in the history
…have some issues (apache#6054)
  • Loading branch information
zhuqy committed Jan 16, 2024
1 parent d816e2a commit 98bf86c
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ public class SqlServerCatalog extends AbstractJdbcCatalog {
+ " col.ORDINAL_POSITION AS column_id,\n"
+ " col.DATA_TYPE AS type,\n"
+ " CASE WHEN col.DATA_TYPE in ('nchar','nvarchar','ntext') THEN col.CHARACTER_MAXIMUM_LENGTH\n"
+ " ELSE col.CHARACTER_OCTET_LENGTH end AS max_length,\n"
+ " WHEN col.CHARACTER_OCTET_LENGTH IS NOT NULL AND col.CHARACTER_OCTET_LENGTH > 0 THEN col.CHARACTER_OCTET_LENGTH\n"
+ " ELSE scol.max_length end AS max_length,\n"
+ " CASE WHEN col.DATA_TYPE in ('datetime','datetime2','datetimeoffset','date','time','smalldatetime' ) THEN col.DATETIME_PRECISION \n"
+ " ELSE col.NUMERIC_PRECISION end AS precision,\n"
+ " col.NUMERIC_SCALE AS scale,\n"
+ " col.IS_NULLABLE AS is_nullable,\n"
+ " col.COLUMN_DEFAULT AS default_value\n"
+ "FROM INFORMATION_SCHEMA.COLUMNS col\n"
+ " JOIN sys.columns scol ON OBJECT_ID(col.TABLE_SCHEMA + '.' + col.TABLE_NAME) = scol.object_id \n"
+ " AND col.COLUMN_NAME = scol.name"
+ " LEFT JOIN sys.extended_properties prop\n"
+ " ON prop.major_id = OBJECT_ID(col.TABLE_SCHEMA + '.' + col.TABLE_NAME)\n"
+ " AND prop.minor_id = col.ORDINAL_POSITION\n"
Expand Down

0 comments on commit 98bf86c

Please sign in to comment.