AppLib READ ROWS FROM FILE
From LucidDB Wiki
Contents |
Syntax
FROM TABLE( APPLIB.READ_ROWS_FROM_FILE ( row_format_cursor, file, is_compressed ) )
Purpose
Allow serialized rows to be read from a file and output in a table function.
Input
- row_format_cursor [CURSOR]: A cursor that contains the row format of the rows that will arrive. The cursor rows are discarded (not used) but metadata (column names, datatypes) are inspected to determine the format of rows in the file. It should be checked against the HEADER of the serialized file.
- file [VARCHAR]: The URL of the file. There should be support for Java file access (file://, etc) but also resources from the classpath. ie, a file on the classpath at com/company/datafile.ldbrows should also be accessible.
- is_compressed [BOOLEAN]: Determines if the serialized file is gzip compressed or not.
Output
- UDX Table - returns a UDX Table of the same format (number of columns, datatypes, and names) as row_format_cursor with rows values that were read, sequentially, from the file.
Example
SELECT ID, NAME from
TABLE(
APPLIB.READ_ROWS_FROM_FILE(
CURSOR(
select cast(null as int) as id, cast(null as varchar(128)) as name
from (values(0))
)
,'file:///tmp/mydatafile.ldbrows'
,true
)
)
RETURNS:
Assumes file contains 3 Java Arrays with values Array1: 1 / String1 Array2: 2 / String2 Array3: 3 / String3 Array4: empty
ID NAME
1 String1
2 String2
3 String3
See Also
- LucidDbUtilityRowSerialization
- Files can be written by custom programs, but most commonly are written using LucidDbAppLib_WRITE_ROWS_TO_FILE