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

use literals in distributed engine definition in ch #6446

Merged
merged 4 commits into from
Jan 18, 2025

Conversation

pjain1
Copy link
Member

@pjain1 pjain1 commented Jan 17, 2025

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

@pjain1 pjain1 requested a review from k-anshul January 17, 2025 15:54
runtime/drivers/clickhouse/olap.go Outdated Show resolved Hide resolved
@pjain1 pjain1 requested a review from k-anshul January 17, 2025 18:53
@@ -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)))
Copy link
Member

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().

Copy link
Member Author

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

Copy link
Member

@k-anshul k-anshul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding a comment

@pjain1 pjain1 requested a review from k-anshul January 18, 2025 15:34
@k-anshul k-anshul merged commit 298f5ea into main Jan 18, 2025
7 checks passed
@k-anshul k-anshul deleted the ch_dist_engine_literals branch January 18, 2025 16:27
pjain1 added a commit that referenced this pull request Jan 18, 2025
* use literals in distributed engine definition in ch

* do not quote db

* use safe sql string

* quote database
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

Successfully merging this pull request may close these issues.

2 participants