Skip to content

Commit

Permalink
Fixes #16235: need quote fullyQualifiedName in Ingestion Framework (#…
Browse files Browse the repository at this point in the history
…16273)

* Fixes #16235: need quote fullyQualifiedName in Ingestion Framework

* MINOR: fix UT issue

* revert: fix UT issue

* revert code

* revert code

* format code
  • Loading branch information
juntaozhang committed May 23, 2024
1 parent 015d71c commit 8dd613c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,9 @@ def _refine_entity_event(self) -> Generator[dict, WebAnalyticEventData, None]:

entity_obj = EntityObj(split_url[0], split_url[1])
entity_type = entity_obj.entity_type
re_pattern = re.compile(f"(.*{entity_type}/{entity_obj.fqn})")
re_pattern = re.compile(
f"(.*{re.escape(entity_type)}/{re.escape(entity_obj.fqn)})"
)

if (
entity_obj.fqn in refined_data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def get_latest_table_profile(
Returns:
Optional[Table]: OM table object
"""
return self._get(Table, f"{quote(model_str(fqn))}/tableProfile/latest")
return self._get(Table, f"{quote(model_str(fqn), safe='')}/tableProfile/latest")

def create_or_update_custom_metric(
self, custom_metric: CreateCustomMetricRequest, table_id: str
Expand Down
13 changes: 10 additions & 3 deletions ingestion/tests/integration/orm_profiler/test_orm_profiler_e2e.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ class User(Base):
signedup = Column(DateTime)


# with weird characters of fqn
class NewUser(Base):
__tablename__ = "new_users"
__tablename__ = "new/users"
id = Column(Integer, primary_key=True)
name = Column(String(256))
fullname = Column(String(256))
Expand Down Expand Up @@ -303,7 +304,7 @@ def test_workflow_sample_profile(self):
{
"type": "Profiler",
"profileSample": 50,
"tableFilterPattern": {"includes": ["new_users"]},
"tableFilterPattern": {"includes": ["new/users"]},
}
)
workflow_config["processor"] = {"type": "orm-profiler", "config": {}}
Expand All @@ -315,13 +316,19 @@ def test_workflow_sample_profile(self):

table = self.metadata.get_by_name(
entity=Table,
fqn="test_sqlite.main.main.new_users",
fqn="test_sqlite.main.main.new/users",
fields=["tableProfilerConfig"],
)
# setting sampleProfile from config has been temporarly removed
# up until we split tests and profiling
assert table.tableProfilerConfig is None

profile = self.metadata.get_latest_table_profile(
table.fullyQualifiedName
).profile

assert profile is not None

def test_workflow_datetime_partition(self):
"""test workflow with partition"""
workflow_config = deepcopy(ingestion_config)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@
timestamp=1667475458757,
eventType=WebAnalyticEventType.PageView.value,
eventData=PageViewData(
fullUrl="http://localhost:8585/table/sample_data.ecommerce_db.shopify.dim_address",
url="/table/sample_data.ecommerce_db.shopify.dim_address",
fullUrl="http://localhost:8585/table/sample_data.ecommerce_db.shopify.dim(address)",
url="/table/sample_data.ecommerce_db.shopify.dim(address)",
hostname="localhost",
language="en-US",
screenSize="2140x1273",
Expand All @@ -58,8 +58,8 @@
timestamp=1667475458757,
eventType=WebAnalyticEventType.PageView.value,
eventData=PageViewData(
fullUrl="http://localhost:8585/table/sample_data.ecommerce_db.shopify.dim_address",
url="/table/sample_data.ecommerce_db.shopify.dim_address",
fullUrl="http://localhost:8585/table/sample_data.ecommerce_db.shopify.dim(address)",
url="/table/sample_data.ecommerce_db.shopify.dim(address)",
hostname="localhost",
language="en-US",
screenSize="2140x1273",
Expand Down Expand Up @@ -111,7 +111,7 @@ def test_refine(self, mocked_ometa):

assert (
web_analytic_entity_report_data[
"sample_data.ecommerce_db.shopify.dim_address"
"sample_data.ecommerce_db.shopify.dim(address)"
].views
== 2
)
Expand Down

0 comments on commit 8dd613c

Please sign in to comment.