mirror of
https://github.com/datahub-project/datahub.git
synced 2025-07-10 10:44:39 +00:00
22 lines
947 B
Python
22 lines
947 B
Python
![]() |
from typing import List
|
||
|
|
||
|
from datahub.ingestion.source.powerbi.m_query import native_sql_parser
|
||
|
|
||
|
|
||
|
def test_join():
|
||
|
query: str = "select A.name from GSL_TEST_DB.PUBLIC.SALES_ANALYST as A inner join GSL_TEST_DB.PUBLIC.SALES_FORECAST as B on A.name = B.name where startswith(A.name, 'mo')"
|
||
|
tables: List[str] = native_sql_parser.get_tables(query)
|
||
|
|
||
|
assert len(tables) == 2
|
||
|
assert tables[0] == "GSL_TEST_DB.PUBLIC.SALES_ANALYST"
|
||
|
assert tables[1] == "GSL_TEST_DB.PUBLIC.SALES_FORECAST"
|
||
|
|
||
|
|
||
|
def test_simple_from():
|
||
|
query: str = "SELECT#(lf)concat((UPPER(REPLACE(SELLER,'-',''))), MONTHID) as AGENT_KEY,#(lf)concat((UPPER(REPLACE(CLIENT_DIRECTOR,'-',''))), MONTHID) as CD_AGENT_KEY,#(lf) *#(lf)FROM#(lf)OPERATIONS_ANALYTICS.TRANSFORMED_PROD.V_APS_SME_UNITS_V4"
|
||
|
|
||
|
tables: List[str] = native_sql_parser.get_tables(query)
|
||
|
|
||
|
assert len(tables) == 1
|
||
|
assert tables[0] == "OPERATIONS_ANALYTICS.TRANSFORMED_PROD.V_APS_SME_UNITS_V4"
|