diff --git a/quesma/clickhouse/table_discovery.go b/quesma/clickhouse/table_discovery.go index 828146f16..313bef8e6 100644 --- a/quesma/clickhouse/table_discovery.go +++ b/quesma/clickhouse/table_discovery.go @@ -45,7 +45,6 @@ type TableDiscovery interface { type tableDiscovery struct { cfg *config.QuesmaConfiguration dbConnPool *sql.DB - tableVerifier tableVerifier tableDefinitions *atomic.Pointer[TableMap] tableDefinitionsAccessUnixSec atomic.Int64 tableDefinitionsLastReloadUnixSec atomic.Int64 @@ -164,7 +163,6 @@ func (td *tableDiscovery) ReloadTableDefinitions() { configuredTables = td.readVirtualTables(configuredTables) td.ReloadTablesError = nil - td.verify(configuredTables) td.populateTableDefinitions(configuredTables, databaseName, td.cfg) } @@ -389,17 +387,6 @@ func (td *tableDiscovery) TableDefinitions() *TableMap { return td.tableDefinitions.Load() } -func (td *tableDiscovery) verify(tables map[string]discoveredTable) { - for _, table := range tables { - logger.Info().Msgf("verifying table %s", table.name) - if correct, violations := td.tableVerifier.verify(table); correct { - logger.Debug().Msgf("table %s verified", table.name) - } else { - logger.Warn().Msgf("table %s verification failed: %s", table.name, violations) - } - } -} - func resolveColumn(colName, colType string) *Column { isNullable := false if isNullableType(colType) { diff --git a/quesma/clickhouse/table_verification.go b/quesma/clickhouse/table_verification.go deleted file mode 100644 index a3bcd5b9e..000000000 --- a/quesma/clickhouse/table_verification.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright Quesma, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 -package clickhouse - -import ( - "fmt" - "strings" -) - -type tableVerifier struct { - // TODO enable various verification strategies -} - -func (t tableVerifier) verify(table discoveredTable) (bool, []string) { - var violations = make([]string, 0) - for columnName := range table.columnTypes { - if strings.Contains(columnName, ".") { - violations = append(violations, fmt.Sprintf("Column name %s in a table %s contains a dot, which is not allowed and might produce undefined behaviour", columnName, table.name)) - } - } - return len(violations) == 0, violations -} diff --git a/quesma/clickhouse/table_verification_test.go b/quesma/clickhouse/table_verification_test.go deleted file mode 100644 index 1d86c6300..000000000 --- a/quesma/clickhouse/table_verification_test.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright Quesma, licensed under the Elastic License 2.0. -// SPDX-License-Identifier: Elastic-2.0 -package clickhouse - -import ( - "github.com/stretchr/testify/assert" - "testing" -) - -func Test_tableVerifier_verify(t1 *testing.T) { - tests := []struct { - name string - table discoveredTable - isValid bool - violations []string - }{ - { - name: "valid table", - table: discoveredTable{ - name: "table", - columnTypes: map[string]columnMetadata{ - "column1": columnMetadata{colType: "String"}, - "column2": columnMetadata{colType: "Int32"}, - }, - }, - isValid: true, - violations: []string{}, - }, - { - name: "table with invalid column names", - table: discoveredTable{ - name: "table", - columnTypes: map[string]columnMetadata{ - "column1": columnMetadata{colType: "String"}, - "foo.bar": columnMetadata{colType: "Int32"}, - }, - }, - isValid: false, - violations: []string{"Column name foo.bar in a table table contains a dot, which is not allowed and might produce undefined behaviour"}, - }, - } - for _, tt := range tests { - t1.Run(tt.name, func(t1 *testing.T) { - t := tableVerifier{} - isValid, violations := t.verify(tt.table) - assert.Equalf(t1, tt.isValid, isValid, "verify(%v)", tt.table) - assert.Equalf(t1, tt.violations, violations, "verify(%v)", tt.table) - }) - } -}