xiangfu0 commented on code in PR #13678: URL: https://github.com/apache/pinot/pull/13678#discussion_r1699176388
########## pinot-common/src/main/java/org/apache/pinot/sql/parsers/dml/DeleteSegmentStatement.java: ########## @@ -0,0 +1,116 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.sql.parsers.dml; + +import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.calcite.sql.SqlBasicCall; +import org.apache.calcite.sql.SqlDelete; +import org.apache.calcite.sql.SqlNode; +import org.apache.pinot.common.utils.DataSchema; +import org.apache.pinot.spi.config.task.AdhocTaskConfig; +import org.apache.pinot.sql.parsers.SqlNodeAndOptions; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class DeleteSegmentStatement implements DataManipulationStatement { + private static final Logger LOGGER = LoggerFactory.getLogger(DeleteSegmentStatement.class); + private static final DataSchema DELETE_FROM_RESPONSE_SCHEMA = + new DataSchema(new String[]{"tableName", "taskJobName"}, + new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.STRING, DataSchema.ColumnDataType.STRING}); + private static final Set<String> VALID_OPERATORS = Set.of("LIKE", "="); + private static final String TASK_NAME = "taskName"; + private static final String TASK_TYPE = "taskType"; + private static final String DEFAULT_TASK_TYPE = "SegmentDeletionTask"; + private static final String SEGMENT_NAME = "segmentName"; + private static final String OPERATOR = "operator"; + + private final String _table; + private final Map<String, String> _queryOptions; + + public DeleteSegmentStatement(String table, Map<String, String> queryOptions) { Review Comment: Say if later on I want to extend the usage to: 1. leverage segment metadata or other criteria for segment selection, e.g. I may want to delete all the segments with a time range [d1, d2] or segments with partition.id = 10 2. query matched segments using pinot query is the predicate is a real query, e.g. `DELETE FROM myTable WHERE uuid='xxx'` , which means you can send a query: `SELECT distinct $segmentName FROM myTable WHERE uuid='xxx'` to pinot first to get all the segment list then drop them accordingly. I feel if we can separate this to just table and a list of segments to delete, and before this, we can have different implementations for a SelectSelector interface. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org For additional commands, e-mail: commits-h...@pinot.apache.org