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 . |
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) |
Connection |
getDbConnection() |
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.
|
void |
open(FunctionContext context)
Setup method for user-defined function.
|
collect, getKind, getTypeInference, 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
@VisibleForTesting public Connection getDbConnection()
public TypeInformation<Row> getResultType()
TableFunction
getResultType
in class TableFunction<Row>
public TypeInformation<?>[] getParameterTypes(Class<?>[] signature)
TableFunction
TypeInformation
about the operands of the evaluation method with a given
signature.getParameterTypes
in class TableFunction<Row>
Copyright © 2014–2022 The Apache Software Foundation. All rights reserved.