Skip to content

Commit

Permalink
fix: Removing t0 alias from column name, while getting schema from qu…
Browse files Browse the repository at this point in the history
…ery. Adding Integration test for Hive Custom-Query (#1164)

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

* fix: Lint Error

---------

Co-authored-by: Piyush Sarraf <[email protected]>
  • Loading branch information
piyushsarraf and Piyush Sarraf committed Jun 10, 2024
1 parent 973e6b6 commit 74a14af
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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

0 comments on commit 74a14af

Please sign in to comment.