0

This is present

PCollection<BeamRecord> rec = rec_out.apply(BeamSql.query(
  "SELECT bnk_name,state_name,val from PCOLLECTION order by val desc limit 2"));

But I need

PCollection<BeamRecord> rec = rec_out.apply(BeamSql.query(
  "SELECT bnk_name,state_name,val from PCOLLECTION order by val desc "));
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
TEJASWAKUMAR
  • 85
  • 1
  • 3
  • 8

1 Answers1

0

This actually wouldn't help. PCollections are unordered in Beam, so you cannot apply ordering to the whole output.

Beam does not have ordering because it is usually not necessary, often not possible. Most problems where ordering is used have another solution that does not require global sorting.

If you describe more about what you will do with the output of the SQL query, I will update my answer with advice.

If you cannot share more, then you have the option of using Beam's sorter extension outside of the SQL query, but again it is not really for global sorting, but per-key order after a shuffle.

Kenn Knowles
  • 5,838
  • 18
  • 22