You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Chris Nix (Jira)" <ji...@apache.org> on 2020/07/05 11:54:00 UTC
[jira] [Commented] (FLINK-18488) Python API CsvTableSource missing
optional constructor params
[ https://issues.apache.org/jira/browse/FLINK-18488?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17151553#comment-17151553 ]
Chris Nix commented on FLINK-18488:
-----------------------------------
One option to fix this might be to add keyword params to the Python constructor and use the Java CsvTableSource.Builder to add those kwargs that are defined. For example:
{code:python}
def __init__(
self,
source_path,
field_names,
field_types,
field_delim=None,
line_delim=None,
quote_character=None,
ignore_first_line=None,
ignore_comments=None,
lenient=None,
):
gateway = get_gateway()
builder = gateway.jvm.CsvTableSource.builder()
builder.path(source_path)
for (field_name, field_type) in zip(field_names, field_types):
builder.field(field_name, _to_java_type(field_type))
if field_delim is not None:
builder.fieldDelimiter(field_delim)
if line_delim is not None:
builder.lineDelimiter(line_delim)
if quote_character is not None:
builder.quoteCharacter(quote_character)
if ignore_first_line:
builder.ignoreFirstLine()
if ignore_comments is not None:
builder.commentPrefix(ignore_comments)
if lenient:
builder.ignoreParseErrors()
super(CsvTableSource, self).__init__(builder.build())
{code}
This way it'd maintain all the defaults defined in Java side, without redefining them on the Python side. As is, it would omit the Java {{selectedFields}} param, for which there isn't a corresponding builder function.
> Python API CsvTableSource missing optional constructor params
> -------------------------------------------------------------
>
> Key: FLINK-18488
> URL: https://issues.apache.org/jira/browse/FLINK-18488
> Project: Flink
> Issue Type: Improvement
> Components: API / Python
> Reporter: Chris Nix
> Priority: Minor
>
> CsvTableSource exists in the Python API, however the Python constructor is missing the optional params available in the overloaded constructors from the Java/Scala APIs. Here's links to the docs:
> * [https://ci.apache.org/projects/flink/flink-docs-master/api/python/pyflink.table.html#pyflink.table.CsvTableSource]
> * [https://ci.apache.org/projects/flink/flink-docs-master/api/java/org/apache/flink/table/sources/CsvTableSource.html]
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)