Skip to content

Datalake: Add manifest file support, fix profiler metrics, add array and json column type support - #13017

Merged
ayush-shah merged 16 commits into
open-metadata:mainfrom
ayush-shah:issue-11421
Sep 13, 2023
Merged

ayush-shah merged 16 commits into
open-metadata:mainfrom
ayush-shah:issue-11421

Conversation

@ayush-shah

@ayush-shah ayush-shah commented Aug 28, 2023 •

Copy link
Copy Markdown
Member

Describe your changes:

Fixes #11421
Fixes #12794
Fixes #12978

Allows user to specify openmetadata.json manifest file to allow ingesting of data without extensions

Type of change:

  • Bug fix
  • Improvement
  • New feature
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation

Checklist:

  • I have read the CONTRIBUTING document.
  • My PR title is Fixes <issue-number>: <short explanation>
  • I have commented on my code, particularly in hard-to-understand areas.
  • For JSON Schema changes: I updated the migration scripts or explained why it is not needed.

@cypress

cypress Bot commented Aug 28, 2023 •

Copy link
Copy Markdown

30 failed tests on run #29490 ↗︎

30 373 37 0 Flakiness 0
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

Details:

Fix Tests
Project: openmetadata Commit: 2cac6afc5d
Status: Failed Duration: 15:12 💡
Started: Sep 12, 2023 8:25 AM Ended: Sep 12, 2023 9:41 AM

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings.

@github-actions

Copy link
Copy Markdown
Contributor

The Python checkstyle failed.

Please run make py_format and py_format_check in the root of your repository and commit the changes to this PR.
You can also use pre-commit to automate the Python code formatting.

You can install the pre-commit hooks with make install_test precommit_install.

# we'll use the first dataframe chunk to get the column name.
column = dfs[0][get_decoded_column(entity_link)]
_type = DATALAKE_DATA_TYPES.get(column.dtypes.name, DataType.STRING.value)
_type = fetch_col_types(dfs[0], get_decoded_column(entity_link))

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

having a common fetching of column types mechanism for data frames

Comment on lines +378 to +429
table_fqn = fqn.build(
self.metadata,
entity_type=Table,
service_name=self.context.database_service.name.__root__,
database_name=self.context.database.name.__root__,
schema_name=self.context.database_schema.name.__root__,
table_name=table_name,
skip_es_search=True,
)

if filter_by_table(
self.config.sourceConfig.config.tableFilterPattern,
table_fqn
if self.config.sourceConfig.config.useFqnForFiltering
else table_name,
):
self.status.filter(
table_fqn,
OBJECT_FILTERED_OUT_MESSAGE,
)
return True

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

centralize common repeated code

Comment on lines -265 to -292
def _load_metadata_file(self, bucket_name: str) -> Optional[StorageContainerConfig]:
"""
Load the metadata template file from the root of the bucket, if it exists
"""
if self._is_metadata_file_present(bucket_name=bucket_name):
try:
logger.info(
f"Found metadata template file at - s3://{bucket_name}/{OPENMETADATA_TEMPLATE_FILE_NAME}"
)
response_object = self.s3_client.get_object(
Bucket=bucket_name, Key=OPENMETADATA_TEMPLATE_FILE_NAME
)
content = json.load(response_object["Body"])
metadata_config = StorageContainerConfig.parse_obj(content)
return metadata_config
except Exception as exc:
logger.debug(traceback.format_exc())
logger.warning(
f"Failed loading metadata file s3://{bucket_name}/{OPENMETADATA_TEMPLATE_FILE_NAME}-{exc}"
)
return None

def _is_metadata_file_present(self, bucket_name: str):
return self.prefix_exits(
bucket_name=bucket_name,
prefix=OPENMETADATA_TEMPLATE_FILE_NAME,
)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

instead of using look before you leap, we will be using easier to ask for forgiveness pattern

col_type = df[self.col.name].dtypes.name
if (
col_type == "object"
and self.col.type in [DataType.FLOAT, DataType.ARRAY, DataType.JSON]
and any(df[self.col.name].values)
):
df_col_value = df[self.col.name].dropna().to_list()[0]
else:
df_col_value = df[self.col.name].dropna().to_list()
counter.update(df_col_value)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This fixes object related and NaN related errors

Comment on lines +66 to +76
max_length_list = []

for df in dfs:
if any(df[self.col.name]):
max_length_list.append(
length_vectorize_func(
df[self.col.name].dropna().astype(str)
).max()
)
if max_length_list:
return max(max_length_list)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This fixes object related and NaN related errors

Comment on lines +108 to +112
mean = None
if any(df[self.col.name]):
mean = length_vectorize_func(
df[self.col.name].dropna().astype(str)
).mean()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixes empty df issues

pmbrull
pmbrull previously approved these changes Sep 12, 2023
pmbrull
pmbrull previously approved these changes Sep 13, 2023
@sonarqubecloud

Copy link
Copy Markdown

[open-metadata-ingestion] Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

69.2% 69.2% Coverage
0.0% 0.0% Duplication

This branch was previously deployed

1 inactive deployment
test — 6827c4c4 Deployed Sep 13, 2023 by ayush-shah
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Ingestion safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Azure Datalake Profiler errors on null values Test Datalake column parser DataLake - Support Manifest file similar to Storage Connectors

4 participants