-
Notifications
You must be signed in to change notification settings - Fork 126
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
use literals in distributed engine definition in ch #6446
Conversation
@@ -609,7 +609,7 @@ func (c *connection) createTable(ctx context.Context, name, sql string, outputPr | |||
database = "currentDatabase()" | |||
} | |||
fmt.Fprintf(&distributed, "CREATE OR REPLACE TABLE %s %s AS %s", safeSQLName(name), onClusterClause, safelocalTableName(name)) | |||
fmt.Fprintf(&distributed, " ENGINE = Distributed(%s, %s, %s", safeSQLName(c.config.Cluster), database, safelocalTableName(name)) | |||
fmt.Fprintf(&distributed, " ENGINE = Distributed(%s, %s, %s", safeSQLString(c.config.Cluster), database, safeSQLString(localTableName(name))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is an existing code but shouldn't database also be quoted ?
If you do quote this then need to take care of fact that database can also be currentDatabase()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I did not quote because of existing code but added it now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding a comment
* use literals in distributed engine definition in ch * do not quote db * use safe sql string * quote database
otherwise it was quoting the local table name like
ENGINE = Distributed('abc', 'default', '"table_local"', rand())
and queries were failing on it saying local table not found