Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correct the way to catch the exception #1727

Merged
merged 5 commits into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion metadata-ingestion/ldap-etl/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
avro-python3==1.8.2
confluent-kafka==1.4.0
confluent-kafka[avro]==1.4.0
python-ldap==3.2.0
2 changes: 1 addition & 1 deletion metadata-ingestion/mysql-etl/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
avro-python3==1.8.2
confluent-kafka==1.4.0
confluent-kafka[avro]==1.4.0
mysql-connector==2.2.9
25 changes: 16 additions & 9 deletions metadata-ingestion/sql-etl/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def build_dataset_mce(platform, dataset_name, columns):
fields.append({
"fieldPath": column["name"],
"nativeDataType": repr(column["type"]),
"type": { "type":get_column_type(column["type"]) }
"type": { "type":get_column_type(column["type"]) },
"description": column["comment"]
})

schema_metadata = {
Expand All @@ -80,21 +81,27 @@ def build_dataset_mce(platform, dataset_name, columns):
}


def delivery_report(err, msg):
""" Called once for each message produced to indicate delivery result.
Triggered by poll() or flush(). """
if err is not None:
print('Message delivery failed: {}'.format(err))
else:
print('Message delivered to {} [{}]'.format(msg.topic(), msg.partition()))


def produce_dataset_mce(mce, kafka_config):
"""
Produces a MetadataChangeEvent to Kafka
"""
conf = {'bootstrap.servers': kafka_config.bootstrap_server,
'on_delivery': delivery_report,
'schema.registry.url': kafka_config.schema_registry}
key_schema = avro.loads('{"type": "string"}')
record_schema = avro.load(kafka_config.avsc_path)
producer = AvroProducer(conf, default_value_schema=record_schema)

try:
producer.produce(topic=kafka_config.kafka_topic, value=mce)
producer.poll(0)
print('\n%s has been successfully produced!\n' % mce)
except ValueError as e:
print('Message serialization failed %s' % e)
producer = AvroProducer(conf, default_key_schema=key_schema, default_value_schema=record_schema)

producer.produce(topic=kafka_config.kafka_topic, key=mce['proposedSnapshot'][1]['urn'], value=mce)
producer.flush()


Expand Down
2 changes: 1 addition & 1 deletion metadata-ingestion/sql-etl/common.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
avro-python3==1.8.2
confluent-kafka==1.1.0
confluent-kafka[avro]==1.4.0
SQLAlchemy==1.3.17