pinot icon indicating copy to clipboard operation
pinot copied to clipboard

SegmentNameGenerator: Extend interface to accept input file name

Open MrNeocore opened this issue 5 years ago • 16 comments

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 !

MrNeocore avatar Jun 24 '21 08:06 MrNeocore

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.

kkrugler avatar Jul 06 '21 18:07 kkrugler

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.

kkrugler avatar Jul 06 '21 18:07 kkrugler

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.

Yes, Java8 is the minimum version.

mayankshriv avatar Jul 06 '21 18:07 mayankshriv

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).

mayankshriv avatar Jul 06 '21 18:07 mayankshriv

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.

kkrugler avatar Jul 06 '21 18:07 kkrugler

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 avatar Jul 06 '21 18:07 kkrugler

@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)

MrNeocore avatar Jul 11 '21 14:07 MrNeocore

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.

kkrugler avatar Jul 11 '21 16:07 kkrugler

Ah that makes sense.. thanks for looking into it, let's hope there's still a nice way to do it

MrNeocore avatar Jul 11 '21 21:07 MrNeocore

May I ask anyone is working on this issue?

troywinter avatar Jul 12 '21 07:07 troywinter

@troywinter - Yes, I've started some work (see above for my comments on why it's a bit harder than I was expecting)

kkrugler avatar Jul 12 '21 13:07 kkrugler

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.

kkrugler avatar Jul 27 '21 00:07 kkrugler

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)

MrNeocore avatar Jul 27 '21 15:07 MrNeocore

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 avatar Jul 27 '21 16:07 kkrugler

@kkrugler I see, thanks for the clarification !

MrNeocore avatar Jul 28 '21 10:07 MrNeocore

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!

kkrugler avatar Jul 29 '21 17:07 kkrugler