-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Variable substitution doesn't work with field names in projection or where clause #8250
Comments
I would like to work on this. Can this be assigned to me. |
@spena I would need some help here. I am thinking it is not possible to define separate parser rules for variableLiteral and variableIdentifier at the Grammar level. |
@sajjadnazrulla I agree. This cannot be fixed at the grammar level (in I am thinking if we can detect the variable in the new |
@spena Correct me if I am wrong here. Is the issue more deep rooted? When the grammar parses the statement -
${replicas} is lexed as a VARIABLE, but '${format}' is lexed as a string. Should we remove the VARIABLE and STRING from
|
Right, I don't think we can do a |
@spena Could you check this WIP :- I would still need to handle AstBuilder and QueryAnonimizer to handle TableProperty changes. QueryAnonimizer is fairly straightforward. AstBuilder changes might be a bit more large. |
@sajjadnazrulla I think you're going in the right direction. Just make sure to sanitize the variables that are inside strings. I run the Regarding the AstBuilder, what changes do you expect to do there? I looked at it and don't know what must be done. |
Thanks @spena . I would need to handle the tableProperty Value - Check if its a variable or a literal and handle accordingly. This is why the tests are failing. This needs to be done in AstBuilder and QueryAnonymizer also. The changes in QueryAnonymizer will be to change a single method. AstBuilder will be a bit more complex since it returns a Map<String, Literal> |
I see. I don't think you need to do changes in the AstBuilder. Variables must be substituted before getting into the AstBuilder. See https://github.com/confluentinc/ksql/blob/master/ksqldb-engine/src/main/java/io/confluent/ksql/engine/EngineContext.java#L174
The ^ same comment for the QueryAnonymizer. I don't think you need to do changes there either. |
Thanks @spena - This really helps I modified tableProperty as Just a question on the validations now : Should we change the validation to just say no spaces within quotes. The validation for |
The See how the string has extra single-quote when escaped:
The above is just variable substitution happening. AstBuilder will fail later because the value in the variable you used is not valid. |
@sajjadnazrulla , are you still planning to work on this? |
Describe the bug
Variable substitution fails for field names in the query projection or
where
clause. According to example in docs here, it should work.To Reproduce
Version: 6.2.1
Expected behavior
Query succeeds, substituting variable (
colName1
) value for field name.Actual behaviour
See above for error details.
Additional context
Initial feedback from @spena:
The text was updated successfully, but these errors were encountered: