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 2022/04/24 14:27:37 UTC
[GitHub] [druid] adarshsanjeev commented on pull request #12431: Validate select columns for insert statement
adarshsanjeev commented on PR #12431:
URL: https://github.com/apache/druid/pull/12431#issuecomment-1107852643
> Is it possible that we can do this on `RelNodes` somehow instead of `SqlNodes`? With SqlNodes, we would have to account for every shape and form of the given statement, but I am assuming that if we can work on `RelNodes` itself, Calcite will convert it into some standard form and we won't have to worry about the cases like gian mentioned in the comments. This might be tricky because there is no distinction between SELECT and INSERT query I think when we plan (because we extract out the INSERT into data source at the beginning itself).
After taking a look at it, `RelNodes` is a lot easier to validate, especially with nested queries. We can also differentiate between INSERT and SELECT in plan() since we have the ParsedNodes available, so that should be fine.
The main issue would be as Rohan mentioned, we wouldn't be able to tell if the name is something that was auto generated or if the user had given that as the name.
It would also be tricky to actually validate, do we just assert that the name isn't EXPR$[digit]+? That would be a very specific assertion to add for inserts only. I think the approach might still have to use the SQLNodes layer, but also go through nested queries though this might be very tricky to get right, like
`INSERT INTO test1 SELECT EXPR$0 FROM (SELECT * FROM (SELECT CONCAT(dim1, 'foo') FROM test)) PARTITIONED BY ALL TIME`
which should be valid, but won't be if we just check for `AS` operator in nested queries. Do you have any suggestions?
--
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