Skip to content
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

Unexpected token "@" #264

Closed
xmlking opened this issue Aug 30, 2017 · 9 comments · Fixed by #581
Closed

Unexpected token "@" #264

xmlking opened this issue Aug 30, 2017 · 9 comments · Fixed by #581
Assignees

Comments

@xmlking
Copy link

xmlking commented Aug 30, 2017

ksql> CREATE STREAM my_logs_stream  ( "@timestamp" varchar, "@version" bigint, message 
varchar, logger_name varchar, thread_name varchar, level varchar, level_value bigint, HOSTNAME 
varchar, app varchar) WITH (kafka_topic='applogs', value_format='JSON');

SELECT app,  HOSTNAME, "@version" FROM my_logs_stream LIMIT 3;

Error:

Line 1, Column 17: Unexpected token "@"

unfortunately my JSON data looks like this

{  
   "@timestamp":"2017-08-30T06:48:05.149+00:00",
   "@version":1,
   "message":"cancel()",
   "logger_name":"ss-QuoteGenerator",
   "thread_name":"reactor-http-nio-4",
   "level":"INFO",
   "level_value":20000,
   "HOSTNAME":"weqeqe",
   "app":"stream-service"
}
@hjafarpour hjafarpour self-assigned this Aug 30, 2017
@hjafarpour
Copy link
Contributor

@xmlking The columns names cannot start with '@'. Can you change the field names in your JSON so they won't start with '@'? I would suggest '_timestamp' and '_version'.

@xmlking
Copy link
Author

xmlking commented Aug 30, 2017

I can certainly change it. KSQL is amazing component in Kafka ecosystem . Thanks.

As logstash by default use this JSON format, and it is valid JSON, wonder if we can remove this limitation in KSQL.
https://github.com/logstash/logstash-logback-encoder#standard-fields

@miguno
Copy link
Contributor

miguno commented Aug 30, 2017

@xmlking Thanks for reporting this. I agree that it would be great to support @... named columns in KSQL in order to support logstash with default settings, but @ is not commonly a valid character in SQL identifiers. Hence we are hesitant at the moment to deviate from that.

@henridf
Copy link

henridf commented Sep 13, 2017

Fwiw this is the first thing that I ran into when using KSQL to do ETL on Elasticsearch-destined data recently... (it's broader than logstash, which I don't use... @timestamp seems to have become a pretty general convention in ES-land).

I do understand the quandary with deviating from SQL. My 2c would be that "loosening" the syntax (e.g. making things that aren't valid SQL be valid kSQL) is ok. But your call of course.

@miguno
Copy link
Contributor

miguno commented Sep 14, 2017

Thanks for the feedback @henridf -- we're still thinking about this, please stay tuned.

Have you been able to come up with a workaround in the meantime?

@henridf
Copy link

henridf commented Sep 14, 2017

I since ran into some other (more significant) issues with ksql and as a result have put this aside for the time being. So, I haven't needed to find a workaround for this.

I'll file the other issues as soon as I have time to do a simple repro. In any case, what little I was able to do was great, and I look forward to seeing this project grow. Thanks!

@miguno
Copy link
Contributor

miguno commented Sep 14, 2017

Thanks for the update @henridf. Appreciate the kind words! And please keep the feedback coming! :-)

@bluemonk3y
Copy link

@henridf - the clickstream demo uses a dynamic-template to configure the timestamp fields, it should provide you with a workaround, then you can use a _timestamp field as the demo does.

Take a look at https://github.com/confluentinc/ksql/blob/0.1.x/ksql-clickstream-demo/demo/elastic-dynamic-template.sh

@apurvam
Copy link
Contributor

apurvam commented Feb 13, 2018

Fixed by #581

@apurvam apurvam closed this as completed Feb 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants