To call and use the data connector functions in your queries,
you must register the data connector functions in one or more NPS® databases.
Before you begin
After you have created at least one connection to your Hadoop
service providers, you can then register functions in a database.
Typically, you register the functions only once in each
NPS database
that is used for SQL select queries with the Hadoop tables.
Procedure
- Log in to the NPS active
host as the nz user.
- Change to the /nz/export/ae/products/fluidquery/ directory.
- Run the fqRegister.sh script to register
the functions. There are four data connector function definitions
that have the same function name but different signatures to support
different types of query invocations. By default, the data connector
functions use the name FqRead(), but you can register the functions
under a unique name for your environment. Sample commands follow.
- To perform a simple registration where you add the FqRead() functions
to the database specified by NZ_DATABASE (which is set to a database
named maindb) using the connection defined in the default.properties configuration:
./fqRegister.sh
Functions and credentials are successfully registered in database "MAINDB".
- To register the functions using the name HdpRead() in the database
named MyDb using the connection defined in themyConfig.properties connection
configuration:
./fqRegister.sh --udtf HdpRead --db MyDb --config myConfig
Functions and credentials are successfully registered in database "MYDB".
Results
The registration function adds the data connector functions
to the specified database. Each registration requires a connection
configuration. You must specify a connection configuration file that
was created by the
fqConfigure.sh script, or the
command uses the default connection called
default.properties.
The functions are owned by the admin user, and for other database
users to use the functions in their queries, you must grant those
users privileges to execute the functions. For more information about
privileges, see
Assigning privileges to run the data connector functions.
After
registering the functions, your
NPS users
who have privileges to the database and to execute the functions can
include them in their SQL queries. To confirm that the functions were
added to the database, you can use the SHOW FUNCTION command to display
the functions in your database. A sample command follows. Note that
the Arguments column is truncated in the documentation because of
the wide length of the field.
MYDB.ADMIN(MYUSER)=> SHOW FUNCTION hdpread;
SCHEMA | RESULT | FUNCTION | BUILTIN | ARGUMENTS
--------+------------+----------+---------+---------------------------------------------------
ADMIN | TABLE(ANY) | HDPREAD | f | (CHARACTER VARYING(ANY), CHARACTER VARYING(ANY))
ADMIN | TABLE(ANY) | HDPREAD | f | (CHARACTER VARYING(ANY), CHARACTER VARYING(ANY), CH...
ADMIN | TABLE(ANY) | HDPREAD | f | (CHARACTER VARYING(ANY), CHARACTER VARYING(ANY), CH...
ADMIN | TABLE(ANY) | HDPREAD | f | (CHARACTER VARYING(ANY), CHARACTER VARYING(ANY), CH...
(4 rows)
If you plan to use the
remote mode for your data connector functions, you must register a
data connector function with the --remote flag, otherwise
the remote service will not start. See Remote mode for more information.
If
the command fails and displays an error message, you can try re-running
command and adding the --debug option for more troubleshooting
information. If you use the --debug option when you
register the functions, the software creates log files each time a
query runs and calls the functions. The log files can help you to
troubleshoot any query problems, but when your queries are operating
as expected, make sure that you re-register the functions without
the --debug option to stop the log files. For more
information about the script and its options, see The fqRegister script.
For more information
about the FqRead() function and the four supported input forms, see The FqRead function.