Skip to content

Commit

Permalink
fix(ingestion/powerbi): Not all arguments converted to string (datahu…
Browse files Browse the repository at this point in the history
…b-project#7157)

Co-authored-by: MohdSiddique Bagwan <[email protected]>
  • Loading branch information
2 people authored and Oleg Ruban committed Feb 28, 2023
1 parent 51d308c commit 7e6e342
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,9 @@ def get_column_unique_count_patch(self: SqlAlchemyDataset, column: str) -> int:
return convert_to_json_serializable(element_values.fetchone()[0])
elif self.engine.dialect.name.lower() == "snowflake":
element_values = self.engine.execute(
sa.select(
sa.func.APPROX_COUNT_DISTINCT(sa.column(column))
).select_from(self._table)
sa.select(sa.func.APPROX_COUNT_DISTINCT(sa.column(column))).select_from(
self._table
)
)
return convert_to_json_serializable(element_values.fetchone()[0])
return convert_to_json_serializable(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def get_upstream_tables(
native_query_enabled: bool = True,
) -> List[resolver.DataPlatformTable]:
if table.expression is None:
logger.debug(table.full_name, "Expression is none")
logger.debug("Expression is none for table %s", table.full_name)
return []

try:
Expand Down
26 changes: 26 additions & 0 deletions metadata-ingestion/tests/integration/powerbi/test_m_parser.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import logging
import sys
from typing import List

from lark import Tree
Expand Down Expand Up @@ -341,3 +343,27 @@ def test_table_combine():
data_platform_tables[1].data_platform_pair.powerbi_data_platform_name
== SupportedDataPlatform.SNOWFLAKE.value.powerbi_data_platform_name
)


def test_expression_is_none():
"""
This test verifies the logging.debug should work if expression is None
:return:
"""
# set logging to console
logging.getLogger().addHandler(logging.StreamHandler(sys.stdout))
logging.getLogger().setLevel(logging.DEBUG)

table: PowerBiAPI.Table = PowerBiAPI.Table(
expression=None, # 1st index has the native query
name="virtual_order_table",
full_name="OrderDataSet.virtual_order_table",
)

reporter = PowerBiDashboardSourceReport()

data_platform_tables: List[DataPlatformTable] = parser.get_upstream_tables(
table, reporter
)

assert len(data_platform_tables) == 0

0 comments on commit 7e6e342

Please sign in to comment.