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(ingestion): powerbi # Not all arguments converted to string #7157

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
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(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is there change in the formatting?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lintFix is doing this

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, can you use fstring instead of format strings?
Something like this:

logger.debug(f"Expression is none for table {table.full_name}")

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used above format because argument only get process if debug is enabled

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