Skip to content

Commit

Permalink
AVRO-1918: Improve logical type documentation. Contributed by Gabor S…
Browse files Browse the repository at this point in the history
…zadovszky.
  • Loading branch information
cutting committed Sep 27, 2016
1 parent 1296ce9 commit a92c8f5
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ Trunk (not yet released)

AVRO-1919: Formalize the presence of build.sh. (Suraj Acharya via cutting)

AVRO-1918: Improve logical type documentation. (Gabor Szadovszky via cutting)

BUG FIXES

AVRO-1741: Python3: Fix error when codec is not in the header.
Expand Down
24 changes: 24 additions & 0 deletions doc/src/content/xdocs/idl.xml
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ error Kaboom {
<p>A type reference in Avro IDL must be one of:</p>
<ul>
<li>A primitive type</li>
<li>A logical type</li>
<li>A named schema defined prior to this usage in the same Protocol</li>
<li>A complex type (array, map, or union)</li>
</ul>
Expand All @@ -218,6 +219,29 @@ error Kaboom {
</p>
</section>

<section id="logical_types">
<title>Logical Types</title>
<p>Some of the logical types supported by Avro's JSON format are also supported by Avro IDL.
The currently supported types are:
</p>
<ul>
<li><code>decimal</code> (logical type <a href="spec.html#Decimal"><code>decimal</code></a>)</li>
<li><code>date</code> (logical type <a href="spec.html#Date"><code>date</code></a>)</li>
<li><code>time_ms</code> (logical type <a href="spec.html#Time+%28millisecond+precision%29"><code>time-millis</code></a>)</li>
<li><code>timestamp_ms</code> (logical type <a href="spec.html#Timestamp+%28millisecond+precision%29"><code>timestamp-millis</code></a>)</li>
</ul>
<p>For example:</p>
<source>
record Job {
string jobid;
date submitDate;
time_ms submitTime;
timestamp_ms finishTime;
decimal(9,2) finishRatio;
}
</source>
</section>

<section id="schema_references">
<title>References to Named Schemata</title>
<p>If a named schema has already been defined in the same Avro IDL file, it may be referenced by name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@

<li>Record, enum, and fixed schemas generate Java class definitions.</li>

<li>If a Conversion instance is available for the related logical type,
the value will be mapped to the object returned by that Conversion. The
logical type conversions for {@code date}, {@code time-millis}, {@code
timestamp-millis} and {@code decimal} are pre-defined in the class {@link
org.apache.avro.compiler.specific.SpecificCompiler SpecificCompiler}.</li>

<li>All other types are mapped as in the {@link org.apache.avro.generic
generic} API.</li>

Expand Down

0 comments on commit a92c8f5

Please sign in to comment.