public class JDBCLookupFunction extends TableFunction<Row>
TableFunction
to query fields from JDBC by keys.
The query template like:
SELECT c, d, e, f from T where a = ? and b = ?
Support cache the result to avoid frequent accessing to remote databases. 1.The cacheMaxSize is -1 means not use cache. 2.For real-time data, you need to set the TTL of cache.
Modifier and Type | Class and Description |
---|---|
static class |
JDBCLookupFunction.Builder
Builder for a
JDBCLookupFunction . |
collector
Constructor and Description |
---|
JDBCLookupFunction(JDBCOptions options,
JDBCLookupOptions lookupOptions,
String[] fieldNames,
TypeInformation[] fieldTypes,
String[] keyNames) |
Modifier and Type | Method and Description |
---|---|
static JDBCLookupFunction.Builder |
builder() |
void |
close()
Tear-down method for user-defined function.
|
void |
eval(Object... keys) |
TypeInformation<?>[] |
getParameterTypes(Class<?>[] signature)
Returns
TypeInformation about the operands of the evaluation method with a given
signature. |
TypeInformation<Row> |
getResultType()
Returns the result type of the evaluation method with a given signature.
|
void |
open(FunctionContext context)
Setup method for user-defined function.
|
collect, getKind, setCollector
functionIdentifier, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getRequirements, isDeterministic
public JDBCLookupFunction(JDBCOptions options, JDBCLookupOptions lookupOptions, String[] fieldNames, TypeInformation[] fieldTypes, String[] keyNames)
public static JDBCLookupFunction.Builder builder()
public void open(FunctionContext context) throws Exception
UserDefinedFunction
open
in class UserDefinedFunction
Exception
public void eval(Object... keys)
public void close() throws IOException
UserDefinedFunction
close
in class UserDefinedFunction
IOException
public TypeInformation<Row> getResultType()
TableFunction
This method needs to be overridden in case Flink's type extraction facilities are not
sufficient to extract the TypeInformation
based on the return type of the evaluation
method. Flink's type extraction facilities can handle basic types or
simple POJOs but might be wrong for more complex, custom, or composite types.
getResultType
in class TableFunction<Row>
TypeInformation
of result type or null
if Flink should determine the typepublic TypeInformation<?>[] getParameterTypes(Class<?>[] signature)
TableFunction
TypeInformation
about the operands of the evaluation method with a given
signature.
In order to perform operand type inference in SQL (especially when NULL is used) it might be
necessary to determine the parameter TypeInformation
of an evaluation method.
By default Flink's type extraction facilities are used for this but might be wrong for
more complex, custom, or composite types.
getParameterTypes
in class TableFunction<Row>
signature
- signature of the method the operand types need to be determinedTypeInformation
of operand typesCopyright © 2014–2020 The Apache Software Foundation. All rights reserved.