Skip to content

Commit

Permalink
fix m-query for connector test
Browse files Browse the repository at this point in the history
  • Loading branch information
sid-acryl committed Dec 19, 2024
1 parent ba4a4a9 commit 6def894
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@
// | empty_string
// | empty_string "," argument_list
// - Added sql_string in any_literal
// - Added WS_INLINE? in field expression
// Added to ignore any comments
// %ignore WS // Ignore whitespace
// %ignore CPP_COMMENT // Ignore single-line comments
// %ignore C_COMMENT // Ignore multi-line comments

lexical_unit: lexical_elements?

Expand Down Expand Up @@ -414,7 +419,7 @@ record_expression: "[" field_list? "]"
field_list: field
| field "," field_list

field: field_name WS_INLINE? "=" WS_INLINE? expression
field: WS_INLINE? field_name WS_INLINE? "=" WS_INLINE? expression

field_name: generalized_identifier
| quoted_identifier
Expand Down Expand Up @@ -626,4 +631,8 @@ any_literal: record_literal
%import common.DIGIT
%import common.LF
%import common.CR
%import common.ESCAPED_STRING
%import common.ESCAPED_STRING

%ignore WS // Ignore whitespace
%ignore CPP_COMMENT // Ignore single-line comments
%ignore C_COMMENT // Ignore multi-line comments
15 changes: 11 additions & 4 deletions metadata-ingestion/tests/integration/powerbi/test_m_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -1172,15 +1172,16 @@ def test_m_query_timeout(mock_get_lark_parser):
is_entry_present
), 'Warning message "M-Query Parsing Timeout" should be present in reporter'

def test_for_each_pattern1():

def test_comments_in_m_query():
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'

table: powerbi_data_classes.Table = powerbi_data_classes.Table(
columns=[],
measures=[],
expression=q,
name="virtual_order_table",
full_name="OrderDataSet.virtual_order_table",
name="pet_price_index",
full_name="datalake.sandbox_pet.pet_price_index",
)

reporter = PowerBiDashboardSourceReport()
Expand All @@ -1193,10 +1194,16 @@ def test_for_each_pattern1():
ctx=ctx,
config=config,
platform_instance_resolver=platform_instance_resolver,
parameters={
"hostname": "xyz.databricks.com",
"http_path": "/sql/1.0/warehouses/abc",
"catalog": "cat",
"schema": "public",
},
)[0].upstreams

assert len(data_platform_tables) == 1
assert (
data_platform_tables[0].urn
== "urn:li:dataset:(urn:li:dataPlatform:snowflake,pbi_test.test.testtable,PROD)"
== "urn:li:dataset:(urn:li:dataPlatform:snowflake,snowflake_sample_data.tpcds_sf100tcl.item,PROD)"
)

0 comments on commit 6def894

Please sign in to comment.