Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 6def894

Browse files
committedDec 19, 2024
fix m-query for connector test
1 parent ba4a4a9 commit 6def894

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed
 

‎metadata-ingestion/src/datahub/ingestion/source/powerbi/powerbi-lexical-grammar.rule

+11-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@
2121
// | empty_string
2222
// | empty_string "," argument_list
2323
// - Added sql_string in any_literal
24+
// - Added WS_INLINE? in field expression
25+
// Added to ignore any comments
26+
// %ignore WS // Ignore whitespace
27+
// %ignore CPP_COMMENT // Ignore single-line comments
28+
// %ignore C_COMMENT // Ignore multi-line comments
2429

2530
lexical_unit: lexical_elements?
2631

@@ -414,7 +419,7 @@ record_expression: "[" field_list? "]"
414419
field_list: field
415420
| field "," field_list
416421

417-
field: field_name WS_INLINE? "=" WS_INLINE? expression
422+
field: WS_INLINE? field_name WS_INLINE? "=" WS_INLINE? expression
418423

419424
field_name: generalized_identifier
420425
| quoted_identifier
@@ -626,4 +631,8 @@ any_literal: record_literal
626631
%import common.DIGIT
627632
%import common.LF
628633
%import common.CR
629-
%import common.ESCAPED_STRING
634+
%import common.ESCAPED_STRING
635+
636+
%ignore WS // Ignore whitespace
637+
%ignore CPP_COMMENT // Ignore single-line comments
638+
%ignore C_COMMENT // Ignore multi-line comments

‎metadata-ingestion/tests/integration/powerbi/test_m_parser.py

+11-4
Original file line numberDiff line numberDiff line change
@@ -1172,15 +1172,16 @@ def test_m_query_timeout(mock_get_lark_parser):
11721172
is_entry_present
11731173
), 'Warning message "M-Query Parsing Timeout" should be present in reporter'
11741174

1175-
def test_for_each_pattern1():
1175+
1176+
def test_comments_in_m_query():
11761177
q: str = 'let\n Source = Snowflake.Databases("xaa48144.snowflakecomputing.com", "COMPUTE_WH", [Role="ACCOUNTADMIN"]),\n SNOWFLAKE_SAMPLE_DATA_Database = Source{[Name="SNOWFLAKE_SAMPLE_DATA", Kind="Database"]}[Data],\n TPCDS_SF100TCL_Schema = SNOWFLAKE_SAMPLE_DATA_Database{[Name="TPCDS_SF100TCL", Kind="Schema"]}[Data],\n ITEM_Table = TPCDS_SF100TCL_Schema{[Name="ITEM", Kind="Table"]}[Data],\n \n // Group by I_BRAND and calculate the count\n BrandCountsTable = Table.Group(ITEM_Table, {"I_BRAND"}, {{"BrandCount", each Table.RowCount(_), Int64.Type}})\nin\n BrandCountsTable'
11771178

11781179
table: powerbi_data_classes.Table = powerbi_data_classes.Table(
11791180
columns=[],
11801181
measures=[],
11811182
expression=q,
1182-
name="virtual_order_table",
1183-
full_name="OrderDataSet.virtual_order_table",
1183+
name="pet_price_index",
1184+
full_name="datalake.sandbox_pet.pet_price_index",
11841185
)
11851186

11861187
reporter = PowerBiDashboardSourceReport()
@@ -1193,10 +1194,16 @@ def test_for_each_pattern1():
11931194
ctx=ctx,
11941195
config=config,
11951196
platform_instance_resolver=platform_instance_resolver,
1197+
parameters={
1198+
"hostname": "xyz.databricks.com",
1199+
"http_path": "/sql/1.0/warehouses/abc",
1200+
"catalog": "cat",
1201+
"schema": "public",
1202+
},
11961203
)[0].upstreams
11971204

11981205
assert len(data_platform_tables) == 1
11991206
assert (
12001207
data_platform_tables[0].urn
1201-
== "urn:li:dataset:(urn:li:dataPlatform:snowflake,pbi_test.test.testtable,PROD)"
1208+
== "urn:li:dataset:(urn:li:dataPlatform:snowflake,snowflake_sample_data.tpcds_sf100tcl.item,PROD)"
12021209
)

0 commit comments

Comments
 (0)
Please sign in to comment.