CREATE PARSER

Adds a user-defined load parser function. You must have already loaded this library using the CREATE LIBRARY statement. When you call the SQL function, Vertica passes the parameters to the function in the library to process it.

Syntax

CREATE [ OR REPLACE ] PARSER [schema.]function-name 
... AS [ LANGUAGE 'language' ] NAME 'factory' LIBRARY library-name
... [ FENCED | NOT FENCED ];

Parameters

OR REPLACE

If you do not supply this parameter, the CREATE PARSER statement fails if an existing function matches the name and parameters of the parser function you are trying to define. If you do supply this parameter, the new parser function definition overwrites the old.

schema

Specifies a schema. If multiple schemas are defined in the database, include the schema name. For example:

myschema.thisDbObject
function‑name

The name of the parser function to create. If the parser function name is schema-qualified (as above), the function is created in the specified schema. This name does not need to match the name of the factory, but it is less confusing if they are the same or similar.

LANGUAGE 'language'

The language used to develop this function, one of the following:

  • C++
  • Java

Default value: C++

NAME 'factory'

The name of the factory class in the shared library that generates the object to handle the parser function's processing.

This is the same name used by the RegisterFactory class.

LIBRARY library‑name

The name of the shared library that contains the C++ object to perform the processing for this parser function. This library must have been previously loaded using the CREATE LIBRARY statement.

FENCED | NOT FENCED

Enables or disables Fenced Mode for this function.

Default Value: FENCED

Notes

Privileges

Important: Installing an untrusted UDL function can compromise the security of the server. UDx's can contain arbitrary code. In particular, UD Source functions can read data from any arbitrary location. It is up to the developer of the function to enforce proper security limitations. Superusers must not grant access to UDx's to untrusted users.

Example

The following example demonstrates loading a library named BasicIntegrerParserLib, then defining a function named BasicIntegerParser that is mapped to the BasicIntegerParserFactory factory class in the library:

=> CREATE LIBRARY BasicIntegerParserLib as '/opt/vertica/sdk/examples/build/BasicIntegerParser.so';
CREATE LIBRARY
=> CREATE PARSER BasicIntegerParser AS LANGUAGE 'C++' NAME 'BasicIntegerParserFactory' LIBRARY BasicIntegerParserLib;
CREATE PARSER FUNCTION
=> \x
Expanded display is on.
=> SELECT * FROM user_functions;
-[ RECORD 1 ]----------+--------------------
schema_name            | public
function_name          | BasicIntegerParser
procedure_type         | User Defined Parser
function_return_type   | 
function_argument_type | 
function_definition    | 
volatility             | 
is_strict              | f
is_fenced              | f
comment                |