Skip to content

Commit

Permalink
[Improve][Jdbc] Optimize the code
Browse files Browse the repository at this point in the history
  • Loading branch information
dailai committed Jul 29, 2024
1 parent d1f0464 commit dc70d47
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ public DamengCatalog(

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where name='%s'", databaseName);
return String.format(getListDatabaseSql() + " where name = '%s'", databaseName);
}

@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getDatabaseName())
+ " where OWNER = '%s' and TABLE_NAME= '%s'",
+ " where OWNER = '%s' and TABLE_NAME = '%s'",
tablePath.getSchemaName(),
tablePath.getTableName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ public boolean tableExists(TablePath tablePath) throws CatalogException {
@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getSchemaName()) + " and TABLE_NAME= '%s'",
getListTableSql(tablePath.getSchemaName()) + " and TABLE_NAME = '%s'",
tablePath.getTableName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ protected String getDatabaseWithConditionSql(String databaseName) {
@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return getListTableSql(tablePath.getDatabaseName())
+ " and OWNER= '"
+ " and OWNER = '"
+ tablePath.getSchemaName()
+ "' and table_name = '"
+ tablePath.getTableName()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public PostgresCatalog(

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where datname='%s'", databaseName);
return String.format(getListDatabaseSql() + " where datname = '%s'", databaseName);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ public RedshiftCatalog(

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where datname='%s'", databaseName);
return String.format(getListDatabaseSql() + " where datname = '%s'", databaseName);
}

@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getDatabaseName())
+ " where table_schema = '%s' and table_name= '%s'",
+ " where table_schema = '%s' and table_name = '%s'",
tablePath.getSchemaName(),
tablePath.getTableName());
}
Expand All @@ -102,12 +102,12 @@ public void close() throws CatalogException {

@Override
protected String getListDatabaseSql() {
return "select datname from pg_database;";
return "select datname from pg_database";
}

@Override
protected String getListTableSql(String databaseName) {
return "SELECT table_schema, table_name FROM information_schema.tables;";
return "SELECT table_schema, table_name FROM information_schema.tables";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,13 +111,13 @@ public SapHanaCatalog(

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where SCHEMA_NAME='%s'", databaseName);
return String.format(getListDatabaseSql() + " where SCHEMA_NAME = '%s'", databaseName);
}

@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getDatabaseName()) + " and TABLE_NAME='%s'",
getListTableSql(tablePath.getDatabaseName()) + " and TABLE_NAME = '%s'",
tablePath.getTableName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ public SqlServerCatalog(

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where name='%s'", databaseName);
return String.format(getListDatabaseSql() + " where name = '%s'", databaseName);
}

@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getDatabaseName())
+ " and TABLE_SCHEMA= '%s' and TABLE_NAME = '%s'",
+ " and TABLE_SCHEMA = '%s' and TABLE_NAME = '%s'",
tablePath.getSchemaName(),
tablePath.getTableName());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,14 @@ public XuguCatalog(

@Override
protected String getDatabaseWithConditionSql(String databaseName) {
return String.format(getListDatabaseSql() + " where DB_NAME='%s'", databaseName);
return String.format(getListDatabaseSql() + " where DB_NAME = '%s'", databaseName);
}

@Override
protected String getTableWithConditionSql(TablePath tablePath) {
return String.format(
getListTableSql(tablePath.getDatabaseName())
+ " where user_name= '%s' and table_name = '%s'",
+ " where user_name = '%s' and table_name = '%s'",
tablePath.getSchemaName(),
tablePath.getTableName());
}
Expand Down

0 comments on commit dc70d47

Please sign in to comment.