diff --git a/ingestion/LICENSE b/ingestion/LICENSE new file mode 100644 index 00000000000..f49a4e16e68 --- /dev/null +++ b/ingestion/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. \ No newline at end of file diff --git a/ingestion/README.md b/ingestion/README.md new file mode 100644 index 00000000000..a55f88de7fe --- /dev/null +++ b/ingestion/README.md @@ -0,0 +1,72 @@ +--- +This guide will help you setup the Ingestion framework and connectors +--- + +![Python version 3.8+](https://img.shields.io/badge/python-3.8%2B-blue) + +OpenMetadata Ingesiton is a simple framework to build connectors and ingest metadata of various systems through OpenMetadata APIs. It could be used in an orchestration framework(e.g. Apache Airflow) to ingest metadata. +**Prerequisites** + +- Python >= 3.8.x + +### Install From PyPI + +```text +python3 -m pip install --upgrade pip wheel setuptools +python3 -m pip install --upgrade openmetadata-ingestion +python3 -m spacy download en_core_web_sm +``` + +### Install Ingestion Connector Dependencies + +Click here to go to [Ingestion Connector's Documentation](https://docs.open-metadata.org/install/metadata-ingestion) +#### Generate Redshift Data + +```text +metadata ingest -c ./pipelines/redshift.json +``` + +#### Generate Redshift Usage Data + +```text +metadata ingest -c ./pipelines/redshift_usage.json +``` + +#### Generate Sample Tables + +```text +metadata ingest -c ./pipelines/sample_tables.json +``` + +#### Generate Sample Users + +```text +metadata ingest -c ./pipelines/sample_users.json +``` + +#### Ingest MySQL data to Metadata APIs + +```text +metadata ingest -c ./pipelines/mysql.json +``` + +#### Ingest Bigquery data to Metadata APIs + +```text +export GOOGLE_APPLICATION_CREDENTIALS="$PWD/pipelines/creds/bigquery-cred.json" +metadata ingest -c ./pipelines/bigquery.json +``` + +#### Index Metadata into ElasticSearch + +#### Run ElasticSearch docker + +```text +docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" docker.elastic.co/elasticsearch/elasticsearch:7.10.2 +``` + +#### Run ingestion connector + +```text +metadata ingest -c ./pipelines/metadata_to_es.json +``` diff --git a/ingestion/setup.cfg b/ingestion/setup.cfg index e0948242aad..15c158b9056 100644 --- a/ingestion/setup.cfg +++ b/ingestion/setup.cfg @@ -12,7 +12,8 @@ exclude = per-file-ignores = # imported but unused __init__.py: F401 - +[metadata] +license_files = LICENSE [mypy] mypy_path = src plugins = diff --git a/ingestion/setup.py b/ingestion/setup.py index 556a866fdb6..236d0b20bf0 100644 --- a/ingestion/setup.py +++ b/ingestion/setup.py @@ -28,14 +28,11 @@ def get_version(): def get_long_description(): root = os.path.dirname(__file__) - with open(os.path.join(root, "../docs/install/setup-ingestion.md")) as f: + with open(os.path.join(root, "README.md")) as f: description = f.read() - description += "\n\nChangelog\n=========\n\n" - with open(os.path.join(root, "CHANGELOG")) as f: description += f.read() - return description @@ -49,7 +46,7 @@ base_requirements = { "typing_extensions>=3.7.4" "mypy_extensions>=0.4.3", "typing-inspect", - "pydantic@https://github.com/samuelcolvin/pydantic/archive/refs/tags/v1.7.4.tar.gz#egg=pydantic", + "pydantic~=1.7.4", "pydantic[email]>=1.7.2", "google>=3.0.0", "google-auth>=1.33.0", @@ -58,7 +55,7 @@ base_requirements = { "wheel~=0.36.2", "python-jose==3.3.0", "okta==1.7.0", - "en_core_web_sm@https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz#egg=en_core_web" + "pandas~=1.3.1" } connector_requirements = { "sqlalchemy>=1.3.24", @@ -66,10 +63,6 @@ connector_requirements = { "spacy==3.0.5", "requests~=2.25.1" } -scheduler_requirements = { - "apns@git+git://github.com/djacobs/PyAPNs.git#egg=apns", - "simplescheduler@git+https://github.com/StreamlineData/sdscheduler.git#egg=simplescheduler" -} base_plugins = { "pii-tags", "query-parser", @@ -91,27 +84,34 @@ plugins: Dict[str, Set[str]] = { "postgres": connector_requirements | {"pymysql>=1.0.2", "psycopg2-binary", "GeoAlchemy2"}, "redshift": connector_requirements | {"sqlalchemy-redshift", "psycopg2-binary", "GeoAlchemy2"}, "redshift-usage": connector_requirements | {"sqlalchemy-redshift", "psycopg2-binary", "GeoAlchemy2"}, - "scheduler": connector_requirements | scheduler_requirements, "snowflake": connector_requirements | {"snowflake-sqlalchemy<=1.2.4"}, "snowflake-usage": connector_requirements | {"snowflake-sqlalchemy<=1.2.4"}, - "sample-tables": connector_requirements | {"faker~=8.1.1", "pandas~=1.3.1", "email-validator>=1.0.3"} + "sample-tables": connector_requirements | {"faker~=8.1.1", } } build_options = {"includes": ["_cffi_backend"]} - setup( - name="metadata", + name="openmetadata-ingestion", version="0.2.0", - url="https://github.com/open-metadata/OpenMetadata", - author="Metadata Committers", + url="https://open-metadata.org/", + author="OpenMetadata Committers", license="Apache License 2.0", - description="Ingestion Framework for OpenMetadata", - long_description="Ingestion Framework for OpenMetadata", + description="Ingestion Framework for OpenMetadata", + long_description=get_long_description(), long_description_content_type="text/markdown", python_requires=">=3.8", options={"build_exe": build_options}, package_dir={"": "src"}, - packages=find_namespace_packages(where='src', exclude=['tests*']), + zip_safe=False, + dependency_links=[ + "apns@git+git://github.com/djacobs/PyAPNs.git#egg=apns", + "simplescheduler@git+https://github.com/StreamlineData/sdscheduler.git#egg=simplescheduler" + ], + project_urls={ + "Documentation": "https://docs.open-metadata.org/", + "Source": "https://github.com/open-metadata/OpenMetadata", + }, + packages=find_namespace_packages(where='./src', exclude=['tests*']), entry_points={ "console_scripts": ["metadata = metadata.cmd:metadata"], "metadata.ingestion.source.plugins": [ diff --git a/ingestion/src/metadata/ingestion/bulksink/metadata_usage_rest.py b/ingestion/src/metadata/ingestion/bulksink/metadata_usage_rest.py index bd886a54fc8..0ff658e74ef 100644 --- a/ingestion/src/metadata/ingestion/bulksink/metadata_usage_rest.py +++ b/ingestion/src/metadata/ingestion/bulksink/metadata_usage_rest.py @@ -107,13 +107,16 @@ class MetadataUsageBulkSink(BulkSink): main_column_fqdn = self.__get_column_fqdn(column_join.table_column) for column in column_join.joined_with: joined_column_fqdn = self.__get_column_fqdn(column) + if joined_column_fqdn in joined_with.keys(): column_joined_with = joined_with[joined_column_fqdn] column_joined_with.joinCount += 1 joined_with[joined_column_fqdn] = column_joined_with - else: + elif joined_column_fqdn is not None: joined_with[joined_column_fqdn] = ColumnJoinedWith(fullyQualifiedName=joined_column_fqdn, joinCount=1) + else: + logger.info("Skipping join columns for {}".format(column)) column_joins_dict[column_join.table_column.column] = joined_with for key, value in column_joins_dict.items(): @@ -122,6 +125,7 @@ class MetadataUsageBulkSink(BulkSink): return table_joins def __get_column_fqdn(self, table_column: TableColumn): + print(table_column.table) if table_column.table not in self.tables_dict: return None table_entity = self.tables_dict[table_column.table] diff --git a/ingestion/tests/integration/mssql/tests/setup/setup.sql b/ingestion/tests/integration/mssql/tests/setup/setup.sql index 9e41aaba54a..ad03eafc2ac 100644 --- a/ingestion/tests/integration/mssql/tests/setup/setup.sql +++ b/ingestion/tests/integration/mssql/tests/setup/setup.sql @@ -2,9 +2,9 @@ CREATE DATABASE catalog_test; GO USE catalog_test; GO -CREATE TABLE Products (ID int, ProductName nvarchar(max)); +CREATE TABLE SampleData (ID int, DataName nvarchar(max)); GO CREATE SCHEMA catalog_test_check; GO -CREATE TABLE catalog_test_check.Items (ID int, ItemName nvarchar(max)); +CREATE TABLE catalog_test_check.SampleItems (ID int, SampleItemName nvarchar(max)); GO \ No newline at end of file