CREATE LIBRARY

Loads a library containing User Defined Extensions (UDxs) into the Vertica catalog. After loading a library in the catalog, you can use statements such as CREATE FUNCTION to define the extensions contained in the library. See Developing User-Defined Extensions (UDxs) in Extending Vertica for details.

Warning: You can choose to run UDxs developed in C++ in unfenced mode. Unfenced UDxs run directly in the Vertica process. If the UDx you run in unfenced mode has bugs, it can negatively impact the database, causing instability or even crashes. To avoid these issues, run your UDx only in fenced mode. A few UDx types can only be run in unfenced mode.

Syntax

CREATE [OR REPLACE] LIBRARY 
    [schema.]library-name 
    AS 'library-path'
    [ DEPENDS 'support-path' ]
    [ LANGUAGE 'language' ]

Parameters

OR REPLACE

Replaces the old library with the new one. If you do not supply this parameter, the CREATE LIBRARY statement fails when an existing library matches the name the library you are trying to define.

schema

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

myschema.thisDbObject
library‑name

A name to assign to this library, where library-name.conforms to conventions described in Identifiers. Use this name in a CREATE FUNCTION statement to enable user defined functions stored in the library.

Best practice:

This name does not have to match the library file name. However, consider using the same name to avoid confusion.

library‑path

The absolute path and file name of the library to load. This file must be located in the initiator node's filesystem.

DEPENDS 'support‑path'

Indicates that the UDx library depends on one or more support libraries. Valid values: One or more absolute paths to the support libraries files, located in the initiator node's filesystem. Separate multiple paths with colons (:). Specify a directory containing multiple libraries using an asterisk wildcard (*). For example: '/home/mydir/mylibs/*'.

LANGUAGE 'language'

The programming language used to develop the function, where language is one of the following:

  • C++
  • Python
  • Java
  • R

Privileges

superuser

Usage Considerations

Examples

To load a library in the home directory of the dbadmin account with the name MyFunctions:

=> CREATE LIBRARY MyFunctions AS 'home/dbadmin/my_functions.so';

To load a library located in the directory where you started vsql:

=> \set libfile '\''`pwd`'/MyOtherFunctions.so\'';
=> CREATE LIBRARY MyOtherFunctions AS :libfile;

To load a Java library named JavaLib.jar that depends on multiple support JAR files in the /home/dbamin/mylibs subdirectory:

=> CREATE LIBRARY DeleteVowelsLib AS '/home/dbadmin/JavaLib.jar' 
   DEPENDS '/home/dbadmin/mylibs/*' LANGUAGE 'JAVA';