exportavro()

Read(186) Label: avro, avsc, data structure,

Description:

Export data to an Avro data file.

Syntax:

exportavro(avrofile,A/cs,Fi:Ti,...)

Note:

External library function (See External Library Guide).

 

The function exports data in a table sequence or a cursor to an Avro data file and returns a file object.

 

When parameter Ti is absent, esProc automatically identifies the data type according to Fi values of table sequence A or cursor cs. As Avro data files do not have time data type such as date, time and datetime, a field of such a data type needs to be specified as long type and values will be exported in milliseconds. For example, the exported value for 2023-11-29 00:45:24 is 1701189924000.

Parameter:

avrofile

Avro file object that cannot be omitted; do not support remote file objects such as httpfile() and Qfile()

A/cs

A table sequence/ cursor

Fi

Field name; export all fields by default

Ti

Specify data type of the to-be-exported field(s), which can be string, boolean, bytes, double, float, int and long

Option:

@a

Append-export; overwrite the existing data by default

Return vlaue:

File object

Example:

 

A

 

1

=file("user1.avro")

Read the Avro file.

2

=connect("mysql")

 

3

=A2.query("select * from orders")

Return a table sequence.

4

=exportavro(A1,A3)

Export all data of table sequence A3 to overwrite the existing data in user1.avro.

5

=importavro(A4)

The exported values of a time type field is in miliseconds.

6

=A5.run(datetime(odate):odate)

7

=exportavro@a(A1,A3,oid:int,oname:string,odate:long)

Append specified data in table sequence A3 to user1.avro.

8

=exportavro@a(A1,A3,oid,oname,odate)

Same as above.