Skip to content

Commit

Permalink
Revert "Use table names in oracle source schemas fetch"
Browse files Browse the repository at this point in the history
This reverts commit 668bf18.
  • Loading branch information
Cloud User committed Apr 8, 2024
1 parent 668bf18 commit a10dd4a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
21 changes: 9 additions & 12 deletions dozer-ingestion/oracle/src/connector/listing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,14 @@ pub struct TableColumn {
}

impl TableColumn {
pub fn list(
connection: &Connection,
table_names: &[String],
) -> Result<Vec<TableColumn>, Error> {
assert!(!table_names.is_empty());
pub fn list(connection: &Connection, schemas: &[String]) -> Result<Vec<TableColumn>, Error> {
assert!(!schemas.is_empty());
let sql = "
SELECT OWNER, TABLE_NAME, COLUMN_NAME, DATA_TYPE, NULLABLE, DATA_PRECISION, DATA_SCALE
FROM ALL_TAB_COLUMNS
WHERE TABLE_NAME IN (:2)
WHERE OWNER IN (SELECT COLUMN_VALUE FROM TABLE(:2))
";
let schemas = super::string_collection(connection, table_names)?;
let schemas = super::string_collection(connection, schemas)?;
debug!("{}, {}", sql, schemas);
let rows = connection.query_as::<(
String,
Expand Down Expand Up @@ -66,19 +63,19 @@ pub struct ConstraintColumn {
impl ConstraintColumn {
pub fn list(
connection: &Connection,
table_names: &[String],
schemas: &[String],
) -> Result<Vec<ConstraintColumn>, Error> {
assert!(!table_names.is_empty());
assert!(!schemas.is_empty());
let sql = "
SELECT
OWNER,
CONSTRAINT_NAME,
TABLE_NAME,
COLUMN_NAME
FROM ALL_CONS_COLUMNS
WHERE TABLE_NAME IN (:2)
WHERE OWNER IN (SELECT COLUMN_VALUE FROM TABLE(:2))
";
let schemas = super::string_collection(connection, table_names)?;
let schemas = super::string_collection(connection, schemas)?;
debug!("{}, {}", sql, schemas);
let rows =
connection.query_as::<(String, String, String, Option<String>)>(sql, &[&schemas])?;
Expand Down Expand Up @@ -113,7 +110,7 @@ impl Constraint {
CONSTRAINT_NAME
FROM ALL_CONSTRAINTS
WHERE
TABLE_NAME IN (SELECT COLUMN_VALUE FROM TABLE(:2))
OWNER IN (SELECT COLUMN_VALUE FROM TABLE(:2))
AND
CONSTRAINT_TYPE = 'P'
";
Expand Down
14 changes: 12 additions & 2 deletions dozer-ingestion/oracle/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,12 @@ impl Connector {
// List all tables and columns.
let schemas = tables
.iter()
.map(|table| table.name.clone())
.map(|table| {
table
.schema
.clone()
.unwrap_or_else(|| self.username.clone())
})
.collect::<HashSet<_>>();
let table_columns =
listing::TableColumn::list(&self.connection, &schemas.into_iter().collect::<Vec<_>>())?;
Expand Down Expand Up @@ -201,7 +206,12 @@ impl Connector {
// Collect all tables and columns.
let schemas = table_infos
.iter()
.map(|table| table.name.clone())
.map(|table| {
table
.schema
.clone()
.unwrap_or_else(|| self.username.clone())
})
.collect::<HashSet<_>>()
.into_iter()
.collect::<Vec<_>>();
Expand Down

0 comments on commit a10dd4a

Please sign in to comment.