Hi Team, i am trying to use `/segments/{tableName}...
# general
v
Hi Team, i am trying to use
/segments/{tableName}/startReplaceSegments
API in swagger api and trying to replace segment here i am trying to replace one segment with other but i am not bale to do it. i am passing
segmentsFrom
those segment which we want to replace with new one.
segmentsTo
is the other segment but before that i have to create and upload that segment. how to create and upload it? i tried to use segment from same table but getting a error as below:
Copy code
Input:
{
    "segmentsTo":["tmptab__4__1__20230214T1305Z"],
    "segmentsFrom":["tmptab__0__0__20230214T0611Z"]
    }
Copy code
{
  "code": 500,
  "error": "Any segments from 'segmentsTo' should not be available in the table at this point. (tableName = 'tmptab_REALTIME', segmentsFrom = '[tmptab__0__0__20230214T0611Z]', segmentsTo = '[tmptab__4__1__20230214T1305Z]', segmentsFromTable = '[tmptab__0__1__20230214T1305Z, tmptab__2__1__20230214T1305Z, tmptab__3__1__20230214T1305Z, tmptab__0__0__20230214T0611Z, tmptab__1__1__20230214T1305Z, tmptab__4__1__20230214T1305Z, tmptab__5__1__20230214T1305Z, tmptab__2__0__20230214T0611Z, tmptab__1__0__20230214T0611Z, tmptab__4__0__20230214T0611Z, tmptab__3__0__20230214T0611Z, tmptab__5__0__20230214T0611Z]')"
}
@saurabh dubey @Xiang Fu @Tim Santos @Xiaobing @Jackie @Kartik Khare
s
You should first hit
/segments/{tableName}/startReplaceSegments
API, then upload the new segments to the table, then hit the
/segments/{tableName}/endReplaceSegments
API
v
but for startreplacesegment i have to define sefmentto and segmentfrom right?
s
Yes. But that should be before you push to segment to the table. It needs just the segment names
v
so i need to define segmentfrom only?
s
you need to set both, just that you should startReplaceSegments -> upload the new segments (the ones in segmentsTo) -> endReplaceSegments This order
v
can i upload through s3?
s
Do you mean metadata push? Yes you can use that
v
using SegmentGenerationAndPushTask task
s
if you can determine the segments names beforehand (maybe by using fixed segment name generator type?), you can manually first hit the startReplace API with the name(s) in the from and to, save the id returned in the reponse somewhere, then run your SegmentGenerationAndPushTask task, and finally manually hit the endSegmentReplace API in the end with the id from first API, it could work. But generally speaking, no SegmentGenerationAndPushTask is not designed to replace segments like that
@Haitao Zhang might have more context
v
okay is there any easy way to upload segment?
h
do you mean replacing segments?
v
yes correct @Haitao Zhang
Copy code
curl -X POST -F segment=@<segment-tar-file-path> <http://controllerHost>:controllerPort/segments
i am trying to use above curl request to create a segment but getting a error that file format is not .gz
i've created csv file and than converted to .tar.gz format but it is not working
s
What is the API error message?
v
Copy code
{
  "code": 500,
  "error": "Exception while uploading segment: Input is not in the .gz format"
}
s
How was the segment created?
v
created simple csv file
than converted it to .tar.gz format
s
No you need to create an actual pinot segment from the file first
v
than how can i create it?
trying to follow this link
but non of them working
s
You should first run this
Copy code
bin/pinot-admin.sh CreateSegment -dataDir <input_data_dir> [-format [CSV/JSON/AVRO]] [-readerConfigFile <csv_config_file>] [-generatorConfigFile <generator_config_file>] -segmentName <segment_name> -schemaFile <input_schema_file> -tableName <table_name> -outDir <output_data_dir> [-overwrite]
Maybe you can run this inside some pinot container. This will generate your segment file. Then push that file using
Copy code
curl -X POST -F segment=@<segment-tar-file-path> <http://controllerHost>:controllerPort/segments
v
bin/pinot-admin.sh CreateSegment -dataDir /home/vishalvanpariya/work/tmp/datadir/ -format CSV -schemaFile /home/vishalvanpariya/work/pinot-poc/s3/json-s3/schema.json -outDir output/ tried this command but returning error
Copy code
java.lang.IllegalArgumentException: 'tableConfigFile' must be specified
s
Add this? -tableName <table_name>
v
bin/pinot-admin.sh CreateSegment -dataDir /home/vishalvanpariya/work/tmp/datadir/ -format CSV -segmentName json_test_OFFLINE_2 -schemaFile /home/vishalvanpariya/work/pinot-poc/s3/json-s3/schema.json -tableName json_test_OFFLINE -outDir output/
its here
Copy code
picocli.CommandLine$UnmatchedArgumentException: Unknown options: '-segmentName', 'json_test_OFFLINE_2', '-tableName', 'json_test_OFFLINE'
s
What version are you on?
v
0.13.0 code from github
s
Try this
Copy code
bin/pinot-admin.sh CreateSegment -dataDir /home/vishalvanpariya/work/tmp/datadir/ -format CSV -schemaFile /home/vishalvanpariya/work/pinot-poc/s3/json-s3/schema.json -tableConfigFile <table config json as a file> -outDir output/
table config you should be able to get using controller, copy it into a file
v
its working
but i am not able to set segment name
-segmentName
if i use this param it returning error
Copy code
picocli.CommandLine$UnmatchedArgumentException: Unknown options: '-segmentName', 'json_test_OFFLINE_1'
s
You can get the file name from the output/ dir?
v
yes i can see the name
but i want to set perticular name
want to automate process
s
typically, the segment replace protocol usage involved first building the segment, getting the generated name, calling the /startSegmentReplca with the from and the to list (to list will have the segment name that was just generated), then call /endSegmentReplace. Also, typically you'd want to do this via minion tasks
v
yeah, i did same way only but as per that doc we can define segment name as well but it is not working
s
Yes the documentations seems outdated. Will get that checked
v
@saurabh dubey can we create segment through using docker command?
Copy code
docker run --rm -ti \
    --network=pinot-demo \
    --name pinot-minion \
    -p 8097:8097 \
    -e JAVA_OPTS="-Dplugins.dir=/opt/pinot/plugins -Xms4G -Xmx16G -XX:+UseG1GC -XX:MaxGCPauseMillis=200 -Xloggc:gc-pinot-server.log" \
    -d apachepinot/pinot:0.12.0 StartMinion \
    -zkAddress pinot-zookeeper:2181
lets say we are starting minion as above can we create segment like this?