Overview of GemFire XD Table Functions

A GemFire XD table function is a Java method that returns a JDBC ResultSet.

Most of the ResultSet methods can be written as stubs that simply raise exceptions. However, a GemFire XD table function must implement the following ResultSet methods:

A GemFire XD table function is materialized by a public static method that returns a ResultSet:

public static ResultSet read() {...}

The public static method is then bound to a GemFire XD function name:

CREATE FUNCTION externalEmployees
()
RETURNS TABLE
(
  employeeId    INT,
  lastName      VARCHAR( 50 ),
  firstName     VARCHAR( 50 ),
  birthday      DATE
)
LANGUAGE JAVA
PARAMETER STYLE DERBY_JDBC_RESULT_SET
READS SQL DATA
EXTERNAL NAME 'com.acme.hrSchema.EmployeeTable.read'

To invoke a table function, wrap it in a TABLE constructor in the FROM list of a query. Note that the table alias (in this example "s") is a required part of the syntax:

INSERT INTO employees
  SELECT s.*
    FROM TABLE (externalEmployees() ) s;