Use ` instead of " to wrap database_and_schema in Slack for "The test query was too long, here's a query to get it."
Describe the bug
When "The test query was too long, here's a query to get it." runs it posts the database_and_schema with quotation " marks around it. This causes the query not to run in SQL query editors like Datagrip or Databricks as it's incorrect syntax.
Currently it's returning this in Slack Test query The test query was too long, here's a query to get it.
SELECT test_results_query FROM "database.schema".elementary_test_results WHERE test_execution_id = '1234.test.xyz.test_model_name'
Expected behavior Would be better if it returned it wrapped in backticks ` so it could run straight from copying and pasting without any editing needed. So ideally it would return this: Test query The test query was too long, here's a query to get it.
SELECT test_results_query FROM `database.schema`.elementary_test_results WHERE test_execution_id = '1234.test.xyz.test_model_name'
Screenshot
Would you be willing to contribute a fix for this issue? Yes, will post PR shortly
Thanks @mschmidoev ! We'll have a look.
Hi @mschmidoev!
If I understand correctly, the quoting rules depend on the SQL dialect being used. Databases that follow Standard SQL (ANSI), like PostgresQL, use double quotes for identifiers. Other databases may use backticks (MySQL) or even square brackets (SQL server).
If this is indeed the case, I would prefer to stick with Standard SQL. What's your thoughts on it?
Thanks @elazarlachkar and @NoyaOffer.
Ah sorry, I think I wasn't very clear, and I think I need to update my PR and description which I'll do in a sec.
The issue isn't the identifiers actually, it's because it's joining the database and schema together like "database.schema" which treats the whole thing as one identifier. Would be best to split it into "database"."schema"
@mschmidoev Got you, that's make sense :) I approved the PR, thanks for the contribution!
Thanks @elazarlachkar, looking forward to this change getting merged. Let me know if there's anything I still need to do :)
This issue is stale because it has been open for too long with no activity. If you would like the issue to remain open, please remove the stale label or leave a comment.