Jackie-Jiang commented on code in PR #8557: URL: https://github.com/apache/pinot/pull/8557#discussion_r862272026
########## pinot-core/src/main/java/org/apache/pinot/core/query/executor/sql/SqlQueryExecutor.java: ########## @@ -0,0 +1,125 @@ +/** + * 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.core.query.executor.sql; + +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.helix.HelixManager; +import org.apache.pinot.common.exception.QueryException; +import org.apache.pinot.common.minion.MinionClient; +import org.apache.pinot.common.response.BrokerResponse; +import org.apache.pinot.common.response.broker.BrokerResponseNative; +import org.apache.pinot.common.response.broker.ResultTable; +import org.apache.pinot.common.utils.helix.LeadControllerUtils; +import org.apache.pinot.spi.config.task.AdhocTaskConfig; +import org.apache.pinot.sql.parsers.SqlNodeAndOptions; +import org.apache.pinot.sql.parsers.dml.DataManipulationStatement; +import org.apache.pinot.sql.parsers.dml.DataManipulationStatementParser; + + +/** + * SqlQueryExecutor executes all SQL queries including DQL, DML, DCL, DDL. + * + */ +public class SqlQueryExecutor { + private final String _controllerUrl; + private final HelixManager _helixManager; + + /** + * Fetch the lead controller from helix, HA is not guaranteed. + * @param helixManager is used to query leader controller from helix. + */ + public SqlQueryExecutor(@Nonnull HelixManager helixManager) { + _helixManager = helixManager; + _controllerUrl = null; + } + + /** + * Recommended to provide the controller vip or service name for access. + * @param controllerUrl controller service name for sending minion task requests + */ + public SqlQueryExecutor(@Nonnull String controllerUrl) { + _controllerUrl = controllerUrl; + _helixManager = null; + } + + private static String getControllerBaseUrl(HelixManager helixManager) { + String instanceHostPort = LeadControllerUtils.getHelixClusterLeader(helixManager); + if (instanceHostPort == null) { + throw new RuntimeException("Unable to locate the leader pinot controller, please retry later..."); + } + int index = instanceHostPort.lastIndexOf('_'); + if (index < 1) { Review Comment: (minor) ```suggestion if (index < 0) { ``` ########## pinot-core/src/main/java/org/apache/pinot/core/query/executor/sql/SqlQueryExecutor.java: ########## @@ -0,0 +1,125 @@ +/** + * 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.core.query.executor.sql; + +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.helix.HelixManager; +import org.apache.pinot.common.exception.QueryException; +import org.apache.pinot.common.minion.MinionClient; +import org.apache.pinot.common.response.BrokerResponse; +import org.apache.pinot.common.response.broker.BrokerResponseNative; +import org.apache.pinot.common.response.broker.ResultTable; +import org.apache.pinot.common.utils.helix.LeadControllerUtils; +import org.apache.pinot.spi.config.task.AdhocTaskConfig; +import org.apache.pinot.sql.parsers.SqlNodeAndOptions; +import org.apache.pinot.sql.parsers.dml.DataManipulationStatement; +import org.apache.pinot.sql.parsers.dml.DataManipulationStatementParser; + + +/** + * SqlQueryExecutor executes all SQL queries including DQL, DML, DCL, DDL. + * + */ +public class SqlQueryExecutor { + private final String _controllerUrl; + private final HelixManager _helixManager; + + /** + * Fetch the lead controller from helix, HA is not guaranteed. + * @param helixManager is used to query leader controller from helix. + */ + public SqlQueryExecutor(@Nonnull HelixManager helixManager) { Review Comment: (minor) Don't annotate `@Nonnull`, we assume everything is non-null, and only annotate `@Nullable` ########## pinot-core/src/main/java/org/apache/pinot/core/query/executor/sql/SqlQueryExecutor.java: ########## @@ -0,0 +1,125 @@ +/** + * 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.core.query.executor.sql; + +import com.google.common.collect.ImmutableList; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import javax.annotation.Nonnull; +import javax.annotation.Nullable; +import org.apache.helix.HelixManager; +import org.apache.pinot.common.exception.QueryException; +import org.apache.pinot.common.minion.MinionClient; +import org.apache.pinot.common.response.BrokerResponse; +import org.apache.pinot.common.response.broker.BrokerResponseNative; +import org.apache.pinot.common.response.broker.ResultTable; +import org.apache.pinot.common.utils.helix.LeadControllerUtils; +import org.apache.pinot.spi.config.task.AdhocTaskConfig; +import org.apache.pinot.sql.parsers.SqlNodeAndOptions; +import org.apache.pinot.sql.parsers.dml.DataManipulationStatement; +import org.apache.pinot.sql.parsers.dml.DataManipulationStatementParser; + + +/** + * SqlQueryExecutor executes all SQL queries including DQL, DML, DCL, DDL. + * + */ +public class SqlQueryExecutor { + private final String _controllerUrl; + private final HelixManager _helixManager; + + /** + * Fetch the lead controller from helix, HA is not guaranteed. + * @param helixManager is used to query leader controller from helix. + */ + public SqlQueryExecutor(@Nonnull HelixManager helixManager) { + _helixManager = helixManager; + _controllerUrl = null; + } + + /** + * Recommended to provide the controller vip or service name for access. + * @param controllerUrl controller service name for sending minion task requests + */ + public SqlQueryExecutor(@Nonnull String controllerUrl) { Review Comment: Same here -- 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