flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Fabian Hueske (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (FLINK-6099) not able to auto infer the row type when getting informationn from jdbc vertica
Date Fri, 17 Mar 2017 09:59:41 GMT

    [ https://issues.apache.org/jira/browse/FLINK-6099?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15929678#comment-15929678
] 

Fabian Hueske commented on FLINK-6099:
--------------------------------------

No, automatic type inference from a SQL query is currently not possible.

The reason is that we need the type when the program is constructed, i.e., before the query
is executed. Flink requires the type information to be able to specify keys and for the choice
of serializers and comparators. In principle, the resulting Rows could also be treated as
GenericType but then using them in following operations would be much more difficult.


> not able to auto infer the row type when getting informationn from jdbc vertica 
> --------------------------------------------------------------------------------
>
>                 Key: FLINK-6099
>                 URL: https://issues.apache.org/jira/browse/FLINK-6099
>             Project: Flink
>          Issue Type: Bug
>          Components: DataSet API
>    Affects Versions: 1.3.0
>         Environment: linux , flink 1.3.0 with scala 2.10 
>            Reporter: naveen holla U
>              Labels: newbie
>   Original Estimate: 3h
>  Remaining Estimate: 3h
>
> How to automatically infer the row type information for a given query
> import org.apache.flink.api.scala._
> import org.apache.flink.table.api.TableEnvironment
> import org.apache.flink.api.java.io.jdbc.JDBCInputFormat
> import org.apache.flink.api.java.typeutils.RowTypeInfo
> import org.apache.flink.api.common.typeinfo.TypeInformation
> var fieldTypes: Array[TypeInformation[_]] = Array(createTypeInformation[String],createTypeInformation[String],createTypeInformation[String])
> var fieldNames: Array[String] = Array("UUID", "Name","instanceid")
> val rowTypeInfo = new RowTypeInfo( fieldTypes,  fieldNames )
> val inputFormat = JDBCInputFormat.buildJDBCInputFormat().setDrivername("com.vertica.jdbc.Driver").setDBUrl("jdbc:vertica://x.x.x.x:5433/hfdb").setUsername("user").setPassword("password").setQuery("select
* from test").setRowTypeInfo(rowTypeInfo).finish()
> val dataset = benv.createInput(inputFormat)
> dataset.print()
> import org.apache.flink.api.scala._
> import org.apache.flink.table.api.TableEnvironment
> import org.apache.flink.api.java.io.jdbc.JDBCInputFormat
> import org.apache.flink.api.java.typeutils.RowTypeInfo
> import org.apache.flink.api.common.typeinfo.TypeInformation
> var fieldTypes: Array[TypeInformation[_]] = Array(createTypeInformation[String],createTypeInformation[String],createTypeInformation[String])
> var fieldNames: Array[String] = Array("UUID", "Name","instanceid")
> val rowTypeInfo = new RowTypeInfo( fieldTypes,  fieldNames )
> val inputFormat = JDBCInputFormat.buildJDBCInputFormat().setDrivername("com.vertica.jdbc.Driver").setDBUrl("jdbc:vertica://x.x.x.x:5433/hfdb").setUsername("user").setPassword("password").setQuery("select
* from test").setRowTypeInfo(rowTypeInfo).finish()
> val dataset = benv.createInput(inputFormat)
> dataset.print()
> So in the above code we have to specify the type of the rows which we are getting . is
there a way to get the answer without setting row type ?



--
This message was sent by Atlassian JIRA
(v6.3.15#6346)

Mime
View raw message