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

fix: Removing t0 alias from column name, while getting schema from query. Adding Integration test for Hive Custom-Query #1164

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions tests/system/data_sources/test_hive.py
Original file line number Diff line number Diff line change
Expand Up @@ -339,3 +339,28 @@ def test_row_validation_binary_pk_to_bigquery():
)
df = run_test_from_cli_args(args)
binary_key_assertions(df)


@mock.patch(
"data_validation.state_manager.StateManager.get_connection_config",
new=mock_get_connection_config,
)
def test_custom_query_validation_core_types():
"""Hive to Hive dvt_core_types custom-query validation"""
parser = cli_tools.configure_arg_parser()
args = parser.parse_args(
[
"validate",
"custom-query",
"column",
"-sc=mock-conn",
"-tc=mock-conn",
"--source-query=select * from pso_data_validator.dvt_core_types",
"--target-query=select * from pso_data_validator.dvt_core_types",
"--filter-status=fail",
"--count=*",
]
)
df = run_test_from_cli_args(args)
# With filter on failures the data frame should be empty
assert len(df) == 0
4 changes: 4 additions & 0 deletions third_party/ibis/ibis_impala/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,10 @@ def _get_schema_using_query(self, query):
# Removing LIMIT 0 around query since it returns no results in Hive
cur = self.raw_sql(f"SELECT * FROM ({query}) t0 LIMIT 1")
cur.fetchall()
cur.description = [
(description[0].replace("t0.", "", 1), *description[1:])
for description in cur.description
]
ibis_fields = self._adapt_types(cur.description)
cur.release()

Expand Down