Skip to content

Commit

Permalink
Fix the documentation for import_parquet_explicity function
Browse files Browse the repository at this point in the history
  • Loading branch information
zilder committed Jul 9, 2020
1 parent 27ed22a commit 1583329
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,14 @@ create function import_parquet_explicit(
tablename text,
schemaname text,
servername text,
attrs text[],
attnames text[],
atttypes regtype[],
userfunc regproc,
args jsonb,
options jsonb)
```

The only difference between `import_parquet` and `import_parquet_explicit` is that the latter allows to specify a set of attributes (columns) to import. `attrs` here is a 2-dimensional text array of the form `[['column1', 'type1'], ['column2', 'type2']]` (see the example below).
The only difference between `import_parquet` and `import_parquet_explicit` is that the latter allows to specify a set of attributes (columns) to import. `attnames` and `atttypes` here are the attributes names and attributes types arrays respectively (see the example below).

`userfunc` is a user-defined function. It must take a `jsonb` argument and return a text array of filesystem paths to parquet files to be imported. `args` is user-specified jsonb object that is passed to `userfunc` as its argument. A simple implementation of such function and its usage may look like this:

Expand All @@ -120,6 +121,15 @@ end
$$
language plpgsql;

select import_parquet_explicit('abc', 'public', 'parquet_srv', 'list_parquet_files', array[['one', 'int8'], ['three', 'text'], ['six', 'bool']], '{"dir": "/path/to/directory"}', '{"sorted": "id"}');
select import_parquet_explicit(
'abc',
'public',
'parquet_srv',
array['one', 'three', 'six'],
array['int8', 'text', 'bool']::regtype[],
'list_parquet_files',
'{"dir": "/path/to/directory"}',
'{"sorted": "one"}'
);
```

0 comments on commit 1583329

Please sign in to comment.