confluentinc/ksql

Variable substitution doesn't work with field names in projection or where clause

Open

#8.250 geöffnet am 12. Okt. 2021

Auf GitHub ansehen
 (12 Kommentare) (0 Reaktionen) (1 zugewiesene Person)Java (1.048 Forks)batch import
bugfix-it-weekgood first issuestreaming-enginevariable-substitution

Repository-Metriken

Stars
 (5.739 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 4T 20h) (6 gemergte PRs in 30 T)

Beschreibung

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

ksql> define colName1 = 'LEVEL';
ksql> select ${colName1} from ksql_processing_log emit changes;
Illegal argument at Line: 1, Col: 8. Got: 'LEVEL'
Statement: select ${colName1} from ksql_processing_log emit changes;
ksql> define colName1 = 'LEVEL';
ksql> select * from ksql_processing_log where ${colName1} = 'ERROR';
Illegal argument at Line: 1, Col: 41. Got: 'LEVEL'
Statement: select * from ksql_processing_log where ${colName1} = 'ERROR';

Expected behavior Query succeeds, substituting variable (colName1) value for field name.

Actual behaviour See above for error details.

Additional context Initial feedback from @spena:

Seems the parser is detecting the ${colName1} from the where clause as a variable literal and not a variable identifier, so the parsing fails because level is not a string literal

Contributor Guide