mirror of
https://github.com/datahub-project/datahub.git
synced 2025-12-27 18:07:57 +00:00
Add get_identifier to hive source in metadata ingestion (#2667)
This commit is contained in:
parent
28b5856c36
commit
91eb3cc57e
@ -145,6 +145,7 @@ base_dev_requirements = {
|
||||
"ldap",
|
||||
"looker",
|
||||
"glue",
|
||||
"hive",
|
||||
"datahub-kafka",
|
||||
"datahub-rest",
|
||||
# airflow is added below
|
||||
|
||||
@ -22,6 +22,12 @@ class HiveConfig(BasicSQLAlchemyConfig):
|
||||
# defaults
|
||||
scheme = "hive"
|
||||
|
||||
def get_identifier(self, schema: str, table: str) -> str:
|
||||
regular = f"{schema}.{table}"
|
||||
if self.database:
|
||||
return f"{self.database}.{regular}"
|
||||
return regular
|
||||
|
||||
|
||||
class HiveSource(SQLAlchemySource):
|
||||
def __init__(self, config, ctx):
|
||||
|
||||
23
metadata-ingestion/tests/unit/test_hive_source.py
Normal file
23
metadata-ingestion/tests/unit/test_hive_source.py
Normal file
@ -0,0 +1,23 @@
|
||||
import unittest
|
||||
|
||||
from datahub.ingestion.source.hive import HiveConfig
|
||||
|
||||
|
||||
class HiveSinkTest(unittest.TestCase):
|
||||
def test_hive_configuration_get_indentifier_with_database(self):
|
||||
test_db_name = "test_database"
|
||||
test_schema_name = "test_schema"
|
||||
test_table_name = "test_table"
|
||||
config_dict = {
|
||||
"username": "test",
|
||||
"password": "test",
|
||||
"host_port": "test:80",
|
||||
"database": test_db_name,
|
||||
"scheme": "hive+https",
|
||||
}
|
||||
hive_config = HiveConfig.parse_obj(config_dict)
|
||||
expected_output = f"{test_db_name}.{test_schema_name}.{test_table_name}"
|
||||
output = hive_config.get_identifier(
|
||||
schema=test_schema_name, table=test_table_name
|
||||
)
|
||||
assert output == expected_output
|
||||
Loading…
x
Reference in New Issue
Block a user