Skip to main content

Avro Data Types

使用输入数据工具读取未压缩和 Deflate 压缩的 Avro 文件,并使用输出数据工具写入 Avro 文件。

输入

仅支持 Deflate 压缩。

支持 14 种原生 Avro 数据类型中的大多数。导入时的类型映射如下:

  • 字符串:UTF-8 转换为 V_WString (UTF-16)

  • 字节:保持为 Blob(必要时使用 Blob 工具进行转换)

  • 整型:保持为 Int32

  • 长整型:保持为 Int64

  • 单精度:保持为单精度

  • 双精度:保持为双精度

  • 布尔:保持为 Bool

  • 空:不支持

  • 枚举型:转换为 String Equivalent

  • Union:Alteryx 支持两个子类型的联合。两个子类型必须相同(例如,都是整型或都是双精度),或者其中一个子类型必须为空。

    • Alteryx 字段类型是非空分支的类型(如果两个分支均为非空分支,则为两个分支的类型)。

    • 如果非空分支处于活动状态,则 Alteryx 字段包含该值。

    • 如果空分支处于活动状态,则 Alteryx 字段被设置为空。

    • 无效联合将作为 JSON 导入到一个 V_WString 中(必要时使用 JSON 解析工具进行转换)。例如,以整型作为其活动分支的一个联合可以表示为“{"int":123}”。

  • 定点数:保持为 Blob(必要时使用 Blob 工具进行转换)

这些 Avro 类型本身不受支持,但可以作为 JSON 导入到一个字符串中(必要时使用 JSON 解析工具进行转换):

  • 记录:例如,对于同时包含整型和字符串字段的记录,使用“{"SubField1":7,"SubField2":"Field2"}”。

  • 数组:例如,“[1,2,3,4,5]”表示一个整型数组。

  • 映射:例如,“{"Key1":Value1,"Key2":Value2}”表示一个字符串到双精度数的映射。

输出

写入 Avro 文件时,有 2 个选项:

  1. 启用压缩 (Deflate):启用压缩会增加输出时间,但是对于较大的文件,也会减少网络时间。支持的压缩使用 DEFLATE 算法(本质上是 gzip),应当得到其他支持 Avro 的工具(如 Hive)的原生支持。

  2. 支持空值:选择此选项会向 _all_ 字段写入具有一个空分支和一个有值分支的联合。如果 Alteryx 值为空,则输出的 Avro union 会选择其空分支,否则会选择其有值分支。

    如果未选择此选项,所有输出字段都会按其原生 Avro 类型写入(非联合)。空的 Alteryx 字段会被写入默认值(例如,int32 字段写入 0,字符串字段写入空字符串)。

    考虑使用公式工具处理具有“已知”值的空值,这样它们就可以在 Hadoop 中处理。

Alteryx 到 Avro 的类型映射如下:

  • Bool:保持为布尔值

  • 字节、Int16、Int32:保持为整型(32 位)

  • Int64:保持为长整型(64 位)

  • 单精度:保持为单精度

  • DateTime 作为日期、时间、日期时间

  • 双精度:保持为双精度

  • 定点十进制:转换为双精度数

  • 字符串、V_String、日期、时间、日期时间:保持为字符串 (UTF-8)

  • WString、V_WString:转换为字符串 (UTF-8)

  • Blob、SpatialBlob:保持为字节

AVRO file Read/Write From Alteryx Designer

Earlier, in the .avro file, the DateTime field was represented solely using the logical type timestamp-millis (i.e., in UTC). Now, a Time Zone dropdown has been introduced in both the Read and Write options, offering the values No Time Zone and Local Time Zone.

  • No Time Zone: The DateTime is treated as timestamp-millis in Avro. This ensures backward compatibility, as no time zone conversion occurs during Avro read or write operations.

  • Local Time Zone: DateTime values are converted. During Avro write, the conversion is based on the Default Time Zone configured in the Runtime settings.

During Avro read, DateTime conversion is performed based on the stored logicalType and the Default Time Zone specified in the Runtime settings. For example: If the local time zone is IST (UTC +05:30) and the Default Time Zone is CEST (UTC +02:00), a DateTime value of 2026-03-25 22:00:00 will be converted during .avro write. Since IST is 3 hours and 30 minutes ahead of CEST, the value will be adjusted to 2026-03-25 18:30:00 in CEST.

Below is a summary of DateTime conversions during Avro write and read operations. In the examples, the Local Time Zone is IST. The first four columns represent the .avro Write scenario, while the next three columns represent the Read scenario for the same Avro data.

Incoming Time

Workflow Runtime TZ

AVRO TZ

AVRO Write

AVRO TZ

Workflow Runtime TZ

Alteryx AVRO Read

2026, 2, 11, 22:00:00

Local

NTZ

2026, 2, 11, 22:00:00 (Timestamp-millis)

NTZ

Local

2026, 2, 11, 22:00:00

NTZ

UTC

2026, 2, 11, 22:00:00

LTZ

UTC

2026, 2, 11, 22:00:00

LTZ

Local

2026, 2, 12, 03:30:00

2026, 2, 11, 22:00:00

Local

LTZ

2026, 2, 11, 22:00:00 (Local timestamp-millis)

NTZ

Local

2026, 2, 11, 22:00:00

LTZ

Local

2026, 2, 11, 22:00:00

NTZ

UTC

2026, 2, 11, 22:00:00

LTZ

UTC

2026, 2, 11, 16:30:00

2026, 2, 11, 22:00:00

UTC

NTZ

2026, 2, 11, 22:00:00 (Timestamp-millis)

LTZ

UTC

2026, 2, 11, 22:00:00

UTC

2026, 2, 11, 22:00:00

Local

2026, 2, 11, 22:00:00

Local

2026, 2, 12, 03:30:00

2026, 2, 11, 22:00:00

UTC

LTZ

2026, 2, 12, 03:30:00 (Local--timestamp-millis)

LTZ

Local

2026, 2, 12, 03:30:00

NTZ

Local

2026, 2, 12, 03:30:00

NTZ

UTC

2026, 2, 12, 03:30:00

LTZ

UTC

2026, 2, 11, 22:00:00

2026, 2, 11, 22:00:00

CEST

LTZ

2026, 2, 12, 2: 30:00 (Local-timestamp-millis)

LTZ

Local

2026-02-12 02:30:00

2026-02-11 21:00:00

2026-02-12 02:30:00

2026-02-12 02:30:00

2026, 2, 11, 22:00:00

CEST

NTZ

2026, 2, 11, 22:00:00 (Timestamp-millis)

LTZ

Local

2026-02-12 03:30:00

LTZ

UTC

2026-02-11 22:00:00

NTZ

UTC

2026-02-11 22:00:00

NTZ

Local

2026-02-11 22:00:00