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

Count query fails if a large query ends in a comment #267

Open
oglehb opened this issue Nov 19, 2022 · 1 comment
Open

Count query fails if a large query ends in a comment #267

oglehb opened this issue Nov 19, 2022 · 1 comment

Comments

@oglehb
Copy link

oglehb commented Nov 19, 2022

Describe the bug
When the final line of a Kusto query ends with a comment, the count query fails if the tabular expression result contains more than truncationmaxrecords rows (500000 by default).

To Reproduce

conn = {
    "kustoCluster": xxx,
    "kustoDatabase": xxx,
    "kustoAadAppId": xxx,
    "kustoAadAppSecret": xxx,
    "kustoAadAuthorityID": xxx,
}
crp = '{"Options": {"truncationmaxrecords": 500000}, "Parameters": {}}'
kql = 'range _ from 1 to 500001 step 1 // this comment causes issue'

df = (spark.read
        .format("com.microsoft.kusto.spark.synapse.datasource")
        .options(**conn)
        .option("kustoQuery", kql)
        .option("clientRequestPropertiesJson", crp)
        .load())

df.limit(0)

Expected behavior
All else the same, I expected the query range _ from 1 to 500001 step 1 // this comment causes issue to behave identically to the query range _ from 1 to 500001 step 1 (when truncationmaxrecords is 500000 or below in this case).

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • Spark v3.2 on Synapse

Additional context
Maybe it has something to do with this code:

def limitQuery(query: String, limit: Int): String = {
query + s"| take $limit"
}

Perhaps changing would solve the issue:

def limitQuery(query: String, limit: Int): String = {
    val trimmedQuery = query.trim
    trimmedQuery + s"\n| take $limit"
}

(I do not know Scala)

@ag-ramachandran
Copy link
Contributor

Hello @oglehb , Will have a look at this right away and potentially fixing this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants