简体   繁体   中英

Avro support in Flink - scala

How to read avro from Flink in scala ?

Is it the same for batch/stream/table: StreamExecutionEnvironment / ExecutionEnvironment / TableEnvironment ?

would it be sth like: val custTS: TableSource = new AvroInputFormat("/path/to/file", ...)

Below is java avro implementation ref ( connectors ), but can't find scala ref anywhere:

  AvroInputFormat<User> users = new AvroInputFormat<User>(in, User.class);
  DataSet<User> usersDS = env.createInput(users);

You can use Flink's InputFormats , including the AvroInputFormat , from the Java as well as the Scala API:

  • Streaming & batch: val avroInputStream = env.createInput(new AvroInputFormat[User](in, classOf[User]))
  • Table API: tableEnv.registerTable("table", avroInputStream.toTable)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM