gianm commented on issue #11929:
URL: https://github.com/apache/druid/issues/11929#issuecomment-1095456471

   > What Druid does is similar to the pair of SQL statements:
   > 
   > ```sql
   > DELETE FROM myTable WHERE ...;
   > INSERT INTO myTable
   >   SELECT ... FROM myInput WHERE ...;
   > ```
   
   How about leaning into this and using DELETE ALL and DELETE WHERE? It's 
similar to @vogievetsky's suggestion but has the advantage of avoiding adding a 
new keyword.
   
   Queries would look like:
   
   ```
   REPLACE dst
   DELETE ALL
   SELECT * FROM src
   ```
   
   And:
   
   ```
   REPLACE dst
   DELETE WHERE __time >= TIMESTAMP '2000-01-01 00:00:00' AND __time < 
TIMESTAMP '2000-01-02 00:00:00'
   SELECT * FROM src
   ```
   
   I would also be OK with `DELETE WHERE TRUE` instead of `DELETE ALL`. The 
important thing, to me, is that the DELETE should be required. Otherwise, it's 
too easy for people to accidentally replace their entire table.
   
   It's (quite explicitly!) similar to a DELETE + INSERT transaction, and would 
behave similarly. But I think we should have one important difference: we'll 
validate that all data from the SELECT matches the DELETE filter. If not, it'd 
be a runtime error. I like this because the alternatives are, IMO, worse: we'd 
need to either append or ignore data outside the DELETE filter. Replacing some 
data and appending other data sounds strange to me, so I wouldn't want to do 
that. Ignoring data outside the filter doesn't seem like a good default. People 
can get the behavior, if they want, by adding a WHERE to their SELECT.


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