SegmentNameGenerator: Extend interface to accept input file name
Following Slack discussion: https://apache-pinot.slack.com/archives/C011C9JHN7R/p1624443889243500
Use case: Some tables in Pinot are used in conjunction with IdSet filtering or Lookups - and in some cases don't have a time column.
- Hence, existing segment name generation strategies (i.e. time-based and fixed) do not allow for simple segment replacements whenever data in those "dimension" tables change (say, data for
ID<X>changed)
Proposition Allow segment name generation to be based on the input file names such that segments can be named following a user provided id (in the file names).
E.g.
basedir/id1/file.parquet
basedir/id2/file.parquet
Would generate segments
<table_name>_id1.segment
<table_name>_id2.segment
Currently, the SegmentNameGenerator interface doesn't allow input file names, therefore it is not possible to implement a strategy similar to the one presented above.
Note: If you known any other alternative to reach the use case goal, please feel free to provide ideas !
Java 8 is the minimum version, right? So we could extend the SegmentNameGenerator interface with a default method that takes the input file path, and just calls the old version.
Also currently is it possible to implement a custom name generator, via java classes in some plugin dir? I guess we could support patterns to be able to define the resulting segment name based on the input file path, but that seems like it could get messy. Wondering if a first cut to just enable this, and ensure you can implement your own name generator class.
Java 8 is the minimum version, right? So we could extend the
SegmentNameGeneratorinterface with a default method that takes the input file path, and just calls the old version.
Yes, Java8 is the minimum version.
Also currently is it possible to implement a custom name generator, via java classes in some plugin dir? I guess we could support patterns to be able to define the resulting segment name based on the input file path, but that seems like it could get messy. Wondering if a first cut to just enable this, and ensure you can implement your own name generator class.
IIRC, segment name generator is not pluggable, atm. I can see that plugging in custom name generators would be useful. It might open up the door for operational overhead though (given that we rely on names to overwrite segments).
And pluggable name generators would make it harder to provide a hosted solution :) But without that, I'd need to also add support to format the input dates to be YYYY-MM.
How about being able to define things via:
"filePathPattern":".+/(.+)/.+\\.parquet",
"segmentName":"${tableName}_${filePathPattern:\\1}.parquet"
or, for our use case:
"filePathPattern":".+/(.+)\\.csv",
"segmentName":"${filePathPattern:\\1}"
We could also support formatting of the input dates via say ${minTimeValue:yyyy-MM}, but maybe that's a bridge too far.
@kkrugler As a user, this idea seems interesting and pretty flexible :) Then, as you suggested, it would seem possible to add more advanced parsing to extend that feature further down the line.
FYI, the way I 'solved' this for now is by using the fixed strategy in conjunction with custom job spec templating.
But this adds business-level complexity and implies to run an ingestion job for every single segment, leading to slower ingestion in case of many segments.
(Idea suggested by @Jackie-Jiang)
I've dug into this a bit, and started a first pass. The problem is that the distinction between real-time (from Kafka) and batch (from input files) is erased early on, as is right and proper :) But it means that where segment generation is occurring, information about the input file path/name has been lost. So the changes are more extensive than I was expecting.
Ah that makes sense.. thanks for looking into it, let's hope there's still a nice way to do it
May I ask anyone is working on this issue?
@troywinter - Yes, I've started some work (see above for my comments on why it's a bit harder than I was expecting)
I'm assuming we don't have to worry about how the SegmentProcessorFramework names segments, as that's all about mapping m input segments into n output segments.
Aren't we mapping n input files to n segments ?
Having multiple input files combined into a single (or m segments) is irrc not a feature yet.
But maybe I misunderstood your message or I'm missing some technical detail (very likely)
Hi @MrNeocore - yes, the scope of this issue is mapping n input files to n segments. I was pointing out that there's one other place in the code where segments are created (SegmentProcessorFramework), but that code is (a) out of scope, and (b) doesn't currently use the SegmentNameGenerator support in any case, though there's a TODO comment in the code about that.
@kkrugler I see, thanks for the clarification !
Hi @mayankshriv - I had two questions on my WIP PR at https://github.com/apache/pinot/pull/7222, any chance you could take a look at give some feedback? I'd like to wrap this up before I leave on vacation, thanks!