ccaominh commented on a change in pull request #6974: sql support for dynamic parameters URL: https://github.com/apache/incubator-druid/pull/6974#discussion_r311330111
########## File path: sql/src/main/java/org/apache/druid/sql/http/SqlParameter.java ########## @@ -0,0 +1,123 @@ +/* + * 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.http; + +import com.fasterxml.jackson.annotation.JsonCreator; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.calcite.avatica.ColumnMetaData; +import org.apache.calcite.avatica.SqlType; +import org.apache.calcite.avatica.remote.TypedValue; +import org.apache.calcite.util.TimestampString; +import org.apache.druid.java.util.common.DateTimes; +import org.joda.time.DateTime; + +import java.util.Objects; + +public class SqlParameter +{ + private int ordinal; + private SqlType type; + private Object value; + + @JsonCreator + public SqlParameter( + @JsonProperty("ordinal") int ordinal, + @JsonProperty("type") SqlType type, + @JsonProperty("value") Object value + ) + { + this.ordinal = ordinal; Review comment: Perhaps add a `Precondition` for `ordinal` to be a positive value. For example, I'm not sure if the code currently fails gracefully if the user specifies an `ordinal` of 0. Having a not-null check for `type` and `value` will give the user a helpful error message if pass in nulls. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org