mirror of
https://github.com/open-metadata/OpenMetadata.git
synced 2025-12-14 09:05:58 +00:00
Modified snowflake, utils (#4364)
This commit is contained in:
parent
a94bb5fc8e
commit
c863fd9d90
@ -14,6 +14,11 @@ MYSQL="${MYSQL_HOST:-mysql}":"${MYSQL_PORT:-3306}"
|
|||||||
while ! wget -O /dev/null -o /dev/null "${MYSQL}";
|
while ! wget -O /dev/null -o /dev/null "${MYSQL}";
|
||||||
do echo "Trying to connect to ${MYSQL}"; sleep 5;
|
do echo "Trying to connect to ${MYSQL}"; sleep 5;
|
||||||
done
|
done
|
||||||
|
ELASTICSEARCH="${ELASTICSEARCH_HOST:-elasticsearch}":"${ELASTICSEARCH_PORT:-9200}"
|
||||||
|
while ! wget -O /dev/null -o /dev/null "${ELASTICSEARCH}";
|
||||||
|
do echo "Trying to connect to ${ELASTICSEARCH}"; sleep 5;
|
||||||
|
done
|
||||||
|
sleep 5
|
||||||
cd /openmetadata-*/
|
cd /openmetadata-*/
|
||||||
./bootstrap/bootstrap_storage.sh migrate-all
|
./bootstrap/bootstrap_storage.sh migrate-all
|
||||||
./bin/openmetadata-server-start.sh conf/openmetadata.yaml
|
./bin/openmetadata-server-start.sh conf/openmetadata.yaml
|
||||||
|
|||||||
@ -14,7 +14,6 @@ from typing import Iterable, Optional
|
|||||||
|
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
from cryptography.hazmat.primitives import serialization
|
from cryptography.hazmat.primitives import serialization
|
||||||
from cryptography.hazmat.primitives.asymmetric import dsa, rsa
|
|
||||||
from snowflake.sqlalchemy.custom_types import VARIANT
|
from snowflake.sqlalchemy.custom_types import VARIANT
|
||||||
from snowflake.sqlalchemy.snowdialect import SnowflakeDialect, ischema_names
|
from snowflake.sqlalchemy.snowdialect import SnowflakeDialect, ischema_names
|
||||||
from sqlalchemy.engine import reflection
|
from sqlalchemy.engine import reflection
|
||||||
@ -43,6 +42,13 @@ ischema_names["GEOGRAPHY"] = GEOGRAPHY
|
|||||||
logger: logging.Logger = logging.getLogger(__name__)
|
logger: logging.Logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
def normalize_names(self, name):
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
|
SnowflakeDialect.normalize_name = normalize_names
|
||||||
|
|
||||||
|
|
||||||
class SnowflakeSource(SQLSource):
|
class SnowflakeSource(SQLSource):
|
||||||
def __init__(self, config, metadata_config):
|
def __init__(self, config, metadata_config):
|
||||||
connection_arguments = (
|
connection_arguments = (
|
||||||
@ -68,14 +74,12 @@ class SnowflakeSource(SQLSource):
|
|||||||
super().__init__(config, metadata_config)
|
super().__init__(config, metadata_config)
|
||||||
|
|
||||||
def get_databases(self) -> Iterable[Inspector]:
|
def get_databases(self) -> Iterable[Inspector]:
|
||||||
|
if self.config.serviceConnection.__root__.config.database:
|
||||||
if self.config.serviceConnection.__root__.config.database != None:
|
|
||||||
yield from super().get_databases()
|
yield from super().get_databases()
|
||||||
else:
|
else:
|
||||||
query = "SHOW DATABASES"
|
query = "SHOW DATABASES"
|
||||||
results = self.connection.execute(query)
|
results = self.connection.execute(query)
|
||||||
for res in results:
|
for res in results:
|
||||||
|
|
||||||
row = list(res)
|
row = list(res)
|
||||||
use_db_query = f"USE DATABASE {row[1]}"
|
use_db_query = f"USE DATABASE {row[1]}"
|
||||||
self.connection.execute(use_db_query)
|
self.connection.execute(use_db_query)
|
||||||
@ -88,7 +92,7 @@ class SnowflakeSource(SQLSource):
|
|||||||
if not resp_sample_data:
|
if not resp_sample_data:
|
||||||
try:
|
try:
|
||||||
logger.info("Using Table Name with quotes to fetch the data")
|
logger.info("Using Table Name with quotes to fetch the data")
|
||||||
query = self.config.query.format(schema, f'"{table}"')
|
query = self.source_config.sampleDataQuery.format(schema, f'"{table}"')
|
||||||
logger.info(query)
|
logger.info(query)
|
||||||
results = self.connection.execute(query)
|
results = self.connection.execute(query)
|
||||||
cols = []
|
cols = []
|
||||||
@ -101,6 +105,7 @@ class SnowflakeSource(SQLSource):
|
|||||||
return TableData(columns=cols, rows=rows)
|
return TableData(columns=cols, rows=rows)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.error(err)
|
logger.error(err)
|
||||||
|
return resp_sample_data
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, config_dict, metadata_config: OpenMetadataConnection):
|
def create(cls, config_dict, metadata_config: OpenMetadataConnection):
|
||||||
|
|||||||
@ -390,7 +390,7 @@ class SQLSource(Source[OMetaDatabaseAndTable]):
|
|||||||
if self.source_config.includeViews:
|
if self.source_config.includeViews:
|
||||||
yield from self.fetch_views(inspector, schema)
|
yield from self.fetch_views(inspector, schema)
|
||||||
if self.source_config.markDeletedTables:
|
if self.source_config.markDeletedTables:
|
||||||
schema_fqdn = f"{self.config.serviceName}.{schema}"
|
schema_fqdn = f"{self.config.serviceName}.{self.service_connection.database}.{schema}"
|
||||||
yield from self.delete_tables(schema_fqdn)
|
yield from self.delete_tables(schema_fqdn)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
logger.debug(traceback.format_exc())
|
logger.debug(traceback.format_exc())
|
||||||
@ -852,19 +852,22 @@ class SQLSource(Source[OMetaDatabaseAndTable]):
|
|||||||
and column["policy_tags"]
|
and column["policy_tags"]
|
||||||
):
|
):
|
||||||
self.metadata.create_primary_tag(
|
self.metadata.create_primary_tag(
|
||||||
category_name=self.config.tag_category_name,
|
category_name=self.service_connection.tagCategoryName,
|
||||||
primary_tag_body=CreateTagRequest(
|
primary_tag_body=CreateTagRequest(
|
||||||
name=column["policy_tags"],
|
name=column["policy_tags"],
|
||||||
description="Bigquery Policy Tag",
|
description="Bigquery Policy Tag",
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
except APIError:
|
except APIError:
|
||||||
if column["policy_tags"] and self.config.enable_policy_tags:
|
if (
|
||||||
|
column["policy_tags"]
|
||||||
|
and self.service_connection.enablePolicyTagImport
|
||||||
|
):
|
||||||
col_dict.tags = [
|
col_dict.tags = [
|
||||||
TagLabel(
|
TagLabel(
|
||||||
tagFQN=get_fqdn(
|
tagFQN=get_fqdn(
|
||||||
Tag,
|
Tag,
|
||||||
self.config.tag_category_name,
|
self.service_connection.tagCategoryName,
|
||||||
column["policy_tags"],
|
column["policy_tags"],
|
||||||
),
|
),
|
||||||
labelType="Automated",
|
labelType="Automated",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user