hdfs_write()

Description:

Upload data to the specified location in HDFS.

Syntax:

hdfs_write(hd,file,A/cs,x:F)

Note:

The external library function uploads a table sequence, a record sequence or a cursor to the specified location in HDFS.

Parameters:

hd

An hd connection

file

The location and name of the file to be loaded to HDFS; can be .txt file or .csv file

A/cs

A table sequence/record sequence/cursor; do not support a random access file, such as .btx

x

The field(s) to be uploaded; upload all fields when the parameter is absent

F

The result field name(s) in the form of string; use original field names when the parameter is absent

Options:

@a

Appen-write; the to-be-appended content should have same structure as the original file content, otherwise error will be reported; ignore @t option when the target file already has content; overwrite the original file by default

@t

Write the field name information (titles) to the target file as the first row

Return value:

Boolean value

Example:

 

A

 

1

=hdfs_open("hdfs://localhost:9000")

Connect to hdfs

2

=file("D:\\tmp\\emp.txt").import@t()

Return a table sequence

3

=hdfs_write@t(A1,"/test1.txt",A2)

Upload all fields of A2’s table sequence to test1.txt

4

=file("D:\\tmp\\employee.xls").xlsimport@t().cursor()

Return a cursor

5

=hdfs_write@a(A1,"/test1.txt",A4)

Upload all fields of A4’s cursor to test1.txt

6

=hdfs_write@t(A1,"/test2.txt",A2,EID,ENAME:name)

Upload specified fields of A2’s table sequence to test2.txt