إشعار
يتطلب الوصول إلى هذه الصفحة تخويلاً. يمكنك محاولة تسجيل الدخول أو تغيير الدلائل.
يتطلب الوصول إلى هذه الصفحة تخويلاً. يمكنك محاولة تغيير الدلائل.
ينطبق على:
Databricks SQL
Databricks Runtime 15.4 والإحدث
إرجاع قيمة بنية مع avroBin و jsonSchemaStr.
بناء الجملة
from_avro(avroBin, jsonSchemaStr [, options] )
الوسيطات
avroBinBINARY: تعبير يحدد صفا من بيانات Avro.avroSchemaSpec: المخطط الهدف بتنسيق JSON. يجب أن يتطابق مع المخطط المشفر فيavroBinكما هو محدد في to_avro().options: توجيه تحديد حرفي اختياريMAP<STRING,STRING>.
المرتجعات
مع STRUCT أسماء الحقول وأنواعها استنادا إلى نتيجة schema_of_json (jsonStr).
avroBin يجب أن تكون جيدة التكوين فيما يتعلق avroSchemaSpec ب و options أو Databricks يثير استثناء.
ملاحظات
الخيارات التالية هي الأكثر شيوعا المدعومة:
| خيار | قيمة | الوصف |
|---|---|---|
'mode' |
'PERMISSIVE', 'FAILFAST' |
في PERMISSIVE الوضع، يتم تعيين أي كائنات أو حقول تالفة في كائن إلى NULL بدلا من رفع خطأ. |
compression |
'uncompressed'، ، 'snappy''deflade'، 'bzip2'، ، 'xz''zstandard' |
يحدد برنامج ترميز الضغط المستخدم لترميز بيانات Avro. |
لمزيد من الخيارات، راجع قراءة وكتابة بيانات Avro المتدفقة.
الأمثلة
> SELECT from_avro(to_avro(5), '{ "type" : "int" }');
5
> SELECT from_avro(to_avro(5, '{ "type" : "int" }'), '{ "type" : "int" }');
5
> SELECT from_avro(to_avro(named_struct('num', 5, 'txt', 'hello')), '{ "type" : "record", "name": "my_record", "fields": [{ "name": "num", "type": "int"}, { "name": "txt", "type": "string"}]}');
{"num":5,"txt":"hello"}
> SELECT from_avro(to_avro(named_struct('num', 5, 'txt', 'hello')),
'{ "type" : "record", "name": "my_record", "fields": [{ "name": "num", "type": "int"}, { "name": "txt", "type": "double"}]}',
map('mode', 'failfast'));
Error: Avro data is not valid for the specified schema.
> SELECT from_avro(to_avro(named_struct('num', 5, 'txt', 'hello')),
'{ "type" : "record", "name": "my_record", "fields": [{ "name": "num", "type": "int"}, { "name": "txt", "type": "double"}]}',
map('mode', 'permissive'));
{"num":null,"txt":null}