Skip to content

Commit

Permalink
fix(clickhouse): fix semver parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
iamKunalGupta committed Apr 12, 2024
1 parent f53e1d8 commit 5b571ed
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions flow/connectors/clickhouse/clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,20 @@ func NewClickhouseConnector(
return nil, err
}
if credentials.AWS.SessionToken != "" {
minSupportedClickhouseVersion := "24.3.1.2672"
minSupportedClickhouseVersion := "v24.3.1"
clickHouseVersionRow := database.QueryRowContext(ctx, "SELECT version()")
var clickHouseVersion string
err := clickHouseVersionRow.Scan(&clickHouseVersion)
if err != nil {
return nil, fmt.Errorf("failed to query clickhouse version: %w", err)
}
if semver.Compare(clickHouseVersion, minSupportedClickhouseVersion) < 0 {
// Ignore everything after patch version and prefix with "v", else semver.Compare will fail
versionParts := strings.SplitN(clickHouseVersion, ".", 4)
if len(versionParts) > 3 {
versionParts = versionParts[:3]
}
cleanedClickHouseVersion := "v" + strings.Join(versionParts, ".")
if semver.Compare(cleanedClickHouseVersion, minSupportedClickhouseVersion) < 0 {
return nil, fmt.Errorf(
"provide AWS access credentials explicitly or upgrade to clickhouse version >= %v, current version is %s. %s",
minSupportedClickhouseVersion, clickHouseVersion,
Expand Down

0 comments on commit 5b571ed

Please sign in to comment.