如何在Flink 2流联接上实现模糊匹配

时间:2019-08-20 08:26:38

标签: apache-flink

我浇水使用flink exector sql,但是它不起作用

SELECT *
FROM  opods.ecsmetadata as b left join opdim.service_info as a
ON  b.instancename like CONCAT(a.service_name,'%');

我正在尝试sql表和join / coGroup

1,表sql

        import org.apache.flink.table.api.scala._
        val tableEnv = StreamTableEnvironment.create(env)
        tableEnv.registerDataStream("ecsMetadata", ecsMetadaClass)
        tableEnv.registerDataStream("serviceInfo", serviceInfoInput)

        val ecsMetadataService  = tableEnv.sqlQuery(
          """
            |SELECT *
            |FROM  ecsMetadata left join serviceInfo
            |ON  instanceName like CONCAT(serviceName,'%')
          """.stripMargin)

    tableEnv.toAppendStream[String](ecsMetadataService).print()

但是输出错误

This exception indicates that the query uses an unsupported SQL feature.
Please check the documentation for the set of currently supported SQL features.

2,join和coGroup

ecsMetadaClass.join(serviceInfoInput)
      .where(_.instanceName)
      .equalTo("(.*)" + _.serviceName + "(.*)")
      .window(TumblingEventTimeWindows.of(Time.minutes(5)))
      .allowedLateness(Time.minutes(5))
      .apply(new JoinFunction[ecsMetadata, serviceInfo, ecsMetadataServiceInfo] {

        System.out.println("join.....")

        override def join(first: ecsMetadata, second: serviceInfo): ecsMetadataServiceInfo = {
          var result: ecsMetadataServiceInfo = null
          if (second.serviceName == null) {
            result = ecsMetadataServiceInfo(xxxx)
          } else {
            result = ecsMetadataServiceInfo(xxxx)
          }
          result
        }
      }).print()

但输出为空

我是flink 1.8.0用户

0 个答案:

没有答案