public class CsvTableSource extends Object implements BatchTableSource<Row>, StreamTableSource<Row>, ProjectableTableSource<Row>
BatchTableSource
and StreamTableSource
for simple CSV files with a
(logically) unlimited number of fields.
param: path The path to the CSV file. param: fieldNames The names of the table fields. param: fieldTypes The types of the table fields. param: fieldDelim The field delimiter, "," by default. param: rowDelim The row delimiter, "\n" by default. param: quoteCharacter An optional quote character for String values, null by default. param: ignoreFirstLine Flag to ignore the first line, false by default. param: ignoreComments An optional prefix to indicate comments, null by default. param: lenient Flag to skip records with parse error instead to fail, false by default.
Modifier and Type | Class and Description |
---|---|
static class |
CsvTableSource.Builder
A builder for creating
CsvTableSource instances. |
Constructor and Description |
---|
CsvTableSource(String path,
String[] fieldNames,
TypeInformation<?>[] fieldTypes)
A
BatchTableSource and StreamTableSource for simple CSV files with a
(logically) unlimited number of fields. |
CsvTableSource(String path,
String[] fieldNames,
TypeInformation<?>[] fieldTypes,
String fieldDelim,
String rowDelim,
Character quoteCharacter,
boolean ignoreFirstLine,
String ignoreComments,
boolean lenient) |
Modifier and Type | Method and Description |
---|---|
static CsvTableSource.Builder |
builder()
Return a new builder that builds a
CsvTableSource . |
boolean |
equals(Object other) |
static String |
explainSource() |
DataSet<Row> |
getDataSet(ExecutionEnvironment execEnv)
Returns the data of the table as a
DataSet of Row . |
DataStream<Row> |
getDataStream(StreamExecutionEnvironment streamExecEnv)
Returns the data of the table as a
DataStream of Row . |
RowTypeInfo |
getReturnType()
Returns the
RowTypeInfo for the return type of the CsvTableSource . |
int |
hashCode() |
CsvTableSource |
projectFields(int[] fields)
Returns a copy of
TableSource with ability to project fields |
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
explainSource
public CsvTableSource(String path, String[] fieldNames, TypeInformation<?>[] fieldTypes, String fieldDelim, String rowDelim, Character quoteCharacter, boolean ignoreFirstLine, String ignoreComments, boolean lenient)
public CsvTableSource(String path, String[] fieldNames, TypeInformation<?>[] fieldTypes)
BatchTableSource
and StreamTableSource
for simple CSV files with a
(logically) unlimited number of fields.
path
- The path to the CSV file.fieldNames
- The names of the table fields.fieldTypes
- The types of the table fields.public static CsvTableSource.Builder builder()
CsvTableSource
.
For example:
val source: CsvTableSource = CsvTableSource
.builder()
.path("/path/to/your/file.csv")
.field("myfield", Types.STRING)
.field("myfield2", Types.INT)
.build()
CsvTableSource
public static String explainSource()
public DataSet<Row> getDataSet(ExecutionEnvironment execEnv)
DataSet
of Row
.
NOTE: This method is for internal use only for defining a TableSource
.
Do not use it in Table API programs.
getDataSet
in interface BatchTableSource<Row>
execEnv
- (undocumented)public RowTypeInfo getReturnType()
RowTypeInfo
for the return type of the CsvTableSource
.getReturnType
in interface TableSource<Row>
public DataStream<Row> getDataStream(StreamExecutionEnvironment streamExecEnv)
DataStream
of Row
.
NOTE: This method is for internal use only for defining a TableSource
.
Do not use it in Table API programs.
getDataStream
in interface StreamTableSource<Row>
streamExecEnv
- (undocumented)public CsvTableSource projectFields(int[] fields)
TableSource
with ability to project fieldsprojectFields
in interface ProjectableTableSource<Row>
fields
- The indexes of the fields to return.TableSource
that projects its output.Copyright © 2014–2018 The Apache Software Foundation. All rights reserved.