Package org.apache.flink.sql.tests
Class StreamSQLTestProgram.GeneratorTableSource
- java.lang.Object
-
- org.apache.flink.sql.tests.StreamSQLTestProgram.GeneratorTableSource
-
- All Implemented Interfaces:
StreamTableSource<Row>
,DefinedFieldMapping
,DefinedRowtimeAttributes
,TableSource<Row>
- Enclosing class:
- StreamSQLTestProgram
public static class StreamSQLTestProgram.GeneratorTableSource extends Object implements StreamTableSource<Row>, DefinedRowtimeAttributes, DefinedFieldMapping
TableSource for generated data.
-
-
Constructor Summary
Constructors Constructor Description GeneratorTableSource(int numKeys, float recordsPerKeyAndSecond, int durationSeconds, int offsetSeconds)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
explainSource()
Describes the table source.DataStream<Row>
getDataStream(StreamExecutionEnvironment execEnv)
Returns the data of the table as aDataStream
.Map<String,String>
getFieldMapping()
Returns the mapping for the fields of theTableSource
'sTableSchema
to the fields of its producedDataType
.TypeInformation<Row>
getReturnType()
List<RowtimeAttributeDescriptor>
getRowtimeAttributeDescriptors()
Returns a list ofRowtimeAttributeDescriptor
for all rowtime attributes of the table.TableSchema
getTableSchema()
Returns the schema of the produced table.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.flink.legacy.table.sources.StreamTableSource
isBounded
-
Methods inherited from interface org.apache.flink.table.legacy.sources.TableSource
getProducedDataType
-
-
-
-
Method Detail
-
getDataStream
public DataStream<Row> getDataStream(StreamExecutionEnvironment execEnv)
Description copied from interface:StreamTableSource
Returns the data of the table as aDataStream
.NOTE: This method is for internal use only for defining a
TableSource
. Do not use it in Table API programs.- Specified by:
getDataStream
in interfaceStreamTableSource<Row>
-
getReturnType
public TypeInformation<Row> getReturnType()
- Specified by:
getReturnType
in interfaceTableSource<Row>
-
getTableSchema
public TableSchema getTableSchema()
Description copied from interface:TableSource
Returns the schema of the produced table.- Specified by:
getTableSchema
in interfaceTableSource<Row>
- Returns:
- The
TableSchema
of the produced table.
-
explainSource
public String explainSource()
Description copied from interface:TableSource
Describes the table source.- Specified by:
explainSource
in interfaceTableSource<Row>
- Returns:
- A String explaining the
TableSource
.
-
getRowtimeAttributeDescriptors
public List<RowtimeAttributeDescriptor> getRowtimeAttributeDescriptors()
Description copied from interface:DefinedRowtimeAttributes
Returns a list ofRowtimeAttributeDescriptor
for all rowtime attributes of the table.All referenced attributes must be present in the
TableSchema
of theTableSource
and of typeTypes.SQL_TIMESTAMP
.- Specified by:
getRowtimeAttributeDescriptors
in interfaceDefinedRowtimeAttributes
- Returns:
- A list of
RowtimeAttributeDescriptor
.
-
getFieldMapping
public Map<String,String> getFieldMapping()
Description copied from interface:DefinedFieldMapping
Returns the mapping for the fields of theTableSource
'sTableSchema
to the fields of its producedDataType
.The mapping is done based on field names, e.g., a mapping "name" -> "f1" maps the schema field "name" to the field "f1" of the produced data type, for example in this case the second field of a
Tuple
.The returned mapping must map all fields (except proctime and rowtime fields) to the produced data type. It can also provide a mapping for fields which are not in the
TableSchema
to make fields in the physicalDataType
accessible for aTimestampExtractor
.- Specified by:
getFieldMapping
in interfaceDefinedFieldMapping
- Returns:
- A mapping from
TableSchema
fields toDataType
fields or null if no mapping is necessary.
-
-