Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-4244

Field names for union operator do not have to be equal

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 1.1.0
    • Fix Version/s: 1.1.0
    • Component/s: Table SQL / API
    • Labels:
      None

      Description

      Flink Table API's documentation says that the schemas of unioned tables have to be identical (wrt types and names). However, union works also with tables where the types are identical but not the names:

      val input1Seq = 0 until 10 map {x => (x, ('a' + x).toChar.toString, x.toDouble)}
          val input2Seq = 0 until 10 map {x => (x, ('a' + x).toChar.toString, x.toDouble)}
      
          val inputDS1 = env.fromCollection(input1Seq)
          val inputDS2 = env.fromCollection(input2Seq)
      
          val input1 = tblEnv.fromDataSet(inputDS1, 'a, 'b, 'c)
          tblEnv.registerTable("foobar", input1)
          val input2 = tblEnv.fromDataSet(inputDS2, 'd, 'e, 'f)
          tblEnv.registerTable("foobar2", input2)
      
          val result = tblEnv.sql("SELECT * FROM foobar UNION ALL SELECT * FROM foobar2")
      
          tblEnv.toDataSet[Row](result).print()
      

      We should update the documentation accordingly.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                jark Jark Wu
                Reporter:
                trohrmann Till Rohrmann
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: