flink-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sunjincheng121 <...@git.apache.org>
Subject [GitHub] flink pull request #4144: [FLINK-6881] [FLINK-6896] [table] Creating a table...
Date Tue, 20 Jun 2017 00:39:45 GMT
Github user sunjincheng121 commented on a diff in the pull request:

    https://github.com/apache/flink/pull/4144#discussion_r122852900
  
    --- Diff: flink-libraries/flink-table/src/main/scala/org/apache/flink/table/api/StreamTableEnvironment.scala
---
    @@ -437,39 +437,64 @@ abstract class StreamTableEnvironment(
         var rowtime: Option[(Int, String)] = None
         var proctime: Option[(Int, String)] = None
     
    -    exprs.zipWithIndex.foreach {
    -      case (RowtimeAttribute(reference@UnresolvedFieldReference(name)), idx) =>
    -        if (rowtime.isDefined) {
    +    def extractRowtime(idx: Int, name: String, origName: Option[String]): Unit = {
    +      if (rowtime.isDefined) {
    +        throw new TableException(
    +          "The rowtime attribute can only be defined once in a table schema.")
    +      } else {
    +        val mappedIdx = streamType match {
    +          case pti: PojoTypeInfo[_] =>
    +            pti.getFieldIndex(origName.getOrElse(name))
    --- End diff --
    
    When user write a mistake row-time property name of POJO. e.g.:
    `(recordTimeA as rowtime).rowtime` --> correct name is `recordTime`.
    will get the exception as follows:
    ```
    Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
    	at org.apache.flink.table.api.StreamTableEnvironment.org$apache$flink$table$api$StreamTableEnvironment$$extractRowtime$1(StreamTableEnvironment.scala:453)
    	at org.apache.flink.table.api.StreamTableEnvironment$$anonfun$validateAndExtractTimeAttributes$1.apply(StreamTableEnvironment.scala:484)
    ```
    I suggest that:
    1. May be we need check the row-time property name of POJO as early as possible. 
    2. We should check the index value must >= 0, If no so, we should throw a exception
with clearly error information. 


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message