fix #2663: added table queries put request (#2768)

This commit is contained in:
Mayur Singal 2022-02-16 10:42:38 +05:30 committed by GitHub
parent 5e4cd516bf
commit 78f5b51e63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View File

@ -9,6 +9,7 @@ from typing import List
from metadata.generated.schema.entity.data.location import Location
from metadata.generated.schema.entity.data.table import (
DataModel,
SqlQuery,
Table,
TableData,
TableJoins,
@ -85,6 +86,22 @@ class OMetaTableMixin:
)
return Table(**resp)
def ingest_table_queries_data(
self, table: Table, table_queries: List[SqlQuery]
) -> None:
"""
PUT table queries for a table
:param table: Table Entity to update
:param table_queries: SqlQuery to add
"""
for query in table_queries:
self.client.put(
f"{self.get_suffix(Table)}/{table.id.__root__}/tableQuery",
data=query.json(),
)
return None
def publish_table_usage(
self, table: Table, table_usage_request: TableUsageRequest
) -> None:

View File

@ -198,6 +198,11 @@ class MetadataRestSink(Sink[Entity]):
table=created_table, data_model=db_and_table.table.dataModel
)
if db_and_table.table.tableQueries is not None:
self.metadata.ingest_table_queries_data(
table=created_table, table_queries=db_and_table.table.tableQueries
)
logger.info(
"Successfully ingested table {}.{}".format(
db_and_table.database.name.__root__,