public TVFInfo deserialize()

in zetasql-toolkit-core/src/main/java/com/google/zetasql/toolkit/catalog/io/JsonCatalogDeserializer.java [373:425]


    public TVFInfo deserialize(
        JsonElement jsonElement, java.lang.reflect.Type type, JsonDeserializationContext context)
        throws JsonParseException {
      JsonObject jsonObject =
          getAsJsonObject(
              jsonElement, "Invalid JSON TVF: " + jsonElement + ". TVFs should be objects.");

      String functionName =
          getFieldAsString(
              jsonObject,
              "name",
              "Invalid JSON TVF: " + jsonElement + ". Field name should be string.");

      FunctionArgumentType[] arguments =
          Optional.ofNullable(jsonObject.get("arguments"))
              .map(
                  jsonArguments -> context.deserialize(jsonArguments, FunctionArgumentType[].class))
              .map(FunctionArgumentType[].class::cast)
              .orElseThrow(
                  () ->
                      new JsonParseException(
                          "Invalid JSON TVF: " + jsonElement + ". Arguments missing."));

      JsonArray outputColumns =
          getFieldAsJsonArray(
              jsonObject,
              "outputColumns",
              "Invalid JSON TVF: "
                  + jsonElement
                  + ". Field outputColumns should be array of columns.");

      List<TVFRelation.Column> parsedOutputColumns =
          outputColumns.asList().stream()
              .map(
                  jsonColumn ->
                      getAsJsonObject(
                          jsonColumn,
                          "Invalid JSON column " + jsonColumn + ". Should be JSON object."))
              .map(JsonCatalogDeserializer::deserializeTVFOutputColumn)
              .collect(Collectors.toList());

      FunctionArgumentType returnType =
          new FunctionArgumentType(
              SignatureArgumentKind.ARG_TYPE_RELATION,
              FunctionArgumentTypeOptions.builder().build(),
              1);

      return TVFInfo.newBuilder()
          .setNamePath(ImmutableList.of(functionName))
          .setSignature(new FunctionSignature(returnType, Arrays.asList(arguments), -1))
          .setOutputSchema(TVFRelation.createColumnBased(parsedOutputColumns))
          .build();
    }