Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot parse schema containing array of non-primitive types #8

Open
emlyn opened this issue Nov 22, 2018 · 0 comments
Open

Cannot parse schema containing array of non-primitive types #8

emlyn opened this issue Nov 22, 2018 · 0 comments

Comments

@emlyn
Copy link

emlyn commented Nov 22, 2018

When I try to build the following schema from JSON:

  [<Fact>]
  let ``Array of records builds`` () =
    JsonSchemaBuilder().BuildSchema("""
{
  "type": "record",
  "name": "OuterRecord",
  "namespace": "test.namespace",
  "fields": [
    {
      "name": "arrField",
      "type": "array",
      "items": {
        "name": "recField",
        "type": {
          "type": "record",
          "name": "InnerRecord",
          "namespace": "test.namespace",
          "fields": [
            {
              "name": "intField",
              "type": "int"
            }
          ]
        }
      }
    }
  ]
}""")

it fails with the following stack trace:

[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5470977]       System.Collections.Generic.KeyNotFoundException : The given key was not present in the dictionary.
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5477750]       Stack Trace:
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5484813]            at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5485430]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.CreatePrimitiveTypeSchema(String type, Dictionary`2 attributes)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5485956]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.Parse(JToken token, NamedSchema parent, Dictionary`2 namedSchemas)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5486442]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.ParseRecordField(JObject field, NamedSchema parent, Dictionary`2 namedSchemas, Int32 position)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5487017]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.<>c__DisplayClass9_0.<ParseRecordType>b__0(JToken field, Int32 index)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5487472]            at System.Linq.Enumerable.<SelectIterator>d__5`2.MoveNext()
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5487888]            at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5488318]            at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5488812]            at Microsoft.Hadoop.Avro.Schema.JsonExtensions.ReadArrayProperty[T](JToken token, String propertyName, Boolean isOptional, Func`3 func)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5489228]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.ParseRecordType(JObject record, NamedSchema parent, Dictionary`2 namedSchemas)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5489725]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.ParseJsonObject(JObject token, NamedSchema parent, Dictionary`2 namedSchemas)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5490233]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.Parse(JToken token, NamedSchema parent, Dictionary`2 namedSchemas)
[20/11/2018 09:42:37 Informational] [xUnit.net 00:00:01.5490674]            at Microsoft.Hadoop.Avro.Schema.JsonSchemaBuilder.BuildSchema(String schema)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant