@Internal public abstract class AbstractHBaseTableSource extends Object implements org.apache.flink.table.sources.BatchTableSource<org.apache.flink.types.Row>, org.apache.flink.table.sources.ProjectableTableSource<org.apache.flink.types.Row>, org.apache.flink.table.sources.StreamTableSource<org.apache.flink.types.Row>, org.apache.flink.table.sources.LookupableTableSource<org.apache.flink.types.Row>
The table name and required HBase configuration is passed during AbstractHBaseTableSource construction. Use addColumn(String, String, Class) to specify
the family, qualifier, and type of columns to scan.
The TableSource returns Row with nested Rows for each column family.
The HBaseTableSource is used as shown in the example below.
HBaseTableSource hSrc = new HBaseTableSource(conf, "hTable");
hSrc.setRowKey("rowkey", String.class);
hSrc.addColumn("fam1", "col1", byte[].class);
hSrc.addColumn("fam1", "col2", Integer.class);
hSrc.addColumn("fam2", "col1", String.class);
tableEnv.registerTableSourceInternal("hTable", hSrc);
Table res = tableEnv.sqlQuery(
"SELECT t.fam2.col1, SUM(t.fam1.col2) FROM hTable AS t " +
"WHERE t.rowkey LIKE 'flink%' GROUP BY t.fam2.col1");
| Modifier and Type | Field and Description |
|---|---|
protected org.apache.hadoop.conf.Configuration |
conf |
protected HBaseTableSchema |
hbaseSchema |
protected String |
tableName |
| Constructor and Description |
|---|
AbstractHBaseTableSource(org.apache.hadoop.conf.Configuration conf,
String tableName,
HBaseTableSchema hbaseSchema,
int[] projectFields) |
| Modifier and Type | Method and Description |
|---|---|
void |
addColumn(String family,
String qualifier,
Class<?> clazz)
Adds a column defined by family, qualifier, and type to the table schema.
|
String |
explainSource() |
org.apache.flink.table.functions.AsyncTableFunction<org.apache.flink.types.Row> |
getAsyncLookupFunction(String[] lookupKeys) |
org.apache.flink.api.java.DataSet<org.apache.flink.types.Row> |
getDataSet(org.apache.flink.api.java.ExecutionEnvironment execEnv) |
org.apache.flink.streaming.api.datastream.DataStream<org.apache.flink.types.Row> |
getDataStream(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment execEnv) |
HBaseTableSchema |
getHBaseTableSchema() |
protected abstract org.apache.flink.api.common.io.InputFormat<org.apache.flink.types.Row,?> |
getInputFormat(HBaseTableSchema projectedSchema) |
org.apache.flink.table.functions.TableFunction<org.apache.flink.types.Row> |
getLookupFunction(String[] lookupKeys) |
org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.types.Row> |
getReturnType() |
org.apache.flink.table.api.TableSchema |
getTableSchema() |
boolean |
isAsyncEnabled() |
boolean |
isBounded() |
void |
setCharset(String charset)
Specifies the charset to parse Strings to HBase byte[] keys and String values.
|
void |
setRowKey(String rowKeyName,
Class<?> clazz)
Sets row key information in the table schema.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitprotected final org.apache.hadoop.conf.Configuration conf
protected final String tableName
protected final HBaseTableSchema hbaseSchema
public AbstractHBaseTableSource(org.apache.hadoop.conf.Configuration conf,
String tableName,
HBaseTableSchema hbaseSchema,
int[] projectFields)
public void addColumn(String family, String qualifier, Class<?> clazz)
family - the family namequalifier - the qualifier nameclazz - the data type of the qualifierpublic void setRowKey(String rowKeyName, Class<?> clazz)
rowKeyName - the row key field nameclazz - the data type of the row keypublic void setCharset(String charset)
charset - Name of the charset to use.public org.apache.flink.api.common.typeinfo.TypeInformation<org.apache.flink.types.Row> getReturnType()
getReturnType in interface org.apache.flink.table.sources.TableSource<org.apache.flink.types.Row>public org.apache.flink.table.api.TableSchema getTableSchema()
getTableSchema in interface org.apache.flink.table.sources.TableSource<org.apache.flink.types.Row>public org.apache.flink.api.java.DataSet<org.apache.flink.types.Row> getDataSet(org.apache.flink.api.java.ExecutionEnvironment execEnv)
getDataSet in interface org.apache.flink.table.sources.BatchTableSource<org.apache.flink.types.Row>public String explainSource()
explainSource in interface org.apache.flink.table.sources.TableSource<org.apache.flink.types.Row>public org.apache.flink.table.functions.TableFunction<org.apache.flink.types.Row> getLookupFunction(String[] lookupKeys)
getLookupFunction in interface org.apache.flink.table.sources.LookupableTableSource<org.apache.flink.types.Row>public org.apache.flink.table.functions.AsyncTableFunction<org.apache.flink.types.Row> getAsyncLookupFunction(String[] lookupKeys)
getAsyncLookupFunction in interface org.apache.flink.table.sources.LookupableTableSource<org.apache.flink.types.Row>public boolean isAsyncEnabled()
isAsyncEnabled in interface org.apache.flink.table.sources.LookupableTableSource<org.apache.flink.types.Row>public boolean isBounded()
isBounded in interface org.apache.flink.table.sources.StreamTableSource<org.apache.flink.types.Row>public org.apache.flink.streaming.api.datastream.DataStream<org.apache.flink.types.Row> getDataStream(org.apache.flink.streaming.api.environment.StreamExecutionEnvironment execEnv)
getDataStream in interface org.apache.flink.table.sources.StreamTableSource<org.apache.flink.types.Row>protected abstract org.apache.flink.api.common.io.InputFormat<org.apache.flink.types.Row,?> getInputFormat(HBaseTableSchema projectedSchema)
@VisibleForTesting public HBaseTableSchema getHBaseTableSchema()
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.