Skip to content

Commit

Permalink
Merge branch 'develop' into fix/clickhouse_array_type
Browse files Browse the repository at this point in the history
  • Loading branch information
maoueh authored Dec 21, 2024
2 parents fb46820 + 6eab99a commit 78d6b77
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## Unreleased

* Added support for the Clickhouse `Date` type.

* Fixed handling of the Clickhouse `Array` type.

* Removed the check for duplicate primary keys on the Clickhouse dialect. This allows inserting multiple rows with the same primary key.

## v4.3.0

* Added a check for non-existent columns in Clickhouse
Expand Down
1 change: 1 addition & 0 deletions db/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ type dialect interface {
Flush(tx Tx, ctx context.Context, l *Loader, outputModuleHash string, lastFinalBlock uint64) (int, error)
Revert(tx Tx, ctx context.Context, l *Loader, lastValidFinalBlock uint64) error
OnlyInserts() bool
AllowPkDuplicates() bool
CreateUser(tx Tx, ctx context.Context, l *Loader, username string, password string, database string, readOnly bool) error
}

Expand Down
4 changes: 4 additions & 0 deletions db/dialect_clickhouse.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ func (d clickhouseDialect) OnlyInserts() bool {
return true
}

func (d clickhouseDialect) AllowPkDuplicates() bool {
return true
}

func (d clickhouseDialect) CreateUser(tx Tx, ctx context.Context, l *Loader, username string, password string, _database string, readOnly bool) error {
user, pass := EscapeIdentifier(username), escapeStringValue(password)

Expand Down
4 changes: 4 additions & 0 deletions db/dialect_postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,10 @@ func (d postgresDialect) OnlyInserts() bool {
return false
}

func (d postgresDialect) AllowPkDuplicates() bool {
return false
}

func (d postgresDialect) CreateUser(tx Tx, ctx context.Context, l *Loader, username string, password string, database string, readOnly bool) error {
user, pass, db := EscapeIdentifier(username), password, EscapeIdentifier(database)
var q string
Expand Down
2 changes: 1 addition & 1 deletion db/ops.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (l *Loader) Insert(tableName string, primaryKey map[string]string, data map
l.entries.Set(tableName, entry)
}

if _, found := entry.Get(uniqueID); found {
if _, found := entry.Get(uniqueID); found && !l.getDialect().AllowPkDuplicates() {
return fmt.Errorf("attempting to insert in table %q a primary key %q, that is already scheduled for insertion, insert should only be called once for a given primary key", tableName, primaryKey)
}

Expand Down

0 comments on commit 78d6b77

Please sign in to comment.