Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature][Jdbc] Support read view for sqlserver/dameng #8287

Draft
wants to merge 8 commits into
base: dev
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected String getDatabaseWithConditionSql(String databaseName) {
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getDatabaseName())
+ " where OWNER = '%s' and TABLE_NAME = '%s'",
+ " AND OWNER = '%s' and OBJECT_NAME = '%s'",
tablePath.getSchemaName(),
tablePath.getTableName());
}
Expand Down Expand Up @@ -122,7 +122,7 @@ protected String getTableName(TablePath tablePath) {

@Override
protected String getListTableSql(String databaseName) {
return "SELECT OWNER, TABLE_NAME FROM ALL_TABLES";
return "SELECT OWNER, OBJECT_NAME FROM ALL_OBJECTS WHERE OBJECT_TYPE IN ('VIEW', 'TABLE') AND GENERATED = 'N'";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public class SqlServerCatalog extends AbstractJdbcCatalog {
+ " col.scale AS scale,\n"
+ " col.is_nullable AS is_nullable,\n"
+ " def.definition AS default_value\n"
+ "FROM sys.tables tbl\n"
+ "FROM sys.objects tbl\n"
+ " INNER JOIN sys.columns col ON tbl.object_id = col.object_id\n"
+ " LEFT JOIN sys.types types ON col.system_type_id = types.user_type_id\n"
+ " LEFT JOIN sys.extended_properties ext ON ext.major_id = col.object_id AND ext.minor_id = col.column_id\n"
Expand Down Expand Up @@ -91,7 +91,7 @@ protected String getListDatabaseSql() {
protected String getListTableSql(String databaseName) {
return "SELECT TABLE_SCHEMA, TABLE_NAME FROM "
+ databaseName
+ ".INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE'";
+ ".INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE IN ('BASE TABLE', 'VIEW')";
}

@Override
Expand Down