FrankChen021 commented on code in PR #20586: URL: https://github.com/apache/druid/pull/20586#discussion_r4270860645
########## sql/src/main/java/org/apache/druid/sql/calcite/schema/SystemQueryContextParametersTable.java: ########## @@ -0,0 +1,316 @@ +/* + * 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.druid.sql.calcite.schema; + +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import org.apache.calcite.DataContext; +import org.apache.calcite.linq4j.Enumerable; +import org.apache.calcite.linq4j.Linq4j; +import org.apache.calcite.rel.type.RelDataType; +import org.apache.calcite.rel.type.RelDataTypeFactory; +import org.apache.calcite.schema.ScannableTable; +import org.apache.calcite.schema.Schema; +import org.apache.calcite.schema.impl.AbstractTable; +import org.apache.druid.error.DruidException; +import org.apache.druid.java.util.common.HumanReadableBytes; +import org.apache.druid.query.BadQueryContextException; +import org.apache.druid.query.QueryConfigProvider; +import org.apache.druid.query.context.QueryContextParameter; +import org.apache.druid.query.context.QueryContextParameters; +import org.apache.druid.query.context.constraint.ParameterConstraint; +import org.apache.druid.query.context.constraint.Range; +import org.apache.druid.query.context.docs.ParameterDocumentation; +import org.apache.druid.segment.column.ColumnType; +import org.apache.druid.segment.column.RowSignature; +import org.apache.druid.server.security.Action; +import org.apache.druid.server.security.AuthenticationResult; +import org.apache.druid.server.security.AuthorizationUtils; +import org.apache.druid.server.security.AuthorizerMapper; +import org.apache.druid.server.security.Resource; +import org.apache.druid.server.security.ResourceAction; +import org.apache.druid.server.security.ResourceType; +import org.apache.druid.sql.calcite.table.RowSignatures; + +import javax.annotation.Nullable; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * System table {@code sys.query_context_parameters}, listing the query context parameters declared in + * {@link QueryContextParameters#ALL} that users can set, together with their type, default, applicability and + * documentation. {@link QueryContextParameter.Visibility#SYSTEM} parameters, which only Druid sets, are excluded. + */ +public class SystemQueryContextParametersTable extends AbstractTable implements ScannableTable +{ + public static final String TABLE_NAME = "query_context_parameters"; + + static final RowSignature ROW_SIGNATURE = RowSignature + .builder() + .add("name", ColumnType.STRING) + .add("type", ColumnType.STRING) + .add("range", ColumnType.STRING) Review Comment: [P2] Use a non-reserved name for range **Finding:** The new column is named `range`, but Druid's Calcite grammar treats RANGE as a reserved window-frame keyword. References such as `SELECT range FROM sys.query_context_parameters` or `WHERE range IS NOT NULL` therefore fail during parsing unless the column is quoted. **Suggestion:** Rename the column to a non-reserved identifier, or add RANGE to Druid's non-reserved keyword set with parser coverage. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
