@Internal public class HBaseTableSource extends AbstractHBaseTableSource
The table name and required HBase configuration is passed during HBaseTableSource
construction. Use AbstractHBaseTableSource.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");
conf, hbaseSchema, tableName
Constructor and Description |
---|
HBaseTableSource(Configuration conf,
String tableName)
The HBase configuration and the name of the table to read.
|
HBaseTableSource(Configuration conf,
String tableName,
HBaseTableSchema hbaseSchema,
int[] projectFields) |
Modifier and Type | Method and Description |
---|---|
InputFormat<Row,?> |
getInputFormat(HBaseTableSchema projectedSchema) |
HBaseTableSource |
projectFields(int[] fields)
Creates a copy of the
TableSource that projects its output to the given field
indexes. |
addColumn, explainSource, getAsyncLookupFunction, getDataSet, getDataStream, getHBaseTableSchema, getLookupFunction, getReturnType, getTableSchema, isAsyncEnabled, isBounded, setCharset, setRowKey
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getProducedDataType
public HBaseTableSource(Configuration conf, String tableName)
conf
- hbase configurationtableName
- the tableNamepublic HBaseTableSource(Configuration conf, String tableName, HBaseTableSchema hbaseSchema, int[] projectFields)
public HBaseTableSource projectFields(int[] fields)
ProjectableTableSource
TableSource
that projects its output to the given field
indexes. The field indexes relate to the physical poduced data type (TableSource.getProducedDataType()
) and not to the table schema (TableSource.getTableSchema()
of the TableSource
.
The table schema (TableSource.getTableSchema()
of the TableSource
copy must
not be modified by this method, but only the produced data type (TableSource.getProducedDataType()
) and the produced DataSet
(BatchTableSource#getDataSet(
) or DataStream
(StreamTableSource#getDataStream
).
If the TableSource
implements the DefinedFieldMapping
interface, it might
be necessary to adjust the mapping as well.
IMPORTANT: This method must return a true copy and must not modify the original table source object.
fields
- The indexes of the fields to return.TableSource
that projects its output.public InputFormat<Row,?> getInputFormat(HBaseTableSchema projectedSchema)
getInputFormat
in class AbstractHBaseTableSource
Copyright © 2014–2021 The Apache Software Foundation. All rights reserved.