Skip to content

Commit

Permalink
fix: support schema validation for more clients (#355) (#380)
Browse files Browse the repository at this point in the history
* fix: support schema validation for more clients (#355)

* fix: use consts.VALIDATION_STATUS_SUCCESS
  • Loading branch information
ajwelch4 committed Mar 16, 2022
1 parent 0ca0ccf commit ed46295
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/system/data_sources/test_sql_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,29 @@ def test_sql_server_count(cloud_sql):
data_validator = data_validation.DataValidation(config_count_valid, verbose=False,)
df = data_validator.execute()
assert df["source_agg_value"][0] == df["target_agg_value"][0]


def test_schema_validation():
conn = {
"source_type": "MSSQL",
"host": SQL_SERVER_HOST,
"user": SQL_SERVER_USER,
"password": SQL_SERVER_PASSWORD,
"port": 1433,
"database": "guestbook",
}

config = {
consts.CONFIG_SOURCE_CONN: conn,
consts.CONFIG_TARGET_CONN: conn,
consts.CONFIG_TYPE: "Schema",
consts.CONFIG_SCHEMA_NAME: "dbo",
consts.CONFIG_TABLE_NAME: "entries",
consts.CONFIG_FORMAT: "table",
}

validator = data_validation.DataValidation(config, verbose=True)
df = validator.execute()

for validation in df.to_dict(orient="records"):
assert validation["status"] == consts.VALIDATION_STATUS_SUCCESS
3 changes: 3 additions & 0 deletions third_party/ibis/ibis_DB2/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,6 @@ def list_tables(self, like=None, database=None, schema=None):
else:
parent = super(DB2Client, self)
return parent.list_tables(like=like, schema=schema)

def get_schema(self, name, schema=None):
return self.table(name, schema=schema).schema()
3 changes: 3 additions & 0 deletions third_party/ibis/ibis_mssql/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,6 @@ def _get_schema_using_query(self, limited_query):
type_map[row[1]] for row in cur.proxy._cursor_description()
]
return sch.Schema(names, ibis_types)

def get_schema(self, name, schema=None):
return self.table(name, schema=schema).schema()
2 changes: 2 additions & 0 deletions third_party/ibis/ibis_oracle/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,5 @@ def list_tables(self, like=None, database=None, schema=None):
parent = super(OracleClient, self)
return parent.list_tables(like=like, schema=schema)

def get_schema(self, name, schema=None):
return self.table(name, schema=schema).schema()
3 changes: 3 additions & 0 deletions third_party/ibis/ibis_snowflake/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ def executeSQL(self, sql):
finally:
connection.close()
return response

def get_schema(self, name, schema=None):
return self.table(name, schema=schema).schema()

0 comments on commit ed46295

Please sign in to comment.