/*
syntax='proto3';

message Test {
  message InnerInner {
    string a = 1;
  }
  message Inner {
    InnerInner i = 1;
  }
  Inner inner = 1;
}
*/

$configNO = @@{
  "name": "Test",
  "format": "json",
  "skip": 0,
  "lists": {
    "optional": false
  },
  "meta": "eNrjamXk4i7ISczM0ysoyi/JV8rjYglJLS4RUuRizczLSy2SYFRg1OA24tYDiep5goSCIDJSUlxcYD6YEOLhYkwEK+YMYkyUUudihQjLcTFmQs0QQDIDYhBjZhIb2FpjAIm1I9Q=",
  "view": {
    "recursion": "bytes",
    "enum": "number",
    "yt_mode": true
  }
}
@@;

/*
syntax='proto3';

import "yt/yt_proto/yt/formats/extension.proto";

message Test {
  option (NYT.default_field_flags) = SERIALIZATION_YT;
  message InnerInner {
    option (NYT.default_field_flags) = SERIALIZATION_YT;
    string a = 1;
  }
  message Inner {
    option (NYT.default_field_flags) = SERIALIZATION_YT;
    InnerInner i = 1;
  }
  Inner inner = 1;
}
*/

$configYT = @@{
  "name": "Test",
  "format": "json",
  "skip": 0,
  "lists": {
    "optional": false
  },
  "meta": "eNrFWs2P28YVrz5XetJqKe7aVtZxbCsf3jixNnA+u27TaCXuRq6+SmmTrIGA4EojmTZFKiRle42iCNBTj7kGRQ+9pOgfUKDopUUvPRUo0OZWoGgLtH9Cj30zQ1KkPrxygCQ5bMQ372ve/GbeezOGP96CK0PTHOpkd2yZjnkyGez2id2ztLFjWiVGEzc4R8njKDYgf6DppOozdogjvgPxARILkSuxnczNF0ozQqWwRJuSZSZR/HccNheMiiLEDXVENUZ20jL7LRZgbaz27qtDUogysvcpPgfQJ2Ni9InROy3E0Iu0HKCIr0B+PDnRtZ4SYANkS8gCH6hOma/BxkOi3g+yZhhrjpIDjBXIjohtowOKczomhTib/ZW52c/OPONKdVFILEOaGJMR15BYEj8JOWa1pKiYq2LNJtYDrUcKSabg2pyCDh+f1eHJ4VTS5JFDDFszjcIaU/LiglUken9WxVROfAvWzLGDv+xCCtcnc/PZhUBocR7ZYxZrINjmxOoRp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JNUljOZluBjk2D/mv7yyL1L8/nRVWLXHTO24pjCvdKR2WUZLrgYhK2Zg7YMyBhYXY33PgQIFvOI9KfBXgwEqscUnPtcW/vo7+haZu3mxhPgpzfnAL0fPDdhbPtPtD9lzVtl76UpW/7bQqo/Heav+kL33GLZDVr2uchW7X7p2L4XsBpaXW74QsBwYtPdkSHAzT35KWRLVmflxVXvvQaZn6pMRf8U5SzONHDvUuAxNd3uHsHGfnCpPoeVLV8s6ylWmigzYXISgs15hVwNRvj8HoIC9IHbOtLcSfDx7AegQWA+j5UxLKwLG+xcj3MzH3rPdMqwEG7rVgscf/bj6BogPVEtTDS9qS1Y8ZMXDjeCKsqjQRd9/7U5JLZ2q9D3xhkPUUcma7D4x9cCfIpAd66pmnHJj20+XqoqfRiDeJTYtwxKagQUA68QyNzMlSi3VKEnmI9tXsHymP9gfPKEjqnuhHVH34r/6+8X49g1I8MHnIKK5moSAJq4uonF2/vckyV8y/w/fjdbu",
  "view": {
    "recursion": "bytes",
    "enum": "number",
    "yt_mode": true
  }
}
@@;

/*
syntax='proto3';

import "yt/yt_proto/yt/formats/extension.proto";

message Test {
  option (NYT.default_field_flags) = SERIALIZATION_PROTOBUF;
  message InnerInner {
    option (NYT.default_field_flags) = SERIALIZATION_PROTOBUF;
    string a = 1;
  }
  message Inner {
    option (NYT.default_field_flags) = SERIALIZATION_PROTOBUF;
    InnerInner i = 1;
  }
  Inner inner = 1;
}
*/

$configPB = @@{
  "name": "Test",
  "format": "json",
  "skip": 0,
  "lists": {
    "optional": false
  },
  "meta": "eNrFWs2P28YVrz5XetJqKe7aVtZxbCsf3jixNnA+u27TaCXuRq6+SmmTrIGA4EojmTZFKiRle42iCNBTj7kGRQ+9pOgfUKDopUUvPRUo0OZWoGgLtH9Cj30zQ1KkPrxygCQ5bMQ372ve/GbeezOGP96CK0PTHOpkd2yZjnkyGez2id2ztLFjWiVGEzc4R8njKDYgf6DppOozdogjvgPxARILkSuxnczNF0ozQqWwRJuSZSZR/HccNhe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YDXR0WP4tCnCZLcQ1i5eYxnmV5WG9135dkpdKqHzWa9CTLQopeg9IrWuwCNrBCoF9uIRPD0AodSa6V67U7ZXqXqRx3hbi4DefD1Lbc6rb2jw6EBLXhXXEq9VqnKySZWfcmlJPWcK9eapTbSrnDCErrgJo8wsNVqUuH5cqxkKJGFrMIaeqnO1atVboCiAXYcgm+JTaSYRPEMqxaxa4nW7wPm16g3FaGharrRuoVuFaV2rJUobexSqcld5WDmlSvdqjmmjtPJNUljOZluBjk2D/mv7yyL1L8/nRVWLXHTO24pjCvdKR2WUZLrgYhK2Zg7YMyBhYXY33PgQIFvOI9KfBXgwEqscUnPtcW/vo7+haZu3mxhPgpzfnAL0fPDdhbPtPtD9lzVtl76UpW/7bQqo/Heav+kL33GLZDVr2uchW7X7p2L4XsBpaXW74QsBwYtPdkSHAzT35KWRLVmflxVXvvQaZn6pMRf8U5SzONHDvUuAxNd3uHsHGfnCpPoeVLV8s6ylWmigzYXISgs15hVwNRvj8HoIC9IHbOtLcSfDx7AegQWA+j5UxLKwLG+xcj3MzH3rPdMqwEG7rVgscf/bj6BogPVEtTDS9qS1Y8ZMXDjeCKsqjQRd9/7U5JLZ2q9D3xhkPUUcma7D4x9cCfIpAd66pmjLmx7adLVcVPIxDvEpuWYQnNwAKAdWKZm5kSpZZqlCTzke0rWD7TH+wPntAR1b3Qjqh78V/9/WJi+wYk+OBzENFcTUJAE1cX0Tg7/3uS5C+Z/wfZGtbo",
  "view": {
    "recursion": "bytes",
    "enum": "number",
    "yt_mode": true
  }
}
@@;

$udfParNO = Udf(Protobuf::Parse, $configNO as TypeConfig);
$udfSerNO = Udf(Protobuf::Serialize, $configNO as TypeConfig);
$udfParYT = Udf(Protobuf::Parse, $configYT as TypeConfig);
$udfSerYT = Udf(Protobuf::Serialize, $configYT as TypeConfig);
$udfParPB = Udf(Protobuf::Parse, $configPB as TypeConfig);
$udfSerPB = Udf(Protobuf::Serialize, $configPB as TypeConfig);

SELECT TestField,
       Ensure("Success", $udfParNO(TestField) == $udfParNO($udfSerNO($udfParNO(TestField))), "Fail"),
       Ensure("Success", $udfParYT(TestField) == $udfParYT($udfSerYT($udfParYT(TestField))), "Fail"),
       Ensure("Success", $udfParPB(TestField) == $udfParPB($udfSerPB($udfParPB(TestField))), "Fail")
FROM plato.Input;

