microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.
Apache License 2.0
510 stars 97 forks source link

When using database names with special characters without escaping, the error message is just 'syntax error' #69

Closed jimbobbennett closed 2 years ago

jimbobbennett commented 2 years ago

Kusto allows certain special characters in entity names, such as -, _ and .. When using these names in queries you need to escape them, according to the Kusto Entity name documentation.

Unfortunately, if you are not aware that these need to be escaped, and use them in queries, the error message you get just says 'Syntax error', and doesn't lead you towards solving the problem. It would be better if the error message provided more guidance.

To reproduce

I have been setting up Azure Data Explorer to show data in Grafana, using the Visualize data from Azure Data Explorer in Grafana guide. I am using my own database and table names, and my database is called iotea-scales.

There is a set to set up Azure Active Directory, and you run this query:

.add database {TestDatabase} viewers ('aadapp={ApplicationID};{TenantID}')

I adjusted this for my database, giving the following:

.add database iotea-scales viewers ('aadapp=<appId>;<tenantId>')

When running this, I get this error:

Error. Syntax error:

The syntax error is not described, it is just shown as a syntax error.

Expected

The syntax error should be more descriptive, helping to find and fix the issue.

Based on the structure of the query, the text between spaces after .add database should be a database name, so is it possible for the parser to know this, and guide the user to escape the name if it contains special characters?

sloutsky commented 2 years ago

You need to escape names that include special characters:

.add database ['iotea-scales'] viewers ('aadapp=;')

jimbobbennett commented 2 years ago

@sloutsky - I am aware you need to escape entity names with special characters, this was mentioned in the issue.

The problem is for folks who don't know that these need to be escaped. If you don't know this, then the error is unhelpful as Syntax error: with no actual syntax error details shown to help guide them to the answer.

My ask with this issue is to either make the error useful and report what the syntax error is, or even better be smart enough to detect that there should be a database name in that field and guide you to escaping it.

sloutsky commented 2 years ago
  1. You can always escape the entity names.
  2. We will look in future in improving the error returned