CREATE LIBRARY

Loads a library containing user defined extensions (UDxs) into the Vertica catalog. Vertica automatically distributes copies of the library file and any supporting libraries to all cluster nodes. UDxs defined in the catalog that reference the updated library automatically start using the new library file. Nodes that are down or added to the cluster also receive a copy of the updated library file as soon as they join the cluster.

Because libraries are added to the database catalog, they persist across database restarts.

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.

Syntax

CREATE [OR REPLACE] LIBRARY 
    [[database.]schema.]library 
    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.

[database.]schema

Specifies a schema, by default public. If schema is any schema other than public, you must supply the schema name. For example:

myschema.thisDbObject

If you specify a database, it must be the current database.

library

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

Tip: While not required, it is good practice to match library to the library file name.

library‑path

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

DEPENDS 'support‑path'

Indicates that the UDx library depends on one or more support libraries, where support‑path specifies one or more absolute paths to the support libraries files, located in the initiator node's file system.

You can specify multiple support paths as follows:

  • Separate multiple paths with colons (:).
  • Specify a directory that contains multiple libraries with an asterisk wildcard (*). For example: /home/mydir/mylibs/*

If your Java library depends on native libraries (SO files), use DEPENDS to specify the path and call System.loadLibrary() in your UDx to load the native libraries from that path.

LANGUAGE 'language'

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

  • C++
  • Python
  • Java
  • R

Privileges

Superuser

Requirements

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';

See Also

DROP LIBRARY