org.apache.avro.SchemaParseException: “enum” is not a defined name
I'm using following tool
<dependency>
<groupId>tech.allegro.schema.json2avro</groupId>
<artifactId>converter</artifactId>
<version>0.2.7</version>
</dependency>
to convert json to avro, but I'm getting exception
Caused by: org.apache.avro.SchemaParseException: "enum" is not a defined name. The type of the "enumValue" field must be a defined name or a {"type": ...} expression.
at org.apache.avro.Schema.parse(Schema.java:1265)
at org.apache.avro.Schema$Parser.parse(Schema.java:1032)
at org.apache.avro.Schema$Parser.parse(Schema.java:997)
... removed by me, our code ...
for avro schema:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
]
}
and json:
{
"enumValue": "val_a"
}
dependency tree shows avro 1.8.2
[INFO] +- org.apache.kafka:kafka-clients:jar:2.0.0:compile
[INFO] | +- org.lz4:lz4-java:jar:1.4.1:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.7.1:compile
[INFO] | - org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | - (org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile - omitted for duplicate)
[INFO] | +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] | +- (org.xerial.snappy:snappy-java:jar:1.1.1.3:compile - omitted for conflict with 1.1.7.1)
[INFO] | +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] | +- org.tukaani:xz:jar:1.5:compile
[INFO] | - (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] +- tech.allegro.schema.json2avro:converter:jar:0.2.7:compile
[INFO] | - (org.apache.avro:avro:jar:1.8.2:compile - omitted for duplicate)
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- info.picocli:picocli:jar:3.7.0:compile
[INFO] - org.slf4j:slf4j-nop:jar:1.7.25:compile
[INFO] - (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
while enum definition seems to be quite the same as the one from avro home page:
For example, playing card suits might be defined with:
{ "type": "enum",
"name": "Suit",
"symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
}
So what can be wrong here? Definitions seems to be OK (is it?), latest avro seems to be used and that one should support enums. So what is wrong here?
avro
add a comment |
I'm using following tool
<dependency>
<groupId>tech.allegro.schema.json2avro</groupId>
<artifactId>converter</artifactId>
<version>0.2.7</version>
</dependency>
to convert json to avro, but I'm getting exception
Caused by: org.apache.avro.SchemaParseException: "enum" is not a defined name. The type of the "enumValue" field must be a defined name or a {"type": ...} expression.
at org.apache.avro.Schema.parse(Schema.java:1265)
at org.apache.avro.Schema$Parser.parse(Schema.java:1032)
at org.apache.avro.Schema$Parser.parse(Schema.java:997)
... removed by me, our code ...
for avro schema:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
]
}
and json:
{
"enumValue": "val_a"
}
dependency tree shows avro 1.8.2
[INFO] +- org.apache.kafka:kafka-clients:jar:2.0.0:compile
[INFO] | +- org.lz4:lz4-java:jar:1.4.1:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.7.1:compile
[INFO] | - org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | - (org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile - omitted for duplicate)
[INFO] | +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] | +- (org.xerial.snappy:snappy-java:jar:1.1.1.3:compile - omitted for conflict with 1.1.7.1)
[INFO] | +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] | +- org.tukaani:xz:jar:1.5:compile
[INFO] | - (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] +- tech.allegro.schema.json2avro:converter:jar:0.2.7:compile
[INFO] | - (org.apache.avro:avro:jar:1.8.2:compile - omitted for duplicate)
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- info.picocli:picocli:jar:3.7.0:compile
[INFO] - org.slf4j:slf4j-nop:jar:1.7.25:compile
[INFO] - (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
while enum definition seems to be quite the same as the one from avro home page:
For example, playing card suits might be defined with:
{ "type": "enum",
"name": "Suit",
"symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
}
So what can be wrong here? Definitions seems to be OK (is it?), latest avro seems to be used and that one should support enums. So what is wrong here?
avro
add a comment |
I'm using following tool
<dependency>
<groupId>tech.allegro.schema.json2avro</groupId>
<artifactId>converter</artifactId>
<version>0.2.7</version>
</dependency>
to convert json to avro, but I'm getting exception
Caused by: org.apache.avro.SchemaParseException: "enum" is not a defined name. The type of the "enumValue" field must be a defined name or a {"type": ...} expression.
at org.apache.avro.Schema.parse(Schema.java:1265)
at org.apache.avro.Schema$Parser.parse(Schema.java:1032)
at org.apache.avro.Schema$Parser.parse(Schema.java:997)
... removed by me, our code ...
for avro schema:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
]
}
and json:
{
"enumValue": "val_a"
}
dependency tree shows avro 1.8.2
[INFO] +- org.apache.kafka:kafka-clients:jar:2.0.0:compile
[INFO] | +- org.lz4:lz4-java:jar:1.4.1:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.7.1:compile
[INFO] | - org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | - (org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile - omitted for duplicate)
[INFO] | +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] | +- (org.xerial.snappy:snappy-java:jar:1.1.1.3:compile - omitted for conflict with 1.1.7.1)
[INFO] | +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] | +- org.tukaani:xz:jar:1.5:compile
[INFO] | - (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] +- tech.allegro.schema.json2avro:converter:jar:0.2.7:compile
[INFO] | - (org.apache.avro:avro:jar:1.8.2:compile - omitted for duplicate)
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- info.picocli:picocli:jar:3.7.0:compile
[INFO] - org.slf4j:slf4j-nop:jar:1.7.25:compile
[INFO] - (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
while enum definition seems to be quite the same as the one from avro home page:
For example, playing card suits might be defined with:
{ "type": "enum",
"name": "Suit",
"symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
}
So what can be wrong here? Definitions seems to be OK (is it?), latest avro seems to be used and that one should support enums. So what is wrong here?
avro
I'm using following tool
<dependency>
<groupId>tech.allegro.schema.json2avro</groupId>
<artifactId>converter</artifactId>
<version>0.2.7</version>
</dependency>
to convert json to avro, but I'm getting exception
Caused by: org.apache.avro.SchemaParseException: "enum" is not a defined name. The type of the "enumValue" field must be a defined name or a {"type": ...} expression.
at org.apache.avro.Schema.parse(Schema.java:1265)
at org.apache.avro.Schema$Parser.parse(Schema.java:1032)
at org.apache.avro.Schema$Parser.parse(Schema.java:997)
... removed by me, our code ...
for avro schema:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
]
}
and json:
{
"enumValue": "val_a"
}
dependency tree shows avro 1.8.2
[INFO] +- org.apache.kafka:kafka-clients:jar:2.0.0:compile
[INFO] | +- org.lz4:lz4-java:jar:1.4.1:compile
[INFO] | +- org.xerial.snappy:snappy-java:jar:1.1.7.1:compile
[INFO] | - org.slf4j:slf4j-api:jar:1.7.25:compile
[INFO] +- org.apache.avro:avro:jar:1.8.2:compile
[INFO] | +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] | +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.13:compile
[INFO] | | - (org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile - omitted for duplicate)
[INFO] | +- com.thoughtworks.paranamer:paranamer:jar:2.7:compile
[INFO] | +- (org.xerial.snappy:snappy-java:jar:1.1.1.3:compile - omitted for conflict with 1.1.7.1)
[INFO] | +- org.apache.commons:commons-compress:jar:1.8.1:compile
[INFO] | +- org.tukaani:xz:jar:1.5:compile
[INFO] | - (org.slf4j:slf4j-api:jar:1.7.7:compile - omitted for conflict with 1.7.25)
[INFO] +- tech.allegro.schema.json2avro:converter:jar:0.2.7:compile
[INFO] | - (org.apache.avro:avro:jar:1.8.2:compile - omitted for duplicate)
[INFO] +- commons-io:commons-io:jar:2.6:compile
[INFO] +- info.picocli:picocli:jar:3.7.0:compile
[INFO] - org.slf4j:slf4j-nop:jar:1.7.25:compile
[INFO] - (org.slf4j:slf4j-api:jar:1.7.25:compile - omitted for duplicate)
while enum definition seems to be quite the same as the one from avro home page:
For example, playing card suits might be defined with:
{ "type": "enum",
"name": "Suit",
"symbols" : ["SPADES", "HEARTS", "DIAMONDS", "CLUBS"]
}
So what can be wrong here? Definitions seems to be OK (is it?), latest avro seems to be used and that one should support enums. So what is wrong here?
avro
avro
asked Nov 19 '18 at 17:48
Martin Mucha
14410
14410
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I was wrong, correct definition looks like:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": {
"name": "EnumType",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
}
]
}
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380112%2forg-apache-avro-schemaparseexception-enum-is-not-a-defined-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I was wrong, correct definition looks like:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": {
"name": "EnumType",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
}
]
}
add a comment |
I was wrong, correct definition looks like:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": {
"name": "EnumType",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
}
]
}
add a comment |
I was wrong, correct definition looks like:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": {
"name": "EnumType",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
}
]
}
I was wrong, correct definition looks like:
{
"namespace": "test",
"type": "record",
"name": "test",
"fields": [
{
"name": "enumValue",
"type": {
"name": "EnumType",
"type": "enum",
"symbols": [
"val_a",
"val_b"
]
}
}
]
}
answered Nov 19 '18 at 19:11
Martin Mucha
14410
14410
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53380112%2forg-apache-avro-schemaparseexception-enum-is-not-a-defined-name%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown