This is an automated email from the ASF dual-hosted git repository.
rskraba pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/avro.git
The following commit(s) were added to refs/heads/master by this push:
new 64267e1 AVRO-3217: Allow any identifier as annotation name (#1414)
64267e1 is described below
commit 64267e1f4e54a12551d02ff85e41c18090917e69
Author: Oscar Westra van Holthe - Kind <[email protected]>
AuthorDate: Sat Dec 4 14:35:16 2021 +0100
AVRO-3217: Allow any identifier as annotation name (#1414)
A field schema can be annotated with the property `avro.java.string`:
{
"name": "fieldName",
"type": {
"type": "string",
"avro.java.string": "String"
}
}
The corresponding IDL is:
@avro.java.`string`("String") string fieldName;
The IDL parser fails on the `. This change fixes that.
---
.../compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj | 7 ++++---
lang/java/compiler/src/test/idl/input/simple.avdl | 2 +-
lang/java/compiler/src/test/idl/output/simple.avpr | 5 ++++-
3 files changed, 9 insertions(+), 5 deletions(-)
diff --git
a/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
b/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
index 0a2b696..15d251e 100644
--- a/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
+++ b/lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
@@ -1551,14 +1551,15 @@ Schema ResultType():
String PropertyName():
{
Token t;
+ String s;
StringBuilder name = new StringBuilder();
}
{
- t = <IDENTIFIER> { name.append(t.image); }
+ s = Identifier() { name.append(s); }
( t = <DASH> { name.append(t.image); }
- t = <IDENTIFIER> { name.append(t.image); } |
+ s = Identifier() { name.append(s); } |
t = <DOT> { name.append(t.image); }
- t = <IDENTIFIER> { name.append(t.image); }
+ s = Identifier() { name.append(s); }
) *
{ return name.toString(); }
}
diff --git a/lang/java/compiler/src/test/idl/input/simple.avdl
b/lang/java/compiler/src/test/idl/input/simple.avdl
index 10e50c9..0d09272 100644
--- a/lang/java/compiler/src/test/idl/input/simple.avdl
+++ b/lang/java/compiler/src/test/idl/input/simple.avdl
@@ -42,7 +42,7 @@ protocol Simple {
/** A TestRecord. */
@my-property({"key":3})
record TestRecord {
- string @order("ignore") name = "foo";
+ @avro.java.`string`("String") string @order("ignore") name = "foo";
/** The kind of record. */
Kind @order("descending") kind;
diff --git a/lang/java/compiler/src/test/idl/output/simple.avpr
b/lang/java/compiler/src/test/idl/output/simple.avpr
index ddcb626..5710f08 100644
--- a/lang/java/compiler/src/test/idl/output/simple.avpr
+++ b/lang/java/compiler/src/test/idl/output/simple.avpr
@@ -26,7 +26,10 @@
"doc" : "A TestRecord.",
"fields" : [ {
"name" : "name",
- "type" : "string",
+ "type" : {
+ "type": "string",
+ "avro.java.string": "String"
+ },
"default" : "foo",
"order" : "ignore"
}, {