Ksql: Support escaping identifier names.

Created on 31 Jan 2018  路  5Comments  路  Source: confluentinc/ksql

In standard SQL we can use escaped names for tables and columns. We should support this in KSQL too.

data-accessibility enhancement

Most helpful comment

First time trying to use KSQL and running directly into this issue. I discovered the undocumented backtick escaping, and then running into https://github.com/confluentinc/ksql/issues/1213. The actually working workaround if table columns are declared with backtick escaping and being uppercase:

CREATE STREAM stream1 (
`window` varchar,
`topic` varchar
) WITH (value_format='JSON');

ksql> select `window`, `topic` from stream1 limit 2;
null | null
null | null
LIMIT reached for the partition.
Query terminated

CREATE STREAM stream2 (
`WINDOW` varchar,
`TOPIC` varchar
) WITH (value_format='JSON');

ksql> select `WINDOW`, `TOPIC` from stream2 limit 2;
1528278435000 | testkafka4
1528278465000 | testkafka5
LIMIT reached for the partition.
Query terminated

My JSON contains "window" and "topic" fields in lower case

All 5 comments

This will enable using reserved keywords as column names, and increase the number of data streams ksql can work with.

What's the current state of this issue?

First time trying to use KSQL and running directly into this issue. I discovered the undocumented backtick escaping, and then running into https://github.com/confluentinc/ksql/issues/1213. The actually working workaround if table columns are declared with backtick escaping and being uppercase:

CREATE STREAM stream1 (
`window` varchar,
`topic` varchar
) WITH (value_format='JSON');

ksql> select `window`, `topic` from stream1 limit 2;
null | null
null | null
LIMIT reached for the partition.
Query terminated

CREATE STREAM stream2 (
`WINDOW` varchar,
`TOPIC` varchar
) WITH (value_format='JSON');

ksql> select `WINDOW`, `TOPIC` from stream2 limit 2;
1528278435000 | testkafka4
1528278465000 | testkafka5
LIMIT reached for the partition.
Query terminated

My JSON contains "window" and "topic" fields in lower case

Experiencing the same. Verified 'workaroud'. Need to uppercase the field name and have it enclosed with backticks.

(Using version 5.1.0)

Closing this ticket out in favor of the more specific issues described in other tickets - there has been a ton of work in recent KSQL versions (will be released in the next upcoming release) to address the quoted identifier issues. Feel free to open new issues with more specific information about the issues you are facing if the issues persist!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bhargav516 picture bhargav516  路  3Comments

eshil-patel picture eshil-patel  路  4Comments

gangadhar01a picture gangadhar01a  路  3Comments

apurvam picture apurvam  路  3Comments

rmoff picture rmoff  路  4Comments