adarshsanjeev commented on code in PR #12386:
URL: https://github.com/apache/druid/pull/12386#discussion_r860505894


##########
sql/src/main/java/org/apache/druid/sql/calcite/parser/DruidSqlReplace.java:
##########
@@ -0,0 +1,119 @@
+/*
+ * 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.parser;
+
+import com.google.common.base.Preconditions;
+import org.apache.calcite.sql.SqlInsert;
+import org.apache.calcite.sql.SqlKind;
+import org.apache.calcite.sql.SqlNode;
+import org.apache.calcite.sql.SqlNodeList;
+import org.apache.calcite.sql.SqlOperator;
+import org.apache.calcite.sql.SqlSpecialOperator;
+import org.apache.calcite.sql.SqlWriter;
+import org.apache.druid.java.util.common.granularity.Granularity;
+
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
+
+/**
+ * Extends the 'replace' call to hold custom parameters specific to Druid i.e. 
PARTITIONED BY and the PARTITION SPECS
+ * This class extends the {@link SqlInsert} so that this SqlNode can be used in
+ * {@link org.apache.calcite.sql2rel.SqlToRelConverter} for getting converted 
into RelNode, and further processing
+ */
+public class DruidSqlReplace extends SqlInsert
+{
+  public static final String SQL_REPLACE_TIME_CHUNKS = "sqlReplaceTimeChunks";
+
+  public static final SqlOperator OPERATOR = new SqlSpecialOperator("REPLACE", 
SqlKind.OTHER);
+
+  private final Granularity partitionedBy;
+  private final String partitionedByStringForUnparse;
+
+  private final SqlNode replaceTimeQuery;
+
+  /**
+   * While partitionedBy and partitionedByStringForUnparse can be null as 
arguments to the constructor, this is
+   * disallowed (semantically) and the constructor performs checks to ensure 
that. This helps in producing friendly
+   * errors when the PARTITIONED BY custom clause is not present, and keeps 
its error separate from JavaCC/Calcite's
+   * custom errors which can be cryptic when someone accidentally forgets to 
explicitly specify the PARTITIONED BY clause
+   */
+  public DruidSqlReplace(
+      @Nonnull SqlInsert insertNode,
+      @Nullable Granularity partitionedBy,
+      @Nullable String partitionedByStringForUnparse,

Review Comment:
   Added



-- 
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]

Reply via email to