/*
syntax='proto3';

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

message Test {
  option (NYT.default_field_flags) = SERIALIZATION_YT;
  option (NYT.default_oneof_flags) = VARIANT;

  oneof Var {
    Test test = 1 [(NYT.column_name) = "_test"];
    string a = 2;
  }
  string Name = 3 [(NYT.column_name) = "name"];;
}
*/

$configVar = @@{
  "name": "Test",
  "format": "json",
  "skip": 0,
  "lists": {
    "optional": false
  },
  "meta": "eNrFWs2P28YVjz5XetrVUty1razjOFESe+PE2sD57LpNow/uWq6+SmmTrIGA4FIjLW2JVEjK9ho9FOippyLXoCiKXlLk1FOBopcWvRcI0OYWoGgLtH9Cj30zQ1KkpPXKAZL4YItv3te8+c2892YMf7kJzw1MczAkO2PLdMyjSX+nR2zN0seOaRUZTVznHEWPo9CA3J4+JFWfsUMc8R2I95GYjzwX287ceLE4I1QMS7QpWWYShX/HYWPBqChC3FBHVGNkOy2z32IeVsaqdk8dkHyUkb1P8VmAHhkTo0cM7SQfQy/ScoAivgK58eRoqGtKgA2QLSELfKA6Zb4K6w+Iei/ImmGsWUoOMFZgdURsGx1QnJMxycfZ7J+bm/3szDOuVBeFxBKkiTEZcQ2JU+InIceslhQVc1Ws2MS6r2skn2QKrs4p6PDxWR2eHE4lTR46xLB108ivMCUvLVhFMuzNqpjKiW/Bijl28JedT+H6ZG48sxAILc4je8xiDQTbnFgaUTSzRxTd6Jv5NFNweX4ijLGCfDVkk7N26Fs8D0n7xHDUh/lVhhD3q/CHJKwvA7GbkOjTWSLAniAGXCYcxOTXDGIJMgaxHdLjiIgtiSngQvOQin8tSH0I675LiqUaAw+bO2d5UpQ8OZmKyVkS+harAKZBzD5uL22IOFkcpRZlmYuSyanaUPzeFGorpyClwTfZHNoOIGsRinsMMZ9ZmjlRPHNmsivGJ7ZmBT/FF8AnKAxWwE6hVY/YRNrWI8iGwyNuQsJ2VMthKEzI/EMUIIaHDDvlEjL9Kb43nXCMTfjK/IqGNM/Oe+ttWAtNYFnThZ/AuYWqESSbE0M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TFw43girKo0EUvv3anqBZPVPqeeN0h6qhoTXYem3rgd1jTnDjc0NaTpanCCOJdYjviFYg7+C/ryjI3EkVKLKc//+piQqH0W0/JbBwL6ojKMzuSIqr4DMSp17wMKqdQgJXAMqPupn6L37/+6uJaOQGx91XrKMlfLP8PjbXUZg==",
  "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;
  option (NYT.default_oneof_flags) = SEPARATE_FIELDS;

  oneof Var {
    Test test = 1 [(NYT.column_name) = "_test"];
    string a = 2;
  }
  string Name = 3 [(NYT.column_name) = "name"];;
}
*/

$configSeparate = @@{
  "name": "Test",
  "format": "json",
  "skip": 0,
  "lists": {
    "optional": false
  },
  "meta": "eNrFWs2P28YVjz5XetrVUty1razjOFESe+PE2sD57LpNow/uWq6+SmmTrIGA4FIjLW2JVEjK9ho9FOippyLXoCiKXlLk1FOBopcWvRcI0OYWoGgLtH9Cj30zQ1KkpPXKAZL4YItv3te8+c2892YMf7kJzw1MczAkO2PLdMyjSX+nR2zN0seOaRUZTVznHEWPo9CA3J4+JFWfsUMc8R2I95GYjzwX287ceLE4I1QMS7QpWWYShX/HYWPBqChC3FBHVGNkOy2z32IeVsaqdk8dkHyUkb1P8VmAHhkTo0cM7SQfQy/ScoAivgK58eRoqGtKgA2QLSELfKA6Zb4K6w+Iei/ImmGsWUoOMFZgdURsGx1QnJMxycfZ7J+bm/3szDOuVBeFxBKkiTEZcQ2JU+InIceslhQVc1Ws2MS6r2skn2QKrs4p6PDxWR2eHE4lTR46xLB108ivMCUvLVhFMuzNqpjKiW/Bijl28JedT+H6ZG48sxAILc4je8xiDQTbnFgaUTSzRxTd6Jv5NFNweX4ijLGCfDVkk7N26Fs8D0n7xHDUh/lVhhD3q/CHJKwvA7GbkOjTWSLAniAGXCYcxOTXDGIJMgaxHdLjiIgtiSngQvOQin8tS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ip7L13K6t8XWvXxOG/VH7J3H8FWyKrXVS5j90vX7qWQ3cDycssXApYDg/auDAlu5vFPKadEdWZ+XNXue5DRzOFkxF9xztJMI8eOOS5DE+DuPqzfIyfKE2j50tWyhnKVqSIDNhYh6KxX2OVAlOvNAShgL4idM+0tBR/PXgA6BNbCaDnT0pKA8f7HCDfzkfdsdxpWgi3ecsHjj35cfQPE+6qlq4YXtVNWPGTFw43girKo0EUvv3anqBZPVPqeeN0h6qhoTXYem3rgd1jTnDjc0NaTpanCCOJdYjviFYg7+C/ryjI3EkVKLKc//+piQqH0W0/JbBwL6ojKMzuSIqr4DMSp17wMKqdQgJXAMqPupn6L37/+6uJqOQGx91XrKMlfLP8PjaXUZQ==",
  "view": {
    "recursion": "bytes",
    "enum": "number",
    "yt_mode": true
  }
}
@@;

$udfParseVar = Udf(Protobuf::Parse, $configVar as TypeConfig);
$udfSerializeVar = Udf(Protobuf::Serialize, $configVar as TypeConfig);

$udfParseSep = Udf(Protobuf::Parse, $configSeparate as TypeConfig);
$udfSerializeSep = Udf(Protobuf::Serialize, $configSeparate as TypeConfig);

SELECT
    TestField,
    $udfParseVar(TestField),
    $udfSerializeVar($udfParseVar(TestField)),
    Ensure("Success", StablePickle($udfParseVar(TestField)) == StablePickle($udfParseVar($udfSerializeVar($udfParseVar(TestField)))), "Fail"),
    $udfParseSep(TestField),
    $udfSerializeSep($udfParseSep(TestField)),
    Ensure("Success", StablePickle($udfParseSep(TestField)) == StablePickle($udfParseSep($udfSerializeSep($udfParseSep(TestField)))), "Fail"),
FROM plato.Input;

