You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@druid.apache.org by GitBox <gi...@apache.org> on 2023/01/19 07:57:29 UTC

[GitHub] [druid] adarshsanjeev commented on a diff in pull request #13674: Add delete syntax

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


##########
sql/src/main/codegen/includes/delete.ftl:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+// Taken from syntax of SqlInsert statement from calcite parser, edited for replace syntax
+SqlNode DruidSqlDeleteEof() :
+{
+    SqlNode table;
+    SqlNode source = null;
+    final Span s;
+    // Using fully qualified name for Pair class, since Calcite also has a same class name being used in the Parser.jj
+    org.apache.druid.java.util.common.Pair<Granularity, String> partitionedBy = new org.apache.druid.java.util.common.Pair(null, null);
+    SqlNodeList clusteredBy = null;
+}
+{
+    <DELETE> { s = span(); }
+    <FROM>
+    table = CompoundIdentifier()
+    [
+      <WHERE> source = Expression(ExprContext.ACCEPT_SUB_QUERY)
+    ]
+    [
+      <PARTITIONED> <BY>
+      partitionedBy = PartitionGranularity()

Review Comment:
   Thanks for the heads up. I'm looking forward to the catalog changes, I think this would make the delete syntax (and all the others actually) a lot more "SQL-like" since we can drop the partitioned by as a necessary part of the query.



##########
sql/src/main/codegen/includes/delete.ftl:
##########
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+// Taken from syntax of SqlInsert statement from calcite parser, edited for replace syntax
+SqlNode DruidSqlDeleteEof() :
+{
+    SqlNode table;
+    SqlNode source = null;
+    final Span s;
+    // Using fully qualified name for Pair class, since Calcite also has a same class name being used in the Parser.jj
+    org.apache.druid.java.util.common.Pair<Granularity, String> partitionedBy = new org.apache.druid.java.util.common.Pair(null, null);
+    SqlNodeList clusteredBy = null;
+}
+{
+    <DELETE> { s = span(); }
+    <FROM>
+    table = CompoundIdentifier()
+    [
+      <WHERE> source = Expression(ExprContext.ACCEPT_SUB_QUERY)
+    ]
+    [
+      <PARTITIONED> <BY>
+      partitionedBy = PartitionGranularity()
+    ]
+    [
+      <CLUSTERED> <BY>
+      clusteredBy = ClusterItems()

Review Comment:
   Since in the backend, Delete triggers a reingest of the datasource, the above is the clustering for that. I think this would be improved with the catalog.



-- 
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-unsubscribe@druid.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@druid.apache.org
For additional commands, e-mail: commits-help@druid.apache.org