Quote table names in ClickHouseTestRunner queries
What does this MR do and why?
This MR fixes a problem with dropping tables that contain special characters. For example, when running require_relative 'spec/support/database/click_house/hooks.rb'; ClickHouseTestRunner.new.ensure_schema
, an error occurs because the following SQL is generated:
gitlab-macbookpro.work.pombei.ro :) DROP TABLE IF EXISTS .inner_id.258e9240-ed22-4347-b173-bb4cd09a5dee
Syntax error: failed at position 22 ('.'):
This prevents ClickHouseTestRunner.new.ensure_schema
from completing successfully. Therefore, we should quote the table names.
Screenshots or screen recordings
Screenshots are required for UI changes, and strongly recommended for all other merge requests.
If a materialized view is created with POPULATE
, this will result in a .
-prefixed table name, which will cause problems to ClickHouseTestRunner
.
This screenshot shows a database being truncated with the parameterized queries:
How to set up and validate locally
Numbered steps to set up and validate the change are strongly suggested.
-
Create a table with a dot prefix:
CREATE TABLE `.t1` (x String) ENGINE = Memory AS SELECT 1;
-
Ensure that the table is seen in
ClickHouseTestRunner
:> require_relative 'spec/support/database/click_house/hooks.rb' > ClickHouseTestRunner.new.send(:tables_for, :main).map.with_index { |table, index| ["table#{index}", table] }.to_h => {"table0"=>".t1", "table1"=>"ci_finished_builds", "table2"=>"ci_finished_builds_aggregated_queueing_delay_percentiles", "table3"=>"ci_finished_builds_aggregated_queueing_delay_percentiles_mv", "table4"=>"contribution_analytics_events", "table5"=>"contribution_analytics_events_mv", "table6"=>"events", "table7"=>"sync_cursors"}
-
Run
ensure_schema
:ClickHouseTestRunner.new.ensure_schema
The tables should be successfully recreated.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.