You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "jiangpengcheng (via GitHub)" <gi...@apache.org> on 2023/02/09 02:27:48 UTC
[GitHub] [pulsar] jiangpengcheng commented on a diff in pull request #18432: [improve][fn] Support schema in python instance
jiangpengcheng commented on code in PR #18432:
URL: https://github.com/apache/pulsar/pull/18432#discussion_r1100912554
##########
pulsar-functions/instance/src/main/python/python_instance.py:
##########
@@ -460,3 +481,45 @@ def close(self):
if self.pulsar_client:
self.pulsar_client.close()
+
+ def get_schema(self, schema_type, type_class_name, schema_properties):
+ schema = DEFAULT_SCHEMA
+ if schema_type == "" or schema_type is None:
+ schema = DEFAULT_SCHEMA
+ elif schema_type.lower() == "string":
+ schema = pulsar.schema.StringSchema()
+ elif schema_type.lower() == "json":
+ record_kclass = self.get_record_class(type_class_name)
+ schema = pulsar.schema.JsonSchema(record_kclass)
+ elif schema_type.lower() == "avro":
+ record_kclass = self.get_record_class(type_class_name)
+ schema = pulsar.schema.AvroSchema(record_kclass, schema_properties)
+ else: # load custom schema
Review Comment:
python client only supports avro, json, string and bytes schema for now
I will add todo here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org